Ejemplo n.º 1
0
void CSplignTrim::CutFromRight(size_t len, TSeg& s) //len is length on alignment to cut
{
    if(len == 0) return;

    if(ThrowAwayShortExon(s)) return;

    string::reverse_iterator irs, irs0, irs1;
    irs0 = s.m_details.rbegin();
    irs1 = s.m_details.rend();

    if(irs1 - irs0 <= (int)len) {//cut all
        s.SetToGap();
        return;
    }
    irs1 = irs0 + len;

    int i0 = 0, i1 = 0;
    for(irs = irs0; irs != irs1; ++irs) {        
        switch(*irs) {            
        case 'M': 
        case 'R': {
            ++i0;
            ++i1;
        }
        break;
        case 'I': {
            ++i1;
        }
        break;
        case 'D': {
            ++i0;
        }
        }
    }

    // resize   
    s.m_box[1] -= i0;
    if(ThrowAwayShortExon(s)) return;//too short 
    s.m_box[3] -= i1;
    s.m_details.resize(s.m_details.size() - len);
    s.Update(m_aligner.GetNonNullPointer());
    
    // update the last two annotation chars
    const size_t adim = s.m_annot.size();
    if(adim > 2 && s.m_annot[adim - 3] == '>') {

        const char c3 (s.m_box[3] + 1 < (size_t)m_seqlen? m_seq[s.m_box[3] + 1]: ' ');
        const char c4 (s.m_box[3] + 2 < (size_t)m_seqlen? m_seq[s.m_box[3] + 2]: ' ');
        s.m_annot[adim-2] = c3;
        s.m_annot[adim-1] = c4;
    }
}
Ejemplo n.º 2
0
void CSplignTrim::CutFromLeft(size_t len, TSeg& s) //len is length on alignment to cut
{
    if(len == 0) return;

    if(ThrowAwayShortExon(s)) return;

    string::iterator irs, irs0, irs1;
    irs0 = s.m_details.begin();
    irs1 = s.m_details.end();

    if(irs1 - irs0 <= (int)len) {//cut all
        s.SetToGap();
        return;
    }
    irs1 = irs0 + len;

    int i0 = 0, i1 = 0;
    for(irs = irs0; irs != irs1; ++irs) {        
        switch(*irs) {            
        case 'M': 
        case 'R': {
            ++i0;
            ++i1;
        }
        break;
        case 'I': {
            ++i1;
        }
        break;
        case 'D': {
            ++i0;
        }
        }
    }

    // resize   
    s.m_box[0] += i0;
    if(ThrowAwayShortExon(s)) return;//too short 
    s.m_box[2] += i1;
    s.m_details.erase(0, len);
    s.Update(m_aligner.GetNonNullPointer());
    
    // update the first two annotation symbols      
    if(s.m_annot.size() > 2 && s.m_annot[2] == '<') {
        int  j1 = int(s.m_box[2]) - 2;
        char c1 = j1 >= 0? m_seq[j1]: ' ';
        s.m_annot[0] = c1;
        int  j2 = int(s.m_box[2]) - 1;
        char c2 = j2 >= 0? m_seq[j2]: ' ';
        s.m_annot[1] = c2;
    }
}