当前位置: 首页>>代码示例>>C++>>正文


C++ BottomSegmentIteratorPtr::bseg方法代码示例

本文整理汇总了C++中BottomSegmentIteratorPtr::bseg方法的典型用法代码示例。如果您正苦于以下问题:C++ BottomSegmentIteratorPtr::bseg方法的具体用法?C++ BottomSegmentIteratorPtr::bseg怎么用?C++ BottomSegmentIteratorPtr::bseg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BottomSegmentIteratorPtr的用法示例。


在下文中一共展示了BottomSegmentIteratorPtr::bseg方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
        }
    }
}
开发者ID:glennhickey,项目名称:hal,代码行数:16,代码来源:halGenomeTest.cpp

示例2: mapDown

// note: takes smart pointer as it maybe added to the results
static hal_size_t mapDown(MappedSegmentPtr mappedSeg, hal_size_t childIndex, list<MappedSegmentPtr> &results,
                          hal_size_t minLength) {
    const Genome *child = mappedSeg->getGenome()->getChild(childIndex);
    assert(child != NULL);
    hal_size_t added = 0;
    if (mappedSeg->isTop() == false) {
        TopSegmentIteratorPtr topSegIt = child->getTopSegmentIterator();
        SegmentIteratorPtr targetSegIt = mappedSeg->getTargetIteratorPtr();
        BottomSegmentIteratorPtr botSegIt = std::dynamic_pointer_cast<BottomSegmentIterator>(targetSegIt);

        if (botSegIt->bseg()->hasChild(childIndex) == true && botSegIt->getLength() >= minLength) {
            topSegIt->toChild(botSegIt, childIndex);
            mappedSeg->setTarget(std::dynamic_pointer_cast<SegmentIterator>(topSegIt));
            results.push_back(MappedSegmentPtr(mappedSeg));
            ++added;
        }
    } else {
        hal_index_t rightCutoff = mappedSeg->getEndPosition();
        TopSegmentIteratorPtr topSegIt = mappedSeg->targetAsTop();
        hal_index_t startOffset = (hal_index_t)topSegIt->getStartOffset();
        hal_index_t endOffset = (hal_index_t)topSegIt->getEndOffset();
        BottomSegmentIteratorPtr botSegIt = mappedSeg->getGenome()->getBottomSegmentIterator();
        botSegIt->toParseDown(topSegIt);
        do {
            BottomSegmentIteratorPtr newBotSegIt = botSegIt->clone();

            // we map the new target back to see how the offsets have
            // changed.  these changes are then applied to the source segment
            // as deltas
            TopSegmentIteratorPtr backTopSegIt = topSegIt->clone();
            backTopSegIt->toParseUp(newBotSegIt);
            hal_index_t startBack = (hal_index_t)backTopSegIt->getStartOffset();
            hal_index_t endBack = (hal_index_t)backTopSegIt->getEndOffset();
            assert(startBack >= startOffset);
            assert(endBack >= endOffset);
            SegmentIteratorPtr newSourceSegIt = mappedSeg->sourceClone();
            hal_index_t startDelta = startBack - startOffset;
            hal_index_t endDelta = endBack - endOffset;
            assert((hal_index_t)newSourceSegIt->getLength() > startDelta + endDelta);
            newSourceSegIt->slice(newSourceSegIt->getStartOffset() + startDelta, newSourceSegIt->getEndOffset() + endDelta);

            MappedSegmentPtr newMappedSeg(new MappedSegment(newSourceSegIt, newBotSegIt));

            assert(newMappedSeg->isTop() == false);
            assert(newMappedSeg->getSource()->getGenome() == mappedSeg->getSource()->getGenome());

            added += mapDown(newMappedSeg, childIndex, results, minLength);

            // stupid that we have to make this check but odn't want to
            // make fundamental api change now
            if (botSegIt->getEndPosition() != rightCutoff) {
                botSegIt->toRight(rightCutoff);
            } else {
                break;
            }
        } while (true);
    }
    return added;
}
开发者ID:glennhickey,项目名称:hal,代码行数:60,代码来源:halSegmentMapper.cpp

示例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;
}
开发者ID:glennhickey,项目名称:hal,代码行数:45,代码来源:halMappedSegment.cpp

示例4: toRightNextUngapped

void GappedBottomSegmentIterator::toRightNextUngapped(BottomSegmentIteratorPtr botSegIt) const {
    while (botSegIt->bseg()->hasChild(_childIndex) == false && botSegIt->getLength() <= _gapThreshold) {
        if ((!botSegIt->getReversed() && botSegIt->getBottomSegment()->isLast()) ||
            (botSegIt->getReversed() && botSegIt->getBottomSegment()->isFirst())) {
            break;
        }
        botSegIt->toRight();
    }
}
开发者ID:glennhickey,项目名称:hal,代码行数:9,代码来源:halGappedBottomSegmentIterator.cpp

示例5: 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);
            }
        }
    }
}
开发者ID:glennhickey,项目名称:hal,代码行数:19,代码来源:halGenomeTest.cpp

示例6: toLeftNextUngapped

void GappedBottomSegmentIterator::toLeftNextUngapped(BottomSegmentIteratorPtr botSegIt) const {
    // FIXME: should be methods of BottomSegmentIterator?
    // FIXME: these are identical in halGappedTopSegmentIterator.
    while (botSegIt->bseg()->hasChild(_childIndex) == false && botSegIt->getLength() <= _gapThreshold) {
        if ((!botSegIt->getReversed() && botSegIt->getBottomSegment()->isFirst()) ||
            (botSegIt->getReversed() && botSegIt->getBottomSegment()->isLast())) {
            break;
        }
        botSegIt->toLeft();
    }
}
开发者ID:glennhickey,项目名称:hal,代码行数:11,代码来源:halGappedBottomSegmentIterator.cpp

示例7: 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());
}
开发者ID:glennhickey,项目名称:hal,代码行数:90,代码来源:halGenomeTest.cpp

示例8: 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);
        }
    }
//.........这里部分代码省略.........
开发者ID:glennhickey,项目名称:hal,代码行数:101,代码来源:halGenomeTest.cpp

示例9: compatible

//////////////////////////////////////////////////////////////////////////////
// INTERNAL METHODS
//////////////////////////////////////////////////////////////////////////////
bool GappedBottomSegmentIterator::compatible(BottomSegmentIteratorPtr leftBotSegIt,
                                             BottomSegmentIteratorPtr rightBotSegIt) const {
    assert(leftBotSegIt->bseg()->hasChild(_childIndex) && rightBotSegIt->bseg()->hasChild(_childIndex));
    assert(leftBotSegIt->equals(rightBotSegIt) == false);

    _leftChild->toChild(leftBotSegIt, _childIndex);
    _rightChild->toChild(rightBotSegIt, _childIndex);

    if (_leftChild->getTopSegment()->getParentReversed() != _rightChild->getTopSegment()->getParentReversed()) {
        return false;
    }

    if (_leftChild->tseg()->hasNextParalogy() != _rightChild->tseg()->hasNextParalogy()) {
        return false;
    }
    if ((!_leftChild->getReversed() && _leftChild->leftOf(_rightChild->getStartPosition()) == false) ||
        (_leftChild->getReversed() && _leftChild->rightOf(_rightChild->getStartPosition()) == false)) {
        return false;
    }

    if (leftBotSegIt->getBottomSegment()->getSequence() != rightBotSegIt->getBottomSegment()->getSequence() ||
        _leftChild->getTopSegment()->getSequence() != _rightChild->getTopSegment()->getSequence()) {
        return false;
    }

    while (true) {
        assert(_leftChild->isLast() == false);
        _leftChild->toRight();
        if (_leftChild->tseg()->hasParent() == true || _leftChild->getLength() > _gapThreshold) {
            if (_leftChild->equals(_rightChild)) {
                break;
            } else {
                return false;
            }
        }
    }

    _leftChild->toChild(leftBotSegIt, _childIndex);
    _rightChild->toChild(rightBotSegIt, _childIndex);
    if (_leftChild->tseg()->hasNextParalogy() == true) {
        _leftDup->copy(_leftChild);
        _leftDup->toNextParalogy();
        _rightDup->copy(_rightChild);
        _rightDup->toNextParalogy();

        if ((_leftDup->getReversed() == false && _leftDup->leftOf(_rightDup->getStartPosition()) == false) ||
            (_leftDup->getReversed() == true && _rightDup->leftOf(_leftDup->getStartPosition()) == false)) {
            return false;
        }
        if (_leftDup->getTopSegment()->getSequence() != _rightDup->getTopSegment()->getSequence()) {
            return false;
        }

        while (true) {
            assert(_leftDup->isLast() == false);
            _leftDup->toRight();
            if (_leftDup->tseg()->hasParent() == true || _leftDup->getLength() > _gapThreshold) {
                if (_leftDup->equals(_rightDup)) {
                    break;
                } else {
                    return false;
                }
            }
        }
    }

    return true;
}
开发者ID:glennhickey,项目名称:hal,代码行数:71,代码来源:halGappedBottomSegmentIterator.cpp


注:本文中的BottomSegmentIteratorPtr::bseg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。