00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CGATOOLS_VARIANTS_PHASEDHYPOTHESIS_HPP_
00016 #define CGATOOLS_VARIANTS_PHASEDHYPOTHESIS_HPP_ 1
00017
00019
00020 #include "cgatools/core.hpp"
00021 #include "cgatools/variants/PhasedAllele.hpp"
00022 #include "cgatools/variants/CallDiffMatchType.hpp"
00023 #include "cgatools/variants/AlleleDiffSegment.hpp"
00024
00025 namespace cgatools { namespace variants {
00026
00027 class Superlocus;
00028 class CallDiffResult;
00029
00031 class PhasedHypothesis
00032 {
00033 public:
00035 PhasedHypothesis();
00036
00038 PhasedHypothesis(const reference::Range& range, size_t ploidy);
00039
00041 size_t size() const
00042 {
00043 return alleles_.size();
00044 }
00045
00047 const reference::Range& getRange() const
00048 {
00049 return range_;
00050 }
00051
00053 const PhasedAllele& operator[](size_t offset) const
00054 {
00055 return alleles_[offset];
00056 }
00057
00059 PhasedAllele& operator[](size_t offset)
00060 {
00061 return alleles_[offset];
00062 }
00063
00064 void swap(PhasedHypothesis& other);
00065
00068 static void findBestDiff(const Superlocus& sl,
00069 size_t maxHypothesisCount,
00070 const std::vector<PhasedHypothesis>& lhs,
00071 const std::vector<PhasedHypothesis>& rhs,
00072 const reference::CrrFile& crr,
00073 CallDiffResult& result);
00074
00075 static void testVariant(const Superlocus& sl,
00076 const std::vector<PhasedHypothesis>& hyps,
00077 const reference::Range& varRange,
00078 const std::string& varAllele,
00079 const reference::CrrFile& crr,
00080 std::string& result);
00081
00082 private:
00083 static void diffHypotheses(const PhasedHypothesis& lhs,
00084 const PhasedHypothesis& rhs,
00085 const std::string& refSequence,
00086 const std::vector<size_t>& perm,
00087 std::vector<cdmt::MatchType>& result);
00088 static void testVariantOneHypothesis(
00089 const PhasedHypothesis& hyp,
00090 const PhasedAllele& rhs,
00091 const reference::Range& variantRange,
00092 const reference::Range& extendedVariantRange,
00093 const std::string& refSequence,
00094 std::string& result);
00095 static char testPhasedAllele(const PhasedAllele& lhs,
00096 const PhasedAllele& rhs,
00097 const std::vector<AlleleDiffSegment>& segs,
00098 int lSeg,
00099 int rSeg);
00100
00101 static void classifyCalls(
00102 const PhasedAllele& lhs,
00103 const PhasedAllele& rhs,
00104 const std::string& refSequence,
00105 const reference::CrrFile& crr,
00106 const reference::Range& range,
00107 cdmt::MatchType mt,
00108 std::vector< std::pair<cdmt::MatchType, const Call*> >& lhsCallClass,
00109 std::vector< std::pair<cdmt::MatchType, const Call*> >& rhsCallClass,
00110 cdmt::MatchType& mtBySeg);
00111
00112 static cdmt::MatchType matchTypeForCall(
00113 cdmt::MatchType mt,
00114 const reference::CrrFile& crr,
00115 const Call* call);
00116
00117 static void splitIntoSegments(const PhasedAllele& lhs,
00118 const PhasedAllele& rhs,
00119 const std::string& refSequence,
00120 const reference::Range& range,
00121 std::vector<AlleleDiffSegment>& segs);
00122 static bool segCanSplit(const Call& call, uint32_t pos);
00123
00124 reference::Range range_;
00125 std::vector<PhasedAllele> alleles_;
00126 };
00127
00128 } }
00129
00130 #endif // CGATOOLS_VARIANTS_PHASEDHYPOTHESIS_HPP_