本文整理汇总了C++中BottomSegmentIteratorPtr::getArrayIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ BottomSegmentIteratorPtr::getArrayIndex方法的具体用法?C++ BottomSegmentIteratorPtr::getArrayIndex怎么用?C++ BottomSegmentIteratorPtr::getArrayIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BottomSegmentIteratorPtr
的用法示例。
在下文中一共展示了BottomSegmentIteratorPtr::getArrayIndex方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: checkBottomSegments
void checkBottomSegments(Genome *genome, hal_size_t width, CuTest *testCase) {
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) {
CuAssertTrue(testCase, bottomIt->getStartPosition() == startPos);
for (hal_size_t i = 0; i < numChildren; i++) {
if (startPos < 170) {
CuAssertStrEquals(testCase, "Sequence2", genome->getSequenceBySite(startPos)->getName().c_str());
CuAssertTrue(testCase, bottomIt->bseg()->getChildIndex(i) == 13 + bottomIt->getArrayIndex());
} else {
CuAssertStrEquals(testCase, "Sequence1", genome->getSequenceBySite(startPos)->getName().c_str());
CuAssertTrue(testCase, bottomIt->bseg()->getChildIndex(i) == bottomIt->getArrayIndex() - 17);
}
}
}
}
示例3: boundComp
int MappedSegment::boundComp(const SegmentIteratorPtr &s1, const SegmentIteratorPtr &s2) {
int res = 0;
bool flip = s2->getReversed();
if (flip) {
s2->toReverse();
}
if (s1->isTop() && !s2->isTop()) {
BottomSegmentIteratorPtr bot = std::dynamic_pointer_cast<BottomSegmentIterator>(s2);
hal_index_t lb = bot->bseg()->getTopParseIndex();
hal_index_t ub = lb;
if ((hal_size_t)bot->getArrayIndex() < bot->getGenome()->getNumBottomSegments() - 1) {
bot = bot->clone();
bot->slice(0, 0);
bot->toRight();
ub = bot->bseg()->getTopParseIndex();
}
if (s1->getArrayIndex() < lb) {
res = -1;
} else if (s1->getArrayIndex() > ub) {
res = 1;
}
} else if (!s1->isTop() && s2->isTop()) {
TopSegmentIteratorPtr top = std::dynamic_pointer_cast<TopSegmentIterator>(s2);
hal_index_t lb = top->tseg()->getBottomParseIndex();
hal_index_t ub = lb;
if ((hal_size_t)top->getArrayIndex() < top->getGenome()->getNumTopSegments() - 1) {
top = top->clone();
top->slice(0, 0);
top->toRight();
ub = top->tseg()->getBottomParseIndex();
}
if (s1->getArrayIndex() < lb) {
res = -1;
} else if (s1->getArrayIndex() > ub) {
res = 1;
}
}
if (flip) {
s2->toReverse();
}
return res;
}
示例4: checkCallBack
void GenomeCopyTest::checkCallBack(const Alignment *alignment) {
// FIXME: halAlignment->open() fails miserably but
// openHalAlignmentReadOnly works? Probably some state isn't cleared
// on close.
AlignmentPtr tmp(getTestAlignmentInstances(alignment->getStorageFormat(), _path, WRITE_ACCESS));
_secondAlignment = tmp;
const Genome *ancGenome = alignment->openGenome("AncGenome");
CuAssertTrue(_testCase, ancGenome->getName() == "AncGenome");
CuAssertTrue(_testCase, ancGenome->getSequenceLength() == 1000000);
CuAssertTrue(_testCase, ancGenome->getNumTopSegments() == 0);
CuAssertTrue(_testCase, ancGenome->getNumBottomSegments() == 700000);
const MetaData *ancMeta = ancGenome->getMetaData();
CuAssertTrue(_testCase, ancMeta->get("Young") == "Jeezy");
const Genome *leafGenome = alignment->openGenome("LeafGenome1");
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();
CuAssertTrue(_testCase, dnaIt->getBase() == ancSeq[i]);
}
TopSegmentIteratorPtr topIt = leafGenome->getTopSegmentIterator();
n = leafGenome->getNumTopSegments();
for (; topIt->getArrayIndex() < n; topIt->toRight()) {
CuAssertTrue(_testCase, topIt->getStartPosition() == topIt->getArrayIndex());
CuAssertTrue(_testCase, topIt->getLength() == 1);
CuAssertTrue(_testCase, topIt->tseg()->getParentIndex() == 3);
CuAssertTrue(_testCase, topIt->tseg()->getParentReversed() == true);
CuAssertTrue(_testCase, topIt->tseg()->getBottomParseIndex() == 5);
if (topIt->getArrayIndex() != 6) {
CuAssertTrue(_testCase, topIt->tseg()->getNextParalogyIndex() == 6);
} else {
CuAssertTrue(_testCase, topIt->tseg()->getNextParalogyIndex() == 7);
}
}
BottomSegmentIteratorPtr botIt = ancGenome->getBottomSegmentIterator();
n = ancGenome->getNumBottomSegments();
for (; botIt->getArrayIndex() < n; botIt->toRight()) {
CuAssertTrue(_testCase, botIt->getStartPosition() == botIt->getArrayIndex());
CuAssertTrue(_testCase, botIt->getLength() == 1);
CuAssertTrue(_testCase, botIt->bseg()->getChildIndex(0) == 3);
CuAssertTrue(_testCase, botIt->bseg()->getChildReversed(0) == true);
CuAssertTrue(_testCase, botIt->bseg()->getTopParseIndex() == 5);
}
const Genome *copyRootGenome = _secondAlignment->openGenome("copyRootGenome");
const Genome *copyLeafGenome = _secondAlignment->openGenome("LeafGenome1");
CuAssertTrue(_testCase, copyRootGenome->getName() == "copyRootGenome");
CuAssertTrue(_testCase, copyRootGenome->getSequenceLength() == 1000000);
CuAssertTrue(_testCase, copyRootGenome->getNumTopSegments() == 0);
CuAssertTrue(_testCase, copyRootGenome->getNumBottomSegments() == 700000);
CuAssertTrue(_testCase, copyLeafGenome->getName() == "LeafGenome1");
CuAssertTrue(_testCase, copyLeafGenome->getSequenceLength() == 1000000);
CuAssertTrue(_testCase, copyLeafGenome->getNumTopSegments() == 5000);
CuAssertTrue(_testCase, copyLeafGenome->getNumBottomSegments() == 0);
const MetaData *copyMeta = copyRootGenome->getMetaData();
CuAssertTrue(_testCase, copyMeta->get("Young") == "Jeezy");
n = copyRootGenome->getSequenceLength();
dnaIt = copyRootGenome->getDnaIterator();
for (; dnaIt->getArrayIndex() < n; dnaIt->toRight()) {
size_t i = dnaIt->getArrayIndex() % ancSeq.size();
CuAssertTrue(_testCase, dnaIt->getBase() == ancSeq[i]);
}
topIt = copyLeafGenome->getTopSegmentIterator();
n = copyLeafGenome->getNumTopSegments();
for (; topIt->getArrayIndex() < n; topIt->toRight()) {
CuAssertTrue(_testCase, topIt->getStartPosition() == topIt->getArrayIndex());
CuAssertTrue(_testCase, topIt->getLength() == 1);
CuAssertTrue(_testCase, topIt->tseg()->getParentIndex() == 3);
CuAssertTrue(_testCase, topIt->tseg()->getParentReversed() == true);
CuAssertTrue(_testCase, topIt->tseg()->getBottomParseIndex() == 5);
if (topIt->getArrayIndex() != 6) {
CuAssertTrue(_testCase, topIt->tseg()->getNextParalogyIndex() == 6);
} else {
CuAssertTrue(_testCase, topIt->tseg()->getNextParalogyIndex() == 7);
}
}
botIt = copyRootGenome->getBottomSegmentIterator();
n = copyRootGenome->getNumBottomSegments();
for (; botIt->getArrayIndex() < n; botIt->toRight()) {
CuAssertTrue(_testCase, botIt->getStartPosition() == botIt->getArrayIndex());
CuAssertTrue(_testCase, botIt->getLength() == 1);
CuAssertTrue(_testCase, botIt->bseg()->getChildIndex(0) == 3);
CuAssertTrue(_testCase, botIt->bseg()->getChildReversed(0) == true);
CuAssertTrue(_testCase, botIt->bseg()->getTopParseIndex() == 5);
}
_secondAlignment->close();
remove(_path.c_str());
}
示例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: updateBlockEdges
void LodExtract::updateBlockEdges(const Genome* inParentGenome,
SegmentMap& segMap,
const LodBlock* block,
BottomSegmentIteratorPtr bottom,
TopSegmentIteratorPtr top)
{
Genome* outParentGenome = bottom->getGenome();
const LodSegment* rootSeg = NULL;
SegmentSet* segSet;
SegmentSet::iterator setIt;
// Zap all segments in parent genome
SegmentMap::iterator mapIt = segMap.find(inParentGenome);
if (mapIt != segMap.end())
{
segSet = mapIt->second;
assert(segSet != NULL);
setIt = segSet->begin();
for (; setIt != segSet->end(); ++setIt)
{
bottom->setArrayIndex(outParentGenome, (*setIt)->getArrayIndex());
for (hal_size_t i = 0; i < bottom->getNumChildren(); ++i)
{
bottom->setChildIndex(i, NULL_INDEX);
bottom->setTopParseIndex(NULL_INDEX);
}
}
// Choose first segment as parent to all segments in the child genome
setIt = segSet->begin();
rootSeg = *(setIt);
bottom->setArrayIndex(outParentGenome, (*setIt)->getArrayIndex());
}
// Do the child genomes
const Genome* inGrandParentGenome = inParentGenome->getParent();
SegmentSet::iterator nextIt;
for (mapIt = segMap.begin(); mapIt != segMap.end(); ++mapIt)
{
if (mapIt->first != inParentGenome and mapIt->first != inGrandParentGenome)
{
Genome* outChildGenome =
_outAlignment->openGenome(mapIt->first->getName());
hal_index_t childIndex = outParentGenome->getChildIndex(outChildGenome);
assert(childIndex >= 0);
segSet = mapIt->second;
assert(segSet != NULL);
for (setIt = segSet->begin(); setIt != segSet->end(); ++setIt)
{
top->setArrayIndex(outChildGenome, (*setIt)->getArrayIndex());
top->setBottomParseIndex(NULL_INDEX);
// Connect to parent
if (rootSeg != NULL)
{
top->setParentIndex(bottom->getArrayIndex());
bool reversed = (*setIt)->getFlipped() != rootSeg->getFlipped();
top->setParentReversed(reversed);
if (setIt == segSet->begin())
{
bottom->setChildIndex(childIndex, top->getArrayIndex());
bottom->setChildReversed(childIndex, reversed);
}
}
else
{
top->setParentIndex(NULL_INDEX);
}
// Connect to next paralogy
SegmentSet::iterator setNext = setIt;
++setNext;
if (setNext == segSet->end())
{
setNext = segSet->begin();
}
if (setNext == setIt)
{
top->setNextParalogyIndex(NULL_INDEX);
}
else
{
top->setNextParalogyIndex((*setNext)->getArrayIndex());
}
}
}
}
}
示例7: 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());
}
}
}