JAL-1066 JAL-968 common interface for objects that can be associated with alignment...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 4 May 2012 15:35:08 +0000 (16:35 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 4 May 2012 15:37:59 +0000 (16:37 +0100)
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AlignmentI.java
src/jalview/datamodel/AnnotatedCollectionI.java [new file with mode: 0644]
src/jalview/datamodel/SequenceGroup.java

index 707eee8..8080fb4 100755 (executable)
@@ -799,10 +799,9 @@ public class Alignment implements AlignmentI
     annotations = temp;
   }
 
+  @Override
   /**
-   * DOCUMENT ME!
-   * 
-   * @return DOCUMENT ME!
+   * returns all annotation on the alignment
    */
   public AlignmentAnnotation[] getAlignmentAnnotation()
   {
index be1bff7..714cf45 100755 (executable)
@@ -22,7 +22,7 @@ import java.util.*;
 /**
  * Data structure to hold and manipulate a multiple sequence alignment
  */
-public interface AlignmentI
+public interface AlignmentI extends AnnotatedCollectionI
 {
   /**
    * Calculates the number of sequences in an alignment
diff --git a/src/jalview/datamodel/AnnotatedCollectionI.java b/src/jalview/datamodel/AnnotatedCollectionI.java
new file mode 100644 (file)
index 0000000..d7a0339
--- /dev/null
@@ -0,0 +1,14 @@
+package jalview.datamodel;
+
+import java.util.List;
+
+public interface AnnotatedCollectionI
+{
+
+  /**
+   * TODO: decide if null is a valid response if there is no annotation on the object
+   * @return null
+   */
+  AlignmentAnnotation[] getAlignmentAnnotation();
+
+}
index 01bf677..94e359a 100755 (executable)
@@ -30,7 +30,7 @@ import jalview.schemes.*;
  * @author $author$
  * @version $Revision$
  */
-public class SequenceGroup
+public class SequenceGroup implements AnnotatedCollectionI
 {
   String groupName;
 
@@ -1167,4 +1167,33 @@ public class SequenceGroup
   {
     return showConsensusHistogram;
   }
+
+  @Override
+  /**
+   * returns a new array with all annotation involving this group
+   */
+  public AlignmentAnnotation[] getAlignmentAnnotation()
+  {
+    // TODO add in other methods like 'getAlignmentAnnotation(String label), etc'
+    ArrayList<AlignmentAnnotation> annot = new ArrayList<AlignmentAnnotation>();
+    for (SequenceI seq:(Vector<SequenceI>)sequences)
+    {
+      for (AlignmentAnnotation al: seq.getAnnotation())
+      {
+        if (al.groupRef==this)
+        {
+          annot.add(al);
+        }
+      }
+    }
+    if (consensus!=null)
+    {
+      annot.add(consensus);
+    }
+    if (conservation!=null)
+    {
+      annot.add(conservation);
+    }
+    return annot.toArray(new AlignmentAnnotation[0]);
+  }
 }