JAL-1912 Double.NaN breaks JSON serialization - added check to prevent this
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Thu, 1 Oct 2015 14:53:10 +0000 (15:53 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Thu, 1 Oct 2015 14:53:10 +0000 (15:53 +0100)
src/jalview/datamodel/AlignmentAnnotation.java
src/jalview/io/JSONFile.java
src/jalview/json/binding/biojson/v1/AlignmentAnnotationPojo.java

index bb45b67..9c3af27 100755 (executable)
@@ -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;
     }
index 4e293db..7e7052f 100644 (file)
@@ -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;
index 9ac3957..7e729f9 100644 (file)
@@ -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()