From: jprocter Date: Tue, 28 Aug 2012 13:46:56 +0000 (+0100) Subject: JAL-1066 - per-sequence colouring with sequence associated alignment annotation X-Git-Tag: Jalview_2_9~384 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7dd551e9777c347dd483519522791d5cbb93576e;p=jalview.git JAL-1066 - per-sequence colouring with sequence associated alignment annotation --- diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 6c46d0e..78e850b 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -18,10 +18,14 @@ package jalview.schemes; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.GraphLine; +import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; import java.awt.Color; +import java.util.IdentityHashMap; +import java.util.Map; public class AnnotationColourGradient extends ResidueColourScheme { @@ -45,6 +49,10 @@ public class AnnotationColourGradient extends ResidueColourScheme public boolean predefinedColours = false; + public boolean seqAssociated = false; + + IdentityHashMap seqannot = null; + /** * Creates a new AnnotationColourGradient object. */ @@ -94,6 +102,33 @@ public class AnnotationColourGradient extends ResidueColourScheme bb = maxColour.getBlue() - b1; } + @Override + public void alignmentChanged(AnnotatedCollectionI alignment, + Map hiddenReps) + { + // TODO Auto-generated method stub + super.alignmentChanged(alignment, hiddenReps); + + if (seqAssociated && annotation.getCalcId() != null) + { + if (seqannot!=null) { + seqannot.clear(); + } else { + seqannot=new IdentityHashMap(); + } + for (AlignmentAnnotation alan : alignment.findAnnotation(annotation + .getCalcId())) + { + if (alan.sequenceRef != null + && (alan.label != null && annotation != null && alan.label + .equals(annotation.label))) + { + seqannot.put(alan.sequenceRef, alan); + } + } + } + } + public String getAnnotation() { return annotation.label; @@ -158,7 +193,11 @@ public class AnnotationColourGradient extends ResidueColourScheme public Color findColour(char c, int j, SequenceI seq) { Color currentColour = Color.white; - + AlignmentAnnotation annotation=(seqAssociated ? seqannot.get(seq):this.annotation); + if (annotation==null) + { + return currentColour; + } if ((threshold == 0) || aboveThreshold(c, j)) { if (j < annotation.annotations.length @@ -226,4 +265,14 @@ public class AnnotationColourGradient extends ResidueColourScheme return currentColour; } + + public boolean isSeqAssociated() + { + return seqAssociated; + } + + public void setSeqAssociated(boolean sassoc) + { + seqAssociated = sassoc; + } }