52 if (blockBuffer_.size() == 0) {
55 MafBlock* block = iterator_->nextBlock();
61 (*logstream_ <<
"FEATURE FILTER: block " << block->
getDescription() <<
" does not contain the reference species and was kept as is.").endLine();
69 std::map<std::string, MultiRange<size_t> >::iterator mr = ranges_.find(refSeq.
getChromosome());
70 if (mr == ranges_.end()) {
72 (*logstream_ <<
"FEATURE FILTER: block " << block->
getDescription() <<
" does not contain any feature and was kept as is.").endLine();
82 (*logstream_ <<
"FEATURE FILTER: block " << block->
getDescription() <<
" does not contain any feature and was kept as is.").endLine();
86 std::vector<size_t> tmp = mRange.
getBounds();
89 std::deque<size_t> refBounds;
91 for (
size_t i = 0; i < tmp.size(); ++i)
93 refBounds.push_front(refSeq.
getSrcSize() - tmp[i]);
96 refBounds = deque<size_t>(tmp.begin(), tmp.end());
104 long int refPos =
static_cast<long int>(refSeq.
start()) - 1;
106 std::vector<size_t> pos;
111 for (
size_t alnPos = 0; alnPos < refSeq.
size() && refBounds.size() > 0; ++alnPos) {
114 if (refSeq[alnPos] != gap) {
117 while (refBounds.front() ==
static_cast<size_t>(refPos)) {
118 pos.push_back(alnPos);
119 refBounds.pop_front();
127 if (refBounds.size() > 0 && refBounds.front() == refSeq.
stop()) {
128 pos.push_back(refSeq.
size());
129 refBounds.pop_front();
132 if (refBounds.size() > 0) {
134 throw Exception(
"FeatureFilterMafIterator::nextBlock(). An error occurred here, " +
TextTools::toString(refBounds.size()) +
" coordinates are left, in sequence " + refSeq.
getDescription() +
"... this is most likely a bug, please report!");
138 if (pos.size() == 2 && pos.front() == 0 && pos.back() == block->
getNumberOfSites()) {
141 (*logstream_ <<
"FEATURE FILTER: block " << block->
getDescription() <<
" was entirely removed. Tried to get the next one.").endLine();
145 (*logstream_ <<
"FEATURE FILTER: block " << block->
getDescription() <<
" with size "<< block->
getNumberOfSites() <<
" will be split into " << (pos.size() / 2 + 1) <<
" blocks.").endLine();
150 for (
size_t i = 0; i < pos.size(); i+=2) {
154 (*logstream_ <<
"FEATURE FILTER: removing region (" << pos[i] <<
", " << pos[i+1] <<
") from block " << block->
getDescription() <<
".").endLine();
171 blockBuffer_.push_back(newBlock);
176 if (keepTrashedBlocks_) {
185 trashBuffer_.push_back(outBlock);
199 blockBuffer_.push_back(newBlock);
206 }
while (blockBuffer_.size() == 0);
209 MafBlock* nxtBlock = blockBuffer_.front();
210 blockBuffer_.pop_front();
virtual int getGapCharacterCode() const=0
virtual const Alphabet * getAlphabet() const=0
virtual size_t size() const=0
MafBlock * analyseCurrentBlock_()
A synteny block data structure, the basic unit of a MAF alignement file.
unsigned int getPass() const
void setScore(double score)
void setPass(unsigned int pass)
size_t getNumberOfSequences() const
size_t getNumberOfSites() const
const MafSequence & getSequence(const std::string &name) const
std::string getDescription() const
void addSequence(const MafSequence &sequence)
bool hasSequenceForSpecies(const std::string &species) const
const MafSequence & getSequenceForSpecies(const std::string &species) const
A sequence class which is used to store data from MAF files.
std::string getDescription() const
const std::string & getChromosome() const
size_t getSrcSize() const
Range< size_t > getRange(bool origin=true) const
MafSequence * subSequence(size_t startAt, size_t length) const
Extract a sub-sequence.
void restrictTo(const Range< T > &r)
std::vector< T > getBounds() const
std::string toString(T t)