コード例 #1
0
//-------------------------------------------------------------------------
void CSeqMaskerWindowPattern::FillWindow( Uint4 winstart )
{
    first_unit = 0;
    TUnit unit = 0;
    Int4 iter = 0;
    end = winstart + unit_size - 1;
    Uint4 wstart = winstart;

    for( ; iter < NumUnits() && end < data.size() && end < winend; )
        if( MakeUnit( winstart, unit ) )
        {
            units[iter] = unit;
            ++iter;
            end += unit_step;
            winstart += unit_step;
        }
        else
        { 
            iter = 0;
            wstart += window_step;
            winstart = wstart;
            end = winstart + unit_size - 1;
        }

    end -= unit_step;
    end += (window_size - unit_size)%unit_step;
    start = end - window_size + 1;
    state = (iter == NumUnits());
}
コード例 #2
0
//-------------------------------------------------------------------------
void CSeqMaskerWindowPatternAmbig::FillWindow( Uint4 winstart )
{
    first_unit = 0;
    TUnit unit = 0;
    Int4 iter = 0;
    end = winstart + unit_size - 1;

    for( ; iter < NumUnits() && end < data.size(); 
         ++iter, end += unit_step, winstart += unit_step ) {
        if( MakeUnit( winstart, unit ) ) {
            units[iter] = unit;
        } else {
            units[iter] = ambig_unit;
        }
    }

    end -= unit_step;
    end += (window_size - unit_size)%unit_step;
    start = end - window_size + 1;
    state = (iter == NumUnits());
}
コード例 #3
0
ファイル: seq_masker_window.cpp プロジェクト: swuecho/igblast
//-------------------------------------------------------------------------
CSeqMaskerWindow::CSeqMaskerWindow( const CSeqVector & arg_data,
                                    Uint1 arg_unit_size,
                                    Uint1 arg_window_size,
                                    Uint4 arg_window_step,
                                    Uint1 arg_unit_step,
                                    Uint4 winstart,
                                    Uint4 arg_winend )
    : data(arg_data), state( false ),
      unit_size( arg_unit_size ), unit_step( arg_unit_step ),
      window_size( arg_window_size ), window_step( arg_window_step ),
      end( 0 ), first_unit( 0 ), unit_mask( 0 ), winend( arg_winend )
{
    static bool first_call = true;

    if( first_call )
    {
        LOOKUP[unsigned('A')] = 1;
        LOOKUP[unsigned('C')] = 2;
        LOOKUP[unsigned('G')] = 3;
        LOOKUP[unsigned('T')] = 4;
        first_call = false;
    }

    if( data.size() < window_size ) {
        // TODO Throw an exception.
    }
    if( unit_size > window_size ) {
        // TODO Throw an exception.
    }

    units.resize( NumUnits(), 0 );
    unit_mask = (unit_size == 16) ? 0xFFFFFFFF : (1 << (unit_size << 1)) - 1;

    if( winend == 0 )
        winend = data.size();

    FillWindow( winstart );
}
コード例 #4
0
//-------------------------------------------------------------------------
void CSeqMaskerWindowAmbig::Advance( Uint4 step )
{
    if( ambig || step >= window_size || unit_step > 1 ) 
    {
        FillWindow( start + step );
        return;
    }

    Uint1 num_units = NumUnits();
    Uint1 last_unit = first_unit ? first_unit - 1 : num_units - 1;
    Uint4 unit = units[last_unit];
    Uint4 iter = 0;
    Uint4 newstart = start + step;

    for( ; ++end < data.size() && iter < step ; ++iter )
    {
        Uint1 letter = LOOKUP[unsigned(data[end])];

        if( !(letter--) )
        { 
            FillWindow( newstart );
            return;
        }

        unit = ((unit<<2)&unit_mask) + letter;

        if( ++first_unit == num_units ) first_unit = 0;

        if( ++last_unit == num_units ) last_unit = 0;

        units[last_unit] = unit;
    }

    --end;
    start = end - window_size + 1;

    if( iter != step ) state = false;
}