lonelyjoeparker / qmul-genome-convergence-pipeline

API and binaries for phylogenomic analyses, particularly comparison of input trees/alignments (CONTEXT) and detecting genomic convergence
4 stars 2 forks source link

ResultsPrinterSimsCDF - java.lang.IllegalArgumentException arising from format call BigDecimal - uk.ac.qmul.sbcs.evolution.sandbox.ResultsPrinterSimsCDF.go2(ResultsPrinterSimsCDF.java:654) #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Analysis is failing midway through serfile parsing for simulated sites:

java -jar /usr/local/apps/convergence_pipeline_alphas/ResultsPrinterSimsCDF.jar 
./g_100_ENSG00000100220_ng.fas/ 0 117 16 116
reading .ser files:
.0
..........10
..........20
..........30
...Analyse simulated ∆SSLS
o0
oooooooooo10
oooooooooo20
oooooooooo30
ooENSG00000100220   http://www.ensembl.org/Homo_sapiens/Gene/Summary?g=ENSG0000010
0220    C22orf28    chromosome 22 open reading frame 28 [Source:HGNC 
Symbol;Acc:26935]   0.16463 wag 100 -1477.086   0.1489  0.002   22  381 1160.90026293901
45841   -0.017596030862362836   0.9094031543662853  
    tH0-H1...   
java.lang.IllegalArgumentException: Digits < 0
    at java.math.MathContext.<init>(MathContext.java:158)
    at java.math.MathContext.<init>(MathContext.java:141)
    at java.util.Formatter$FormatSpecifier.print(Formatter.java:3559)
    at java.util.Formatter$FormatSpecifier.print(Formatter.java:3484)
    at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2736)
    at java.util.Formatter$FormatSpecifier.print(Formatter.java:2683)
    at java.util.Formatter.format(Formatter.java:2449)
    at java.util.Formatter.format(Formatter.java:2383)
    at java.lang.String.format(String.java:2781)
    at uk.ac.qmul.sbcs.evolution.sandbox.ResultsPrinterSimsCDF.go2(ResultsPrinterSimsCDF.java:654)
    at uk.ac.qmul.sbcs.evolution.sandbox.ResultsPrinterSimsCDF.main(ResultsPrinterSimsCDF.java:119)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)

Relevant call is a String.format(BigDecimal) call which formats the calculated 
∆SSLS for stdout.

Some googling suggests this may be to do with BigDecimal's precision:
https://www.google.co.uk/search?q=string.format+java.lang.illegalargumentexcepti
on+digits+0&oq=string.format&aqs=chrome.0.69i59j69i57j5j0l3.3188j0j7&sourceid=ch
rome&espv=210&es_sm=91&ie=UTF-8

Issue affects ~ 70 / 2300 test loci.

Original issue reported on code.google.com by joeparke...@gmail.com on 6 Mar 2014 at 9:15

Attachments:

GoogleCodeExporter commented 9 years ago
This has been patched with r206 to ResultsPrinterSimsCDFMetadata and r207 to 
ResultsPrinterSimsCDF, where:

BigDecimal avgOfSummedDiffs = diffsSummed[t].divide(new 
BigDecimal(nSites),RoundingMode.HALF_EVEN);
String AOSD = String.format("%.16f",avgOfSummedDiff);

Is now explicitly cast to double:

BigDecimal avgOfSummedDiffs = diffsSummed[t].divide(new 
BigDecimal(nSites),RoundingMode.HALF_EVEN);
String AOSD = String.format("%.16f",avgOfSummedDiffs.doubleValue());

** NOT TESTED YET **                                    

Original comment by joeparke...@gmail.com on 7 Mar 2014 at 1:04