1 package jalview.schemes;
3 import jalview.analysis.SequenceIdMatcher;
4 import jalview.datamodel.AlignmentAnnotation;
5 import jalview.datamodel.AlignmentI;
6 import jalview.datamodel.AnnotatedCollectionI;
7 import jalview.datamodel.Annotation;
8 import jalview.datamodel.SequenceCollectionI;
9 import jalview.datamodel.SequenceI;
10 import jalview.io.TCoffeeScoreFile;
12 import java.awt.Color;
13 import java.util.ArrayList;
14 import java.util.IdentityHashMap;
16 import java.util.TreeMap;
19 * Defines the color score for T-Coffee MSA
21 * See http://tcoffee.org
24 * @author Paolo Di Tommaso
27 public class TCoffeeColourScheme extends ResidueColourScheme
30 static final Color[] colors =
31 { new Color(102, 102, 255), // #6666FF
32 new Color(0, 255, 0), // #00FF00
33 new Color(102, 255, 0), // #66FF00
34 new Color(204, 255, 0), // #CCFF00
35 new Color(255, 255, 0), // #FFFF00
36 new Color(255, 204, 0), // #FFCC00
37 new Color(255, 153, 0), // #FF9900
38 new Color(255, 102, 0), // #FF6600
39 new Color(255, 51, 0), // #FF3300
40 new Color(255, 34, 0) // #FF2000
43 IdentityHashMap<SequenceI, Color[]> seqMap;
46 * the color scheme needs to look at the alignment to get and cache T-COFFEE
50 * - annotated sequences to be searched
52 public TCoffeeColourScheme(AnnotatedCollectionI alignment)
54 alignmentChanged(alignment, null);
58 public void alignmentChanged(AnnotatedCollectionI alignment,
59 Map<SequenceI, SequenceCollectionI> hiddenReps)
61 // TODO: if sequences have been represented and they have scores, could
62 // compute an average sequence score for the representative
64 // assume only one set of TCOFFEE scores - but could have more than one
66 ArrayList<AlignmentAnnotation> annots = new ArrayList<AlignmentAnnotation>();
67 // Search alignment to get all tcoffee annotation and pick one set of
68 // annotation to use to colour seqs.
69 seqMap = new IdentityHashMap<SequenceI, Color[]>();
71 for (AlignmentAnnotation al : alignment
72 .findAnnotation(TCoffeeScoreFile.TCOFFEE_SCORE))
74 if (al.sequenceRef != null && !al.belowAlignment)
77 if (w < al.annotations.length)
79 w = al.annotations.length;
81 Color[] scores = new Color[al.annotations.length];
83 for (Annotation an : al.annotations)
85 scores[i++] = (an != null) ? an.colour : Color.white;
87 seqMap.put(al.sequenceRef, scores);
90 // TODO: compute average colour for each symbol type in each column - gives
91 // a second order colourscheme for colouring a sequence logo derived from
92 // the alignment (colour reflects quality of alignment for each residue
97 public Color findColour(char c, int j, SequenceI seq)
101 if (seqMap == null || (cols = seqMap.get(seq)) == null)
103 // see above TODO about computing a colour for each residue in each
104 // column: cc = _rcols[i][indexFor[c]];
108 if (j < 0 || j >= cols.length)