From: tcofoegbu Date: Thu, 1 Oct 2015 14:53:10 +0000 (+0100) Subject: JAL-1912 Double.NaN breaks JSON serialization - added check to prevent this X-Git-Tag: Release_2_10_0~365^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bc85369667c2665d81631e96f0701038f04f9bb3;p=jalview.git JAL-1912 Double.NaN breaks JSON serialization - added check to prevent this --- diff --git a/src/jalview/datamodel/AlignmentAnnotation.java b/src/jalview/datamodel/AlignmentAnnotation.java index bb45b67..9c3af27 100755 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@ -959,12 +959,8 @@ public class AlignmentAnnotation public void adjustForAlignment() { - if (sequenceRef == null) - { - return; - } - - if (annotations == null) + if (sequenceRef == null || sequenceMapping == null + || annotations == null) { return; } diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index 4e293db..7e7052f 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -374,7 +374,10 @@ public class JSONFile extends AlignFile implements ComplexAlignFile AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo(); alignAnnotPojo.setDescription(annot.description); alignAnnotPojo.setLabel(annot.label); - alignAnnotPojo.setScore(annot.score); + if (!Double.isNaN(annot.score)) + { + alignAnnotPojo.setScore(annot.score); + } alignAnnotPojo.setCalcId(annot.getCalcId()); alignAnnotPojo.setGraphType(annot.graph); @@ -528,11 +531,6 @@ public class JSONFile extends AlignFile implements ComplexAlignFile .hasNext();) { JSONObject alAnnot = alAnnotIter.next(); - if (alAnnot == null) - { - continue; - } - JSONArray annotJsonArray = (JSONArray) alAnnot.get("annotations"); Annotation[] annotations = new Annotation[annotJsonArray.size()]; int count = 0; diff --git a/src/jalview/json/binding/biojson/v1/AlignmentAnnotationPojo.java b/src/jalview/json/binding/biojson/v1/AlignmentAnnotationPojo.java index 9ac3957..7e729f9 100644 --- a/src/jalview/json/binding/biojson/v1/AlignmentAnnotationPojo.java +++ b/src/jalview/json/binding/biojson/v1/AlignmentAnnotationPojo.java @@ -60,6 +60,7 @@ public class AlignmentAnnotationPojo @Attributes(required = false, description = "Score of the annotation") private double score; + @Attributes(required = false, description = "Annotation generation source") private String calcId; public String getLabel()