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.SequenceI;
9 import jalview.io.TCoffeeScoreFile;
11 import java.awt.Color;
12 import java.util.ArrayList;
13 import java.util.IdentityHashMap;
14 import java.util.TreeMap;
17 * Defines the color score for T-Coffee MSA
19 * See http://tcoffee.org
22 * @author Paolo Di Tommaso
25 public class TCoffeeColourScheme extends ResidueColourScheme {
27 static final Color[] colors = {
28 new Color( 102, 102, 255 ), // #6666FF
29 new Color( 0, 255, 0), // #00FF00
30 new Color( 102, 255, 0), // #66FF00
31 new Color( 204, 255, 0), // #CCFF00
32 new Color( 255, 255, 0), // #FFFF00
33 new Color( 255, 204, 0), // #FFCC00
34 new Color( 255, 153, 0), // #FF9900
35 new Color( 255, 102, 0), // #FF6600
36 new Color( 255, 51, 0), // #FF3300
37 new Color( 255, 34, 0) // #FF2000
41 IdentityHashMap<SequenceI, Color[]> seqMap;
43 * the color scheme needs to look at the alignment to get and cache T-COFFEE scores
45 * @param alignment - annotated sequences to be searched
47 public TCoffeeColourScheme(AnnotatedCollectionI alignment) {
48 alignmentChanged(alignment);
50 @Override public void alignmentChanged(AnnotatedCollectionI alignment)
52 // assume only one set of TCOFFEE scores - but could have more than one potentially.
53 ArrayList<AlignmentAnnotation> annots = new ArrayList<AlignmentAnnotation>();
54 // Search alignment to get all tcoffee annotation and pick one set of annotation to use to colour seqs.
55 seqMap = new IdentityHashMap<SequenceI, Color[]>();
56 for (AlignmentAnnotation al:alignment.getAlignmentAnnotation())
58 if (al.sequenceRef!=null && !al.belowAlignment && al.label!=null && (al.label==TCoffeeScoreFile.TCOFFEE_SCORE || al.label.equals(TCoffeeScoreFile.TCOFFEE_SCORE)))
61 Color[] scores=new Color[al.annotations.length];
63 for (Annotation an:al.annotations)
65 scores[i++]=(an!=null) ? an.colour : Color.white;
67 seqMap.put(al.sequenceRef, scores);
72 public Color findColour(char c, int j, SequenceI seq) {
75 if( seqMap==null || (cols=seqMap.get(seq))==null) {
79 if( j < 0 || j>= cols.length ) {