41 #include <Bpp/Text/TextTools.h> 42 #include <Bpp/Text/StringTokenizer.h> 47 MafBlock* SequenceStreamToMafIterator::analyseCurrentBlock_() throw (Exception)
49 auto_ptr<MafBlock> block(
new MafBlock());
52 if (stream_->eof())
return 0;
54 seqStream_->nextSequence(*stream_, mafSeq);
56 string meta = mafSeq.getName();
57 StringTokenizer st(meta,
":");
58 if (st.numberOfRemainingTokens() == 5) {
59 string species = st.nextToken();
60 string chr = st.nextToken();
61 unsigned int start = TextTools::to<unsigned int>(st.nextToken());
62 if (!zeroBasedCoords_)
64 string strand = st.nextToken();
65 unsigned int length = TextTools::to<unsigned int>(st.nextToken());
66 mafSeq.
setName(species +
"." + chr);
69 if (mafSeq.size() != length)
70 throw Exception(
"SequenceStreamToMafIterator::analyseCurrentBlock_. Sequence size does not match its header specification: expected " + TextTools::toString(length) +
" and found " + TextTools::toString(mafSeq.size()));
74 return block.release();
void setName(const std::string &name)
void setStart(size_t begin)
A synteny block data structure, the basic unit of a MAF alignement file.
void addSequence(const MafSequence &sequence)
A sequence class which is used to store data from MAF files.