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;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
-import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.SeqCigar;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import jalview.jbgui.GPCAPanel;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
PCAModel pcaModel;
+ private static final int MIN_WIDTH = 470;
+
+ private static final int MIN_HEIGHT = 250;
+
int top = 0;
/**
*/
public PCAPanel(AlignmentPanel alignPanel)
{
- this(alignPanel, ScoreModels.getInstance().getDefaultModel(
- !alignPanel.av.getAlignment().isNucleotide()),
- SimilarityParams.SeqSpace);
+ this(alignPanel, ScoreModels.getInstance()
+ .getDefaultModel(!alignPanel.av.getAlignment().isNucleotide())
+ .getName(), SimilarityParams.SeqSpace);
}
/**
- * Constructor given sequence data, a similarity (or distance) score model,
- * and score calculation parameters
+ * Constructor given sequence data, a similarity (or distance) score model
+ * name, and score calculation parameters
*
* @param alignPanel
- * @param scoreModel
+ * @param modelName
* @param params
*/
- public PCAPanel(AlignmentPanel alignPanel, ScoreModelI scoreModel,
+ public PCAPanel(AlignmentPanel alignPanel, String modelName,
SimilarityParamsI params)
{
super();
seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
- // TODO can we allow PCA on unaligned data given choice of
- // similarity measure parameters?
- if (!checkAligned(seqstrings))
- {
- JvOptionPane.showMessageDialog(Desktop.desktop,
- MessageManager.getString("label.pca_sequences_not_aligned"),
- MessageManager.getString("label.sequences_not_aligned"),
- JvOptionPane.WARNING_MESSAGE);
-
- return;
- }
-
+ ScoreModelI scoreModel = ScoreModels.getInstance().getScoreModel(
+ modelName, ap);
pcaModel = new PCAModel(seqstrings, seqs, nucleotide, scoreModel,
params);
PaintRefresher.Register(this, av.getSequenceSetId());
}
/**
- * Answers true if all sequences have the same aligned length, else false
- *
- * @param seqstrings
- * @return
- */
- protected boolean checkAligned(AlignmentView seqstrings)
- {
- SeqCigar sq[] = seqstrings.getSequences();
- int length = sq[0].getWidth();
- boolean sameLength = true;
- for (int i = 0; i < sq.length; i++)
- {
- if (sq[i].getWidth() != length)
- {
- sameLength = false;
- break;
- }
- }
- return sameLength;
- }
-
- /**
* Ensure references to potentially very large objects (the PCA matrices) are
* nulled when the frame is closed
*/
{
if (!pcaModel.getScoreModelName().equals(name))
{
- ScoreModelI sm2 = configureScoreModel(sm);
+ ScoreModelI sm2 = ScoreModels.getInstance().getScoreModel(
+ name, ap);
pcaModel.setScoreModel(sm2);
Thread worker = new Thread(PCAPanel.this);
worker.start();
addKeyListener(rc);
Desktop.addInternalFrame(this, MessageManager
.getString("label.principal_component_analysis"), 475, 450);
+ this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
}
}
}
;
Object[] alAndColsel = pcaModel.getSeqtrings()
- .getAlignmentAndColumnSelection(gc);
+ .getAlignmentAndHiddenColumns(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
if (true)
{
// make a new frame!
- AlignFrame af = new AlignFrame(al,
- (ColumnSelection) alAndColsel[1], AlignFrame.DEFAULT_WIDTH,
+ AlignFrame af = new AlignFrame(al, (HiddenColumns) alAndColsel[1],
+ AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
// >>>This is a fix for the moment, until a better solution is
top = t;
zCombobox.setSelectedIndex(2);
}
-
- /**
- * If the score model is one that requires to get state data from the current
- * view, allow it to do so
- *
- * @param sm
- * @return
- */
- protected ScoreModelI configureScoreModel(ScoreModelI sm)
- {
- if (sm instanceof ViewBasedAnalysisI)
- {
- try
- {
- sm = sm.getClass().newInstance();
- ((ViewBasedAnalysisI) sm).configureFromAlignmentView(ap);
- } catch (Exception q)
- {
- Cache.log.error("Couldn't create a scoremodel instance for "
- + sm.getName());
- }
- }
- return sm;
- }
}