JAL-3854 patched SeqSeqUtils.deUniquify to not use instanceOf - seems to work
[jalview.git] / src / jalview / analysis / SeqsetUtils.java
index 921ab2a..4118124 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.analysis;
 
+import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.HiddenMarkovModel;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.Sequence;
@@ -46,8 +47,8 @@ public class SeqsetUtils
   {
     Hashtable sqinfo = new Hashtable();
     sqinfo.put("Name", seq.getName());
-    sqinfo.put("Start", new Integer(seq.getStart()));
-    sqinfo.put("End", new Integer(seq.getEnd()));
+    sqinfo.put("Start", Integer.valueOf(seq.getStart()));
+    sqinfo.put("End", Integer.valueOf(seq.getEnd()));
     if (seq.getDescription() != null)
     {
       sqinfo.put("Description", seq.getDescription());
@@ -74,6 +75,12 @@ public class SeqsetUtils
     {
       sqinfo.put("HMM", seq.getHMM());
     }
+
+    if (seq.getAnnotation("Search Scores") != null)
+    {
+      sqinfo.put("Score", seq.getAnnotation("Search Scores"));
+    }
+
     return sqinfo;
   }
 
@@ -103,6 +110,9 @@ public class SeqsetUtils
     String description = (String) sqinfo.get("Description");
     Sequence seqds = (Sequence) sqinfo.get("datasetSequence");
     HiddenMarkovModel hmm = (HiddenMarkovModel) sqinfo.get("HMM");
+    AlignmentAnnotation[] scores = (AlignmentAnnotation[]) sqinfo
+            .get("Score");
+
     if (oldname == null)
     {
       namePresent = false;
@@ -145,6 +155,14 @@ public class SeqsetUtils
     {
       sq.setHMM(new HiddenMarkovModel(hmm, sq));
     }
+
+    if (scores != null)
+    {
+      for (AlignmentAnnotation score : scores)
+      {
+        sq.addAlignmentAnnotation(score);
+      }
+    }
     return namePresent;
   }
 
@@ -242,8 +260,7 @@ public class SeqsetUtils
     while (keys.hasMoreElements())
     {
       Object key = keys.nextElement();
-      if (key instanceof String)
-      {
+      try {
         if ((msq = matcher.findIdMatch((String) key)) != null)
         {
           Hashtable sqinfo = (Hashtable) map.get(key);
@@ -258,6 +275,11 @@ public class SeqsetUtils
                     + "' in uniquified alignment");
           }
         }
+      } catch (ClassCastException ccastex) {
+        if (!quiet)
+        {
+          System.err.println("Unexpected object in SeqSet map : "+key.getClass());
+        }
       }
     }
     if (unmatched.size() > 0 && !quiet)