package jalview.schemes; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.HiddenMarkovModel; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; import jalview.util.ColorUtils; import jalview.util.Comparison; import java.awt.Color; import java.util.Map; public class HMMERColourScheme extends ResidueColourScheme { AnnotatedCollectionI alignment; HiddenMarkovModel hmm; boolean peptideSpecific; boolean nucleotideSpecific; public HMMERColourScheme(HiddenMarkovModel markov) { hmm = markov; } public HMMERColourScheme() { } @Override public Color findColour(char symbol, int position, SequenceI seq, String consensusResidue, float pid) { if (hmm ==null) { return Color.white; } return findColour(symbol, position); } public Color findColour(char symbol, int position) { if (Comparison.isGap(symbol)) { return Color.white; } Double prob; prob = hmm.getMatchEmissionProbability(position, symbol); double freq = ResidueProperties.aminoBackgroundFrequencies.get(symbol); Double value = prob - freq; Color colour = null; if (value >= 0) { colour = ColorUtils.getGraduatedColour(value.floatValue(), 0, Color.WHITE, 1f, Color.green); } else if (value < 0) { return Color.YELLOW; } return colour; } @Override public void alignmentChanged(AnnotatedCollectionI collection, Map hiddenReps) { AlignmentAnnotation[] annArr = collection.getAlignmentAnnotation(); for (AlignmentAnnotation ann : annArr) { if (ann.label.indexOf("Information Content") > -1) { hmm = ann.getHMM(); } } } @Override public ColourSchemeI getInstance(AnnotatedCollectionI sg, Map hiddenRepSequences) { HiddenMarkovModel markov = null; AlignmentAnnotation[] annArr = sg.getAlignmentAnnotation(); for (AlignmentAnnotation ann : annArr) { if (ann.label.indexOf("Information Content") > -1) { markov = ann.getHMM(); } } HMMERColourScheme colour = new HMMERColourScheme(markov); return colour; } @Override public boolean isApplicableTo(AnnotatedCollectionI ac) { return true; } @Override public String getSchemeName() { return JalviewColourScheme.HMMER.name(); } @Override public boolean isSimple() { // TODO Auto-generated method stub return false; } }