bool CSplignTrim::ThrowAway20_28_90(TSeg& s) { if( s.m_len < 20 || // 20 rule ( s.m_idty < 0.9 && s.m_len < 28 ) ) {// 28_90 rule s.SetToGap(); return true; } return false; }
//legacy check //it two short throws away and returns true //otherwise returns false bool CSplignTrim::ThrowAwayShortExon(TSeg& s) { const size_t min_query_size = 4; if( int(s.m_box[1] - s.m_box[0] + 1) < int(min_query_size)) { s.SetToGap(); return true; } return false; }
void CSplignTrim::CutToMatchLeft(TSeg& s) { size_t pos = s.m_details.find('M'); if(pos == string::npos) { s.SetToGap(); return; } if(pos > 0) { CutFromLeft(pos, s); } }
void CSplignTrim::CutToMatchRight(TSeg& s) { size_t pos = s.m_details.rfind('M'); if(pos == string::npos) { s.SetToGap(); return; } size_t len = s.m_details.length() - pos - 1;//length to cut if(len > 0) { CutFromRight(len, s); } }
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; } }
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; } }