From: jprocter Date: Fri, 4 May 2012 15:35:08 +0000 (+0100) Subject: JAL-1066 JAL-968 common interface for objects that can be associated with alignment... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b65e8427808280faf920f306f7f0e5a71a9ff6bf;p=jalview.git JAL-1066 JAL-968 common interface for objects that can be associated with alignment annotation --- diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 707eee8..8080fb4 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -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() { diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index be1bff7..714cf45 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -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 index 0000000..d7a0339 --- /dev/null +++ b/src/jalview/datamodel/AnnotatedCollectionI.java @@ -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(); + +} diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 01bf677..94e359a 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -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 annot = new ArrayList(); + for (SequenceI seq:(Vector)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]); + } }