bool tMatch(GffObj& a, GffObj& b) { //strict intron chain match, or single-exon perfect match int imax=a.exons.Count()-1; int jmax=b.exons.Count()-1; int ovlen=0; if (imax!=jmax) return false; //different number of introns if (imax==0) { //single-exon mRNAs //if (equnspl) { //fuzz match for single-exon transfrags: // it's a match if they overlap at least 80% of max len ovlen=a.exons[0]->overlapLen(b.exons[0]); int maxlen=GMAX(a.covlen,b.covlen); return (ovlen>=maxlen*0.8); /*} else { //only exact match ovlen=a.covlen; return (a.exons[0]->start==b.exons[0]->start && a.exons[0]->end==b.exons[0]->end); }*/ } //check intron overlaps ovlen=a.exons[0]->end-(GMAX(a.start,b.start))+1; ovlen+=(GMIN(a.end,b.end))-a.exons.Last()->start; for (int i=1;i<=imax;i++) { if (i<imax) ovlen+=a.exons[i]->len(); if ((a.exons[i-1]->end!=b.exons[i-1]->end) || (a.exons[i]->start!=b.exons[i]->start)) { return false; //intron mismatch } } return true; }
void IntervalTree::FixUpMaxHigh(IntervalTreeNode * x) { while(x != root) { x->maxHigh=GMAX(x->high,GMAX(x->left->maxHigh,x->right->maxHigh)); x=x->parent; } #ifdef CHECK_INTERVAL_TREE_ASSUMPTIONS CheckAssumptions(); #endif }
bool singleExonTMatch(GffObj& m, GffObj& r, int& ovlen) { //if (m.exons.Count()>1 || r.exons.Count()>1..) GSeg mseg(m.start, m.end); ovlen=mseg.overlapLen(r.start,r.end); int lmax=GMAX(r.covlen, m.covlen); return ((ovlen >= lmax*0.8) // fuzz matching for single-exon transcripts: 80% of the longer one || (ovlen >= r.covlen*0.9)); // fuzzy reverse-containment - the reference transcript is shorter }
bool tMatch(GffObj& a, GffObj& b, int& ovlen, bool fuzzunspl, bool contain_only) { //strict intron chain match, or single-exon perfect match int imax=a.exons.Count()-1; int jmax=b.exons.Count()-1; ovlen=0; if (imax!=jmax) return false; //different number of introns if (imax==0) { //single-exon mRNAs if (contain_only) { return ((a.start>=b.start && a.end<=b.end) || (b.start>=a.start && b.end<=a.end)); } if (fuzzunspl) { //fuzz match for single-exon transfrags: // it's a match if they overlap at least 80% of shortest one ovlen=a.exons[0]->overlapLen(b.exons[0]); int maxlen=GMAX(a.covlen,b.covlen); return (ovlen>=maxlen*0.8); } else { //only exact match, or strictly contained ovlen=a.covlen; return (a.exons[0]->start==b.exons[0]->start && a.exons[0]->end==b.exons[0]->end); } } if ( a.exons[imax]->start<b.exons[0]->end || b.exons[jmax]->start<a.exons[0]->end ) return false; //intron chains do not overlap at all //check intron overlaps ovlen=a.exons[0]->end-(GMAX(a.start,b.start))+1; ovlen+=(GMIN(a.end,b.end))-a.exons.Last()->start; for (int i=1;i<=imax;i++) { if (i<imax) ovlen+=a.exons[i]->len(); if ((a.exons[i-1]->end!=b.exons[i-1]->end) || (a.exons[i]->start!=b.exons[i]->start)) { return false; //intron mismatch } } if (contain_only) return ((a.start>=b.start && a.end<=b.end) || (b.start>=a.start && b.end<=a.end)); else return true; }
void IntervalTree::LeftRotate(IntervalTreeNode* x) { IntervalTreeNode* y; /* I originally wrote this function to use the sentinel for */ /* nil to avoid checking for nil. However this introduces a */ /* very subtle bug because sometimes this function modifies */ /* the parent pointer of nil. This can be a problem if a */ /* function which calls LeftRotate also uses the nil sentinel */ /* and expects the nil sentinel's parent pointer to be unchanged */ /* after calling this function. For example, when DeleteFixUP */ /* calls LeftRotate it expects the parent pointer of nil to be */ /* unchanged. */ y=x->right; x->right=y->left; if (y->left != nil) y->left->parent=x; /* used to use sentinel here */ /* and do an unconditional assignment instead of testing for nil */ y->parent=x->parent; /* instead of checking if x->parent is the root as in the book, we */ /* count on the root sentinel to implicitly take care of this case */ if( x == x->parent->left) { x->parent->left=y; } else { x->parent->right=y; } y->left=x; x->parent=y; x->maxHigh=GMAX(x->left->maxHigh,GMAX(x->right->maxHigh,x->high)); y->maxHigh=MAX(x->maxHigh,GMAX(y->right->maxHigh,y->high)); #ifdef CHECK_INTERVAL_TREE_ASSUMPTIONS CheckAssumptions(); #elif defined(DEBUG_ASSERT) Assert(!nil->red,"nil not red in ITLeftRotate"); Assert((nil->maxHigh=MIN_INT), "nil->maxHigh != MIN_INT in ITLeftRotate"); #endif }