00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CGA_TOOLS_CONV_VCFRECORDSOURCE_HPP_
00016 #define CGA_TOOLS_CONV_VCFRECORDSOURCE_HPP_ 1
00017
00019
00020 #include "cgatools/core.hpp"
00021 #include "cgatools/reference/CrrFile.hpp"
00022
00023 #include <iostream>
00024
00025 namespace cgatools { namespace conv {
00026
00029 class VcfRecordWriter
00030 {
00031 public:
00032 virtual ~VcfRecordWriter()
00033 {
00034 }
00035
00039 void writeRecord(
00040 std::ostream& out,
00041 const cgatools::reference::CrrFile& crr,
00042 size_t sampleCount) const;
00043
00046 virtual cgatools::reference::Location getLocation() const = 0;
00047
00049 virtual void writeId(std::ostream& out) const
00050 {
00051 out << ".";
00052 }
00053
00055 virtual void writeRef(std::ostream& out) const = 0;
00056
00058 virtual void writeAlt(std::ostream& out) const = 0;
00059
00061 virtual void writeQual(std::ostream& out) const
00062 {
00063 out << ".";
00064 }
00065
00067 virtual void writeFilter(std::ostream& out) const
00068 {
00069 out << ".";
00070 }
00071
00073 virtual void writeInfo(std::ostream& out) const = 0;
00074
00076 virtual void writeFormat(std::ostream& out) const = 0;
00077
00081 virtual void writeSample(std::ostream& out, size_t idxGenome) const = 0;
00082
00085 static std::string getVcfChromosomeName(
00086 size_t chromosomeId,
00087 const cgatools::reference::CrrFile& crr);
00088 };
00089
00090 struct VcfSubFieldHeaderRecord
00091 {
00092 enum Key
00093 {
00094 VCF_ALT = 0,
00095 VCF_FILTER = 1,
00096 VCF_INFO = 2,
00097 VCF_FORMAT = 3,
00098 VCF_END = 4
00099 };
00100
00101 VcfSubFieldHeaderRecord(
00102 Key key,
00103 const std::string& id,
00104 const std::string& number,
00105 const std::string& type,
00106 const std::string& description)
00107 : key_(key),
00108 id_(id),
00109 number_(number),
00110 type_(type),
00111 description_(description)
00112 {
00113 };
00114
00115 Key key_;
00116 std::string id_;
00117 std::string number_;
00118 std::string type_;
00119 std::string description_;
00120 };
00121
00124 struct VcfKvHeaderRecord
00125 {
00126 VcfKvHeaderRecord(const std::string& key,
00127 const std::string& value)
00128 : key_(key),
00129 value_(value)
00130 {
00131 }
00132
00133 std::string key_;
00134 std::string value_;
00135 };
00136
00140 class VcfRecordSource
00141 {
00142 public:
00143 virtual ~VcfRecordSource()
00144 {
00145 }
00146
00149 virtual std::vector<VcfSubFieldHeaderRecord> getSubFieldHeaderRecords() const = 0;
00150
00154 virtual std::string getSource(size_t idxGenome) const = 0;
00155
00158 virtual std::vector<VcfKvHeaderRecord> getKeyValueHeaderRecords(size_t idxGenome) const = 0;
00159
00161 virtual std::string getAssemblyId(size_t idxGenome) const = 0;
00162
00164
00165 virtual bool eof() const = 0;
00166 virtual VcfRecordSource& operator++() = 0;
00167 virtual const VcfRecordWriter& operator*() const = 0;
00168 virtual const VcfRecordWriter* operator->() const = 0;
00169 };
00170
00171 } }
00172
00173 #endif // CGA_TOOLS_CONV_VCFRECORDSOURCE_HPP_