Пример #1
0
void CTestRangeMap::TestRangeMap(void) const
{
    Filling("CRangeMap");

    typedef CRangeMultimap<CConstRef<CObject> > TMap;
    typedef TMap::const_iterator TMapCI;

    TMap m;

    // fill
    for ( int count = 0; count < m_RangeNumber; ) {
        TRange range = RandomRange();
        m.insert(TMap::value_type(range, CConstRef<CObject>(0)));
        ++count;
        Added(range);
    }
    
    if ( m_PrintSize ) {
        Filled(m.size());
        // Stat(m.stat());
    }

    for ( TMapCI i = m.begin(); i; ++i ) {
        FromAll(i.GetInterval());
    }

    size_t scannedCount = 0;
    for ( int count = 0; count < m_ScanCount; ++count ) {
        for ( int pos = 0; pos <= m_Length + 2*m_RangeLength;
              pos += m_ScanStep ) {
            TRange range;
            range.Set(pos, pos + m_ScanLength - 1);
            
            StartFrom(range);
            
            for ( TMapCI i = m.begin(range); i; ++i ) {
                From(range, i.GetInterval());
                ++scannedCount;
            }
        }
    }
    PrintTotalScannedNumber(scannedCount);

    End();
}
Пример #2
0
/// Update the extent of a sequence that figures into its self
/// score, based upon the sequence ranges of a pairwise alignment
/// @param seq1 The current sequence range [in/out]
/// @param align1 The range of the current alignment on sequence 1
/// @param seq1_length Length of sequence 1
/// @param align2 The range of the current alignment on sequence 2
/// @param seq2_length Length of sequence 2
///
static void
x_UpdateRanges(TRange& seq1,
               TRange align1,
               int seq1_length,
               TRange align2,
               int seq2_length)
{
    // extend the alignment bounds to the left and right
    // until one sequence runs out.

    TOffset first = min(seq1.GetFrom(), align1.GetFrom() - align2.GetFrom());
    first = max(first, 0);

    TOffset second = max(seq1.GetTo(), 
                      align1.GetTo() + (seq2_length - 1 - align2.GetTo()));
    second = min(second, seq1_length - 1);

    seq1.Set(first, second);
}