StringBuffer details = new StringBuffer();
/**
- * Creates a new PCA object.
- * By default, uses blosum62 matrix to generate sequence similarity matrices
+ * Creates a new PCA object. By default, uses blosum62 matrix to generate
+ * sequence similarity matrices
+ *
* @param s
* Set of amino acid sequences to perform PCA on
*/
{
this(s, false);
}
-
+
/**
- * Creates a new PCA object.
- * By default, uses blosum62 matrix to generate sequence similarity matrices
+ * Creates a new PCA object. By default, uses blosum62 matrix to generate
+ * sequence similarity matrices
+ *
* @param s
* Set of sequences to perform PCA on
- * @param nucleotides if true, uses standard DNA/RNA matrix for sequence similarity calculation.
+ * @param nucleotides
+ * if true, uses standard DNA/RNA matrix for sequence similarity
+ * calculation.
*/
public PCA(String[] s, boolean nucleotides)
{
while ((ii < s.length) && (s[ii] != null))
{
- bs[ii] = new BinarySequence(s[ii],nucleotides);
+ bs[ii] = new BinarySequence(s[ii], nucleotides);
bs[ii].encode();
ii++;
}
BinarySequence[] bs2 = new BinarySequence[s.length];
ii = 0;
- String sm=nucleotides ? "DNA" : "BLOSUM62";
- ScoreMatrix smtrx=ResidueProperties.getScoreMatrix(sm);
- details.append("PCA calculation using "+sm+" sequence similarity matrix\n========\n\n");
-
+ String sm = nucleotides ? "DNA" : "BLOSUM62";
+ ScoreMatrix smtrx = ResidueProperties.getScoreMatrix(sm);
+ details.append("PCA calculation using " + sm
+ + " sequence similarity matrix\n========\n\n");
while ((ii < s.length) && (s[ii] != null))
{
bs2[ii] = new BinarySequence(s[ii], nucleotides);
* @author $author$
* @version $Revision$
*/
-public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator
+public class PCAPanel extends GPCAPanel implements Runnable,
+ IProgressIndicator
{
-
RotatableCanvas rc;
AlignmentPanel ap;
AlignViewport av;
+
PCAModel pcaModel;
- int top=0;
+
+ int top = 0;
/**
* Creates a new PCAPanel object.
boolean sameLength = true;
- AlignmentView seqstrings = av.getAlignmentView(av.getSelectionGroup() != null);
- boolean nucleotide=av.getAlignment().isNucleotide();
+ AlignmentView seqstrings = av
+ .getAlignmentView(av.getSelectionGroup() != null);
+ boolean nucleotide = av.getAlignment().isNucleotide();
SequenceI[] seqs;
if (av.getSelectionGroup() == null)
{
}
pcaModel = new PCAModel(seqstrings, seqs, nucleotide);
PaintRefresher.Register(this, av.getSequenceSetId());
-
+
rc = new RotatableCanvas(ap);
this.getContentPane().add(rc, BorderLayout.CENTER);
Thread worker = new Thread(this);
*/
public void run()
{
- long progId=System.currentTimeMillis();
- IProgressIndicator progress=this;
- String message="Recalculating PCA";
- if (getParent()==null) {
- progress=ap.alignFrame;
+ long progId = System.currentTimeMillis();
+ IProgressIndicator progress = this;
+ String message = "Recalculating PCA";
+ if (getParent() == null)
+ {
+ progress = ap.alignFrame;
message = "Calculating PCA";
}
progress.setProgressBar(message, progId);
xCombobox.setSelectedIndex(0);
yCombobox.setSelectedIndex(1);
zCombobox.setSelectedIndex(2);
-
+
pcaModel.updateRc(rc);
// rc.invalidate();
nuclSetting.setSelected(pcaModel.isNucleotide());
protSetting.setSelected(!pcaModel.isNucleotide());
- top=pcaModel.getTop();
jvVersionSetting.setSelected(pcaModel.isJvCalcMode());
+ top = pcaModel.getTop();
} catch (OutOfMemoryError er)
{
new OOMWarning("calculating PCA", er);
return;
- }
- finally {
+ } finally
+ {
progress.setProgressBar("", progId);
}
calcSettings.setEnabled(true);
repaint();
- if (getParent()==null)
+ if (getParent() == null)
{
addKeyListener(rc);
- Desktop.addInternalFrame(this, "Principal component analysis", 475, 450);
+ Desktop.addInternalFrame(this, "Principal component analysis", 475,
+ 450);
}
}
+
@Override
protected void nuclSetting_actionPerfomed(ActionEvent arg0)
{
if (!pcaModel.isNucleotide())
{
pcaModel.setNucleotide(true);
- Thread worker = new Thread(this);
- worker.start();
+ Thread worker = new Thread(this);
+ worker.start();
}
-
+
}
+
@Override
protected void protSetting_actionPerfomed(ActionEvent arg0)
{
-
+
if (pcaModel.isNucleotide())
{
pcaModel.setNucleotide(false);
{
}
;
- Object[] alAndColsel = pcaModel.getSeqtrings().getAlignmentAndColumnSelection(gc);
+ Object[] alAndColsel = pcaModel.getSeqtrings()
+ .getAlignmentAndColumnSelection(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
try
{
- cap.setText(pcaModel.getPointsasCsv(false, xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), zCombobox.getSelectedIndex()));
+ cap.setText(pcaModel.getPointsasCsv(false,
+ xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
+ zCombobox.getSelectedIndex()));
Desktop.addInternalFrame(cap, "Points for " + getTitle(), 500, 500);
} catch (OutOfMemoryError oom)
{
}
}
-
-
/*
* (non-Javadoc)
*
CutAndPasteTransfer cap = new CutAndPasteTransfer();
try
{
- cap.setText(pcaModel.getPointsasCsv(true, xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), zCombobox.getSelectedIndex()));
+ cap.setText(pcaModel.getPointsasCsv(true,
+ xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
+ zCombobox.getSelectedIndex()));
Desktop.addInternalFrame(cap, "Transformed points for " + getTitle(),
500, 500);
} catch (OutOfMemoryError oom)
/*
* (non-Javadoc)
- *
+ *
* @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
*/
@Override
}
/**
- *
+ *
* @return true if any progress bars are still active
*/
@Override
}
return false;
}
+
@Override
protected void resetButton_actionPerformed(ActionEvent e)
{
- int t=top;
- top=0; // ugly - prevents dimensionChanged events from being processed
+ int t = top;
+ top = 0; // ugly - prevents dimensionChanged events from being processed
xCombobox.setSelectedIndex(0);
yCombobox.setSelectedIndex(1);
- top=t;
+ top = t;
zCombobox.setSelectedIndex(2);
}
}