From bc85369667c2665d81631e96f0701038f04f9bb3 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Thu, 1 Oct 2015 15:53:10 +0100 Subject: [PATCH] JAL-1912 Double.NaN breaks JSON serialization - added check to prevent this --- src/jalview/datamodel/AlignmentAnnotation.java | 8 ++------ src/jalview/io/JSONFile.java | 10 ++++------ .../json/binding/biojson/v1/AlignmentAnnotationPojo.java | 1 + 3 files changed, 7 insertions(+), 12 deletions(-) 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() -- 1.7.10.2