MappedSegment *MappedSegment::clone() const { // FIXME: having both sourceCpySegIt and sourceSegIt seems pointless, same for target. SegmentIteratorPtr sourceCpySegIt; if (_source->isTop()) { sourceCpySegIt = std::dynamic_pointer_cast<TopSegmentIterator>(_source)->clone(); } else { sourceCpySegIt = std::dynamic_pointer_cast<BottomSegmentIterator>(_source)->clone(); } SegmentIteratorPtr sourceSegIt = std::dynamic_pointer_cast<SegmentIterator>(sourceCpySegIt); SegmentIteratorPtr targetCopySegIt; if (_target->isTop()) { targetCopySegIt = std::dynamic_pointer_cast<TopSegmentIterator>(_target)->clone(); } else { targetCopySegIt = std::dynamic_pointer_cast<BottomSegmentIterator>(_target)->clone(); } SegmentIteratorPtr targetSegIt = std::static_pointer_cast<SegmentIterator>(targetCopySegIt); assert(sourceSegIt->getStartPosition() == _source->getStartPosition() && sourceSegIt->getEndPosition() == _source->getEndPosition()); assert(targetSegIt->getStartPosition() == _target->getStartPosition() && targetSegIt->getEndPosition() == _target->getEndPosition()); assert(_source->getLength() == _target->getLength()); assert(sourceSegIt->getLength() == targetSegIt->getLength()); MappedSegment *newSeg = new MappedSegment(sourceSegIt, targetSegIt); assert(newSeg->getStartPosition() == getStartPosition() && newSeg->getEndPosition() == getEndPosition() && newSeg->_source->getStartPosition() == _source->getStartPosition() && newSeg->_source->getEndPosition() == _source->getEndPosition()); assert(newSeg->_source.get() != _source.get() && newSeg->_target.get() != _target.get()); return newSeg; }
int MappedSegment::slowComp(const SegmentIteratorPtr &s1, const SegmentIteratorPtr &s2) { assert(s1->getGenome() == s2->getGenome()); int res = 0; hal_index_t sp1 = s1->getStartPosition(); hal_index_t ep1 = s1->getEndPosition(); hal_index_t sp2 = s2->getStartPosition(); hal_index_t ep2 = s2->getEndPosition(); if (s1->getReversed()) { swap(sp1, ep1); } if (s2->getReversed()) { swap(sp2, ep2); } if (sp1 < sp2) { res = -1; } else if (sp1 > sp2) { res = 1; } else if (ep1 < ep2) { res = -1; } else if (ep1 > ep2) { res = 1; } return res; }