1 package jalview.schemes;
3 import jalview.datamodel.AnnotatedCollectionI;
4 import jalview.datamodel.ResidueCount;
5 import jalview.datamodel.SequenceCollectionI;
6 import jalview.datamodel.SequenceI;
8 import java.util.HashMap;
13 * An HMM colour scheme that uses local (alignment or sub-group) background
14 * frequencies for residues
18 public class HmmerLocalBackground extends HmmerColourScheme
23 * Constructor given a sequence collection
27 public HmmerLocalBackground(AnnotatedCollectionI ac)
29 super(ac.getHmmSequences());
34 * Default constructor (required by ColourSchemes.loadColourSchemes)
36 public HmmerLocalBackground()
41 public String getSchemeName()
43 return JalviewColourScheme.HMMERA.toString();
47 * Counts and stores the relative frequency of every residue in the alignment
48 * (apart from any HMM consensus sequences)
52 public void countFrequencies(SequenceCollectionI sc)
54 // TODO or total counts in Consensus Profile (how do we get at it?)?
55 Map<Character, Float> freqs = new HashMap<>();
58 * count symbols, excluding any HMM consensus sequences
60 ResidueCount counts = new ResidueCount();
61 List<SequenceI> seqs = sc.getSequences();
62 for (SequenceI seq : seqs)
64 if (!seq.hasHMMProfile())
66 for (char c : seq.getSequence())
72 int total = counts.getTotalResidueCount(); // excludes gaps
74 for (char symbol : counts.getSymbolCounts().symbols)
76 double freq = counts.getCount(symbol) / (double) total;
77 freqs.put(symbol, (float) freq);
80 setFrequencies(freqs);
82 logTotalCount = (float) Math.log(total);
86 float getMaxInformationScore()
92 protected HmmerColourScheme newInstance(AnnotatedCollectionI ac)
94 return new HmmerLocalBackground(ac);