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


C++ Genome::getSequenceLength方法代码示例

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


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

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

示例2: createCallBack

// Test copying when the sequences aren't in the same order.
//
// Create an alignment with "Sequence1" positions aligned to
// "Sequence1" positions, and "Sequence2" to "Sequence2", but try
// copying the segments to an alignment with "Sequence2" before
// "Sequence1" in the ordering.
void GenomeCopySegmentsWhenSequencesOutOfOrderTest::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, CREATE_ACCESS));

    Genome *rootGenome = alignment->addRootGenome("root", 0);
    Genome *internalGenome = alignment->addLeafGenome("internal", "root", 0);
    Genome *leaf1Genome = alignment->addLeafGenome("leaf1", "root", 0);
    Genome *leaf2Genome = alignment->addLeafGenome("leaf2", "internal", 0);
    Genome *copyRootGenome = _secondAlignment->addRootGenome("root", 0);
    Genome *copyInternalGenome = _secondAlignment->addLeafGenome("internal", "root", 0);
    Genome *copyLeaf1Genome = _secondAlignment->addLeafGenome("leaf1", "root", 0);
    Genome *copyLeaf2Genome = _secondAlignment->addLeafGenome("leaf2", "internal", 0);

    vector<Sequence::Info> seqVec(2);
    seqVec[0] = Sequence::Info("Sequence1", 130, 0, 13);
    seqVec[1] = Sequence::Info("Sequence2", 170, 0, 17);
    rootGenome->setDimensions(seqVec);
    rootGenome->setString(randomString(rootGenome->getSequenceLength()));
    seqVec[0] = Sequence::Info("Sequence1", 130, 13, 13);
    seqVec[1] = Sequence::Info("Sequence2", 170, 17, 17);
    internalGenome->setDimensions(seqVec);
    internalGenome->setString(randomString(internalGenome->getSequenceLength()));
    seqVec[0] = Sequence::Info("Sequence1", 130, 13, 0);
    seqVec[1] = Sequence::Info("Sequence2", 170, 17, 0);
    leaf1Genome->setDimensions(seqVec);
    leaf1Genome->setString(randomString(leaf1Genome->getSequenceLength()));
    leaf2Genome->setDimensions(seqVec);
    leaf2Genome->setString(randomString(leaf2Genome->getSequenceLength()));

    setTopSegments(internalGenome, 10);
    setTopSegments(leaf1Genome, 10);
    setTopSegments(leaf2Genome, 10);

    setBottomSegments(rootGenome, 10);
    setBottomSegments(internalGenome, 10);

    rootGenome->fixParseInfo();
    internalGenome->fixParseInfo();
    leaf1Genome->fixParseInfo();
    leaf2Genome->fixParseInfo();

    seqVec[0] = Sequence::Info("Sequence1", 130, 0, 13);
    seqVec[1] = Sequence::Info("Sequence2", 170, 0, 17);
    copyRootGenome->setDimensions(seqVec);
    copyRootGenome->setString(randomString(copyRootGenome->getSequenceLength()));
    seqVec[0] = Sequence::Info("Sequence1", 130, 13, 0);
    seqVec[1] = Sequence::Info("Sequence2", 170, 17, 0);
    copyLeaf1Genome->setDimensions(seqVec);
    copyLeaf2Genome->setDimensions(seqVec);
    copyLeaf1Genome->setString(randomString(copyLeaf1Genome->getSequenceLength()));
    copyLeaf2Genome->setString(randomString(copyLeaf2Genome->getSequenceLength()));
    seqVec[0] = Sequence::Info("Sequence2", 170, 17, 17);
    seqVec[1] = Sequence::Info("Sequence1", 130, 13, 13);
    copyInternalGenome->setDimensions(seqVec);
    copyInternalGenome->setString(randomString(copyInternalGenome->getSequenceLength()));

    rootGenome->copyBottomDimensions(copyRootGenome);
    rootGenome->copyBottomSegments(copyRootGenome);
    copyRootGenome->fixParseInfo();

    internalGenome->copyBottomDimensions(copyInternalGenome);
    internalGenome->copyBottomSegments(copyInternalGenome);
    internalGenome->copyTopDimensions(copyInternalGenome);
    internalGenome->copyTopSegments(copyInternalGenome);
    copyInternalGenome->fixParseInfo();

    leaf1Genome->copyTopDimensions(copyLeaf1Genome);
    leaf1Genome->copyTopSegments(copyLeaf1Genome);
    copyLeaf1Genome->fixParseInfo();

    leaf2Genome->copyTopDimensions(copyLeaf2Genome);
    leaf2Genome->copyTopSegments(copyLeaf2Genome);
    copyLeaf2Genome->fixParseInfo();

    _secondAlignment->close();
}
开发者ID:glennhickey,项目名称:hal,代码行数:89,代码来源:halGenomeTest.cpp

示例3: createCallBack


//.........这里部分代码省略.........

  ti = child2->getTopSegmentIterator();
  ts.set(0, 12, 0, false, 0);
  ts.applyTo(ti);
  
  for (size_t i = 0; i < 6; ++i)
  {
    bi = child2->getBottomSegmentIterator(i);
    bs.set(i * 2, 2, 0);
    bs._children.clear();
    bs._children.push_back(pair<hal_size_t, bool>(i, false));
    bs.applyTo(bi);

    ti = g1->getTopSegmentIterator(i);
    ts.set(i * 2, 2, i, false);
    ts.applyTo(ti);
  }

  for (size_t i = 0; i < 6; ++i)
  {
    bi = child1->getBottomSegmentIterator(i);
    bs.set(i * 2, 2, 0);
    bs._children.clear();
    bs._children.push_back(pair<hal_size_t, bool>(i, false));
    bs.applyTo(bi);

    ti = gi1->getTopSegmentIterator(i);
    ts.set(i * 2, 2, i, false);
    ts.applyTo(ti);
  }

  for (size_t i = 0; i < 5; ++i)
  {
    const Genome* g = gs[i];
    const Genome* parent = g->getParent();
    const Genome* child = i == 4 ? NULL : g->getChild(0);
    hal_size_t segLen = g->getSequenceLength() / g->getNumTopSegments();
    hal_size_t psegLen = parent->getSequenceLength() / 
       parent->getNumTopSegments();
    hal_size_t csegLen = 0;
    if (child)
    {
      csegLen =  child->getSequenceLength() / child->getNumTopSegments();
    }
    
    for (size_t j = 0; j < g->getNumTopSegments(); ++j)
    {
      bool inv = false;
      bi = parent->getBottomSegmentIterator(j);
      bs.set(j * segLen, segLen, (j * segLen) / psegLen);
      bs._children.clear();
      bs._children.push_back(pair<hal_size_t, bool>(j, inv));
      bs.applyTo(bi);

      hal_index_t bparse = NULL_INDEX;
      if (child != NULL)
      {
        bparse = (j * segLen) / csegLen;
      }
      ti = g->getTopSegmentIterator(j);
      ts.set(j * segLen, segLen, j, inv, bparse);
      ts.applyTo(ti);      
    }
  }
  
  for (size_t i = 0; i < 5; ++i)
  {
    const Genome* g = gis[i];
    const Genome* parent = g->getParent();
    const Genome* child = i == 4 ? NULL : g->getChild(0);
    hal_size_t segLen = g->getSequenceLength() / g->getNumTopSegments();
    hal_size_t psegLen = parent->getSequenceLength() / 
       parent->getNumTopSegments();
    hal_size_t csegLen = 0;
    if (child)
    {
      csegLen =  child->getSequenceLength() / child->getNumTopSegments();
    }
    
    for (size_t j = 0; j < g->getNumTopSegments(); ++j)
    {
      bool inv = rand() % 4 == 0;
      bi = parent->getBottomSegmentIterator(j);
      bs.set(j * segLen, segLen, (j * segLen) / psegLen);
      bs._children.clear();
      bs._children.push_back(pair<hal_size_t, bool>(j, inv));
      bs.applyTo(bi);

      hal_index_t bparse = NULL_INDEX;
      if (child != NULL)
      {
        bparse = (j * segLen) / csegLen;
      }
      ti = g->getTopSegmentIterator(j);
      ts.set(j * segLen, segLen, j, inv, bparse);
      ts.applyTo(ti);      
    }
  }

}
开发者ID:dayin1989,项目名称:hal,代码行数:101,代码来源:halMappedSegmentTest.cpp


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