for (char symbol : hmm.getSymbols())
{
float freq = 0f;
- if ("amino".equals(hmm.getAlphabetType()))
- {
- freq = ResidueProperties.aminoBackgroundFrequencies.get(symbol);
- }
- if ("DNA".equals(hmm.getAlphabetType()))
- {
- freq = ResidueProperties.dnaBackgroundFrequencies.get(symbol);
- }
- if ("RNA".equals(hmm.getAlphabetType()))
- {
- freq = ResidueProperties.rnaBackgroundFrequencies.get(symbol);
- }
+ freq = ResidueProperties.backgroundFrequencies
+ .get(hmm.getAlphabetType()).get(symbol);
Double hmmProb = hmm.getMatchEmissionProbability(column, symbol);
float prob = hmmProb.floatValue();
informationContent += prob * (Math.log(prob / freq) / Math.log(2));
value = hmm.getMatchEmissionProbability(column, symbol);
double freq;
- if (AMINO.equals(alph) && removeBelowBackground)
+ freq = ResidueProperties.backgroundFrequencies.get(alph).get(symbol);
+ if (value < freq && removeBelowBackground)
{
- freq = ResidueProperties.aminoBackgroundFrequencies.get(symbol);
- if (value < freq)
- {
- value = 0d;
- }
- }
- else if (DNA.equals(alph) && removeBelowBackground)
- {
- freq = ResidueProperties.dnaBackgroundFrequencies.get(symbol);
- if (value < freq)
- {
- value = 0d;
- }
- }
- else if (RNA.equals(alph) && removeBelowBackground)
- {
- freq = ResidueProperties.rnaBackgroundFrequencies.get(symbol);
- if (value < freq)
- {
- value = 0d;
- }
+ return 0;
}
+
value = value * 10000;
return Math.round(value.floatValue());
}
Double prob;
prob = hmm.getMatchEmissionProbability(position, symbol);
double freq = 0;
- if ("amino".equals(hmm.getAlphabetType()))
+ String alpha = hmm.getAlphabetType();
+ if (!ResidueProperties.backgroundFrequencies.get(alpha).containsKey(symbol))
{
- if (!ResidueProperties.aminoBackgroundFrequencies.containsKey(symbol))
- {
- return Color.white;
- }
- freq = ResidueProperties.aminoBackgroundFrequencies.get(symbol);
- }
- else if ("DNA".equals(hmm.getAlphabetType()))
- {
- if (!ResidueProperties.dnaBackgroundFrequencies.containsKey(symbol))
- {
- return Color.white;
- }
- freq = ResidueProperties.dnaBackgroundFrequencies.get(symbol);
+ return Color.white;
}
- else if ("RNA".equals(hmm.getAlphabetType()))
+ else
{
- if (!ResidueProperties.rnaBackgroundFrequencies.containsKey(symbol))
- {
- return Color.white;
- }
- freq = ResidueProperties.rnaBackgroundFrequencies.get(symbol);
+ freq = ResidueProperties.backgroundFrequencies.get(alpha).get(symbol);
}
if (prob == 0)
{
return new Color(230, 0, 0);
}
- Double value = Math.log(prob / freq);
+ Double value = Math.log(prob / freq) / Math.log(2);
Color colour = null;
if (value > 0)
{
colour = ColorUtils.getGraduatedColour(value.floatValue(), 0,
- Color.WHITE, 4.52f, Color.blue);
+ Color.WHITE, 6.52f, Color.blue);
}
else if (value < 0)
{
// lookup from modified amino acid (e.g. MSE) to canonical form (e.g. MET)
public static final Map<String, String> modifications = new HashMap<>();
- // amino acid background Frequencies
- public static final Map<Character, Float> aminoBackgroundFrequencies = new HashMap<>();
-
- // dna background Frequencies
- public static final Map<Character, Float> dnaBackgroundFrequencies = new HashMap<>();
-
- // rna background Frequencies
- public static final Map<Character, Float> rnaBackgroundFrequencies = new HashMap<>();
+ // residue background frequencies across different alphabets
+ public static final Map<String, Map<Character, Float>> backgroundFrequencies = new HashMap<>();
static
{
static
{
- aminoBackgroundFrequencies.put('A', 0.0826f);
- aminoBackgroundFrequencies.put('Q', 0.0393f);
- aminoBackgroundFrequencies.put('L', 0.0965f);
- aminoBackgroundFrequencies.put('S', 0.0661f);
- aminoBackgroundFrequencies.put('R', 0.0553f);
- aminoBackgroundFrequencies.put('E', 0.0674f);
- aminoBackgroundFrequencies.put('K', 0.0582f);
- aminoBackgroundFrequencies.put('T', 0.0535f);
- aminoBackgroundFrequencies.put('N', 0.0406f);
- aminoBackgroundFrequencies.put('G', 0.0708f);
- aminoBackgroundFrequencies.put('M', 0.0241f);
- aminoBackgroundFrequencies.put('W', 0.0109f);
- aminoBackgroundFrequencies.put('D', 0.0546f);
- aminoBackgroundFrequencies.put('H', 0.0227f);
- aminoBackgroundFrequencies.put('F', 0.0386f);
- aminoBackgroundFrequencies.put('Y', 0.0292f);
- aminoBackgroundFrequencies.put('C', 0.0137f);
- aminoBackgroundFrequencies.put('I', 0.0593f);
- aminoBackgroundFrequencies.put('P', 0.0472f);
- aminoBackgroundFrequencies.put('V', 0.0686f);
+ Map<Character, Float> amino = new HashMap<>();
+ amino.put('A', 0.0826f);
+ amino.put('Q', 0.0393f);
+ amino.put('L', 0.0965f);
+ amino.put('S', 0.0661f);
+ amino.put('R', 0.0553f);
+ amino.put('E', 0.0674f);
+ amino.put('K', 0.0582f);
+ amino.put('T', 0.0535f);
+ amino.put('N', 0.0406f);
+ amino.put('G', 0.0708f);
+ amino.put('M', 0.0241f);
+ amino.put('W', 0.0109f);
+ amino.put('D', 0.0546f);
+ amino.put('H', 0.0227f);
+ amino.put('F', 0.0386f);
+ amino.put('Y', 0.0292f);
+ amino.put('C', 0.0137f);
+ amino.put('I', 0.0593f);
+ amino.put('P', 0.0472f);
+ amino.put('V', 0.0686f);
+ backgroundFrequencies.put("amino", amino);
}
static
{
- dnaBackgroundFrequencies.put('A', 0.25f);
- dnaBackgroundFrequencies.put('C', 0.25f);
- dnaBackgroundFrequencies.put('T', 0.25f);
- dnaBackgroundFrequencies.put('G', 0.25f);
+ Map<Character, Float> dna = new HashMap<>();
+ dna.put('A', 0.25f);
+ dna.put('C', 0.25f);
+ dna.put('T', 0.25f);
+ dna.put('G', 0.25f);
+ backgroundFrequencies.put("DNA", dna);
}
static
{
- rnaBackgroundFrequencies.put('A', 0.25f);
- rnaBackgroundFrequencies.put('C', 0.25f);
- rnaBackgroundFrequencies.put('T', 0.25f);
- rnaBackgroundFrequencies.put('G', 0.25f);
+ Map<Character, Float> rna = new HashMap<>();
+ rna.put('A', 0.25f);
+ rna.put('C', 0.25f);
+ rna.put('T', 0.25f);
+ rna.put('G', 0.25f);
+ backgroundFrequencies.put("RNA", rna);
}