}
else
{
- alignment = viewport.getAlignment();
+ if (viewport != null && alignment == null)
+ {
+ alignment = viewport.getAlignment();
+ }
}
if (alignment != null)
alignment.insertSequenceAt(0, seq);
}
- viewport.alignmentChanged(viewport.getAlignPanel());
- viewport.getAlignPanel().adjustAnnotationHeight();
- viewport.updateSequenceIdColours();
-
- if (viewport.getAlignPanel().alignFrame.getSelectedHMM() == null)
+ if (viewport != null)
{
- viewport.getAlignPanel().alignFrame.setSelectedHMMSequence(seq);
+ viewport.alignmentChanged(viewport.getAlignPanel());
+ viewport.getAlignPanel().adjustAnnotationHeight();
+ viewport.updateSequenceIdColours();
+
+ if (viewport.getAlignPanel().alignFrame.getSelectedHMM() == null)
+ {
+ viewport.getAlignPanel().alignFrame.setSelectedHMMSequence(seq);
+ }
}
hmmTemp.delete();
stoTemp.delete();
import jalview.datamodel.AnnotatedCollectionI;
import jalview.datamodel.HiddenMarkovModel;
+import jalview.datamodel.ResidueCount;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceI;
import jalview.util.ColorUtils;
import jalview.util.Comparison;
import java.awt.Color;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HMMERAlignmentColourScheme extends ResidueColourScheme
{
+ Map<Character, Double> backgroundFrequencies = new HashMap<>();
- AnnotatedCollectionI alignment;
+ Double maxLLR;
HiddenMarkovModel hmm;
}
Double prob;
prob = hmm.getMatchEmissionProbability(position, symbol);
- double freq = 0;
- String alpha = hmm.getAlphabetType();
- if (!ResidueProperties.backgroundFrequencies.get(alpha)
- .containsKey(symbol))
+ Double freq = backgroundFrequencies.get(symbol);
+ if (freq == null)
{
return Color.white;
}
- else
- {
- freq = ResidueProperties.backgroundFrequencies.get(alpha).get(symbol);
- }
if (prob == 0)
{
return new Color(230, 0, 0);
{
colour = ColorUtils.getGraduatedColour(value.floatValue(), 0,
- Color.WHITE, 4.52f, Color.blue);
+ Color.WHITE, maxLLR.floatValue(), Color.blue);
}
else if (value < 0)
{
}
return colour;
-
}
@Override
}
}
+ count(collection);
+
}
@Override
break;
}
}
- HMMERColourScheme colour = new HMMERColourScheme(markov);
+
+ count(sg);
+
+ HMMERAlignmentColourScheme colour = new HMMERAlignmentColourScheme(
+ markov);
return colour;
}
return false;
}
+ public void count(AnnotatedCollectionI sg)
+ {
+ ResidueCount counts = new ResidueCount();
+ for (SequenceI seq : sg.getSequences())
+ {
+ for (int i = 0; i < seq.getLength(); i++)
+ {
+ if (!Comparison.isGap(seq.getCharAt(i)))
+ {
+ counts.add(seq.getCharAt(i));
+ }
+ }
+ }
+
+ int total = counts.getTotalCount();
+
+ for (char symbol : counts.getSymbolCounts().symbols)
+ {
+ double count = Double.valueOf(counts.getCount(symbol))
+ / Double.valueOf(total);
+ backgroundFrequencies.put(symbol, count);
+ }
+ maxLLR = Math.log(total);
+ }
}