ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/gff.cpp
(Generate patch)
# Line 1155 | Line 1155
1155              if (transcriptsOnly && discarded_ids.Find(gffline->parents[i])!=NULL)
1156                  continue; //skipping discarded parent feature
1157              GfoHolder* parentgfo=NULL;
1158 <            if (gffline->is_transcript || gffline->exontype==0) //possibly a transcript
1159 <              parentgfo=gfoFind(gffline->parents[i], gffline->gseqname,
1160 <                                          &newgflst, gffline->strand, gffline->fstart, gffline->fend);
1161 <            else
1162 <              parentgfo=gfoFind(gffline->parents[i], gffline->gseqname,
1163 <                                          &newgflst, gffline->strand, gffline->fstart);
1158 >            if (gffline->is_transcript || gffline->exontype==0) {//possibly a transcript
1159 >               parentgfo=gfoFind(gffline->parents[i], gffline->gseqname,
1160 >                                    &newgflst, gffline->strand, gffline->fstart, gffline->fend);
1161 >               }
1162 >            else {
1163 >               //for exon-like entities we only need a parent to be in locus distance,
1164 >               //on the same strand
1165 >               parentgfo=gfoFind(gffline->parents[i], gffline->gseqname,
1166 >                                     &newgflst, gffline->strand, gffline->fstart);
1167 >               }
1168              if (parentgfo!=NULL) { //parent GffObj parsed earlier
1169 <
1166 <                   //found_parent=true;
1169 >                   found_parent=true;
1170                     if (parentgfo->gffobj->isGene() && gffline->is_transcript
1171                                     && gffline->exontype==0) {
1172                         //not an exon, but a transcript parented by a gene
# Line 1235 | Line 1238
1238      ftype_id=gff_fid_mRNA;
1239      //exon_ftype_id=gff_fid_exon;
1240      }
1241 < //if (ftype_id==gff_fid_mRNA || exon_ftype_id==gff_fid_exon || mergeCloseExons) {
1242 < if (isTranscript() || exon_ftype_id==gff_fid_exon || mergeCloseExons) {
1243 <   int mindist=mergeCloseExons ? 5:1;
1244 <   for (int i=0;i<exons.Count()-1;i++) {
1245 <     int ni=i+1;
1246 <     uint mend=exons[i]->end;
1247 <     while (ni<exons.Count()) {
1248 <       int dist=(int)(exons[ni]->start-mend);
1249 <       if (dist>mindist) break; //no merging with next segment
1250 <       if (gfr!=NULL && gfr->gff_warns && dist!=0 && (exons[ni]->exontype!=exgffUTR && exons[i]->exontype!=exgffUTR)) {
1251 <          GMessage("GFF warning: merging adjacent/overlapping segments of %s on %s (%d-%d, %d-%d)\n",
1252 <               gffID, getGSeqName(), exons[i]->start, exons[i]->end,exons[ni]->start, exons[ni]->end);
1253 <          }
1254 <       mend=exons[ni]->end;
1255 <       covlen-=exons[i]->len();
1256 <       exons[i]->end=mend;
1257 <       covlen+=exons[i]->len();
1258 <       covlen-=exons[ni]->len();
1259 <       if (exons[ni]->attrs!=NULL && (exons[i]->attrs==NULL ||
1260 <            exons[i]->attrs->Count()<exons[ni]->attrs->Count())) {
1261 <              //use the other exon attributes, if more
1262 <              delete(exons[i]->attrs);
1263 <              exons[i]->attrs=exons[ni]->attrs;
1264 <              exons[ni]->attrs=NULL;
1265 <              }
1266 <       exons.Delete(ni);
1267 <       } //check for merge with next exon
1241 > if (exons.Count()>0 && (isTranscript() || exon_ftype_id==gff_fid_exon)) {
1242 >   if (mergeCloseExons) {
1243 >     int mindist=mergeCloseExons ? 5:1;
1244 >     for (int i=0;i<exons.Count()-1;i++) {
1245 >       int ni=i+1;
1246 >       uint mend=exons[i]->end;
1247 >       while (ni<exons.Count()) {
1248 >         int dist=(int)(exons[ni]->start-mend);
1249 >         if (dist>mindist) break; //no merging with next segment
1250 >         if (gfr!=NULL && gfr->gff_warns && dist!=0 && (exons[ni]->exontype!=exgffUTR && exons[i]->exontype!=exgffUTR)) {
1251 >            GMessage("GFF warning: merging adjacent/overlapping segments of %s on %s (%d-%d, %d-%d)\n",
1252 >                 gffID, getGSeqName(), exons[i]->start, exons[i]->end,exons[ni]->start, exons[ni]->end);
1253 >            }
1254 >         mend=exons[ni]->end;
1255 >         covlen-=exons[i]->len();
1256 >         exons[i]->end=mend;
1257 >         covlen+=exons[i]->len();
1258 >         covlen-=exons[ni]->len();
1259 >         if (exons[ni]->attrs!=NULL && (exons[i]->attrs==NULL ||
1260 >              exons[i]->attrs->Count()<exons[ni]->attrs->Count())) {
1261 >                //use the other exon attributes, if more
1262 >                delete(exons[i]->attrs);
1263 >                exons[i]->attrs=exons[ni]->attrs;
1264 >                exons[ni]->attrs=NULL;
1265 >                }
1266 >         exons.Delete(ni);
1267 >         } //check for merge with next exon
1268       } //for each exon
1269 <   }
1269 >   } //merge close exons
1270 >   //shrink transcript to the exons' span
1271 >   this->start=exons.First()->start;
1272 >   this->end=exons.Last()->end;
1273 > }
1274   //attribute reduction for GTF records
1275   if (keepAttrs && !noExonAttr && !hasGffID()
1276            && exons.Count()>0 && exons[0]->attrs!=NULL) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines