本文整理汇总了C++中BottomSegmentIteratorPtr::setCoordinates方法的典型用法代码示例。如果您正苦于以下问题:C++ BottomSegmentIteratorPtr::setCoordinates方法的具体用法?C++ BottomSegmentIteratorPtr::setCoordinates怎么用?C++ BottomSegmentIteratorPtr::setCoordinates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BottomSegmentIteratorPtr
的用法示例。
在下文中一共展示了BottomSegmentIteratorPtr::setCoordinates方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setBottomSegments
// Set bottom segments to be equal width and so that segment 1, 2, 3,
// etc. corresponds to child segment 1, 2, 3, etc.
void setBottomSegments(Genome *genome, hal_size_t width) {
hal_size_t numChildren = genome->getNumChildren();
BottomSegmentIteratorPtr bottomIt = genome->getBottomSegmentIterator();
hal_size_t n = genome->getNumBottomSegments();
hal_index_t startPos = 0;
for (; bottomIt->getArrayIndex() < n; bottomIt->toRight(), startPos += width) {
for (hal_size_t i = 0; i < numChildren; i++) {
bottomIt->setCoordinates(startPos, width);
bottomIt->bseg()->setChildIndex(i, bottomIt->getArrayIndex());
bottomIt->bseg()->setChildReversed(i, false);
bottomIt->bseg()->setTopParseIndex(NULL_INDEX);
}
}
}
示例2: 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);
}
}
//.........这里部分代码省略.........
示例3: copyBottomSegments
void Genome::copyBottomSegments(Genome *dest) const
{
assert(getNumBottomSegments() == dest->getNumBottomSegments());
hal_size_t inNc = getNumChildren();
hal_size_t outNc = dest->getNumChildren();
// The child indices aren't consistent across files--make sure each bottom
// segment points to the correct children
vector<string> inChildNames;
vector<string> outChildNames;
for (hal_size_t inChild = 0; inChild < inNc; ++inChild)
{
inChildNames.push_back(getChild(inChild)->getName());
}
for (hal_size_t outChild = 0; outChild < outNc; ++outChild)
{
outChildNames.push_back(dest->getChild(outChild)->getName());
}
map<hal_size_t, hal_size_t> inChildToOutChild;
for (hal_size_t inChild = 0; inChild < inNc; inChild++)
{
hal_size_t outChild;
for (outChild = 0; outChild < outNc; outChild++)
{
if (inChildNames[inChild] == outChildNames[outChild])
{
inChildToOutChild[inChild] = outChild;
break;
}
}
if (outChild == outNc)
{
inChildToOutChild[inChild] = outNc;
}
}
// Go through each sequence in this genome, find the matching
// sequence in the dest genome, then copy over the segments for each
// sequence.
SequenceIteratorConstPtr seqIt = getSequenceIterator();
SequenceIteratorConstPtr seqEndIt = getSequenceEndIterator();
for (; seqIt != seqEndIt; seqIt->toNext())
{
const Sequence *inSeq = seqIt->getSequence();
const Sequence *outSeq = dest->getSequence(inSeq->getName());
BottomSegmentIteratorPtr inBot = inSeq->getBottomSegmentIterator();
BottomSegmentIteratorPtr outBot = outSeq->getBottomSegmentIterator();
cout << "DEBUG: inSeq name: " << inSeq->getName() << ", outSeq name: " << outSeq->getName() << endl;
if (inSeq->getName() != outSeq->getName()) {
// This check is important enough that it can't be an assert.
stringstream ss;
ss << "When copying bottom segments: segment #" << inBot->getArrayIndex() << " of source genome is from sequence " << inBot->getSequence()->getName() << ", but segment #" << outBot->getArrayIndex() << " is from sequence " << outBot->getSequence()->getName();
throw hal_exception(ss.str());
}
if (inSeq->getNumBottomSegments() != outSeq->getNumBottomSegments()) {
stringstream ss;
ss << "When copying bottom segments: sequence " << inSeq->getName() << " has " << inSeq->getNumBottomSegments() << " in genome " << getName() << ", while it has " << outSeq->getNumBottomSegments() << " in genome " << dest->getName();
throw hal_exception(ss.str());
}
hal_index_t inSegmentEnd = inSeq->getBottomSegmentArrayIndex() + inSeq->getNumBottomSegments();
cout << "DEBUG: inSegmentStart: " << inSeq->getBottomSegmentArrayIndex() << " inSegmentEnd: " << inSegmentEnd << " num bottom segments: " << inSeq->getNumBottomSegments() << endl;
for (; inBot->getArrayIndex() < inSegmentEnd; inBot->toRight(),
outBot->toRight())
{
hal_index_t outStartPosition = inBot->getStartPosition() - inSeq->getStartPosition() + outSeq->getStartPosition();
cout << "Decided on outStartPosition " << outStartPosition << " for seg index " << outBot->getArrayIndex() << " (src index " << inBot->getArrayIndex() << ")" << endl;
if (dest->getSequenceBySite(outStartPosition) != outSeq) {
stringstream ss;
ss << "When copying bottom segments from " << getName() << " to " << dest->getName() << ": expected destination sequence " << outSeq->getName() << " for segment # " << inBot->getArrayIndex() << " but got " << dest->getSequenceBySite(outStartPosition)->getName();
throw hal_exception(ss.str());
}
outBot->setCoordinates(outStartPosition, inBot->getLength());
for(hal_size_t inChild = 0; inChild < inNc; inChild++) {
hal_size_t outChild = inChildToOutChild[inChild];
if (outChild != outNc) {
outBot->setChildIndex(outChild, inBot->getChildIndex(inChild));
cout << "genome " << getName() << ": Set child index " << inChild << " to " << inBot->getChildIndex(inChild) << endl;
outBot->setChildReversed(outChild, inBot->getChildReversed(inChild));
}
}
outBot->setTopParseIndex(inBot->getTopParseIndex());
}
}
}