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


C++ BottomSegmentIteratorPtr类代码示例

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


在下文中一共展示了BottomSegmentIteratorPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: seqVec

void TopSegmentIsGapTest::createCallBack(Alignment *alignment) {
    size_t numSequences = 3;
    vector<Sequence::Info> seqVec(numSequences);

    BottomSegmentIteratorPtr bi;
    BottomSegmentStruct bs;
    TopSegmentIteratorPtr ti;
    TopSegmentStruct ts;

    Genome *parent1 = alignment->addRootGenome("parent1");
    Genome *child1 = alignment->addLeafGenome("child1", "parent1", 1);

    // set up two genomes.  each with three sequences.  each sequence
    // with 5 segments of length two.  start with segment i in parent
    // aligned with segment i in child.
    for (size_t i = 0; i < numSequences; ++i) {
        string name = "Sequence" + std::to_string(i);
        seqVec[i] = Sequence::Info(name, 10, 5, 5);
    }
    parent1->setDimensions(seqVec);
    child1->setDimensions(seqVec);

    for (bi = parent1->getBottomSegmentIterator(); not bi->atEnd(); bi->toRight()) {
        bs.set(bi->getBottomSegment()->getArrayIndex() * 2, 2);
        bs._children.clear();
        bs._children.push_back(pair<hal_size_t, bool>(bi->getBottomSegment()->getArrayIndex(), false));
        bs.applyTo(bi);
    }

    for (ti = child1->getTopSegmentIterator(); not ti->atEnd(); ti->toRight()) {
        ts.set(ti->getTopSegment()->getArrayIndex() * 2, 2, ti->getTopSegment()->getArrayIndex());
        ts.applyTo(ti);
    }

    // insertion in middle (8th top segment)

    bi = parent1->getBottomSegmentIterator(8);
    ti = child1->getTopSegmentIterator(8);
    assert(bi->getBottomSegment()->getChildIndex(0) == 8 && ti->getTopSegment()->getParentIndex() == 8);
    bi->getBottomSegment()->setChildIndex(0, 9);
    ti->getTopSegment()->setParentIndex(NULL_INDEX);
    ti->toRight();
    ti->getTopSegment()->setParentIndex(8);

    // insertion at begining (10th top segment)

    bi = parent1->getBottomSegmentIterator(10);
    ti = child1->getTopSegmentIterator(10);
    assert(bi->getBottomSegment()->getChildIndex(0) == 10 && ti->getTopSegment()->getParentIndex() == 10);
    bi->getBottomSegment()->setChildIndex(0, 11);
    ti->getTopSegment()->setParentIndex(NULL_INDEX);
    ti->toRight();
    ti->getTopSegment()->setParentIndex(10);

    // just having a null parent is not enough for an insertion
    bi = parent1->getBottomSegmentIterator(2);
    ti = child1->getTopSegmentIterator(2);
    assert(bi->getBottomSegment()->getChildIndex(0) == 2 && ti->getTopSegment()->getParentIndex() == 2);
    ti->getTopSegment()->setParentIndex(NULL_INDEX);
}
开发者ID:glennhickey,项目名称:hal,代码行数:60,代码来源:halTopSegmentTest.cpp

示例2: assert

void LodExtract::writeUnsampledSequence(const Sequence* outSequence,
                                        SegmentIteratorPtr outSegment)
{
  outSegment->setCoordinates(outSequence->getStartPosition(),
                             outSequence->getSequenceLength());
  if (outSegment->isTop())
  {
    assert(outSequence->getNumTopSegments() == 1);
    TopSegmentIteratorPtr top = outSegment.downCast<TopSegmentIteratorPtr>();
    top->setParentIndex(NULL_INDEX);
    top->setParentReversed(false);
    top->setNextParalogyIndex(NULL_INDEX);
    top->setBottomParseIndex(NULL_INDEX);
  }
  else
  {
    assert(outSequence->getNumBottomSegments() == 1);
    BottomSegmentIteratorPtr bottom = 
       outSegment.downCast<BottomSegmentIteratorPtr>();
    hal_size_t numChildren = bottom->getNumChildren();
    for (hal_size_t childNum = 0; childNum < numChildren; ++childNum)
    {
      bottom->setChildIndex(childNum, NULL_INDEX);
      bottom->setChildReversed(childNum, false);
    }
    bottom->setTopParseIndex(NULL_INDEX);
  }
}
开发者ID:dayin1989,项目名称:hal,代码行数:28,代码来源:halLodExtract.cpp

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

示例4: CuAssertTrue

void SequenceIteratorTest::checkCallBack(const Alignment *alignment) {
    const Genome *ancGenome = alignment->openGenome("AncGenome");

    hal_size_t numSequences = ancGenome->getNumSequences();
    CuAssertTrue(_testCase, numSequences = 1000);

    for (SequenceIteratorPtr seqIt = ancGenome->getSequenceIterator(); not seqIt->atEnd(); seqIt->toNext()) {
        const Sequence *seq = seqIt->getSequence();
        hal_size_t i = seq->getArrayIndex();

        TopSegmentIteratorPtr tsIt = seq->getTopSegmentIterator();
        hal_size_t numTopSegments = seq->getNumTopSegments();
        for (hal_size_t j = 0; j < numTopSegments; ++j) {
            TopSegmentIteratorPtr gtsIt = ancGenome->getTopSegmentIterator((i - 1) * 100 + j);
            const TopSegment *gsTopSegment = gtsIt->getTopSegment();
            const TopSegment *sqTopSegment = tsIt->getTopSegment();

            CuAssertTrue(_testCase, gsTopSegment->getArrayIndex() == sqTopSegment->getArrayIndex());
            tsIt->toRight();
        }

        BottomSegmentIteratorPtr bsIt = seq->getBottomSegmentIterator();
        hal_size_t numBottomSegments = seq->getNumBottomSegments();
        for (hal_size_t j = 0; j < numBottomSegments; ++j) {
            BottomSegmentIteratorPtr gbsIt = ancGenome->getBottomSegmentIterator((i - 1) * 100 + j);
            const BottomSegment *gsBottomSegment = gbsIt->getBottomSegment();
            const BottomSegment *sqBottomSegment = bsIt->getBottomSegment();

            CuAssertTrue(_testCase, gsBottomSegment->getArrayIndex() == sqBottomSegment->getArrayIndex());
            bsIt->toRight();
        }
    }
}
开发者ID:glennhickey,项目名称:hal,代码行数:33,代码来源:halSequenceTest.cpp

示例5: fixParseInfo

void Genome::fixParseInfo()
{
  if (getParent() == NULL || getNumChildren() == 0)
  {
    return;
  }
  
  // copied from CactusHalConverter::updateRootParseInfo() in
  // cactus2hal/src/cactusHalConverter.cpp 
  BottomSegmentIteratorPtr bottomIterator = 
    getBottomSegmentIterator();
  TopSegmentIteratorPtr topIterator = getTopSegmentIterator();
  BottomSegmentIteratorConstPtr bend = getBottomSegmentEndIterator();
  TopSegmentIteratorConstPtr tend = getTopSegmentEndIterator();
  int top = 0, bot = 0;
  while (bottomIterator != bend && topIterator != tend)
  {
    bool bright = false;
    bool tright = false;
    BottomSegment* bseg = bottomIterator->getBottomSegment();
    TopSegment* tseg = topIterator->getTopSegment();
    hal_index_t bstart = bseg->getStartPosition();
    hal_index_t bendidx = bstart + (hal_index_t)bseg->getLength();
    hal_index_t tstart = tseg->getStartPosition();
    hal_index_t tendidx = tstart + (hal_index_t)tseg->getLength();

    if (bstart >= tstart && bstart < tendidx)
    {
      bseg->setTopParseIndex(tseg->getArrayIndex());
    }
    if (bendidx <= tendidx || bstart == bendidx)
    {
      bright = true;
    }
        
    if (tstart >= bstart && tstart < bendidx)
    {
      tseg->setBottomParseIndex(bseg->getArrayIndex());
    }
    if (tendidx <= bendidx || tstart == tendidx)
    {
      tright = true;
    }

    assert(bright || tright);
    if (bright == true)
    {
      bot += 1;
      bottomIterator->toRight();
    }
    if (tright == true)
    {
      top += 1;
      topIterator->toRight();
    }
  }
}
开发者ID:dayin1989,项目名称:hal,代码行数:57,代码来源:halGenome.cpp

示例6: mapUp

// note: takes smart pointer as it maybe added to the results
static hal_size_t mapUp(MappedSegmentPtr mappedSeg, list<MappedSegmentPtr> &results, bool doDupes, hal_size_t minLength) {
    const Genome *parent = mappedSeg->getGenome()->getParent();
    assert(parent != NULL);
    hal_size_t added = 0;
    if (mappedSeg->isTop() == true) {
        BottomSegmentIteratorPtr botSegIt = parent->getBottomSegmentIterator();
        TopSegmentIteratorPtr topSegIt = mappedSeg->targetAsTop();
        if (topSegIt->tseg()->hasParent() == true && topSegIt->getLength() >= minLength &&
            (doDupes == true || topSegIt->tseg()->isCanonicalParalog() == true)) {
            botSegIt->toParent(topSegIt);
            mappedSeg->setTarget(std::dynamic_pointer_cast<SegmentIterator>(botSegIt));
            results.push_back(mappedSeg);
            ++added;
        }
    } else {
        hal_index_t rightCutoff = mappedSeg->getEndPosition();
        BottomSegmentIteratorPtr botSegIt = mappedSeg->targetAsBottom();
        hal_index_t startOffset = (hal_index_t)botSegIt->getStartOffset();
        hal_index_t endOffset = (hal_index_t)botSegIt->getEndOffset();
        TopSegmentIteratorPtr topSegIt = mappedSeg->getGenome()->getTopSegmentIterator();
        topSegIt->toParseUp(botSegIt);
        do {
            TopSegmentIteratorPtr newTopSegIt = topSegIt->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
            BottomSegmentIteratorPtr backBotSegIt = botSegIt->clone();
            backBotSegIt->toParseDown(newTopSegIt);
            hal_index_t startBack = (hal_index_t)backBotSegIt->getStartOffset();
            hal_index_t endBack = (hal_index_t)backBotSegIt->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, newTopSegIt));

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

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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: seqVec

void TopSegmentIteratorReverseTest::createCallBack(AlignmentPtr alignment)
{
  vector<Sequence::Info> seqVec(1);
  
  BottomSegmentIteratorPtr bi;
  BottomSegmentStruct bs;
  TopSegmentIteratorPtr ti;
  TopSegmentStruct ts;
  
  // setup simple case were there is an edge from a parent to 
  // child and it is reversed
  Genome* parent1 = alignment->addRootGenome("parent1");
  Genome* child1 = alignment->addLeafGenome("child1", "parent1", 1);
  seqVec[0] = Sequence::Info("Sequence", 10, 2, 2);
  parent1->setDimensions(seqVec);
  seqVec[0] = Sequence::Info("Sequence", 10, 2, 2);
  child1->setDimensions(seqVec);

  parent1->setString("CCCTACGTGC");
  child1->setString("CCCTACGTGC");

  bi = parent1->getBottomSegmentIterator();
  bs.set(0, 10, 0);
  bs._children.push_back(pair<hal_size_t, bool>(0, true));
  bs.applyTo(bi);
     
  ti = child1->getTopSegmentIterator();
  ts.set(0, 10, 0, true, 0);
  ts.applyTo(ti);

  bi = child1->getBottomSegmentIterator();
  bs.set(0, 5, 0);
  bs._children.clear();
  bs.applyTo(bi);
  bi->toRight();
  bs.set(5, 5, 0);
  bs.applyTo(bi);
}
开发者ID:BioinformaticsArchive,项目名称:hal,代码行数:38,代码来源:halTopSegmentTest.cpp

示例12: 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

示例13: 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

示例14: hal_exception

GappedBottomSegmentIterator::GappedBottomSegmentIterator(BottomSegmentIteratorPtr leftBotSegIt, hal_size_t childIndex,
                                                         hal_size_t gapThreshold, bool atomic)
    : _childIndex(childIndex), _gapThreshold(gapThreshold), _atomic(atomic) {
    if (leftBotSegIt->getStartOffset() != 0 || leftBotSegIt->getEndOffset() != 0) {
        throw hal_exception("offset not currently supported in gapped iterators");
    }
    const Genome *child = leftBotSegIt->getBottomSegment()->getGenome()->getChild(_childIndex);
    if (child == NULL) {
        throw hal_exception("can't init GappedBottomIterator with no child genome");
    }
    assert(_atomic == false || _gapThreshold == 0);
    _left = leftBotSegIt->clone();
    _right = leftBotSegIt->clone();
    _temp = leftBotSegIt->clone();
    _temp2 = leftBotSegIt->clone();
    _leftChild = child->getTopSegmentIterator();
    _rightChild = _leftChild->clone();
    _leftDup = _leftChild->clone();
    _rightDup = _leftChild->clone();
    extendRight();
}
开发者ID:glennhickey,项目名称:hal,代码行数:21,代码来源:halGappedBottomSegmentIterator.cpp

示例15: assert

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


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