示例#1
0
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);
  }
}
示例#2
0
void LodExtract::writeSegments(const Genome* inParent,
                               const vector<const Genome*>& inChildren)
{
  vector<const Genome*> inGenomes = inChildren;
  inGenomes.push_back(inParent);
  const Genome* outParent = _outAlignment->openGenome(inParent->getName());
  assert(outParent != NULL && outParent->getNumBottomSegments() > 0);
  BottomSegmentIteratorPtr bottom;
  TopSegmentIteratorPtr top;
  SegmentIteratorPtr outSegment;

  // FOR EVERY GENOME
  for (hal_size_t i = 0; i < inGenomes.size(); ++i)
  {
    const Genome* inGenome = inGenomes[i];
    Genome* outGenome = _outAlignment->openGenome(inGenome->getName());

    SequenceIteratorPtr outSeqIt = outGenome->getSequenceIterator();
    SequenceIteratorConstPtr outSeqEnd = outGenome->getSequenceEndIterator();
    
    // FOR EVERY SEQUENCE IN GENOME
    for (; outSeqIt != outSeqEnd; outSeqIt->toNext())
    {
      const Sequence* outSequence = outSeqIt->getSequence();
      const Sequence* inSequence = 
         inGenome->getSequence(outSequence->getName());
      if (outGenome != outParent && outSequence->getNumTopSegments() > 0)
      {
        top = outSequence->getTopSegmentIterator();
        outSegment = top;
      }
      else if (outSequence->getNumBottomSegments() > 0)
      {
        bottom = outSequence->getBottomSegmentIterator();
        outSegment = bottom;
      }
      const LodGraph::SegmentSet* segSet = _graph.getSegmentSet(inSequence);
      assert(segSet != NULL);
      LodGraph::SegmentSet::const_iterator segIt = segSet->begin();
      if (segSet->size() > 2)
      {
        //skip left telomere
        ++segIt;
        // use to skip right telomere:
        LodGraph::SegmentSet::const_iterator segLast = segSet->end();
        --segLast;
      
        // FOR EVERY SEGMENT IN SEQUENCE
        for (; segIt != segLast; ++segIt)
        {
          // write the HAL array index back to the segment to make
          // future passes quicker. 
          (*segIt)->setArrayIndex(outSegment->getArrayIndex());
          outSegment->setCoordinates((*segIt)->getLeftPos(), 
                                     (*segIt)->getLength());
          assert(outSegment->getSequence()->getName() == inSequence->getName());
          outSegment->toRight();
        }
      }
      else if (outSequence->getSequenceLength() > 0)
      {
        assert(segSet->size() == 2);
        writeUnsampledSequence(outSequence, outSegment);
      }
    }
  } 
}