00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CGATOOLS_MOBILEELEMENT_MEIFILEVCFSOURCE_HPP_
00016 #define CGATOOLS_MOBILEELEMENT_MEIFILEVCFSOURCE_HPP_ 1
00017
00019
00020 #include "cgatools/core.hpp"
00021 #include "cgatools/conv/VcfRecordSource.hpp"
00022 #include "cgatools/reference/CrrFile.hpp"
00023 #include "cgatools/util/DelimitedFile.hpp"
00024
00025 #include <set>
00026 #include <vector>
00027
00028
00029 namespace cgatools { namespace cgdata {
00030 class GenomeMetadata;
00031 } }
00032
00033 namespace cgatools { namespace mobileelement {
00034
00035
00036 struct meiData {
00037 std::string chr;
00038 int begin;
00039 int end;
00040 int pos;
00041 uint16_t chrId;
00042 cgatools::reference::Location location;
00043 std::string strand;
00044 std::string ET;
00045 std::string IS;
00046 std::string IDC;
00047 std::string IDCL;
00048 std::string IDCR;
00049 int RDC;
00050 std::string NBET;
00051 std::string ETS;
00052 std::string KES;
00053 int elemBegin;
00054 int elemEnd;
00055 };
00056
00057 class MeiFileVcfRecordWriter : public cgatools::conv::VcfRecordWriter
00058 {
00059 public:
00060 MeiFileVcfRecordWriter(
00061 const std::vector< std::string> meiFieldNames,
00062 const cgatools::reference::CrrFile& crr,
00063 int numGenomes);
00064
00065
00066 cgatools::reference::Location getLocation() const;
00067 void writeRef(std::ostream& out) const;
00068 void writeAlt(std::ostream& out) const;
00069 void writeInfo(std::ostream& out) const;
00070 void writeFormat(std::ostream& out) const;
00071 void writeSample(std::ostream& out, size_t gIdx) const;
00072
00073
00074 void setMeiData(meiData &data, int gIdx);
00075
00076 private:
00077 std::string superType(meiData) const;
00078
00079 const cgatools::reference::CrrFile& crr_;
00080 std::vector< meiData > meiData_;
00081 std::vector< std::string > formatIds_;
00082 };
00083
00084 class MeiFileVcfRecordSource : public cgatools::conv::VcfRecordSource
00085 {
00086 public:
00087 MeiFileVcfRecordSource(
00088 const std::vector< std::string >& meiInput,
00089 const std::vector<std::string> fieldNames,
00090 const cgatools::reference::CrrFile& crr);
00091
00092
00093
00094 std::vector<cgatools::conv::VcfSubFieldHeaderRecord> getSubFieldHeaderRecords() const;
00095 std::string getSource(size_t idxGenome) const;
00096 std::vector<cgatools::conv::VcfKvHeaderRecord> getKeyValueHeaderRecords(size_t idxGenome) const;
00097 std::string getAssemblyId(size_t idxGenome) const;
00098
00099 bool eof() const;
00100 cgatools::conv::VcfRecordSource& operator++();
00101 const cgatools::conv::VcfRecordWriter& operator*() const;
00102 const cgatools::conv::VcfRecordWriter* operator->() const;
00103
00104 private:
00105
00106 void limitFieldNames(const std::vector< std::string > & fieldNames);
00107 void setUpDelimitedFiles();
00108
00109 private:
00110
00111 const cgatools::reference::CrrFile& crr_;
00112 std::vector< std::string > meiFn_;
00113 std::vector< boost::shared_ptr<std::istream> > meiIStr_;
00114 std::vector< boost::shared_ptr<cgatools::util::DelimitedFile> > meiInput_;
00115 meiData tmpMei_;
00116 std::vector< std::string > meiFieldNames_;
00117 std::set< std::string > meiFieldNamesSet_;
00118 boost::shared_ptr<MeiFileVcfRecordWriter> writer_;
00119 bool eof_;
00120 };
00121
00122 } }
00123
00124 #endif // CGATOOLS_MOBILEELEMENT_MEIFILEVCFSOURCE_HPP_