ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/seqalign/GXAlign.h
(Generate patch)
# Line 394 | Line 394
394      delete abmp;
395      delete gapinfo;
396      }
397 +  bool operator<(GXAlnInfo& d) {
398 +    return ((score==d.score)? pid>d.pid : score>d.score);
399 +    }
400 +  bool operator>(GXAlnInfo& d) {
401 +    return ((score==d.score)? pid<d.pid : score<d.score);
402 +    }
403 +  bool operator==(GXAlnInfo& d) {
404 +    return (score==d.score && pid==d.pid);
405 +    }
406 +
407   };
408  
409  
# Line 420 | Line 430
430       }
431   };
432  
433 + int cmpSeedLen(const pointer s1, const pointer s2);
434 +
435   struct GXBand {
436    //bundle of seed matches on 3 adjacent diagonals
437    int diag; //first anti-diagonal (b_ofs-a_ofs) in this group of 3
# Line 427 | Line 439
439    int min_a, max_a; //maximal coordinates of the bundle
440    int min_b, max_b;
441    GList<GXSeed> seeds; //sorted by x coordinate (b_ofs)
430  GPVec<GXSeed> cutseeds; //copy-on-cut list of seeds that will replace the seed instances when a seed gets edited
442    int score; //sum of seed scores (- overlapping_bases/2 - gaps)
443 <  GXBand(int start_diag=-1, GXSeed* seed=NULL):seeds(true, false, false),
433 <                  cutseeds(10, true){
443 >  GXBand(int start_diag=-1, GXSeed* seed=NULL):seeds(true, false, false) {
444            diag=start_diag;
445            min_a=MAX_INT;
446            min_b=MAX_INT;
447            max_a=0;
448            max_b=0;
449            score=0;
450 <      if (seed!=NULL) addSeed(seed);
451 <      }
450 >    if (seed!=NULL) addSeed(seed);
451 >    }
452    void addSeed(GXSeed* seed) {
453       seeds.Add(seed);
454       score+=seed->len;
# Line 449 | Line 459
459       if (seed->b_ofs+seed->len > max_b) max_b=seed->b_ofs+seed->len;
460       }
461    void finalize() {
462 <         //!! to be called only AFTER all seeds have been added
463 <         // seeds are sorted by b_ofs
464 <         //penalize gaps and overlaps on b sequence
455 <         //cut out overlapping regions from shorter seeds
456 <
457 <         bool had_cut=false;
458 <         do {
462 >          //!! to be called only AFTER all seeds have been added
463 >          // seeds are sorted by b_ofs
464 >          //penalize seed gaps and overlaps on b sequence
465            for (int i=1;i<seeds.Count();i++) {
466          GXSeed& sprev=*seeds[i-1];
461        if (sprev.len<=0) continue;
467          GXSeed& scur=*seeds[i];
468          if (scur==sprev) GError("Error: duplicate seeds found (%d-%d:%d-%d)!\n",
469                                scur.a_ofs+1, scur.a_ofs+scur.len, scur.b_ofs+1, scur.b_ofs+scur.len);
# Line 467 | Line 472
472          int max_gap=b_gap;
473          int min_gap=a_gap;
474          if (min_gap>max_gap) swap(max_gap, min_gap);
475 <        if (min_gap<0) {
476 <            //cut shorter or previous seed by -min_gap amount
477 <            GXSeed* cseed=NULL;
473 <            had_cut=true;
474 <            if (scur.len<sprev.len) {
475 <               //cut beginning of scur
476 <               cseed=new GXSeed(scur);
477 <               cseed->edited=1;
478 <               cseed->len+=min_gap; //this can get negative!
479 <               cseed->a_ofs+=min_gap;//these can get invalid
480 <               cseed->b_ofs+=min_gap;
481 <               seeds.Put(i,cseed); //TODO: re-sort?
475 >        if (min_gap<0) { //overlap
476 >               if (max_gap>0) { score-=GMAX((-min_gap), max_gap); }
477 >                  else score+=min_gap;
478                 }
479 <            else { //cut ending of sprev
480 <               cseed=new GXSeed(sprev);
485 <               cseed->edited=1;
486 <               cseed->len+=min_gap; //this can get negative!
487 <               seeds.Put(i-1,cseed);
479 >            else { //gap
480 >               score-=max_gap;
481                 }
482 <            }//overlap
490 <            }
491 <           } while (had_cut); //repeat until no more cuts
482 >              }//for each seed
483       }
484 +
485    //bands will be sorted by decreasing score eventually, after all seeds are added
486    bool operator<(GXBand& d){
487       return ((score==d.score) ? seeds.Count()>d.seeds.Count() : score>d.score);
# Line 521 | Line 513
513            //by idxoffset we get a max of a_len+b_len-2
514        int bcount=a_len+b_len-1;
515        for (int i=0;i<bcount;i++)
516 <           fList[i]=new GXBand(i-idxoffset);
516 >                   this->Add(new GXBand(i-idxoffset));
517 >           //unsorted, this should set fList[i]
518        }
519     void addSeed(GXSeed* seed) {
520           //MUST be unsorted !!!

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines