本文整理汇总了C++中Genome::getTopSegmentIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ Genome::getTopSegmentIterator方法的具体用法?C++ Genome::getTopSegmentIterator怎么用?C++ Genome::getTopSegmentIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Genome
的用法示例。
在下文中一共展示了Genome::getTopSegmentIterator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createCallBack
void GappedSegmentIteratorIndelTest::createCallBack(AlignmentPtr alignment)
{
addIdenticalParentChild(alignment, 1, 20, 5);
Genome* parent = alignment->openGenome(alignment->getRootName());
Genome* child = parent->getChild(0);
TopSegmentIteratorPtr ti = child->getTopSegmentIterator();
BottomSegmentIteratorPtr bi = parent->getBottomSegmentIterator();
// int i = 0;
// bool reversed = true;
bi = parent->getBottomSegmentIterator(0);
makeDelGap(bi);
bi = parent->getBottomSegmentIterator(3);
makeDelGap(bi);
/*
ti = child->getTopSegmentIterator(1);
makeInsGap(ti);
ti = child->getTopSegmentIterator(21);
makeInsGap(ti);
ti = child->getTopSegmentIterator(28);
makeInsGap(ti);
*/
/* for (size_t i = 0; i < 20; ++i)
{
cout << i << ": ";
bi = parent->getBottomSegmentIterator(i);
ti = child->getTopSegmentIterator(i);
cout << "ci=" << bi->getBottomSegment()->getChildIndex(0)
<< " pi=" << ti->getTopSegment()->getParentIndex() << endl;
}*/
}
示例2: addIdenticalParentChild
void GappedSegmentSimpleIteratorTest2::createCallBack(AlignmentPtr alignment)
{
addIdenticalParentChild(alignment, 2, 100, 5);
Genome* parent = alignment->openGenome(alignment->getRootName());
Genome* child = parent->getChild(0);
TopSegmentIteratorPtr ti = child->getTopSegmentIterator();
BottomSegmentIteratorPtr bi = parent->getBottomSegmentIterator();
hal_index_t i = 0;
bool reversed = true;
while (ti != child->getTopSegmentEndIterator())
{
if (i % 5 == 0)
{
reversed = !reversed;
if (reversed && i < (hal_index_t)(parent->getNumBottomSegments() - 1))
{
makeInversion(ti, 5);
}
}
ti->toRight();
bi->toRight();
++i;
}
}
示例3: createCallBack
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);
}
}
示例4: writeHomologies
void LodExtract::writeHomologies(const Genome* inParent,
const vector<const Genome*>& inChildren)
{
vector<const Genome*> inGenomes = inChildren;
inGenomes.push_back(inParent);
Genome* outParent = _outAlignment->openGenome(inParent->getName());
assert(outParent != NULL && outParent->getNumBottomSegments() > 0);
assert(inChildren.size() > 0);
Genome* outChild = _outAlignment->openGenome(inChildren[0]->getName());
BottomSegmentIteratorPtr bottom = outParent->getBottomSegmentIterator();
TopSegmentIteratorPtr top = outChild->getTopSegmentIterator();
// FOR EVERY BLOCK
for (hal_size_t blockIdx = 0; blockIdx < _graph.getNumBlocks(); ++blockIdx)
{
SegmentMap segMap;
const LodBlock* block = _graph.getBlock(blockIdx);
for (hal_size_t segIdx = 0; segIdx < block->getNumSegments(); ++segIdx)
{
const LodSegment* segment = block->getSegment(segIdx);
const Genome* genome = segment->getSequence()->getGenome();
// ADD TO MAP
pair<SegmentMap::iterator, bool> res = segMap.insert(
pair<const Genome*, SegmentSet*>(genome, NULL));
if (res.second == true)
{
assert(res.first->second == NULL);
res.first->second = new SegmentSet();
}
res.first->second->insert(segment);
}
updateBlockEdges(inParent, segMap, block, bottom, top);
// free the temporary sets!
for (SegmentMap::iterator mapIt = segMap.begin(); mapIt != segMap.end();
++mapIt)
{
delete mapIt->second;
}
}
}
示例5: createCallBack
void GenomeCopyTest::createCallBack(Alignment *alignment) {
hal_size_t alignmentSize = alignment->getNumGenomes();
CuAssertTrue(_testCase, alignmentSize == 0);
// Hacky: Need a different alignment to test copying the bottom
// segments correctly. (the names of a node's children are used
// when copying bottom segments, and two genomes can't have the same
// name in the same alignment)
_path = getTempFile();
_secondAlignment =
AlignmentPtr(getTestAlignmentInstances(alignment->getStorageFormat(), _path, WRITE_ACCESS | CREATE_ACCESS));
Genome *ancGenome = alignment->addRootGenome("AncGenome", 0);
Genome *leafGenome = alignment->addLeafGenome("LeafGenome1", "AncGenome", 0);
// This genome will test copyDimensions, copyTopSegments,
// copyBottomSegments, copySequence, copyMetadata
Genome *copyRootGenome = _secondAlignment->addRootGenome("copyRootGenome", 0);
Genome *copyLeafGenome = _secondAlignment->addLeafGenome("LeafGenome1", "copyRootGenome", 0);
MetaData *ancMeta = ancGenome->getMetaData();
ancMeta->set("Young", "Jeezy");
vector<Sequence::Info> seqVec(1);
seqVec[0] = Sequence::Info("Sequence", 1000000, 0, 700000);
ancGenome->setDimensions(seqVec);
seqVec[0] = Sequence::Info("Sequence", 1000000, 5000, 0);
leafGenome->setDimensions(seqVec);
string ancSeq = "CAT";
hal_index_t n = ancGenome->getSequenceLength();
DnaIteratorPtr dnaIt = ancGenome->getDnaIterator();
for (; dnaIt->getArrayIndex() < n; dnaIt->toRight()) {
size_t i = dnaIt->getArrayIndex() % ancSeq.size();
dnaIt->setBase(ancSeq[i]);
}
dnaIt->flush();
n = leafGenome->getSequenceLength();
dnaIt = leafGenome->getDnaIterator();
for (; dnaIt->getArrayIndex() < n; dnaIt->toRight()) {
size_t i = dnaIt->getArrayIndex() % ancSeq.size();
dnaIt->setBase(ancSeq[i]);
}
dnaIt->flush();
TopSegmentIteratorPtr topIt = leafGenome->getTopSegmentIterator();
n = leafGenome->getNumTopSegments();
for (; topIt->getArrayIndex() < n; topIt->toRight()) {
topIt->setCoordinates(topIt->getArrayIndex(), 1);
topIt->tseg()->setParentIndex(3);
topIt->tseg()->setParentReversed(true);
topIt->tseg()->setBottomParseIndex(5);
if (topIt->getArrayIndex() != 6) {
topIt->tseg()->setNextParalogyIndex(6);
} else {
topIt->tseg()->setNextParalogyIndex(7);
}
}
BottomSegmentIteratorPtr botIt = ancGenome->getBottomSegmentIterator();
n = ancGenome->getNumBottomSegments();
for (; botIt->getArrayIndex() < n; botIt->toRight()) {
botIt->setCoordinates(botIt->getArrayIndex(), 1);
botIt->bseg()->setChildIndex(0, 3);
botIt->bseg()->setChildReversed(0, true);
botIt->bseg()->setTopParseIndex(5);
}
seqVec[0] = Sequence::Info("Sequence", 3300, 0, 1100);
copyRootGenome->setDimensions(seqVec);
seqVec[0] = Sequence::Info("Sequence", 3300, 2200, 0);
copyLeafGenome->setDimensions(seqVec);
string copySeq = "TAG";
dnaIt = copyRootGenome->getDnaIterator();
n = copyRootGenome->getSequenceLength();
for (; dnaIt->getArrayIndex() < n; dnaIt->toRight()) {
size_t i = dnaIt->getArrayIndex() % copySeq.size();
dnaIt->setBase(copySeq[i]);
}
dnaIt->flush();
dnaIt = copyLeafGenome->getDnaIterator();
n = copyLeafGenome->getSequenceLength();
for (; dnaIt->getArrayIndex() < n; dnaIt->toRight()) {
size_t i = dnaIt->getArrayIndex() % copySeq.size();
dnaIt->setBase(copySeq[i]);
}
dnaIt->flush();
topIt = copyLeafGenome->getTopSegmentIterator();
n = copyLeafGenome->getNumTopSegments();
for (; topIt->getArrayIndex() < n; topIt->toRight()) {
topIt->setCoordinates(7, 8);
topIt->tseg()->setParentIndex(9);
topIt->tseg()->setParentReversed(false);
topIt->tseg()->setBottomParseIndex(11);
if (topIt->getArrayIndex() != 12) {
topIt->tseg()->setNextParalogyIndex(12);
} else {
topIt->tseg()->setNextParalogyIndex(7);
}
}
//.........这里部分代码省略.........
示例6: createCallBack
void MappedSegmentMapExtraParalogsTest::createCallBack(AlignmentPtr alignment)
{
vector<Sequence::Info> seqVec(1);
BottomSegmentIteratorPtr bi;
BottomSegmentStruct bs;
TopSegmentIteratorPtr ti;
TopSegmentStruct ts;
// Set up a case where all the segments of grandChild1 coalesce with
// the first segment of grandChild2, but only if using the root as
// the coalescence limit. Otherwise only the first segments map to
// each other.
Genome* root = alignment->addRootGenome("root");
Genome* parent = alignment->addLeafGenome("parent", "root", 1);
Genome* grandChild1 = alignment->addLeafGenome("grandChild1", "parent", 1);
Genome* grandChild2 = alignment->addLeafGenome("grandChild2", "parent", 1);
seqVec[0] = Sequence::Info("Sequence", 3, 0, 1);
root->setDimensions(seqVec);
seqVec[0] = Sequence::Info("Sequence", 9, 3, 3);
parent->setDimensions(seqVec);
seqVec[0] = Sequence::Info("Sequence", 9, 3, 0);
grandChild1->setDimensions(seqVec);
seqVec[0] = Sequence::Info("Sequence", 9, 3, 0);
grandChild2->setDimensions(seqVec);
root->setString("CCC");
parent->setString("CCCTACGTG");
grandChild1->setString("CCCTACGTG");
grandChild2->setString("CCCTACGTG");
bi = root->getBottomSegmentIterator();
bs.set(0, 3);
bs._children.push_back(pair<hal_size_t, bool>(0, false));
bs.applyTo(bi);
ti = parent->getTopSegmentIterator();
ts.set(0, 3, 0, false, NULL_INDEX, 1);
ts.applyTo(ti);
ti->toRight();
ts.set(3, 3, 0, false, NULL_INDEX, 2);
ts.applyTo(ti);
ti->toRight();
ts.set(6, 3, 0, false, NULL_INDEX, 0);
ts.applyTo(ti);
bi = parent->getBottomSegmentIterator();
bs.set(0, 3);
bs._children.clear();
bs._children.push_back(pair<hal_size_t, bool>(0, true));
bs._children.push_back(pair<hal_size_t, bool>(0, false));
bs.applyTo(bi);
bi->toRight();
bs.set(3, 3);
bs._children.clear();
bs._children.push_back(pair<hal_size_t, bool>(1, true));
bs._children.push_back(pair<hal_size_t, bool>(NULL_INDEX, true));
bs.applyTo(bi);
bi->toRight();
bs.set(6, 3);
bs._children.clear();
bs._children.push_back(pair<hal_size_t, bool>(2, true));
bs._children.push_back(pair<hal_size_t, bool>(NULL_INDEX, false));
bs.applyTo(bi);
ti = grandChild1->getTopSegmentIterator();
ts.set(0, 3, 0, true);
ts.applyTo(ti);
ti->toRight();
ts.set(3, 3, 1, true);
ts.applyTo(ti);
ti->toRight();
ts.set(6, 3, 2, true);
ts.applyTo(ti);
ti = grandChild2->getTopSegmentIterator();
ts.set(0, 3, 0, false);
ts.applyTo(ti);
ti->toRight();
ts.set(3, 3, NULL_INDEX, true);
ts.applyTo(ti);
ti->toRight();
ts.set(6, 3, NULL_INDEX, false);
ts.applyTo(ti);
parent->fixParseInfo();
}