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:
00035 void writeRecord(
00036 std::ostream& out,
00037 const cgatools::reference::CrrFile& crr,
00038 size_t sampleCount) const;
00039
00042 virtual cgatools::reference::Location getLocation() const = 0;
00043
00045 virtual void writeId(std::ostream& out) const
00046 {
00047 out << ".";
00048 }
00049
00051 virtual void writeRef(std::ostream& out) const = 0;
00052
00054 virtual void writeAlt(std::ostream& out) const = 0;
00055
00057 virtual void writeQual(std::ostream& out) const
00058 {
00059 out << ".";
00060 }
00061
00063 virtual void writeFilter(std::ostream& out) const
00064 {
00065 out << ".";
00066 }
00067
00069 virtual void writeInfo(std::ostream& out) const = 0;
00070
00072 virtual void writeFormat(std::ostream& out) const = 0;
00073
00077 virtual void writeSample(std::ostream& out, size_t idxGenome) const = 0;
00078
00081 static std::string getVcfChromosomeName(
00082 size_t chromosomeId,
00083 const cgatools::reference::CrrFile& crr);
00084 };
00085
00086 struct VcfSubFieldHeaderRecord
00087 {
00088 enum Key
00089 {
00090 VCF_ALT = 0,
00091 VCF_FILTER = 1,
00092 VCF_INFO = 2,
00093 VCF_FORMAT = 3,
00094 VCF_END = 4
00095 };
00096
00097 VcfSubFieldHeaderRecord(
00098 Key key,
00099 const std::string& id,
00100 const std::string& number,
00101 const std::string& type,
00102 const std::string& description)
00103 : key_(key),
00104 id_(id),
00105 number_(number),
00106 type_(type),
00107 description_(description)
00108 {
00109 };
00110
00111 Key key_;
00112 std::string id_;
00113 std::string number_;
00114 std::string type_;
00115 std::string description_;
00116 };
00117
00120 struct VcfKvHeaderRecord
00121 {
00122 VcfKvHeaderRecord(const std::string& key,
00123 const std::string& value)
00124 : key_(key),
00125 value_(value)
00126 {
00127 }
00128
00129 std::string key_;
00130 std::string value_;
00131 };
00132
00136 class VcfRecordSource
00137 {
00138 public:
00141 virtual std::vector<VcfSubFieldHeaderRecord> getSubFieldHeaderRecords() const = 0;
00142
00146 virtual std::string getSource(size_t idxGenome) const = 0;
00147
00150 virtual std::vector<VcfKvHeaderRecord> getKeyValueHeaderRecords(size_t idxGenome) const = 0;
00151
00153 virtual std::string getAssemblyId(size_t idxGenome) const = 0;
00154
00156
00157 virtual bool eof() const = 0;
00158 virtual VcfRecordSource& operator++() = 0;
00159 virtual const VcfRecordWriter& operator*() const = 0;
00160 virtual const VcfRecordWriter* operator->() const = 0;
00161 };
00162
00163 } }
00164
00165 #endif // CGA_TOOLS_CONV_VCFRECORDSOURCE_HPP_