Skip to content

Commit

Permalink
fix for a numerical overflow error with the enumerate command
Browse files Browse the repository at this point in the history
the issue was that for loci with more possible isoforms than can be
represented by an integer variable the count would overflow before
making the comparison with the user specified max_isoforms parameter.

To fix this I replaced the counter with a BigInteger, which won't
overflow.
  • Loading branch information
shenkers committed Jul 17, 2015
1 parent 43ed1cf commit 81e46a5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions IsoSCM/src/splicegraph/ExonSpliceGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
Expand Down Expand Up @@ -301,7 +302,7 @@ public static void iterateSpliceIsoforms(File assembly_gtf, GTFWriter isoform_gt

Set<String> skipped_ids = new HashSet<String>();
for(AnnotatedRegion r : exon_5p){
if(max_paths == null || countPaths(r, exon_3p, sj5p) < max_paths){
if(max_paths == null || countPaths(r, exon_3p, sj5p).compareTo(new BigInteger(String.format("%d", max_paths))) < 0){
Stack<AnnotatedRegion> isoform_exons = new Stack<AnnotatedRegion>();
iterateIsoforms(isoform_count, isoform_exons, r, exon_3p, sj5p, isoform_gtf);
}
Expand Down Expand Up @@ -372,21 +373,22 @@ public static List<AnnotatedRegion> listChildren(AnnotatedRegion r, StrandedGeno
return children;
}

public static Integer countPaths(AnnotatedRegion r, StrandedGenomicIntervalTree<Map<String, Object>> exon_3p, StrandedGenomicIntervalTree<Map<String, Object>> sj5p){
public static BigInteger countPaths(AnnotatedRegion r, StrandedGenomicIntervalTree<Map<String, Object>> exon_3p, StrandedGenomicIntervalTree<Map<String, Object>> sj5p){
String path_att = "nPaths";

Integer nPaths = (Integer) r.getAttribute(path_att);
BigInteger nPaths = (BigInteger) r.getAttribute(path_att);

if(nPaths==null){
List<AnnotatedRegion> children = listChildren(r, exon_3p, sj5p);

if(children.size()==0){
nPaths=1;
nPaths=new BigInteger("1");
}
else{
nPaths = 0;
nPaths = new BigInteger("0");
for(AnnotatedRegion c : children){
nPaths += countPaths(c, exon_3p, sj5p);
nPaths = nPaths.add(countPaths(c, exon_3p, sj5p));
// nPaths += countPaths(c, exon_3p, sj5p);
}
}

Expand Down Expand Up @@ -420,7 +422,7 @@ public static void countSpliceIsoforms(File assembly_gtf) throws FileNotFoundExc
}

for(AnnotatedRegion r : exon_5p){
int n = countPaths(r,exon_3p,sj5p);
int n = countPaths(r,exon_3p,sj5p).intValue();
System.out.printf("e5p %s %d\n", r,n);
}
}
Expand Down

0 comments on commit 81e46a5

Please sign in to comment.