55 if (!incomingBlock_)
return 0;
56 currentBlock_ = incomingBlock_;
57 incomingBlock_ = iterator_->nextBlock();
61 while (incomingBlock_ &&
63 (incomingBlock_->hasSequenceForSpecies(refSpecies_) &&
64 currentBlock_->hasSequenceForSpecies(refSpecies_) &&
65 incomingBlock_->getSequenceForSpecies(refSpecies_).getChromosome() ==
66 currentBlock_->getSequenceForSpecies(refSpecies_).getChromosome()
71 if (currentBlock_->getNumberOfSites() >= minimumSize_) {
79 vector<string> sp1 = currentBlock_->getSpeciesList();
80 vector<string> sp2 = incomingBlock_->getSpeciesList();
85 unsigned int p1 = currentBlock_->getPass();
86 unsigned int p2 = incomingBlock_->getPass();
87 if (p1 == p2) mergedBlock->
setPass(p1);
88 double s1 = currentBlock_->getScore();
89 double n1 =
static_cast<double>(currentBlock_->getNumberOfSites());
90 double s2 = incomingBlock_->getScore();
91 double n2 =
static_cast<double>(incomingBlock_->getNumberOfSites());
92 mergedBlock->
setScore((s1 * n1 + s2 * n2) / (n1 + n2));
95 for (
size_t i = 0; i < allSp.size(); ++i) {
96 unique_ptr<MafSequence> seq;
98 seq.reset(
new MafSequence(currentBlock_->getSequenceForSpecies(allSp[i])));
102 unique_ptr<MafSequence> tmp(
new MafSequence(incomingBlock_->getSequenceForSpecies(allSp[i])));
103 string ref1 = seq->getDescription(), ref2 = tmp->getDescription();
104 if (seq->getChromosome() != tmp->getChromosome()) {
105 seq->setChromosome(
"fus");
106 seq->removeCoordinates();
108 if (seq->getStrand() != tmp->getStrand()) {
110 seq->removeCoordinates();
112 if (seq->getName() != tmp->getName())
113 tmp->setName(seq->getName());
116 (*logstream_ <<
"BLOCK CONCATENATE: merging " << ref1 <<
" with " << ref2 <<
" into " << seq->getDescription()).endLine();
120 string ref1 = seq->getDescription();
121 seq->setToSizeR(seq->size() + incomingBlock_->getNumberOfSites());
123 (*logstream_ <<
"BLOCK CONCATENATE: extending " << ref1 <<
" with " << incomingBlock_->getNumberOfSites() <<
" gaps on the right.").endLine();
128 seq.reset(
new MafSequence(incomingBlock_->getSequenceForSpecies(allSp[i])));
129 string ref2 = seq->getDescription();
130 seq->setToSizeL(seq->size() + currentBlock_->getNumberOfSites());
132 (*logstream_ <<
"BLOCK CONCATENATE: adding " << ref2 <<
" and extend it with " << currentBlock_->getNumberOfSites() <<
" gaps on the left.").endLine();
138 delete currentBlock_;
139 delete incomingBlock_;
140 currentBlock_ = mergedBlock;
142 incomingBlock_ = iterator_->nextBlock();
144 return currentBlock_;
MafBlock * analyseCurrentBlock_()
A synteny block data structure, the basic unit of a MAF alignement file.
void setScore(double score)
void setPass(unsigned int pass)
void addSequence(const MafSequence &sequence)
A sequence class which is used to store data from MAF files.
std::size_t count(const std::string &s, const std::string &pattern)