00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CGATOOLS_VARIANTS_SUPERLOCUSITERATOR_HPP_
00016 #define CGATOOLS_VARIANTS_SUPERLOCUSITERATOR_HPP_ 1
00017
00019
00020 #include "cgatools/core.hpp"
00021 #include "cgatools/variants/Superlocus.hpp"
00022 #include "cgatools/variants/VariantFileIterator.hpp"
00023
00024 #include <deque>
00025
00026 namespace cgatools { namespace variants {
00027
00028 class SuperlocusQueueIterator;
00029
00043 class SuperlocusIterator : private boost::noncopyable
00044 {
00045 public:
00046 enum IterationFlags
00047 {
00049 ITER_INCONSISTENT_ONLY = 1,
00050
00054 ITER_CIRCULAR_MATCHING = 2
00055 };
00056
00064 SuperlocusIterator(
00065 uint32_t extend3Mers = 4,
00066 uint32_t extendBases = 0,
00067 int iterationFlags = ITER_INCONSISTENT_ONLY | ITER_CIRCULAR_MATCHING);
00068
00070 void setVariantFile(VariantFileIterator& iter);
00071
00073 void setVariantFiles(VariantFileIterator& iterA, VariantFileIterator& iterB);
00074
00076 void setVariantFiles(const std::vector<VariantFileIterator*> iters);
00077
00080 void skipToVariant(const reference::Range& range, const std::string& alleleSeq);
00081
00083 void seekFirst();
00084
00086 bool eof() const
00087 {
00088 return eof_;
00089 }
00090
00092 const Superlocus& operator*() const
00093 {
00094 return sl_;
00095 }
00096
00098 const Superlocus* operator->() const
00099 {
00100 return &sl_;
00101 }
00102
00107 reference::Location getPrecedingRefStart() const
00108 {
00109 return precedingRefStart_;
00110 }
00111
00113 SuperlocusIterator& operator++()
00114 {
00115 next();
00116 return *this;
00117 }
00118
00119 private:
00120 void next();
00121 bool findVariant(
00122 const reference::Location& loc, bool trackRefStart,
00123 reference::Range& range, reference::Range& searchRange);
00124 void retireLoci();
00125 void extendVariant();
00126 void extendVariant(reference::Range& slRange, reference::Range& searchRange);
00127
00128 reference::Range extendSearchRange(
00129 const reference::Range& range, const Locus& locus) const;
00130 uint32_t extendLeftBySuffixMatching(const Locus& locus) const;
00131 uint32_t extendRightByPrefixMatching(const Locus& locus) const;
00132 uint32_t extendLeftBySuffixMatching(
00133 const reference::Location& loc, const std::string& sequence) const;
00134 uint32_t extendRightByPrefixMatching(
00135 const reference::Location& loc, const std::string& sequence) const;
00136 size_t findContig(const reference::Location& loc) const;
00137
00138 Superlocus sl_;
00139 std::vector<VariantFileIterator*> iters_;
00140 std::vector< std::deque<Locus> >& queues_;
00141 std::vector< size_t > countRetired_;
00142 std::vector< boost::shared_ptr<SuperlocusQueueIterator> > qIters_;
00143 bool started_;
00144 bool eof_;
00145 uint32_t extend3Mers_;
00146 uint32_t extendBases_;
00147 int iterationFlags_;
00148 uint32_t padBases_;
00149 reference::Location queueCutoff_;
00150 reference::Location slRetired_;
00151 const reference::CrrFile* crr_;
00152 std::vector<reference::Range> contigs_;
00153
00154
00155
00156
00157 reference::Location precedingRefStart_;
00158 };
00159
00160 } }
00161
00162 #endif // CGATOOLS_VARIANTS_SUPERLOCUSITERATOR_HPP_