ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/gff.cpp
(Generate patch)
# Line 645 | Line 645
645       }
646     if (end<exons.Last()->end) end=exons.Last()->end;
647      
648   if (uptr!=NULL) { //collect stats about the underlying genomic sequence
649       GSeqStat* gsd=(GSeqStat*)uptr;
650       if (start<gsd->mincoord) gsd->mincoord=start;
651       if (end>gsd->maxcoord) gsd->maxcoord=end;
652       if (this->len()>gsd->maxfeat_len) {
653          gsd->maxfeat_len=this->len();
654          gsd->maxfeat=this;
655          }
656       }
648     return eidx;
649   }
650  
# Line 853 | Line 844
844    //GSeqStat* gsd=gfrd->gseqstats.AddIfNew(new GSeqStat(gseq_id,names->gseqs.lastNameUsed()),true);
845    GSeqStat* gsd=gfrd->gseqstats.AddIfNew(new GSeqStat(gseq_id,gffline->gseqname), true);
846    uptr=gsd;
847 +  /*
848    if (start<gsd->mincoord) gsd->mincoord=start;
849    if (end>gsd->maxcoord) gsd->maxcoord=end;
850      if (this->len()>gsd->maxfeat_len) {
851          gsd->maxfeat_len=this->len();
852          gsd->maxfeat=this;
853          }
854 +  */
855   }
856  
857   GffLine* GffReader::nextGffLine() {
# Line 1220 | Line 1213
1213        gffline=NULL;
1214        }//while gff lines
1215    gflst.finalize(this, mergeCloseExons, keepAttr, noExonAttr); //force sorting by locus if so constructed
1216 +  gseqStats.setCount(gseqstats.Last()->gseqid+1);
1217 +  for (int gi=0;gi<gseqstats.Count();gi++) {
1218 +    gseqStats.Put(gseqstats[gi]->gseqid, gseqstats[gi]); //copy the pointer only
1219 +  }
1220   // all gff records are now loaded in GList gflst
1221   // so we can free the hash
1222    phash.Clear();
# Line 1229 | Line 1226
1226      }
1227   }
1228  
1229 + void GfList::finalize(GffReader* gfr, bool mergeCloseExons,
1230 +             bool keepAttrs, bool noExonAttr) { //if set, enforce sort by locus
1231 +  if (mustSort) { //force (re-)sorting
1232 +     this->setSorted(false);
1233 +     this->setSorted((GCompareProc*)gfo_cmpByLoc);
1234 +     }
1235 +  GList<GffObj> discarded(false,true,false);
1236 +  for (int i=0;i<Count();i++) {
1237 +    //finish the parsing for each GffObj
1238 +    fList[i]->finalize(gfr, mergeCloseExons, keepAttrs, noExonAttr);
1239 +    if (fList[i]->isDiscarded()) {
1240 +       discarded.Add(fList[i]);
1241 +       this->Forget(i);
1242 +    }
1243 +  }
1244 +  if (discarded.Count()>0) this->Pack();
1245 + }
1246 +
1247   GffObj* GffObj::finalize(GffReader* gfr, bool mergeCloseExons, bool keepAttrs, bool noExonAttr) {
1248   //merge
1249   //always merge adjacent or overlapping segments
# Line 1274 | Line 1289
1289     //shrink transcript to the exons' span
1290     this->start=exons.First()->start;
1291     this->end=exons.Last()->end;
1292 +   //also update the stats for the reference sequence
1293 +   if (uptr!=NULL) { //collect stats about the underlying genomic sequence
1294 +       GSeqStat* gsd=(GSeqStat*)uptr;
1295 +       if (start<gsd->mincoord) gsd->mincoord=start;
1296 +       if (end>gsd->maxcoord) gsd->maxcoord=end;
1297 +       if (this->len()>gsd->maxfeat_len) {
1298 +          gsd->maxfeat_len=this->len();
1299 +          gsd->maxfeat=this;
1300 +          }
1301 +       }
1302 +   this->uptr=NULL;
1303 +   this->udata=0;
1304   }
1305   //attribute reduction for GTF records
1306   if (keepAttrs && !noExonAttr && !hasGffID()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines