43 #include <Bpp/Seq/SequenceWithAnnotationTools.h> 44 #include <Bpp/Seq/SequenceWithQuality.h> 56 out <<
"##maf version=1 program=Bio++" << endl <<
"#" << endl;
64 out <<
" score=" << block.
getScore();
66 out <<
" pass=" << block.
getPass();
70 size_t mxcSrc = 0, mxcStart = 0, mxcSize = 0, mxcSrcSize = 0;
76 mxcSrc = max(mxcSrc , seq->getName().size());
77 mxcStart = max(mxcStart , TextTools::toString(start).size());
78 mxcSize = max(mxcSize , TextTools::toString(seq->
getGenomicSize()).size());
79 mxcSrcSize = max(mxcSrcSize, TextTools::toString(seq->
getSrcSize()).size());
85 out << TextTools::resizeRight(seq->getName(), mxcSrc,
' ') <<
" ";
89 out << TextTools::resizeLeft(TextTools::toString(start), mxcStart,
' ') <<
" ";
90 out << TextTools::resizeLeft(TextTools::toString(seq->
getGenomicSize()), mxcSize,
' ') <<
" ";
92 out << TextTools::resizeLeft(TextTools::toString(seq->
getSrcSize()), mxcSrcSize,
' ') <<
" ";
94 string seqstr = seq->toString();
95 if (mask_ && seq->hasAnnotation(SequenceMask::MASK)) {
96 const SequenceMask* mask = &
dynamic_cast<const SequenceMask&
>(seq->getAnnotation(SequenceMask::MASK));
97 for (
size_t j = 0; j < seqstr.size(); ++j) {
98 char c = ((*mask)[j] ?
static_cast<char>(tolower(static_cast<int>(seqstr[j]))) : seqstr[j]);
106 if (mask_ && seq->hasAnnotation(SequenceQuality::QUALITY_SCORE)) {
107 const SequenceQuality* qual = &
dynamic_cast<const SequenceQuality&
>(seq->getAnnotation(SequenceQuality::QUALITY_SCORE));
109 out << TextTools::resizeRight(seq->getName(), mxcSrc + mxcStart + mxcSize + mxcSrcSize + 5,
' ') <<
" ";
111 for (
size_t j = 0; j < seq->size(); ++j) {
115 }
else if (s == -2) {
117 }
else if (s >=0 && s < 10) {
118 qualStr += TextTools::toString(s);
119 }
else if (s == 10) {
122 throw Exception(
"MafAlignmentParser::writeBlock. Unsuported score value: " + TextTools::toString(s));
125 out << qualStr << endl;
unsigned int getPass() const
bool hasCoordinates() const
size_t getGenomicSize() const
void writeHeader(std::ostream &out) const
A synteny block data structure, the basic unit of a MAF alignement file.
size_t getSrcSize() const
size_t getNumberOfSequences() const
void writeBlock(std::ostream &out, const MafBlock &block) const
const MafSequence & getSequence(const std::string &name) const
A sequence class which is used to store data from MAF files.