JAL-1114 - refactor methods handling Vectors and Hashtables to Lists and Maps, and...
[jalview.git] / src / jalview / datamodel / Alignment.java
index 708e566..23fe057 100755 (executable)
@@ -122,6 +122,13 @@ public class Alignment implements AlignmentI
   {
     return sequences;
   }
+  @Override
+  public List<SequenceI> getSequences(
+          Map<SequenceI, SequenceCollectionI> hiddenReps)
+  {
+    // TODO: in jalview 2.8 we don't do anything with hiddenreps - fix design to work on this.
+    return sequences;
+  }
 
   public SequenceI[] getSequencesArray()
   {
@@ -1219,13 +1226,12 @@ public class Alignment implements AlignmentI
     {
       this.addCodonFrame(acod[a]);
     }
-    Vector sg = toappend.getGroups();
+    List<SequenceGroup> sg = toappend.getGroups();
     if (sg != null)
     {
-      Enumeration el = sg.elements();
-      while (el.hasMoreElements())
+      for (SequenceGroup _sg:sg)
       {
-        addGroup((SequenceGroup) el.nextElement());
+        addGroup(_sg);
       }
     }
     if (toappend.getHiddenSequences() != null)
@@ -1292,4 +1298,47 @@ public class Alignment implements AlignmentI
     }
   }
 
+  @Override
+  public AlignmentAnnotation findOrCreateAnnotation(String name, boolean autoCalc,
+          SequenceI seqRef, SequenceGroup groupRef)
+  {
+    for (AlignmentAnnotation annot : 
+            getAlignmentAnnotation())
+    {
+      if (annot.autoCalculated == autoCalc
+              && annot.getCalcId().equals(name)
+              && annot.sequenceRef == seqRef && annot.groupRef == groupRef)
+      {
+        return annot;
+      }
+    }
+    AlignmentAnnotation annot = new AlignmentAnnotation(name, name,
+            new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH);
+    annot.hasText = false;
+    annot.setCalcId(new String(name));
+    annot.autoCalculated = autoCalc;
+    if (seqRef != null)
+    {
+      annot.setSequenceRef(seqRef);
+    }
+    annot.groupRef = groupRef;
+    addAnnotation(annot);
+
+    return annot;
+  }
+
+  @Override
+  public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
+  {
+    ArrayList<AlignmentAnnotation> aa=new ArrayList<AlignmentAnnotation>();
+    for (AlignmentAnnotation a:getAlignmentAnnotation())
+    {
+      if (a.getCalcId()==calcId || (a.getCalcId()!=null && calcId!=null && a.getCalcId().equals(calcId)))
+      {
+        aa.add(a);
+      }
+    }
+    return aa;
+  }
+
 }