From 3e9eba89979511361b51f1c78882c9877874f2ba Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 15 Jun 2012 17:52:37 +0100 Subject: [PATCH] JAL-1125 option to switch between Jalview and SeqSpace PCA calculation modes --- src/jalview/analysis/PCA.java | 18 ++++++++++++++++-- src/jalview/gui/PCAPanel.java | 12 +++++++++++- src/jalview/jbgui/GPCAPanel.java | 20 +++++++++++++++++++- src/jalview/viewmodel/PCAModel.java | 15 ++++++++++++++- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/jalview/analysis/PCA.java b/src/jalview/analysis/PCA.java index b001549..4441eeb 100755 --- a/src/jalview/analysis/PCA.java +++ b/src/jalview/analysis/PCA.java @@ -232,11 +232,18 @@ public class PCA implements Runnable */ public void run() { + details.append("PCA Calculation Mode is "+(jvCalcMode ? "Jalview variant" : "Original SeqSpace")+"\n"); Matrix mt = m.transpose(); details.append(" --- OrigT * Orig ---- \n"); - // eigenvector = mt.preMultiply(m); // standard seqspace comparison matrix - eigenvector = mt.preMultiply(m2); // jalview variation on seqsmace method + if (!jvCalcMode) + { + eigenvector = mt.preMultiply(m); // standard seqspace comparison matrix + } + else + { + eigenvector = mt.preMultiply(m2); // jalview variation on seqsmace method + } PrintStream ps = new PrintStream(System.out) { @@ -280,4 +287,11 @@ public class PCA implements Runnable * ps.print(","+component(seq, ev)); } ps.println(); } */ } + + boolean jvCalcMode = true; + + public void setJvCalcMode(boolean calcMode) + { + this.jvCalcMode = calcMode; + } } diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index eb7806f..f951acf 100755 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -145,6 +145,7 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator nuclSetting.setSelected(pcaModel.isNucleotide()); protSetting.setSelected(!pcaModel.isNucleotide()); top=pcaModel.getTop(); + jvVersionSetting.setSelected(pcaModel.isJvCalcMode()); } catch (OutOfMemoryError er) { @@ -180,10 +181,19 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator if (pcaModel.isNucleotide()) { pcaModel.setNucleotide(false); + Thread worker = new Thread(this); + worker.start(); + } + } + + @Override + protected void jvVersionSetting_actionPerfomed(ActionEvent arg0) + { + pcaModel.setJvCalcMode(jvVersionSetting.isSelected()); Thread worker = new Thread(this); worker.start(); - } } + /** * DOCUMENT ME! */ diff --git a/src/jalview/jbgui/GPCAPanel.java b/src/jalview/jbgui/GPCAPanel.java index c0905a8..15d4b3e 100755 --- a/src/jalview/jbgui/GPCAPanel.java +++ b/src/jalview/jbgui/GPCAPanel.java @@ -76,6 +76,7 @@ public class GPCAPanel extends JInternalFrame protected JMenu calcSettings=new JMenu(); protected JCheckBoxMenuItem nuclSetting=new JCheckBoxMenuItem(); protected JCheckBoxMenuItem protSetting=new JCheckBoxMenuItem(); + protected JCheckBoxMenuItem jvVersionSetting=new JCheckBoxMenuItem(); protected JLabel statusBar = new JLabel(); protected GridLayout statusPanelLayout = new GridLayout(); @@ -257,7 +258,18 @@ public class GPCAPanel extends JInternalFrame { protSetting_actionPerfomed(arg0); } - });calcSettings.add(nuclSetting); + }); + jvVersionSetting.setText("Jalview PCA Calculation"); + jvVersionSetting.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent arg0) + { + jvVersionSetting_actionPerfomed(arg0); + } + }); + calcSettings.add(jvVersionSetting); + calcSettings.add(nuclSetting); calcSettings.add(protSetting); statusPanel.setLayout(statusPanelLayout); statusBar.setFont(new java.awt.Font("Verdana",0,12)); @@ -372,4 +384,10 @@ public class GPCAPanel extends JInternalFrame { } + + protected void jvVersionSetting_actionPerfomed(ActionEvent arg0) + { + // TODO Auto-generated method stub + + } } diff --git a/src/jalview/viewmodel/PCAModel.java b/src/jalview/viewmodel/PCAModel.java index 6002c8a..64f2497 100644 --- a/src/jalview/viewmodel/PCAModel.java +++ b/src/jalview/viewmodel/PCAModel.java @@ -19,7 +19,7 @@ public class PCAModel nucleotide=nucleotide2; } - PCA pca; + private volatile PCA pca; int top; @@ -34,10 +34,18 @@ public class PCAModel private Vector points; + private boolean jvCalcMode=true; + + public boolean isJvCalcMode() + { + return jvCalcMode; + } + public void run() { pca = new PCA(seqstrings.getSequenceStrings(' '), nucleotide); + pca.setJvCalcMode(jvCalcMode); pca.run(); // Now find the component coordinates @@ -188,4 +196,9 @@ public class PCAModel return pts; } + public void setJvCalcMode(boolean state) + { + jvCalcMode=state; + } + } -- 1.7.10.2