Skip to content

Commit a655733

Browse files
committed
attempt to fix a float precision bug in TPM/FPKM calculation
1 parent d2473c4 commit a655733

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

stringtie.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -780,19 +780,18 @@ if(!mergeMode) {
780780
int nl;
781781
int istr;
782782
int tlen;
783-
float tcov;
783+
double tcov;
784784
//float fpkm;
785-
float calc_fpkm;
786-
float calc_tpm;
785+
double calc_fpkm;
786+
double calc_tpm;
787787
int t_id;
788788
while(fgetline(linebuf,linebuflen,ftmp_in)) {
789-
//sscanf(linebuf,"%d %d %d %g %g", &nl, &tlen, &t_id, &fpkm, &tcov);
790-
sscanf(linebuf,"%d %d %d %d %g", &istr, &nl, &tlen, &t_id, &tcov);
789+
sscanf(linebuf,"%d %d %d %d %lf", &istr, &nl, &tlen, &t_id, &tcov);
791790
//for the rare cases tcov < 0, invert it ??
792791
//if (tcov<0) tcov=-tcov; //should not happen
793-
if (tcov<0) tcov=0;
794-
calc_fpkm=tcov*1000000000/Frag_Len;
795-
calc_tpm=tcov*1000000/Cov_Sum;
792+
if (tcov<0.0) tcov=0.0;
793+
calc_fpkm=tcov*1000000000.0/Frag_Len;
794+
calc_tpm=tcov*1000000.0/Cov_Sum;
796795
if(istr) { // this is a transcript
797796
if (ballgown && t_id>0) {
798797
guides_RC_tdata[t_id-1]->fpkm=calc_fpkm;

0 commit comments

Comments
 (0)