00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CGATOOLS_VARIANTS_SUPERLOCUS_HPP_
00016 #define CGATOOLS_VARIANTS_SUPERLOCUS_HPP_ 1
00017
00019
00020 #include "cgatools/core.hpp"
00021 #include "cgatools/variants/PhasedHypothesis.hpp"
00022 #include "cgatools/variants/Locus.hpp"
00023
00024 #include <deque>
00025
00026 namespace cgatools { namespace variants {
00027
00028 class SuperlocusIterator;
00029
00032 class Superlocus
00033 {
00034 public:
00036 Superlocus();
00037
00039 void buildPhasedHypotheses(std::vector< std::vector<PhasedHypothesis> >& hypotheses,
00040 size_t maxHypothesisCount,
00041 bool useHapLinks) const;
00042
00044 const reference::Range& getRange() const
00045 {
00046 return range_;
00047 }
00048
00050 uint32_t getId() const
00051 {
00052 return id_;
00053 }
00054
00057 std::pair<std::deque<Locus>::const_iterator, std::deque<Locus>::const_iterator>
00058 getLoci(size_t fileOffset) const;
00059
00060 static uint32_t extendRightByPrefixMatching(
00061 const reference::CrrFile& crr, const reference::Location& loc, const std::string& sequence);
00062 static uint32_t extendLeftBySuffixMatching(
00063 const reference::CrrFile& crr, const reference::Location& loc, const std::string& sequence);
00064
00065 private:
00066 void buildPhasedHypotheses(std::vector<PhasedHypothesis>& hypotheses,
00067 size_t maxHypothesisCount,
00068 bool useHapLinks,
00069 size_t fileOffset) const;
00070 bool hypothesisPermutationsAreEqual(const PhasedHypothesis& hypothesis) const;
00071 bool callPermutationsAreEqual(const Call& lhs, const Call& rhs) const;
00072 bool allelePermutationsAreEqual(const Locus& locus) const;
00073 void addCalls(PhasedHypothesis& hypothesis,
00074 const Locus& locus,
00075 const std::vector<size_t>& perm) const;
00076 void addSequence(PhasedHypothesis& hypothesis,
00077 const Locus& locus,
00078 const std::vector<size_t>& perm,
00079 const std::string& sequence) const;
00080 bool areHapLinksConsistent(const PhasedHypothesis& hypothesis,
00081 const Locus& locus,
00082 const std::vector<size_t>& perm) const;
00083 void downSample(std::vector<PhasedHypothesis>& hypotheses,
00084 size_t maxHypothesisCount) const;
00085 uint32_t hashHypothesis(const PhasedHypothesis& hyp) const;
00086
00087 std::vector< std::deque<Locus> > queues_;
00088 reference::Range range_;
00089 reference::Range searchRange_;
00090 uint32_t id_;
00091
00092 friend class SuperlocusIterator;
00093 };
00094
00095 } }
00096
00097 #endif // CGATOOLS_VARIANTS_SUPERLOCUS_HPP_