label.groups_and_alignment = All groups and alignment
label.groups = All groups
label.selected_group = Selected group
+label.use_info_for_height = Use Information Content as Letter Height
*/
public static ProfilesI calculateHMMProfiles(final HiddenMarkovModel hmm,
int width, int start, int end, boolean saveFullProfile,
- boolean removeBelowBackground)
+ boolean removeBelowBackground, boolean infoLetterHeight)
{
ProfileI[] result = new ProfileI[width];
int symbolCount = hmm.getNumberOfSymbols();
for (char symbol : hmm.getSymbols())
{
int value = getAnalogueCount(hmm, column, symbol,
- removeBelowBackground);
+ removeBelowBackground, infoLetterHeight);
counts.put(symbol, value);
}
int maxCount = counts.getModalCount();
* @param nseq
* number of sequences
*/
- public static void completeInformation(AlignmentAnnotation information,
- ProfilesI profiles, int startCol, int endCol,
- boolean ignoreBelowBackground,
- boolean showSequenceLogo, long nseq)
+ public static float completeInformation(AlignmentAnnotation information,
+ ProfilesI profiles, int startCol, int endCol, long nseq,
+ Float currentMax)
{
// long now = System.currentTimeMillis();
if (information == null || information.annotations == null
* called with a bad alignment annotation row
* wait for it to be initialised properly
*/
- return;
+ return 0;
}
Float max = 0f;
* shorter than alignment width
*/
information.annotations[i] = null;
- return;
+ return 0;
}
HiddenMarkovModel hmm;
.toUpperCase(hmm.getConsensusAtAlignColumn(i))),
description, ' ', value);
}
- information.graphMax = max;
- // long elapsed = System.currentTimeMillis() - now;
- // System.out.println(-elapsed);
+ if (max > currentMax)
+ {
+ information.graphMax = max;
+ return max;
+ }
+ else
+ {
+ information.graphMax = currentMax;
+ return currentMax;
+ }
}
/**
* @return
*/
public static int[] extractHMMProfile(HiddenMarkovModel hmm, int column,
- boolean removeBelowBackground)
+ boolean removeBelowBackground, boolean infoHeight)
{
if (hmm != null)
char symbol = charList.get(i);
symbols[i] = symbol;
int value = getAnalogueCount(hmm, column, symbol,
- removeBelowBackground);
+ removeBelowBackground, infoHeight);
values[i] = value;
totalCount += value;
}
* @return
*/
static int getAnalogueCount(HiddenMarkovModel hmm, int column,
- char symbol, boolean removeBelowBackground)
+ char symbol, boolean removeBelowBackground, boolean infoHeight)
{
Double value;
return 0;
}
+ if (infoHeight)
+ {
+ value = value * (Math.log(value / freq) / Math.log(2));
+ }
+
value = value * 10000;
return Math.round(value.floatValue());
}
*/
void updateInformation(AlignmentViewPanel ap);
+ boolean isInfoLetterHeight();
+
}
private boolean ignoreBelowBackground = true;
+ private boolean infoLetterHeight = false;
+
/**
* consensus calculation property
*/
width = seqsel.width;
ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
ignoreBelowBackground = seqsel.ignoreBelowBackground;
+ infoLetterHeight = seqsel.infoLetterHeight;
if (seqsel.conserve != null)
{
recalcConservation(); // safer than
ProfilesI info = AAFrequency.calculateHMMProfiles(hmm,
(endRes + 1) - startRes, startRes, endRes + 1,
- showHMMSequenceLogo, ignoreBelowBackground);
+ showHMMSequenceLogo, ignoreBelowBackground,
+ infoLetterHeight);
_updateInformationRow(info, sequences.size());
upd = true;
}
// width
information.calcId = "HMM";
AAFrequency.completeInformation(information, cnsns, startRes,
- endRes + 1, ignoreBelowBackground, showSequenceLogo, nseq); // TODO:
+ endRes + 1, nseq, 0f); // TODO:
// setting
// container
// for
public boolean getIgnoreBelowBackground()
{
- return true;
+ return ignoreBelowBackground;
+ }
+
+ public void setInfoLetterHeight(boolean state)
+ {
+ if (this.infoLetterHeight != state)
+ {
+ infoLetterHeight = state;
+ }
+ infoLetterHeight = state;
+ }
+
+ public boolean getInfoLetterHeight()
+ {
+ return infoLetterHeight;
}
/**
@Override
public void actionPerformed(ActionEvent e)
{
+
+ if (aaa.groupRef != null)
+ {
+ // TODO: pass on reference to ap so the view can be updated.
+ if (aaa.groupRef.getInfoLetterHeight() == false)
+ {
+ aaa.groupRef.setIgnoreBelowBackground(cbmi.getState());
+ ap.getAnnotationPanel()
+ .paint(ap.getAnnotationPanel().getGraphics());
+ }
+ }
+ else if (ap.av.isInfoLetterHeight() == false)
+ {
+ ap.av.setIgnoreBelowBackground(cbmi.getState(), ap);
+ }
+ ap.alignmentChanged();
+ }
+ });
+ pop.add(cbmi);
+ final JCheckBoxMenuItem letteHeight = new JCheckBoxMenuItem(
+ MessageManager.getString("label.use_info_for_height"),
+ (aa[selectedRow].groupRef != null)
+ ? aa[selectedRow].groupRef.getInfoLetterHeight()
+ : ap.av.isInfoLetterHeight());
+
+ letteHeight.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
if (aaa.groupRef != null)
{
// TODO: pass on reference to ap so the view can be updated.
- aaa.groupRef.setIgnoreBelowBackground(cbmi.getState());
+ aaa.groupRef.setInfoLetterHeight((letteHeight.getState()));
+ if (aaa.groupRef.getIgnoreBelowBackground() == false)
+ {
+ aaa.groupRef.setIgnoreBelowBackground(true);
+ }
ap.getAnnotationPanel()
.paint(ap.getAnnotationPanel().getGraphics());
}
else
{
- ap.av.setIgnoreBelowBackground(cbmi.getState(), ap);
+ ap.av.setInfoLetterHeight(letteHeight.getState(), ap);
+ if (ap.av.isIgnoreBelowBackground() == false)
+ {
+ ap.av.setIgnoreBelowBackground(true, ap);
+ }
}
ap.alignmentChanged();
}
});
- pop.add(cbmi);
+ pop.add(letteHeight);
if (aaa.groupRef != null)
{
final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
av_normaliseProfile = false;
boolean av_renderInformationHistogram = true, av_renderHMMProfile = true,
- av_normaliseHMMProfile = false;
+ av_normaliseHMMProfile = false, av_infoHeight = false;
ResidueShaderI profcolour = null;
hStrucConsensus = av.getRnaStructureConsensusHash();
av_ignoreGapsConsensus = av.isIgnoreGapsConsensus();
av_ignoreBelowBackground = av.isIgnoreBelowBackground();
+ av_infoHeight = av.isInfoLetterHeight();
}
{
HiddenMarkovModel hmm = aa.sequenceRef.getHMM();
return AAFrequency.extractHMMProfile(hmm, column,
- av_ignoreBelowBackground); // TODO check if this follows standard
+ av_ignoreBelowBackground, av_infoHeight); // TODO check if this follows standard
// pipeline
}
if (aa.autoCalculated
protected boolean ignoreBelowBackGroundFrequencyCalculation = false;
+ protected boolean infoLetterHeight = false;
+
protected ResidueShaderI residueShading = new ResidueShader();
@Override
}
+ public void setInfoLetterHeight(boolean b, AlignmentViewPanel ap)
+ {
+ infoLetterHeight = b;
+ if (ap != null)
+ {
+ updateInformation(ap);
+ }
+
+ }
+
private long sgrouphash = -1, colselhash = -1;
/**
return ignoreBelowBackGroundFrequencyCalculation;
}
+ @Override
+ public boolean isInfoLetterHeight()
+ {
+ return infoLetterHeight;
+ }
+
// property change stuff
// JBPNote Prolly only need this in the applet version.
private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
public class InformationThread extends AlignCalcWorker
{
+
+ Float max = 0f;
+
/**
* Constructor for information thread.
*
int width = alignment.getWidth();
List<SequenceI> hmmSeqs = alignment.getHMMConsensusSequences(false);
int index = 0;
+
for (SequenceI seq : hmmSeqs)
{
HiddenMarkovModel hmm = seq.getHMM();
ProfilesI hinformation = AAFrequency.calculateHMMProfiles(hmm, width,
- 0, width, true, alignViewport.isIgnoreBelowBackground());
+ 0, width, true, alignViewport.isIgnoreBelowBackground(),
+ alignViewport.isInfoLetterHeight());
alignViewport.setSequenceInformationHash(hinformation, index);
// setColourSchemeInformation(hinformation);
index++;
protected void deriveInformation(
AlignmentAnnotation informationAnnotation, ProfilesI hinformation)
{
-
long nseq = getSequences().length;
- AAFrequency.completeInformation(informationAnnotation, hinformation,
- hinformation.getStartColumn(), hinformation.getEndColumn() + 1,
- alignViewport.isIgnoreBelowBackground(),
- alignViewport.isShowHMMSequenceLogo(), nseq);
+ max = AAFrequency.completeInformation(informationAnnotation,
+ hinformation, hinformation.getStartColumn(),
+ hinformation.getEndColumn() + 1, nseq, max);
}
"test/jalview/io/test_MADE1_hmm.txt", DataSourceType.FILE));
hmm = hmmFile.getHMM();
int[] expected = { 0, 4, 100, 'T', 71, 'C', 12, 'G', 9, 'A', 9 };
- int[] actual = AAFrequency.extractHMMProfile(hmm, 17, false);
+ int[] actual = AAFrequency.extractHMMProfile(hmm, 17, false, false);
for (int i = 0; i < actual.length; i++)
{
if (i == 2)
}
int[] expected2 = { 0, 4, 100, 'A', 85, 'C', 0, 'G', 0, 'T', 0 };
- int[] actual2 = AAFrequency.extractHMMProfile(hmm, 2, true);
+ int[] actual2 = AAFrequency.extractHMMProfile(hmm, 2, true, false);
for (int i = 0; i < actual2.length; i++)
{
if (i == 2)
}
}
- assertNull(AAFrequency.extractHMMProfile(null, 98978867, true));
+ assertNull(AAFrequency.extractHMMProfile(null, 98978867, true, false));
}
@Test(groups = { "Functional" }, priority = 2)
public void testGetAnalogueCount()
{
int count;
- count = AAFrequency.getAnalogueCount(hmm, 0, 'T', false);
+ count = AAFrequency.getAnalogueCount(hmm, 0, 'T', false, false);
assertEquals(7859, count);
- count = AAFrequency.getAnalogueCount(hmm, 20, 'G', false);
+ count = AAFrequency.getAnalogueCount(hmm, 20, 'G', false, false);
assertEquals(7546, count);
- count = AAFrequency.getAnalogueCount(hmm, 1077, 'G', true);
+ count = AAFrequency.getAnalogueCount(hmm, 1077, 'G', true, false);
assertEquals(0, count);
}
seq.setHMM(hmm);
AlignmentAnnotation annot = new AlignmentAnnotation("", "", annots);
annot.setSequenceRef(seq);
- AAFrequency.completeInformation(annot, profs, 0, 1, false, true, 1);
+ AAFrequency.completeInformation(annot, profs, 0, 1, 1, 1f);
float ic = annot.annotations[0].value;
assertEquals(0.91532f, ic, 0.0001f);
ic = annot.annotations[1].value;