--- /dev/null
+package jalview.schemes;
+
+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.List;
+import java.util.Map;
+
+public class HMMERAlignmentColourScheme extends ResidueColourScheme
+{
+
+ AnnotatedCollectionI alignment;
+
+ HiddenMarkovModel hmm;
+
+ boolean peptideSpecific;
+
+ boolean nucleotideSpecific;
+
+ public HMMERAlignmentColourScheme(HiddenMarkovModel markov)
+ {
+ hmm = markov;
+ }
+
+ public HMMERAlignmentColourScheme()
+ {
+
+ }
+
+ @Override
+ public Color findColour(char symbol, int position, SequenceI seq,
+ String consensusResidue, float pid)
+ {
+ if (hmm == null)
+ {
+ return Color.white;
+ }
+ return findColour(symbol, position);
+ }
+
+ /**
+ * Returns the colour at a particular symbol at a column in the alignment.
+ *
+ * @param symbol
+ * @param position
+ * @return Red for an insertion, white for a gap, orange for a negative
+ * information content, white to blue for increasing information
+ * content.
+ */
+ private Color findColour(char symbol, int position)
+ {
+
+ if (Comparison.isGap(symbol))
+ {
+ return Color.white;
+ }
+ if (Character.isLowerCase(symbol))
+ {
+ symbol = Character.toUpperCase(symbol);
+ }
+ Double prob;
+ prob = hmm.getMatchEmissionProbability(position, symbol);
+ double freq = 0;
+ String alpha = hmm.getAlphabetType();
+ if (!ResidueProperties.backgroundFrequencies.get(alpha)
+ .containsKey(symbol))
+ {
+ return Color.white;
+ }
+ else
+ {
+ freq = ResidueProperties.backgroundFrequencies.get(alpha).get(symbol);
+ }
+ if (prob == 0)
+ {
+ return new Color(230, 0, 0);
+ }
+ Double value = Math.log(prob / freq);
+ Color colour = null;
+ if (value > 0)
+ {
+
+ colour = ColorUtils.getGraduatedColour(value.floatValue(), 0,
+ Color.WHITE, 4.52f, Color.blue);
+ }
+ else if (value < 0)
+ {
+ return Color.ORANGE;
+
+ }
+ return colour;
+
+ }
+
+ @Override
+ public void alignmentChanged(AnnotatedCollectionI collection,
+ Map<SequenceI, SequenceCollectionI> hiddenReps)
+ {
+ List<SequenceI> seqs = collection.getSequences();
+ for (SequenceI seq : seqs)
+ {
+ if (seq.isHMMConsensusSequence())
+ {
+ hmm = seq.getHMM();
+ break;
+ }
+ }
+
+ }
+
+ @Override
+ public ColourSchemeI getInstance(AnnotatedCollectionI sg,
+ Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+ {
+ HiddenMarkovModel markov = null;
+ List<SequenceI> seqs = sg.getSequences();
+ for (SequenceI seq : seqs)
+ {
+ if (seq.getHMM() != null)
+ {
+ markov = seq.getHMM();
+ break;
+ }
+ }
+ HMMERColourScheme colour = new HMMERColourScheme(markov);
+ return colour;
+
+ }
+
+ @Override
+ public boolean isApplicableTo(AnnotatedCollectionI ac)
+ {
+ return true;
+
+ }
+
+ @Override
+ public String getSchemeName()
+ {
+
+ return JalviewColourScheme.HMMERA.name();
+ }
+
+ @Override
+ public boolean isSimple()
+ {
+ return false;
+ }
+
+}
+
PurinePyrimidine("Purine/Pyrimidine", PurinePyrimidineColourScheme.class),
RNAHelices("RNA Helices", RNAHelicesColour.class),
TCoffee("T-Coffee Scores", TCoffeeColourScheme.class),
- HMMER("HMMER", HMMERColourScheme.class);
+ HMMERU("HMMER-Uniprot", HMMERColourScheme.class),
+ HMMERA("HMMER-Alignment", HMMERAlignmentColourScheme.class);
// RNAInteraction("RNA Interaction type", RNAInteractionColourScheme.class)
private String name;