Skip to content

Commit 7b1a4f4

Browse files
committed
fixed -e bug for unstranded alignments; fixed TPM -nan
1 parent 43b5df7 commit 7b1a4f4

2 files changed

Lines changed: 23 additions & 15 deletions

File tree

rlink.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13144,12 +13144,15 @@ int print_predcluster(GList<CPrediction>& pred,int geneno,GStr& refname,
1314413144
// build maxIntv
1314513145
CMaxIntv *maxint=new CMaxIntv(pred[0]->exons[0].start,pred[0]->exons[0].end);
1314613146

13147-
if(!pred[0]->t_eq && pred[0]->exons.Count()==1 && pred[0]->strand!='.') { // neutral strand if most reads are neutral
13148-
int s=0;
13149-
if(pred[0]->strand=='+') s=2;
13150-
float totalcov=get_cov(1,pred[0]->start-bundleData->start,pred[0]->end-bundleData->start,bpcov);
13151-
float strandcov=get_cov(s,pred[0]->start-bundleData->start,pred[0]->end-bundleData->start,bpcov);
13152-
if(strandcov<ERROR_PERC*totalcov) pred[0]->strand='.';
13147+
if(!pred[0]->t_eq) {
13148+
if(eonly) pred[0]->flag=false;
13149+
else if(pred[0]->exons.Count()==1 && pred[0]->strand!='.') { // neutral strand if most reads are neutral
13150+
int s=0;
13151+
if(pred[0]->strand=='+') s=2;
13152+
float totalcov=get_cov(1,pred[0]->start-bundleData->start,pred[0]->end-bundleData->start,bpcov);
13153+
float strandcov=get_cov(s,pred[0]->start-bundleData->start,pred[0]->end-bundleData->start,bpcov);
13154+
if(strandcov<ERROR_PERC*totalcov) pred[0]->strand='.';
13155+
}
1315313156
}
1315413157

1315513158
CExon ex(0,0,pred[0]->cov*pred[0]->len()); // this keeps the exon flow based on per bp coverage
@@ -13205,12 +13208,15 @@ int print_predcluster(GList<CPrediction>& pred,int geneno,GStr& refname,
1320513208
nextmaxint=maxint;
1320613209
for(int n=1;n<npred;n++) {
1320713210

13208-
if(!pred[n]->t_eq && pred[n]->exons.Count()==1 && pred[n]->strand!='.') { // neutral strand if most reads are neutral
13209-
int s=0;
13210-
if(pred[n]->strand=='+') s=2;
13211-
float totalcov=get_cov(1,pred[n]->start-bundleData->start,pred[n]->end-bundleData->start,bpcov);
13212-
float strandcov=get_cov(s,pred[n]->start-bundleData->start,pred[n]->end-bundleData->start,bpcov);
13213-
if(strandcov<ERROR_PERC*totalcov) pred[n]->strand='.';
13211+
if(!pred[n]->t_eq) {
13212+
if(eonly) pred[n]->flag=false;
13213+
else if(pred[n]->exons.Count()==1 && pred[n]->strand!='.') { // neutral strand if most reads are neutral
13214+
int s=0;
13215+
if(pred[n]->strand=='+') s=2;
13216+
float totalcov=get_cov(1,pred[n]->start-bundleData->start,pred[n]->end-bundleData->start,bpcov);
13217+
float strandcov=get_cov(s,pred[n]->start-bundleData->start,pred[n]->end-bundleData->start,bpcov);
13218+
if(strandcov<ERROR_PERC*totalcov) pred[n]->strand='.';
13219+
}
1321413220
}
1321513221

1321613222
color.Add(n);

stringtie.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "proc_mem.h"
1212
#endif
1313

14-
#define VERSION "2.0.3"
14+
#define VERSION "2.0.4"
1515

1616
//#define DEBUGPRINT 1
1717

@@ -786,8 +786,10 @@ if(!mergeMode) {
786786
while(fgetline(linebuf,linebuflen,ftmp_in)) {
787787
sscanf(linebuf,"%d %d %d %d %g", &istr, &nl, &tlen, &t_id, &tcov);
788788
if (tcov<0) tcov=0;
789-
calc_fpkm=tcov*1000000000/Frag_Len;
790-
calc_tpm=tcov*1000000/Cov_Sum;
789+
if (Frag_Len>0.001) calc_fpkm=tcov*1000000000/Frag_Len;
790+
else calc_fpkm=0.0;
791+
if (Cov_Sum>0.00001) calc_tpm=tcov*1000000/Cov_Sum;
792+
else calc_tpm=0.0;
791793
if(istr) { // this is a transcript
792794
if (ballgown && t_id>0) {
793795
guides_RC_tdata[t_id-1]->fpkm=calc_fpkm;

0 commit comments

Comments
 (0)