action.border_colour = Border colour
action.edit_new_group = Edit New Group
action.hide_sequences = Hide Sequences
+action.add_background_frequencies = Add Background Frequencies
action.sequences = Sequences
action.ids = IDS
action.ids_sequences = IDS and sequences
label.colourScheme_nucleotide = Nucleotide
label.colourScheme_hmmer-uniprot = HMMER profile v global background
label.colourScheme_hmmer-alignment = HMMER profile v alignment background
+label.colourScheme_hmm_match_score = HMM Match Score
label.colourScheme_t-coffeescores = T-Coffee Scores
label.colourScheme_rnahelices = By RNA Helices
label.colourScheme_sequenceid = Sequence ID Colour
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
+import jalview.datamodel.ResidueCount;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.ColourMenuHelper.ColourChangeListener;
+import jalview.io.CountReader;
import jalview.io.FileFormatI;
import jalview.io.FileFormats;
import jalview.io.FormatAdapter;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
}
}
+ if (seq.hasHMMProfile())
+ {
+ menuItem = new JMenuItem(MessageManager
+ .getString("action.add_background_frequencies"));
+ menuItem.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ ResidueCount counts = CountReader.getBackgroundFrequencies(ap,
+ seq);
+ if (counts != null)
+ {
+ seq.getHMM().setBackgroundFrequencies(counts);
+ ap.alignFrame.buildColourMenu();
+ }
+ } catch (MalformedURLException e1)
+ {
+ e1.printStackTrace();
+ } catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+ }
+ });
+ add(menuItem);
+ }
+
menuItem = new JMenuItem(
MessageManager.getString("action.hide_sequences"));
menuItem.addActionListener(new ActionListener()
--- /dev/null
+package jalview.io;
+
+import jalview.bin.Jalview;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ResidueCount;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.Desktop;
+import jalview.gui.JvOptionPane;
+import jalview.util.MessageManager;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import javax.swing.JFileChooser;
+
+public class CountReader
+{
+ public static ResidueCount getBackgroundFrequencies(AlignmentPanel ap, SequenceI seq) throws MalformedURLException, IOException
+ {
+ JFileChooser bkgdFreqChooser = new JFileChooser();
+
+ bkgdFreqChooser.showOpenDialog(ap);
+
+ File file = bkgdFreqChooser.getSelectedFile();
+ if (file == null)
+ {
+ return null;
+ }
+
+ IdentifyFile identifier = new IdentifyFile();
+ FileFormatI format = null;
+ try
+ {
+ format = identifier.identify(file.getPath(), DataSourceType.FILE);
+ } catch (Exception e)
+ {
+
+ }
+
+ if (format == null)
+ {
+ if (!Jalview.isHeadlessMode())
+ {
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.getString("label.couldnt_read_data") + " in "
+ + file + "\n"
+ + AppletFormatAdapter.getSupportedFormats(),
+ MessageManager.getString("label.couldnt_read_data"),
+ JvOptionPane.WARNING_MESSAGE);
+ }
+ }
+
+ FileParse parser = new FileParse(file.getPath(), DataSourceType.FILE);
+ AlignmentI al = new FormatAdapter().readFromFile(parser, format);
+ parser.close();
+
+ ResidueCount counts = new ResidueCount(al.getSequences());
+
+ return counts;
+ }
+}
symbol = Character.toUpperCase(symbol);
}
- double llr = Math
- .log(getHmm().getMatchEmissionProbability(column, symbol)
- / hmm.getBackgroundFrequencies().get(symbol));
+ double prob = 0;
+ if (hmm.getBackgroundFrequencies().containsKey(symbol))
+ {
+ double llr = Math
+ .log(getHmm().getMatchEmissionProbability(column, symbol)
+ / hmm.getBackgroundFrequencies().get(symbol));
+
+ if (!probabilities.get(symbol).containsKey(format(llr)))
+ {
+ return Color.green;
+ }
- double prob = probabilities.get(symbol).get(format(llr));
+ prob = probabilities.get(symbol).get(format(llr));
+ }
+ else
+ {
+ return new Color(140, 140, 140);
+ }
Color colour = Color.ORANGE;
if (prob >= 0.5)
}
/**
- * Answers true if the sequence collection has an HMM consensus sequence, else
- * false
+ * Answers true if the sequence collection has an HMM consensus sequence and
+ * that the first HMM sequence contains background frequencies, else false
*/
@Override
public boolean isApplicableTo(AnnotatedCollectionI ac)
{
- return !ac.getHmmSequences().isEmpty();
+ return !ac.getHmmSequences().isEmpty() && ac.getHmmSequences().get(0)
+ .getHMM().getBackgroundFrequencies() != null;
}
protected Map<Character, Float> getFrequencies()