52 if (!incomingBlock_)
return 0;
53 currentBlock_ = incomingBlock_;
54 incomingBlock_ = iterator_->nextBlock();
55 while (incomingBlock_) {
56 if (currentBlock_->getNumberOfSites() >= minimumSize_) {
61 vector<string> sp2 = incomingBlock_->getSpeciesList();
62 vector<string> allSp = VectorTools::unique(VectorTools::vectorUnion(sp1, sp2));
66 unsigned int p1 = currentBlock_->getPass();
67 unsigned int p2 = incomingBlock_->getPass();
68 if (p1 == p2) mergedBlock->
setPass(p1);
69 double s1 = currentBlock_->getScore();
70 double n1 =
static_cast<double>(currentBlock_->getNumberOfSites());
71 double s2 = incomingBlock_->getScore();
72 double n2 =
static_cast<double>(incomingBlock_->getNumberOfSites());
73 mergedBlock->
setScore((s1 * n1 + s2 * n2) / (n1 + n2));
76 for (
size_t i = 0; i < allSp.size(); ++i) {
77 auto_ptr<MafSequence> seq;
79 seq.reset(
new MafSequence(currentBlock_->getSequenceForSpecies(allSp[i])));
83 auto_ptr<MafSequence> tmp(
new MafSequence(incomingBlock_->getSequenceForSpecies(allSp[i])));
93 if (seq->getName() != tmp->getName())
97 (*logstream_ <<
"BLOCK CONCATENATE: merging " << ref1 <<
" with " << ref2 <<
" into " << seq->
getDescription()).endLine();
99 }
catch (SequenceNotFoundException& snfe2) {
102 seq->setToSizeR(seq->size() + incomingBlock_->getNumberOfSites());
104 (*logstream_ <<
"BLOCK CONCATENATE: extending " << ref1 <<
" with " << incomingBlock_->getNumberOfSites() <<
" gaps on the right.").endLine();
107 }
catch (SequenceNotFoundException& snfe1) {
109 seq.reset(
new MafSequence(incomingBlock_->getSequenceForSpecies(allSp[i])));
111 seq->setToSizeL(seq->size() + currentBlock_->getNumberOfSites());
113 (*logstream_ <<
"BLOCK CONCATENATE: adding " << ref2 <<
" and extend it with " << currentBlock_->getNumberOfSites() <<
" gaps on the left.").endLine();
119 delete currentBlock_;
120 delete incomingBlock_;
121 currentBlock_ = mergedBlock;
123 incomingBlock_ = iterator_->nextBlock();
125 return currentBlock_;
void setName(const std::string &name)
void setScore(double score)
void setChromosome(const std::string &chr)
A synteny block data structure, the basic unit of a MAF alignement file.
void addSequence(const MafSequence &sequence)
std::vector< std::string > getSpeciesList() const
const std::string & getChromosome() const
MafBlock * analyseCurrentBlock_()
void setPass(unsigned int pass)
A sequence class which is used to store data from MAF files.
std::string getDescription() const