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 {
29 static final Color[] colors = {
30 new Color( 102, 102, 255 ), // #6666FF
31 new Color( 0, 255, 0), // #00FF00
32 new Color( 102, 255, 0), // #66FF00
33 new Color( 204, 255, 0), // #CCFF00
34 new Color( 255, 255, 0), // #FFFF00
35 new Color( 255, 204, 0), // #FFCC00
36 new Color( 255, 153, 0), // #FF9900
37 new Color( 255, 102, 0), // #FF6600
38 new Color( 255, 51, 0), // #FF3300
39 new Color( 255, 34, 0) // #FF2000
43 IdentityHashMap<SequenceI, Color[]> seqMap;
45 * the color scheme needs to look at the alignment to get and cache T-COFFEE scores
47 * @param alignment - annotated sequences to be searched
49 public TCoffeeColourScheme(AnnotatedCollectionI alignment) {
50 alignmentChanged(alignment, null);
53 public void alignmentChanged(AnnotatedCollectionI alignment, Map<SequenceI, SequenceCollectionI> hiddenReps)
55 // TODO: if sequences have been represented and they have scores, could compute an average sequence score for the representative
57 // assume only one set of TCOFFEE scores - but could have more than one potentially.
58 ArrayList<AlignmentAnnotation> annots = new ArrayList<AlignmentAnnotation>();
59 // Search alignment to get all tcoffee annotation and pick one set of annotation to use to colour seqs.
60 seqMap = new IdentityHashMap<SequenceI, Color[]>();
62 for (AlignmentAnnotation al:alignment.findAnnotation(TCoffeeScoreFile.TCOFFEE_SCORE))
64 if (al.sequenceRef!=null && !al.belowAlignment)
67 if (w<al.annotations.length)
69 w=al.annotations.length;
71 Color[] scores=new Color[al.annotations.length];
73 for (Annotation an:al.annotations)
75 scores[i++]=(an!=null) ? an.colour : Color.white;
77 seqMap.put(al.sequenceRef, scores);
80 // TODO: compute average colour for each symbol type in each column - gives
81 // a second order colourscheme for colouring a sequence logo derived from
82 // the alignment (colour reflects quality of alignment for each residue
86 public Color findColour(char c, int j, SequenceI seq) {
89 if( seqMap==null || (cols=seqMap.get(seq))==null) {
90 // see above TODO about computing a colour for each residue in each column: cc = _rcols[i][indexFor[c]];
94 if( j < 0 || j>= cols.length ) {