00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CGATOOLS_VARIANTS_CALL_HPP_
00016 #define CGATOOLS_VARIANTS_CALL_HPP_ 1
00017
00019
00020 #include "cgatools/core.hpp"
00021 #include "cgatools/reference/CrrFile.hpp"
00022 #include "cgatools/util/DelimitedFile.hpp"
00023 #include <string>
00024
00025 namespace cgatools { namespace variants {
00026
00029 struct Call
00030 {
00031 public:
00032 class VarQualityField : public util::DelimitedFieldParser
00033 {
00034 public:
00035 VarQualityField(const std::string& name, std::vector<std::string>* varFilter);
00036
00037 void parse(const char* first, const char* last);
00038
00039 private:
00040 std::vector<std::string>* varFilter_;
00041 };
00042
00043 class VarFilterField : public util::DelimitedFieldParser
00044 {
00045 public:
00046 VarFilterField(const std::string& name, std::vector<std::string>* varFilter);
00047
00048 void parse(const char* first, const char* last);
00049
00050 private:
00051 std::vector<std::string>* varFilter_;
00052 };
00053
00054 class TotalScoreField : public util::DelimitedFieldParser
00055 {
00056 public:
00057 TotalScoreField(
00058 const std::string& name,
00059 int32_t* varScoreVAF,
00060 int32_t* varScoreEAF);
00061
00062 void parse(const char* first, const char* last);
00063
00064 private:
00065 int32_t* varScoreVAF_;
00066 int32_t* varScoreEAF_;
00067 };
00068
00069 struct AlternativeCall
00070 {
00071 AlternativeCall()
00072 : score_(0)
00073 {
00074 }
00075
00076 AlternativeCall(const std::string& alleleSeq, int32_t score)
00077 : alleleSeq_(alleleSeq),
00078 score_(score)
00079 {
00080 }
00081
00082 std::string alleleSeq_;
00083 int32_t score_;
00084 };
00085
00086 class AlternativeCallsField : public util::DelimitedFieldParser
00087 {
00088 public:
00089 AlternativeCallsField(
00090 const std::string& name,
00091 std::vector<AlternativeCall>* alternativeCalls);
00092
00093 void parse(const char* first, const char* last);
00094
00095 private:
00096 std::vector<AlternativeCall>* alternativeCalls_;
00097 };
00098
00100 static const uint16_t ALL_HAPLOTYPES;
00101
00103 static const uint16_t UNKNOWN_PLOIDY;
00104
00106 static const int32_t EMPTY_SCORE;
00107
00109 Call ();
00110
00113 std::string calledSequence(const reference::CrrFile& crr) const;
00114
00117 std::string refSequence(const reference::CrrFile& crr) const;
00118
00121 bool isRefConsistent(const reference::CrrFile& crr) const;
00122
00125 bool hasNoCalls() const;
00126
00129 void addFieldParsers(util::DelimitedFile& df, const reference::CrrFile& crr);
00130
00132 void addVarFilter(const std::string& filter);
00133
00135 std::ostream& write(std::ostream& out,
00136 const reference::CrrFile& crr,
00137 const char sep = '\t') const;
00138
00140 static void parseAlternativeCalls(
00141 const char* first, const char* last, std::vector<AlternativeCall>& alternativeCalls);
00142
00144 static void parseVarFilter(
00145 const char* first, const char* last, std::vector<std::string>& varFilter);
00146
00148 static std::string getHeader (const char separator = '\t');
00149
00151 uint32_t locus_;
00152
00155 uint16_t ploidy_;
00156
00159 uint16_t haplotype_;
00160
00162 reference::Range range_;
00163
00165 std::string varType_;
00166
00168 std::string reference_;
00169
00171 std::string alleleSeq_;
00172
00174 int32_t varScoreVAF_;
00175
00180 int32_t varScoreEAF_;
00181
00186 std::vector<std::string> varFilter_;
00187
00189 std::string hapLink_;
00190
00192 std::string xRef_;
00193
00195 std::string alleleFreq_;
00196
00198 std::vector<AlternativeCall> alternativeCalls_;
00199 };
00200
00203 void upgradeOldFieldValues(Call& c);
00204
00205 } }
00206
00207 #endif // CGATOOLS_VARIANTS_CALL_HPP_