ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/fqtrim/fqtrim.cpp
(Generate patch)
# Line 957 | Line 957
957   int wlen=rlen;
958   GXSeqData seqdata;
959   int numruns=revCompl ? 2 : 1;
960 <
960 > GList<GXAlnInfo> bestalns(true, true, false);
961   for (int ai=0;ai<adaptors3.Count();ai++) {
962     for (int r=0;r<numruns;r++) {
963       if (r) {
# Line 968 | Line 968
968              seqdata.update(adaptors3[ai].seq.chars(), adaptors3[ai].seq.length(),
969                   adaptors3[ai].pz, wseq.chars(), wlen, adaptors3[ai].amlen);
970          }
971 <
972 <  GXAlnInfo* aln=match_adaptor(seqdata, adaptors3[ai].trim_type, gxmem_r, 86);
973 <  if (aln) {
974 <     trimmed=true;
975 <     //keep unmatched region on the left OR right (the longer one)
976 <     if (aln->sl > wlen-aln->sr) {
977 <         //keep left side
978 <         l3-=(wlen-aln->sl+1);
979 <         if (l3<0) l3=0;
980 <         }
981 <     else { //keep right side
982 <         l5+=aln->sr;
983 <         if (l5>=rlen) l5=rlen-1;
984 <         }
985 <     delete aln;
986 <     if (l3-l5+1<min_read_len) return true;
987 <     wseq=seq.substr(l5,l3-l5+1);
988 <     wlen=wseq.length();
989 <     }
971 >     GXAlnInfo* aln=match_adaptor(seqdata, adaptors3[ai].trim_type, gxmem_r, 86);
972 >         if (aln) {
973 >           if (aln->strong) {
974 >                   trimmed=true;
975 >                   bestalns.Add(aln);
976 >                   break; //will check the rest next time
977 >                   }
978 >            else bestalns.Add(aln);
979 >           }
980     }//forward and reverse adaptors
981 +   if (trimmed) break; //will check the rest in the next cycle
982    }//for each 3' adaptor
983 <  return trimmed;
983 > if (bestalns.Count()>0) {
984 >           GXAlnInfo* aln=bestalns[0];
985 >           if (aln->sl-1 > wlen-aln->sr) {
986 >                   //keep left side
987 >                   l3-=(wlen-aln->sl+1);
988 >                   if (l3<0) l3=0;
989 >                   }
990 >           else { //keep right side
991 >                   l5+=aln->sr;
992 >                   if (l5>=rlen) l5=rlen-1;
993 >                   }
994 >           //delete aln;
995 >           //if (l3-l5+1<min_read_len) return true;
996 >           wseq=seq.substr(l5,l3-l5+1);
997 >           wlen=wseq.length();
998 >           return true; //break the loops here to report a good find
999 >     }
1000 >  return false;
1001   }
1002  
1003   bool trim_adaptor5(GStr& seq, int&l5, int &l3) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines