1 package jalview.schemes;
3 import jalview.datamodel.AlignmentAnnotation;
4 import jalview.datamodel.AnnotatedCollectionI;
5 import jalview.datamodel.HiddenMarkovModel;
6 import jalview.datamodel.SequenceCollectionI;
7 import jalview.datamodel.SequenceI;
8 import jalview.util.ColorUtils;
9 import jalview.util.Comparison;
11 import java.awt.Color;
14 public class HMMERColourScheme extends ResidueColourScheme
17 AnnotatedCollectionI alignment;
19 HiddenMarkovModel hmm;
21 boolean peptideSpecific;
23 boolean nucleotideSpecific;
25 public HMMERColourScheme(HiddenMarkovModel markov)
29 public HMMERColourScheme()
35 public Color findColour(char symbol, int position, SequenceI seq,
36 String consensusResidue, float pid)
42 return findColour(symbol, position);
45 public Color findColour(char symbol, int position)
48 if (Comparison.isGap(symbol))
53 prob = hmm.getMatchEmissionProbability(position, symbol);
55 if ("amino".equals(hmm.getAlphabetType()))
57 if (!ResidueProperties.aminoBackgroundFrequencies.containsKey(symbol))
61 freq = ResidueProperties.aminoBackgroundFrequencies.get(symbol);
63 else if ("DNA".equals(hmm.getAlphabetType()))
65 if (!ResidueProperties.dnaBackgroundFrequencies.containsKey(symbol))
69 freq = ResidueProperties.dnaBackgroundFrequencies.get(symbol);
71 else if ("RNA".equals(hmm.getAlphabetType()))
73 if (!ResidueProperties.rnaBackgroundFrequencies.containsKey(symbol))
77 freq = ResidueProperties.rnaBackgroundFrequencies.get(symbol);
83 Double value = Math.log(prob / freq);
88 colour = ColorUtils.getGraduatedColour(value.floatValue(), 0,
89 Color.WHITE, 3f, Color.blue);
106 public void alignmentChanged(AnnotatedCollectionI collection,
107 Map<SequenceI, SequenceCollectionI> hiddenReps)
109 AlignmentAnnotation[] annArr = collection.getAlignmentAnnotation();
110 for (AlignmentAnnotation ann : annArr)
112 if (ann.label.indexOf("Information Content") > -1)
121 public ColourSchemeI getInstance(AnnotatedCollectionI sg,
122 Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
124 HiddenMarkovModel markov = null;
125 AlignmentAnnotation[] annArr = sg.getAlignmentAnnotation();
126 for (AlignmentAnnotation ann : annArr)
128 if (ann.label.indexOf("Information Content") > -1)
130 markov = ann.getHMM();
138 HMMERColourScheme colour = new HMMERColourScheme(markov);
144 public boolean isApplicableTo(AnnotatedCollectionI ac)
151 public String getSchemeName()
154 return JalviewColourScheme.HMMER.name();
158 public boolean isSimple()
160 // TODO Auto-generated method stub