void LodExtract::writeSequences(const Genome* inParent, const vector<const Genome*>& inChildren) { vector<const Genome*> inGenomes = inChildren; inGenomes.push_back(inParent); const Genome* outParent = _outAlignment->openGenome(inParent->getName()); (void)outParent; assert(outParent != NULL && outParent->getNumBottomSegments() > 0); string buffer; for (hal_size_t i = 0; i < inGenomes.size(); ++i) { const Genome* inGenome = inGenomes[i]; Genome* outGenome = _outAlignment->openGenome(inGenome->getName()); if (inGenome == inParent || outGenome->getNumChildren() == 0) { SequenceIteratorConstPtr inSeqIt = inGenome->getSequenceIterator(); SequenceIteratorConstPtr end = inGenome->getSequenceEndIterator(); for (; inSeqIt != end; inSeqIt->toNext()) { const Sequence* inSequence = inSeqIt->getSequence(); if (inSequence->getSequenceLength() > 0) { Sequence* outSequence = outGenome->getSequence(inSequence->getName()); assert(outSequence != NULL); inSequence->getString(buffer); outSequence->setString(buffer); } } } } }
void TopSegmentSimpleIteratorTest::createCallBack(Alignment *alignment) { Genome *ancGenome = alignment->addRootGenome("Anc0", 0); size_t numChildren = 9; for (size_t i = 0; i < numChildren; ++i) { alignment->addLeafGenome("Leaf" + std::to_string(i), "Anc0", 0.1); } vector<Sequence::Info> seqVec(1); seqVec[0] = Sequence::Info("Sequence", 1000000, 5000, 10000); ancGenome->setDimensions(seqVec); CuAssertTrue(_testCase, ancGenome->getNumChildren() == numChildren); _topSegments.clear(); for (size_t i = 0; i < ancGenome->getNumTopSegments(); ++i) { TopSegmentStruct topSeg; topSeg.setRandom(); topSeg._length = ancGenome->getSequenceLength() / ancGenome->getNumTopSegments(); topSeg._startPosition = i * topSeg._length; _topSegments.push_back(topSeg); } TopSegmentIteratorPtr tsIt = ancGenome->getTopSegmentIterator(0); for (size_t i = 0; not tsIt->atEnd(); tsIt->toRight(), ++i) { CuAssertTrue(_testCase, (size_t)tsIt->getTopSegment()->getArrayIndex() == i); _topSegments[i].applyTo(tsIt); } }