Exemplo n.º 1
0
Arquivo: poly.c Projeto: gitpan/GH
static void remove_polyA_back(struct edit_script_list **Sptr, Exon *Exons, uchar *s1, uchar *s2, int len2, int *lastA) {
     Exon *t, *exons_tail, *prev; /* start from Lblock */
     uchar *b, *end;
     int numA, pA, dummy, trim_p, reverse_script=0;

     *lastA = len2+1;  pA = 0;
     if (!Exons || ! Exons->next_exon || ! Exons->next_exon->to1) return;

     if ((*Sptr)->next_script &&
         (*Sptr)->offset1<(*Sptr)->next_script->offset1) {
         reverse_script = 1;
         script_flip_list(Sptr);
     }

     
     exons_tail = Exons->next_exon; prev = Exons;
     for ( ; exons_tail->next_exon && exons_tail->next_exon->to1; 
             prev=exons_tail, exons_tail=exons_tail->next_exon);

     trim_p = TRUE;
     while ((t=exons_tail)!=NULL && t->to1 && trim_p) {
        /* compute the 'A' contents of the exon */
        b = s2 + t->to2-1; end = s2+t->from2-1; numA = 0;
        while (b>=end && numA+(b-s2)>=.60*t->length) { 
               numA += (*b--=='A'); 
        }
        if (numA>=.60*t->length) {
            /* remove the entire exon */
            trim_polyA_align(Sptr,Exons,&exons_tail,t->from2,lastA,s1,s2);
/*          assert(*lastA==t->from2);  t was removed */
        } else {
            get_polyAT(s2+(*Sptr)->offset2-1,(*Sptr)->len2,&dummy,&pA,A_ONLY);
            if (pA) {
               int ct_pA;
               /* first position to be removed */ 
               ct_pA = t->to2-pA+1; 
               ct_pA = (ct_pA-t->from2>=MIN_EXON) ? ct_pA : t->from2;
               /* note: pA is the last (innermost) position in the tail */
               trim_polyA_align(Sptr,Exons,&exons_tail,ct_pA,lastA,s1,s2);
            }
            if (t==exons_tail) trim_p = FALSE;
        }
     }

     if (reverse_script) script_flip_list(Sptr);
}
Exemplo n.º 2
0
void
Sim4::remove_polyA_back(struct edit_script_list **Sptr, Exon *Exons,
                        char *s1, char *s2,
                        int l2, int *lastA) {
  Exon *t;
  Exon *exons_tail;
  char *b, *end;
  int numA, pA, dummy, trim_p, reverse_script=0;
  int startPos=0, cutAmount=0;

  *lastA = l2+1;  pA = 0;
  if (!Exons || ! Exons->next_exon || ! Exons->next_exon->toGEN) return;

  if ((*Sptr)->next_script &&
      (*Sptr)->offset1<(*Sptr)->next_script->offset1) {
    reverse_script = 1;
    script_flip_list(Sptr);
  }

  exons_tail = Exons->next_exon;
  while (exons_tail->next_exon && exons_tail->next_exon->toGEN)
    exons_tail=exons_tail->next_exon;

  trim_p = 1;

  if (exons_tail) {
    startPos = exons_tail->toEST;

    while ((t=exons_tail)!=NULL && t->toGEN && trim_p) {
      /* compute the 'A' contents of the exon */
      b = s2 + t->toEST-1; end = s2+t->frEST-1; numA = 0;
      while (b>=end && numA+(b-end)>=globalParams->_polyTailPercent*t->length) { 
        numA += (*b--=='A'); 
      }

      //  Determine how much of the cut stuff was actually
      //  poly-containing.  The first method below returns the number of
      //  bases cut from the end of the est, while the second return the
      //  number of bases cut from the end of the alignment.
      //
      //cutAmount = l2 - *lastA + 1;

      if (numA>=globalParams->_polyTailPercent*t->length) {
        /* remove the entire exon */
        trim_polyA_align(Sptr,Exons,&exons_tail,t->frEST,lastA,s1,s2);
        cutAmount = startPos - *lastA + 1;
      } else {
        get_polyAT(s2+(*Sptr)->offset2-1,(*Sptr)->len2,&dummy,&pA,A_ONLY);
        if (pA) {
          int ct_pA;
          /* first position to be removed */ 
          ct_pA = t->toEST-pA+1; 
          ct_pA = (ct_pA-t->frEST>MIN_EXON) ? ct_pA : t->frEST;
          /* note: pA is the last (innermost) position in the tail */
          trim_polyA_align(Sptr,Exons,&exons_tail,ct_pA,lastA,s1,s2);
          cutAmount = startPos - *lastA + 1;
        }
        if (t==exons_tail) trim_p = 0;
      }
    }
  }

  *lastA = cutAmount;

  if (reverse_script) script_flip_list(Sptr);
}