ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/gff.cpp
(Generate patch)
# Line 403 | Line 403
403   skip=false;
404   }
405  
406 +
407 + void GffObj::addCDS(uint cd_start, uint cd_end, char phase) {
408 +  if (cd_start>=this->start) {
409 +        this->CDstart=cd_start;
410 +        if (strand=='+') this->CDphase=phase;
411 +        }
412 +      else this->CDstart=this->start;
413 +  if (cd_end<=this->end) {
414 +      this->CDend=cd_end;
415 +      if (strand=='-') this->CDphase=phase;
416 +      }
417 +     else this->CDend=this->end;
418 +  isTranscript(true);
419 +  exon_ftype_id=gff_fid_exon;
420 +  if (monoFeature()) {
421 +     if (exons.Count()==0) addExon(this->start, this->end,0,'.',0,0,false,exgffExon);
422 +            else exons[0]->exontype=exgffExon;
423 +     }
424 + }
425 +
426   int GffObj::addExon(GffReader* reader, GffLine* gl, bool keepAttr, bool noExonAttr) {
427    //this will make sure we have the right subftype_id!
428 <  int subf_id=-1;
429 <  if (!isTranscript() && gl->is_cds && monoFeature()) {
428 >  //int subf_id=-1;
429 >  if (!isTranscript() && gl->is_cds) {
430            isTranscript(true);
431            exon_ftype_id=gff_fid_exon;
432            if (exons.Count()==1) exons[0]->exontype=exgffExon;
# Line 426 | Line 446
446            }
447       }
448    else { //non-mRNA parent feature, check this subf type
449 <    subf_id=names->feats.addName(gl->ftype);
449 >    int subf_id=names->feats.addName(gl->ftype);
450      if (exon_ftype_id<0 || exons.Count()==0) //never assigned a subfeature type before (e.g. first exon being added)
451         exon_ftype_id=subf_id;
452       else {
# Line 572 | Line 592
592             } //check for overlap
593     // --- no overlap, or accepted micro-overlap (ribosomal slippage)
594     // create & add the new segment
595 +   /*
596 +   if (start>0 && exontype==exgffCDS && exons.Count()==0) {
597 +      //adding a CDS directly as the first subfeature of a declared parent
598 +      segstart=start;
599 +      segend=end;
600 +      }
601 +   */
602     GffExon* enew=new GffExon(segstart, segend, sc, fr, qs, qe, exontype);
603     int eidx=exons.Add(enew);
604     if (eidx<0) {
# Line 584 | Line 611
611       return -1;            
612       }
613     covlen+=(int)(exons[eidx]->end-exons[eidx]->start)+1;
614 <   start=exons.First()->start;
615 <   end=exons.Last()->end;
614 >   //adjust parent feature coordinates to contain this exon
615 >   if (start==0 || start>exons.First()->start) {
616 >     start=exons.First()->start;
617 >     }
618 >   if (end<exons.Last()->end) end=exons.Last()->end;
619 >    
620     if (uptr!=NULL) { //collect stats about the underlying genomic sequence
621         GSeqStat* gsd=(GSeqStat*)uptr;
622         if (start<gsd->mincoord) gsd->mincoord=start;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines