action.by_tree_order = By Tree Order
action.sort = Sort
action.calculate_tree = Calculate Tree...
+action.calculate_tree_pca = Calculate Tree or PCA...
action.help = Help
action.by_annotation = By Annotation...
action.invert_sequence_selection = Invert Sequence Selection
label.save_as_html = Save as HTML
label.recently_opened = Recently Opened
label.blasting_for_unidentified_sequence_jobs_running = BLASTing for unidentified sequences - {0} jobs running.
+label.tree = Tree
label.tree_from = Tree from {0}
label.webservice_job_title = {0} using {1}
label.select_visible_region_of = selected {0} region of {1}
label.save_as_html = Guardar como HTML
label.recently_opened = Abiertos recientemente
label.blasting_for_unidentified_sequence_jobs_running = Ejecutando BLAST de las secuencias no indentificadas - {0} trabajos en marcha.
+label.tree = Árbol
label.tree_from = Árbol de {0}
label.webservice_job_title = {0} usando {1}
label.select_visible_region_of = seleccionada {0} región de {1}
*/
package jalview.appletgui;
+import jalview.analysis.scoremodels.ScoreModels;
import jalview.analysis.scoremodels.SimilarityParams;
+import jalview.api.analysis.ScoreModelI;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.ColumnSelection;
int top = 0;
- public PCAPanel(AlignViewport av)
+ public PCAPanel(AlignViewport viewport)
{
try
{
zCombobox.addItem("dim " + i);
}
- this.av = av;
- boolean selected = av.getSelectionGroup() != null
- && av.getSelectionGroup().getSize() > 0;
- AlignmentView seqstrings = av.getAlignmentView(selected);
- boolean nucleotide = av.getAlignment().isNucleotide();
+ this.av = viewport;
+ boolean selected = viewport.getSelectionGroup() != null
+ && viewport.getSelectionGroup().getSize() > 0;
+ AlignmentView seqstrings = viewport.getAlignmentView(selected);
+ boolean nucleotide = viewport.getAlignment().isNucleotide();
SequenceI[] seqs;
if (!selected)
{
- seqs = av.getAlignment().getSequencesArray();
+ seqs = viewport.getAlignment().getSequencesArray();
}
else
{
- seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
+ seqs = viewport.getSelectionGroup().getSequencesInOrder(viewport.getAlignment());
}
SeqCigar sq[] = seqstrings.getSequences();
int length = sq[0].getWidth();
return;
}
}
+
+ ScoreModelI scoreModel = ScoreModels.getInstance().getDefaultModel(
+ !nucleotide);
pcaModel = new PCAModel(seqstrings, seqs, nucleotide,
+ scoreModel,
SimilarityParams.SeqSpace);
- rc = new RotatableCanvas(av);
+ rc = new RotatableCanvas(viewport);
embedMenuIfNeeded(rc);
add(rc, BorderLayout.CENTER);
import jalview.analysis.scoremodels.ScoreModels;
import jalview.analysis.scoremodels.SimilarityParams;
import jalview.api.analysis.ScoreModelI;
+import jalview.api.analysis.SimilarityParamsI;
import jalview.api.analysis.ViewBasedAnalysisI;
import jalview.bin.Cache;
import jalview.datamodel.Alignment;
int top = 0;
/**
- * Creates a new PCAPanel object.
+ * Creates a new PCAPanel object using default score model and parameters
*
- * @param av
- * DOCUMENT ME!
- * @param s
- * DOCUMENT ME!
+ * @param alignPanel
*/
public PCAPanel(AlignmentPanel alignPanel)
{
+ this(alignPanel, ScoreModels.getInstance().getDefaultModel(
+ !alignPanel.av.getAlignment().isNucleotide()),
+ SimilarityParams.SeqSpace);
+ }
+
+ /**
+ * Constructor given sequence data, a similarity (or distance) score model,
+ * and score calculation parameters
+ *
+ * @param alignPanel
+ * @param scoreModel
+ * @param params
+ */
+ public PCAPanel(AlignmentPanel alignPanel, ScoreModelI scoreModel,
+ SimilarityParamsI params)
+ {
super();
this.av = alignPanel.av;
this.ap = alignPanel;
+ boolean nucleotide = av.getAlignment().isNucleotide();
progressBar = new ProgressBar(statusPanel, statusBar);
boolean selected = av.getSelectionGroup() != null
&& av.getSelectionGroup().getSize() > 0;
AlignmentView seqstrings = av.getAlignmentView(selected);
- boolean nucleotide = av.getAlignment().isNucleotide();
SequenceI[] seqs;
if (!selected)
{
return;
}
- pcaModel = new PCAModel(seqstrings, seqs, nucleotide,
- SimilarityParams.SeqSpace);
+ pcaModel = new PCAModel(seqstrings, seqs, nucleotide, scoreModel,
+ params);
PaintRefresher.Register(this, av.getSequenceSetId());
rc = new RotatableCanvas(alignPanel);
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
import java.beans.PropertyVetoException;
import javax.swing.ButtonGroup;
AlignFrame af;
+ JRadioButton pca;
+
+ JRadioButton tree;
+
JRadioButton neighbourJoining;
JRadioButton averageDistance;
this.setBackground(Color.white);
/*
- * Layout consists of 4 panels:
- * - first with choice of tree method NJ or AV
- * - second with choice of score model
- * - third with score model parameter options
- * - fourth with OK and Cancel
+ * Layout consists of 5 panels:
+ * - first with choice of Tree or PCA
+ * - second with choice of tree method NJ or AV
+ * - third with choice of score model
+ * - fourth with score model parameter options
+ * - fifth with OK and Cancel
*/
+ tree = new JRadioButton(MessageManager.getString("label.tree"));
+ tree.setOpaque(false);
+ pca = new JRadioButton(
+ MessageManager.getString("label.principal_component_analysis"));
+ pca.setOpaque(false);
neighbourJoining = new JRadioButton(
MessageManager.getString("label.tree_calc_nj"));
- neighbourJoining.setOpaque(false);
averageDistance = new JRadioButton(
MessageManager.getString("label.tree_calc_av"));
+ ItemListener listener = new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ neighbourJoining.setEnabled(tree.isSelected());
+ averageDistance.setEnabled(tree.isSelected());
+ }
+ };
+ pca.addItemListener(listener);
+ tree.addItemListener(listener);
+ ButtonGroup calcTypes = new ButtonGroup();
+ calcTypes.add(pca);
+ calcTypes.add(tree);
+ JPanel calcChoicePanel = new JPanel();
+ calcChoicePanel.setOpaque(false);
+ tree.setSelected(true);
+ calcChoicePanel.add(tree);
+ calcChoicePanel.add(pca);
+
+ neighbourJoining.setOpaque(false);
treeTypes = new ButtonGroup();
treeTypes.add(neighbourJoining);
treeTypes.add(averageDistance);
actionPanel.add(ok);
actionPanel.add(cancel);
+ this.add(calcChoicePanel);
this.add(treeChoicePanel);
this.add(scoreModelPanel);
this.add(paramsPanel);
*/
protected void ok_actionPerformed(ActionEvent e)
{
- String treeType = neighbourJoining.isSelected() ? NJTree.NEIGHBOUR_JOINING
- : NJTree.AVERAGE_DISTANCE;
ScoreModelI sm = ScoreModels.getInstance().forName(
matrixNames.getSelectedItem().toString());
SimilarityParamsI params = getSimilarityParameters();
- af.newTreePanel(treeType, sm, params);
+ if (pca.isSelected())
+ {
+ AlignViewport viewport = af.getViewport();
+ if (((viewport.getSelectionGroup() != null)
+ && (viewport.getSelectionGroup().getSize() < 4) && (viewport
+ .getSelectionGroup().getSize() > 0))
+ || (viewport.getAlignment().getHeight() < 4))
+ {
+ JvOptionPane
+ .showInternalMessageDialog(
+ this,
+ MessageManager
+ .getString("label.principal_component_analysis_must_take_least_four_input_sequences"),
+ MessageManager
+ .getString("label.sequence_selection_insufficient"),
+ JvOptionPane.WARNING_MESSAGE);
+ return;
+ }
+ new PCAPanel(af.alignPanel, sm, params);
+ }
+ else
+ {
+ String treeType = neighbourJoining.isSelected() ? NJTree.NEIGHBOUR_JOINING
+ : NJTree.AVERAGE_DISTANCE;
+ af.newTreePanel(treeType, sm, params);
+ }
+
+ // closeFrame();
+ }
+
+ /**
+ *
+ */
+ protected void closeFrame()
+ {
try
{
frame.setClosed(true);
});
sortByAnnotScore.setVisible(false);
- calculateTree
- .setText(MessageManager.getString("action.calculate_tree"));
+ calculateTree.setText(MessageManager
+ .getString("action.calculate_tree_pca"));
padGapsMenuitem.setText(MessageManager.getString("label.pad_gaps"));
padGapsMenuitem.setState(jalview.bin.Cache
calculateMenu.add(calculateTree);
calculateMenu.addSeparator();
calculateMenu.add(pairwiseAlignmentMenuItem);
- calculateMenu.add(PCAMenuItem);
+ // calculateMenu.add(PCAMenuItem);
calculateMenu.addSeparator();
calculateMenu.add(showTranslation);
calculateMenu.add(showReverse);
package jalview.viewmodel;
import jalview.analysis.PCA;
-import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.RotatableCanvasI;
import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.SimilarityParamsI;
private SimilarityParamsI similarityParams;
/**
- * Constructor given sequence data and score calculation parameter options.
- * The initial state is to compute PCA using a default score model (BLOSUM62
- * for peptide, DNA for nucleotide).
+ * Constructor given sequence data, score model and score calculation
+ * parameter options.
*
* @param seqData
* @param sqs
* @param nuc
+ * @param sm
* @param params
*/
- public PCAModel(AlignmentView seqData, SequenceI[] sqs, boolean nuc,
+ public PCAModel(AlignmentView seqData, SequenceI[] sqs, boolean nuc, ScoreModelI sm,
SimilarityParamsI params)
{
seqstrings = seqData;
seqs = sqs;
nucleotide = nuc;
- scoreModel = ScoreModels.getInstance().getDefaultModel(!nucleotide);
+ scoreModel = sm;
similarityParams = params;
}