label.anti_alias_fonts = Anti-alias Fonts (Slower to render)
label.monospaced_font= Monospaced
label.quality = Quality
+label.quality_label = Alignment Quality based on {0} scores
label.maximize_window = Maximize Window
label.conservation = Conservation
label.consensus = Consensus
package jalview.analysis;
import jalview.analysis.scoremodels.ScoreMatrix;
-import jalview.analysis.scoremodels.ScoreModels;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.ResidueCount;
}
// From Alignment.java in jalview118
- public void findQuality()
+ public void findQuality(ScoreMatrix scoreModel)
{
- findQuality(0, maxLength - 1, ScoreModels.getInstance().getBlosum62());
+ findQuality(0, maxLength - 1, scoreModel);
}
/**
*/
public static Conservation calculateConservation(String name,
List<SequenceI> seqs, int start, int end, boolean positiveOnly,
- int maxPercentGaps, boolean calcQuality)
+ int maxPercentGaps, boolean calcQuality, ScoreMatrix scoreModel)
{
Conservation cons = new Conservation(name, seqs, start, end);
cons.calculate();
if (calcQuality)
{
- cons.findQuality();
+ cons.findQuality(scoreModel);
}
return cons;
if (conservationColour.getState())
{
Conservation conservation = Conservation.calculateConservation(
- "Group", sg
- .getSequences(ap.av.getHiddenRepSequences()), 0, ap.av
- .getAlignment().getWidth(), false, ap.av.getConsPercGaps(),
- false);
+ "Group", sg.getSequences(ap.av.getHiddenRepSequences()), 0,
+ ap.av.getAlignment().getWidth(), false,
+ ap.av.getConsPercGaps(), false, null);
sg.getGroupColourScheme().setConservation(conservation);
SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
SliderPanel.showConservationSlider();
import jalview.analysis.Dna;
import jalview.analysis.ParseProperties;
import jalview.analysis.SequenceIdMatcher;
+import jalview.analysis.scoremodels.ScoreMatrix;
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.api.AlignCalcManagerI;
+import jalview.api.AlignCalcWorkerI;
import jalview.api.AlignExportSettingI;
import jalview.api.AlignViewControllerGuiI;
import jalview.api.AlignViewControllerI;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
import jalview.viewmodel.ViewportRanges;
+import jalview.workers.ConservationThread;
import jalview.ws.DBRefFetcher;
import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
import jalview.ws.jws1.Discoverer;
modifyConservation.setEnabled(!nucleotide
&& conservationMenuItem.isSelected());
showGroupConservation.setEnabled(!nucleotide);
+ qualityScoreModel.setEnabled(!nucleotide);
showComplementMenuItem.setText(nucleotide ? MessageManager
.getString("label.protein") : MessageManager
ColourMenuHelper.setColourSelected(colourMenu, schemeName);
}
+
+ /**
+ * Repopulates the sub-menu with choice of score matrices each time the menu
+ * is selected, in case matrices have been added dynamically
+ */
+ @Override
+ protected void scoreModel_menuSelected()
+ {
+ qualityScoreModel.removeAll();
+ boolean nucleotide = getViewport().getAlignment().isNucleotide();
+ final AlignCalcManagerI calcManager = getViewport().getCalcManager();
+
+ /*
+ * which model is currently selected?
+ */
+ String modelName = null;
+ final List<AlignCalcWorkerI> cons = calcManager
+ .getRegisteredWorkersOfClass(ConservationThread.class);
+ if (cons == null || cons.isEmpty())
+ {
+ return;
+ }
+ for (AlignCalcWorkerI worker : cons)
+ {
+ modelName = ((ConservationThread) worker).getScoreModel().getName();
+ }
+
+ /*
+ * repopulate menu
+ */
+ final ScoreModels scoreModels = ScoreModels.getInstance();
+ for (final ScoreModelI sm : scoreModels.getModels())
+ {
+ final String name = sm.getName();
+ JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(name);
+
+ /*
+ * if the score model doesn't provide a description, try to look one
+ * up in the text bundle, falling back on its name
+ * TODO push this inside ScoreModels?
+ */
+ String tooltip = sm.getDescription();
+ if (tooltip == null)
+ {
+ tooltip = MessageManager.getStringOrReturn("label.score_model_",
+ name);
+ }
+ menuItem.setToolTipText(tooltip);
+ menuItem.setSelected(modelName.equals(name));
+ if (sm.isProtein() && (sm instanceof ScoreMatrix))
+ {
+ menuItem.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ // set model on ConservationThread, restart thread
+ for (AlignCalcWorkerI worker : cons)
+ {
+ ((ConservationThread) worker)
+ .setScoreModel((ScoreMatrix) scoreModels
+ .forName(name));
+ }
+ getViewport().alignmentChanged(alignPanel);
+ }
+ });
+ qualityScoreModel.add(menuItem);
+ }
+ }
+ }
}
class PrintThread extends Thread
protected JCheckBoxMenuItem showGroupConservation = new JCheckBoxMenuItem();
+ protected JMenu qualityScoreModel = new JMenu();
+
protected JCheckBoxMenuItem showConsensusHistogram = new JCheckBoxMenuItem();
protected JCheckBoxMenuItem showSequenceLogo = new JCheckBoxMenuItem();
}
});
+
+ qualityScoreModel.setText("Quality Score Model"); // todo i18n
+ qualityScoreModel.addMenuListener(new MenuListener()
+ {
+ @Override
+ public void menuSelected(MenuEvent e)
+ {
+ scoreModel_menuSelected();
+ }
+
+ @Override
+ public void menuDeselected(MenuEvent e)
+ {
+ }
+
+ @Override
+ public void menuCanceled(MenuEvent e)
+ {
+ }
+ });
+
showConsensusHistogram.setText(MessageManager
.getString("label.show_consensus_histogram"));
showConsensusHistogram.addActionListener(new ActionListener()
autoAnnMenu.addSeparator();
autoAnnMenu.add(showGroupConservation);
autoAnnMenu.add(showGroupConsensus);
+ autoAnnMenu.addSeparator();
+ autoAnnMenu.add(qualityScoreModel);
annotationsMenu.add(autoAnnMenu);
// selectMenu.add(listenToViewSelections);
}
+ protected void scoreModel_menuSelected()
+ {
+ }
+
/**
* Constructs the entries on the Colour menu (but does not add them to the
* menu).
*/
package jalview.viewmodel;
-import java.awt.Color;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.analysis.Conservation;
import jalview.api.AlignCalcManagerI;
import jalview.util.Comparison;
import jalview.util.MapList;
import jalview.util.MappingUtils;
+import jalview.util.MessageManager;
import jalview.viewmodel.styles.ViewStyle;
import jalview.workers.AlignCalcManager;
import jalview.workers.ComplementConsensusThread;
import jalview.workers.ConsensusThread;
import jalview.workers.StrucConsensusThread;
+import java.awt.Color;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
/**
* base class holding visualization and analysis attributes and common logic for
* an active alignment view displayed in the GUI
{
rs.setConservation(Conservation.calculateConservation("All",
alignment.getSequences(), 0, alignment.getWidth(), false,
- getConsPercGaps(), false));
+ getConsPercGaps(), false, null));
}
}
if (quality == null)
{
quality = new AlignmentAnnotation("Quality",
- "Alignment Quality based on Blosum62 scores",
- new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
+ MessageManager.formatMessage("label.quality_label",
+ "Blosum62"), new Annotation[1], 0f, 11f,
+ AlignmentAnnotation.BAR_GRAPH);
quality.hasText = true;
quality.autoCalculated = true;
alignment.addAnnotation(quality);
package jalview.workers;
import jalview.analysis.Conservation;
+import jalview.analysis.scoremodels.ScoreMatrix;
+import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.util.MessageManager;
import java.util.ArrayList;
import java.util.List;
{
super(alignViewport, alignPanel);
ConsPercGaps = alignViewport.getConsPercGaps();
+ setScoreModel(ScoreModels.getInstance().getBlosum62());
}
private Conservation cons;
int alWidth;
+ private ScoreMatrix scoreModel;
+
@Override
public void run()
{
{
cons = Conservation.calculateConservation("All",
alignment.getSequences(), 0, alWidth - 1, false,
- ConsPercGaps, quality != null);
+ ConsPercGaps, quality != null, scoreModel);
} catch (IndexOutOfBoundsException x)
{
// probable race condition. just finish and return without any fuss.
updateResultAnnotation(false);
}
+
+ /**
+ * Sets the substitution matrix to be used in the Quality calculation. This
+ * method is not thread-safe.
+ *
+ * @param model
+ */
+ public void setScoreModel(ScoreMatrix model)
+ {
+ scoreModel = model;
+ if (quality != null)
+ {
+ quality.description = MessageManager.formatMessage(
+ "label.quality_label", model.getName());
+ }
+ }
+
+ public ScoreMatrix getScoreModel()
+ {
+ return scoreModel;
+ }
}