ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/GAlnExtend.h
(Generate patch)
# Line 5 | Line 5
5  
6   #include "GBase.h"
7   #include "GList.hh"
8 < #include <string.h>
8 > #include "gdna.h"
9  
10   //#define GDEBUG 1
11  
# Line 98 | Line 98
98  
99          if (GX_EDITOP_GET(oplast) == op) {
100              uint32 l=ops[opnum-1];
101 <            ops[opnum-1]=GX_EDITOP_CONS((GX_EDITOP_GET(l)),
101 >            ops[opnum-1]=GX_EDITOP_CONS((GX_EDITOP_GET(l)),
102                 (GX_EDITOP_VAL(l) + k));
103              }
104          else {
# Line 346 | Line 346
346         a_len=0;
347             b_len=0;
348             if (ed_script==NULL) return;
349 <           for (uint32 i=0; i<ed_script->opnum; i++) {
349 >           for (uint32 i=0; i<ed_script->opnum; i++) {
350                    int num=((ed_script->ops[i]) >> 2);
351                    char op_type = 3 - ( ed_script->ops[i] & gxEDIT_OP_MASK );
352                    if (op_type == 3 || op_type < 0 )
# Line 371 | Line 371
371             }
372  
373   #ifdef GDEBUG
374 <        void printAlignment(FILE* f, const char* sa, int sa_len,
374 >        void printAlignment(FILE* f, const char* sa, int sa_len,
375                       const char* sb, int sb_len) {
376                  //print seq A
377             char al[1024]; //display buffer for seq A
# Line 436 | Line 436
436         }
437   #endif
438    };
439 <  
439 >
440   struct GXAlnInfo {
441   const char *qseq;
442   int ql,qr;
# Line 597 | Line 597
597            //by idxoffset we get a max of a_len+b_len-2
598        int bcount=a_len+b_len-1;
599        for (int i=0;i<bcount;i++)
600 <                   this->Add(new GXBand(i-idxoffset));
600 >              this->Add(new GXBand(i-idxoffset));
601             //unsorted, this should set fList[i]
602        }
603     ~GXBandSet() {
# Line 612 | Line 612
612       }
613   };
614  
615 + struct GXSeqData {
616 +  const char* aseq;
617 +  int alen;
618 +  const char* bseq;
619 +  int blen;
620 +  GVec<uint16>** amers;
621 +  int amlen; //minimum alignment length that's sufficient to
622 +             //trigger the quick extension heuristics
623 +  GXSeqData(const char* sa=NULL, int la=0, const char* sb=NULL, int lb=0,
624 +  GVec<uint16>* mers[]=NULL):aseq(sa), alen(la),
625 +     bseq(sb),  blen(lb), amers(mers), amlen(0) {
626 +   calc_amlen();
627 +   calc_bmlen();
628 +   }
629 +  void calc_amlen() {
630 +    if (alen) {
631 +       int ah=iround(double(alen)*0.8);
632 +       if (ah<12) ah=12;
633 +       if (amlen>ah) amlen=ah;
634 +       }
635 +    }
636 +  void calc_bmlen() {
637 +    if (blen) {
638 +      int bh = iround(double(alen)*0.6);
639 +      if (bh<12) bh=12;
640 +      if (amlen>bh) amlen=bh;
641 +      }
642 +    }
643 +  void update(const char* sa, int la, GVec<uint16>** mers,
644 +          const char* sb, int lb, int mlen=0) {
645 +     aseq=sa;
646 +     alen=la;
647 +     amers=mers;
648 +     if (mlen) {
649 +       amlen=mlen;
650 +       }
651 +       else calc_amlen();
652 +     if (sb==bseq && blen==lb) return;
653 +     bseq=sb;
654 +     blen=lb;
655 +     calc_bmlen();
656 +     }
657 +  /*
658 +  void update_b(const char* sb, int lb) {
659 +     if (sb==bseq && blen==lb) return;
660 +     bseq=sb;
661 +     blen=lb;
662 +     calc_bmlen();
663 +     }*/
664 + };
665 +
666 + uint16 get6mer(char* p);
667 + void table6mers(const char* s, int slen, GVec<uint16>* amers[]);
668  
669 < GXBandSet* collectSeeds_R(GList<GXSeed>& seeds, const char* seqa, int a_len, const char* seqb, int b_len); //for overlap at 3' end of seqb
669 > GXBandSet* collectSeeds_R(GList<GXSeed>& seeds, GXSeqData& sd); //for overlap at 3' end of seqb
670  
671 < GXBandSet* collectSeeds_L(GList<GXSeed>& seeds, const char* seqa, int a_len, const char* seqb, int b_len); //for overlap at 5' end of seqb
671 > GXBandSet* collectSeeds_L(GList<GXSeed>& seeds, GXSeqData& sd); //for overlap at 5' end of seqb
672  
673   void printEditScript(GXEditScript* ed_script);
674  
# Line 638 | Line 691
691   struct CAlnTrim {
692    GAlnTrimType type;
693    int boundary; //base index (either left or right) excluding terminal poly-A stretches
694 <  void prepare(GAlnTrimType trim_type, const char* s, int s_len) {
695 <    type=trim_type;
694 >  int safelen; //alignment length > amlen should be automatically validated
695 >  int seedlen;
696 >  void prepare(const char* s, int s_len) {
697 >    //type=trim_type;
698 >    //amlen=smlen;
699      boundary=0;
700      if (type==galn_TrimLeft) {
701          int s_lbound=0;
# Line 668 | Line 724
724         }
725      }
726  
727 <  CAlnTrim(GAlnTrimType trim_type, const char* s, int s_len) {
728 <    prepare(trim_type, s, s_len);
727 >  CAlnTrim(GAlnTrimType trim_type, const char* s, int s_len, int smlen):
728 >                   type(trim_type), boundary(0), safelen(smlen) {
729 >    prepare(s, s_len);
730      }
731  
732    bool validate(int sl, int sr, int alnpid, int adist) {
733     int alnlen=sr-sl+1;
734 +   if (alnpid>93 && alnlen>safelen) return true;
735     sl--;sr--; //boundary is 0-based
736     int badj=0; //default boundary is 3 bases distance to end
737     int admax=1;
# Line 713 | Line 771
771   GXAlnInfo* GreedyAlign(const char* q_seq,  int q_alnstart, const char* s_seq, int s_alnstart,
772          bool editscript=false, int reward=2, int penalty=3, int xdrop=8);
773  
774 < GXAlnInfo* match_LeftEnd(const char* seqa, int seqa_len, const char* seqb, int seqb_len,
775 <          CGreedyAlignData* gxmem=NULL, int min_pid=83);
718 < GXAlnInfo* match_RightEnd(const char* seqa, int seqa_len, const char* seqb, int seqb_len,
719 <          CGreedyAlignData* gxmem=NULL, int min_pid=73);
774 > GXAlnInfo* match_LeftEnd(GXSeqData& sd, CGreedyAlignData* gxmem=NULL, int min_pid=83);
775 > GXAlnInfo* match_RightEnd(GXSeqData& sd, CGreedyAlignData* gxmem=NULL, int min_pid=73);
776   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines