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 size_t getGenomeCount() const
00061 {
00062 return queues_.size();
00063 }
00064
00065 static uint32_t extendRightByPrefixMatching(
00066 const reference::CrrFile& crr, const reference::Location& loc, const std::string& sequence);
00067 static uint32_t extendLeftBySuffixMatching(
00068 const reference::CrrFile& crr, const reference::Location& loc, const std::string& sequence);
00069
00070 private:
00071 void buildPhasedHypotheses(std::vector<PhasedHypothesis>& hypotheses,
00072 size_t maxHypothesisCount,
00073 bool useHapLinks,
00074 size_t fileOffset) const;
00075 bool hypothesisPermutationsAreEqual(const PhasedHypothesis& hypothesis) const;
00076 bool callPermutationsAreEqual(const Call& lhs, const Call& rhs) const;
00077 bool allelePermutationsAreEqual(const Locus& locus) const;
00078 void addCalls(PhasedHypothesis& hypothesis,
00079 const Locus& locus,
00080 const std::vector<size_t>& perm) const;
00081 void addSequence(PhasedHypothesis& hypothesis,
00082 const Locus& locus,
00083 const std::vector<size_t>& perm,
00084 const std::string& sequence) const;
00085 bool areHapLinksConsistent(const PhasedHypothesis& hypothesis,
00086 const Locus& locus,
00087 const std::vector<size_t>& perm) const;
00088 void downSample(std::vector<PhasedHypothesis>& hypotheses,
00089 size_t maxHypothesisCount) const;
00090 uint32_t hashHypothesis(const PhasedHypothesis& hyp) const;
00091
00092 std::vector< std::deque<Locus> > queues_;
00093 reference::Range range_;
00094 reference::Range searchRange_;
00095 uint32_t id_;
00096
00097 friend class SuperlocusIterator;
00098 };
00099
00100 } }
00101
00102 #endif // CGATOOLS_VARIANTS_SUPERLOCUS_HPP_