Merge branch 'alpha/JAL-3362_Jalview_212_alpha' into alpha/merge_212_JalviewJS_2112
[jalview.git] / src / jalview / analysis / SeqsetUtils.java
index fdca89d..61fc747 100755 (executable)
@@ -20,6 +20,8 @@
  */
 package jalview.analysis;
 
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.HiddenMarkovModel;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceFeature;
@@ -35,7 +37,7 @@ public class SeqsetUtils
 
   /**
    * Store essential properties of a sequence in a hashtable for later recovery
-   * Keys are Name, Start, End, SeqFeatures, PdbId
+   * Keys are Name, Start, End, SeqFeatures, PdbId, HMM
    * 
    * @param seq
    *          SequenceI
@@ -52,7 +54,7 @@ public class SeqsetUtils
       sqinfo.put("Description", seq.getDescription());
     }
 
-    Vector<SequenceFeature> sfeat = new Vector<SequenceFeature>();
+    Vector<SequenceFeature> sfeat = new Vector<>();
     List<SequenceFeature> sfs = seq.getFeatures().getAllFeatures();
     sfeat.addAll(sfs);
 
@@ -69,6 +71,16 @@ public class SeqsetUtils
               (seq.getDatasetSequence() != null) ? seq.getDatasetSequence()
                       : new Sequence("THISISAPLACEHOLDER", ""));
     }
+    if (seq.hasHMMProfile())
+    {
+      sqinfo.put("HMM", seq.getHMM());
+    }
+
+    if (seq.getAnnotation("Search Scores") != null)
+    {
+      sqinfo.put("Score", seq.getAnnotation("Search Scores"));
+    }
+
     return sqinfo;
   }
 
@@ -97,6 +109,10 @@ public class SeqsetUtils
     Vector<PDBEntry> pdbid = (Vector<PDBEntry>) sqinfo.get("PdbId");
     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;
@@ -135,6 +151,18 @@ public class SeqsetUtils
       sq.setDatasetSequence(seqds);
     }
 
+    if (hmm != null)
+    {
+      sq.setHMM(new HiddenMarkovModel(hmm, sq));
+    }
+
+    if (scores != null)
+    {
+      for (AlignmentAnnotation score : scores)
+      {
+        sq.addAlignmentAnnotation(score);
+      }
+    }
     return namePresent;
   }