From c08183017072db6074e9df8c35216dd39a68abe1 Mon Sep 17 00:00:00 2001 From: Adam Tenderholt Date: Mon, 18 Jan 2016 09:31:58 -0800 Subject: [PATCH 1/8] Use Math.max instead of Integer.max (Java 7 compatability) * Integer.max was introduced in Java 8: https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#max-int-int- --- src/main/java/com/veritomyx/PeakInvestigatorSaaS.java | 2 +- .../PeakInvestigator/PeakInvestigatorParameters.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java b/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java index 9c511f842..7e6e9d9c5 100644 --- a/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java +++ b/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java @@ -312,7 +312,7 @@ private int getPage(String action, int count, int minMass, int maxMass) for(int scanNum = 1; scanNum <= scanCount; scanNum++) { Scan scan = file.getScan(scanNum); int dpCount = scan.getNumberOfDataPoints(); - maxMasses = Integer.max(maxMasses.intValue(), dpCount); + maxMasses = Math.max(maxMasses.intValue(), dpCount); } } if(maxMass > maxMasses) { diff --git a/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorParameters.java b/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorParameters.java index 28d9110e2..fd3393069 100644 --- a/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorParameters.java +++ b/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorParameters.java @@ -57,7 +57,7 @@ public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) for(int scanNum = 1; scanNum <= scanCount; scanNum++) { Scan scan = file.getScan(scanNum); int dpCount = scan.getNumberOfDataPoints(); - maxMasses = Integer.max(maxMasses.intValue(), dpCount); + maxMasses = Math.max(maxMasses.intValue(), dpCount); } } minMass.setMinMax(0, maxMasses-1); From b6664b4f78c0c08619f2b4696da970fdddb7e162 Mon Sep 17 00:00:00 2001 From: Adam Tenderholt Date: Mon, 18 Jan 2016 10:03:37 -0800 Subject: [PATCH 2/8] PISaaS: don't delete results file via SFTP * The API should be responsible for DELETE operations --- src/main/java/com/veritomyx/PeakInvestigatorSaaS.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java b/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java index 7e6e9d9c5..5d92f55c5 100644 --- a/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java +++ b/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java @@ -635,14 +635,12 @@ public boolean getFile(String fname) result = sftp.get(session, fname); if (!result.getSuccessFlag()) { -// sftp.cd(session, ".."); closeSession(session); web_result = W_ERROR_SFTP; web_str = "Cannot read file: " + fname; return false; } - sftp.rm(session, fname); -// sftp.cd(session, ".."); + closeSession(session); return true; } From 54c677527f1d8a5818a2b3121fe896a2c0fade15 Mon Sep 17 00:00:00 2001 From: Adam Tenderholt Date: Mon, 18 Jan 2016 10:04:26 -0800 Subject: [PATCH 3/8] PITask: need just the root filename * Now that API returns absolute path (e.g. /files/JOB/JOB.mass_list.tar), need to pull out just filename when trying to read file. --- .../massdetection/PeakInvestigator/PeakInvestigatorTask.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorTask.java b/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorTask.java index f4c48dddb..c01621c33 100644 --- a/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorTask.java +++ b/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorTask.java @@ -354,7 +354,8 @@ private void startRetrieve() TarInputStream tis = null; FileOutputStream outputStream = null; try { - tis = new TarInputStream(new GZIPInputStream(new FileInputStream(outputFilename))); + File fullPath = new File(outputFilename); // outputfilename looks like /files/C-1022.1391/C-1022.1391.mass_list.tar + tis = new TarInputStream(new GZIPInputStream(new FileInputStream(fullPath.getName()))); TarEntry tf; int bytesRead; byte buf[] = new byte[1024]; From e2257b5810f7cc12bd4ac8bc97c196f95ea8c3e2 Mon Sep 17 00:00:00 2001 From: Adam Tenderholt Date: Mon, 18 Jan 2016 11:50:45 -0800 Subject: [PATCH 4/8] PISaaS: bug fix when scans are NOT sequentially numbered * Batch2 small scans are numbered 1, 7, 13, etc. which caused a null pointer exception prior to this commit. --- src/main/java/com/veritomyx/PeakInvestigatorSaaS.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java b/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java index 5d92f55c5..628e1f35d 100644 --- a/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java +++ b/src/main/java/com/veritomyx/PeakInvestigatorSaaS.java @@ -308,8 +308,8 @@ private int getPage(String action, int count, int minMass, int maxMass) RawDataFile[] files = MZmineCore.getProjectManager().getCurrentProject().getDataFiles(); for(RawDataFile file : files) { - int scanCount = file.getNumOfScans(); - for(int scanNum = 1; scanNum <= scanCount; scanNum++) { + int[] scanNumbers = file.getScanNumbers(); + for(int scanNum : scanNumbers) { Scan scan = file.getScan(scanNum); int dpCount = scan.getNumberOfDataPoints(); maxMasses = Math.max(maxMasses.intValue(), dpCount); From ef39b5bedf34d1981add3730301d877850672574 Mon Sep 17 00:00:00 2001 From: Adam Tenderholt Date: Mon, 18 Jan 2016 14:31:43 -0800 Subject: [PATCH 5/8] PIInitDialog: fix to make RTO specification actually work This includes the following changes: * Don't create custom strings for RTO Combobox. Instead, have a new row of text labels that show estimated cost. When the RTO Combobox changes, this text label is updated. * SLA [ed: RTO] & PI Version getters directly call the Combobox getSelectedItems() function instead of relying on an instance variable. --- .../veritomyx/PeakInvestigatorInitDialog.java | 64 ++++++++++--------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java b/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java index f2a4a478e..232b5ec5f 100644 --- a/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java +++ b/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java @@ -33,6 +33,8 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; + + //import net.sf.mzmine.main.MZmineCore; import net.sf.mzmine.util.ExitCode; import net.sf.mzmine.util.GUIUtils; @@ -68,8 +70,9 @@ public class PeakInvestigatorInitDialog extends JDialog implements ActionListene protected JComboBox SLA_list; protected JComboBox PIV_list; + protected JLabel estimatedCost; - protected String SLA_key; + protected Map SLAs; protected String PIV; /** @@ -81,6 +84,8 @@ public PeakInvestigatorInitDialog(Window parent, Double funds, Map SLAs, Strin JLabel PIV_label = new JLabel("Use Peak Investigator Version:"); mainPanel.add(PIV_label, 0, 2); - // Create the 2 combo boxes, filled with the available selections. - String[] r = new String[SLAs.size()]; - int s = 0; - for(String key : SLAs.keySet()) { - r[s] = "RTO: " + key + " Estimate Cost: $" + String.format( "%.2f", SLAs.get(key)); - if(s == 0) - SLA_key = key; - s++; - } - SLA_list = new JComboBox(r); - SLA_list.setEditable(false); - SLA_list.setSelectedIndex(0); - mainPanel.add(SLA_list, 1, 1); - - PIV = PIversions[0]; - PIV_list = new JComboBox(PIversions); - PIV_list.setEditable(false); - PIV_list.setSelectedIndex(0); - mainPanel.add(PIV_list, 1, 2); + // Create the 2 combo boxes, filled with the available selections. + SLA_list = new JComboBox(SLAs.keySet().toArray(new String[SLAs.size()])); + SLA_list.setEditable(false); + SLA_list.setSelectedIndex(0); + SLA_list.addActionListener(this); + mainPanel.add(SLA_list, 1, 1); + + PIV_list = new JComboBox(PIversions); + PIV_list.setEditable(false); + PIV_list.setSelectedIndex(0); + mainPanel.add(PIV_list, 1, 2); + + JLabel costLabel = new JLabel("Estimated cost:"); + mainPanel.add(costLabel, 0, 3); + estimatedCost = new JLabel(formatCost()); + mainPanel.add(estimatedCost, 1, 3); // Add a single empty cell to the 4th row. This cell is expandable // (weightY is 1), therefore the other components will be @@ -192,8 +194,7 @@ public void actionPerformed(ActionEvent ae) { } if (src instanceof JComboBox) { - SLA_key = SLA_list.getSelectedItem().toString(); - PIV = PIV_list.getSelectedItem().toString(); + estimatedCost.setText(formatCost()); } } @@ -221,8 +222,7 @@ public void closeDialog(ExitCode exitCode) { @Override public void changedUpdate(DocumentEvent event) { - SLA_key = SLA_list.getSelectedItem().toString(); - PIV = PIV_list.getSelectedItem().toString(); + System.out.println("changeUpdate called"); } @Override @@ -235,13 +235,17 @@ public void removeUpdate(DocumentEvent event) { } - public String getSLA() - { - return SLA_key; + public String getSLA() { + return SLA_list.getSelectedItem().toString(); + } + + public String getPIversion() { + return PIV_list.getSelectedItem().toString(); } - public String getPIversion() - { - return PIV; + // convenience method to use the selected SLA to return a cost + private String formatCost() { + String currentSelection = SLA_list.getSelectedItem().toString(); + return String.format("$%.2f", SLAs.get(currentSelection)); } } From 4dceb75aa80ffd4d224f3e0c177b4bbe4baf7971 Mon Sep 17 00:00:00 2001 From: Adam Tenderholt Date: Mon, 18 Jan 2016 14:53:48 -0800 Subject: [PATCH 6/8] PIInitDialog: rename various variables * SLAs are now RTOs * Match Java convention that variables start with lower case letter * Variable name to match type where appropriate (e.g. Combobox, not List) --- .../veritomyx/PeakInvestigatorInitDialog.java | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java b/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java index 232b5ec5f..7c875d91a 100644 --- a/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java +++ b/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java @@ -68,25 +68,24 @@ public class PeakInvestigatorInitDialog extends JDialog implements ActionListene */ protected GridBagPanel mainPanel; - protected JComboBox SLA_list; - protected JComboBox PIV_list; - protected JLabel estimatedCost; + protected JComboBox responseTimeObjectiveComboBox; + protected JComboBox versionsComboBox; + protected JLabel estimatedCostLabel; - protected Map SLAs; - protected String PIV; + protected Map responseTimeObjectives; /** * Constructor */ - public PeakInvestigatorInitDialog(Window parent, Double funds, Map SLAs, String[] PIversions) { + public PeakInvestigatorInitDialog(Window parent, Double funds, Map responseTimeObjectives, String[] PIversions) { // Make dialog modal super(parent, "Please set the parameters", Dialog.ModalityType.DOCUMENT_MODAL); - this.SLAs = SLAs; + this.responseTimeObjectives = responseTimeObjectives; - addDialogComponents(funds, SLAs, PIversions); + addDialogComponents(funds, responseTimeObjectives, PIversions); updateMinimumSize(); pack(); @@ -128,21 +127,21 @@ protected void addDialogComponents(Double funds, Map SLAs, Strin mainPanel.add(PIV_label, 0, 2); // Create the 2 combo boxes, filled with the available selections. - SLA_list = new JComboBox(SLAs.keySet().toArray(new String[SLAs.size()])); - SLA_list.setEditable(false); - SLA_list.setSelectedIndex(0); - SLA_list.addActionListener(this); - mainPanel.add(SLA_list, 1, 1); + responseTimeObjectiveComboBox = new JComboBox(SLAs.keySet().toArray(new String[SLAs.size()])); + responseTimeObjectiveComboBox.setEditable(false); + responseTimeObjectiveComboBox.setSelectedIndex(0); + responseTimeObjectiveComboBox.addActionListener(this); + mainPanel.add(responseTimeObjectiveComboBox, 1, 1); - PIV_list = new JComboBox(PIversions); - PIV_list.setEditable(false); - PIV_list.setSelectedIndex(0); - mainPanel.add(PIV_list, 1, 2); + versionsComboBox = new JComboBox(PIversions); + versionsComboBox.setEditable(false); + versionsComboBox.setSelectedIndex(0); + mainPanel.add(versionsComboBox, 1, 2); JLabel costLabel = new JLabel("Estimated cost:"); mainPanel.add(costLabel, 0, 3); - estimatedCost = new JLabel(formatCost()); - mainPanel.add(estimatedCost, 1, 3); + estimatedCostLabel = new JLabel(formatCost()); + mainPanel.add(estimatedCostLabel, 1, 3); // Add a single empty cell to the 4th row. This cell is expandable // (weightY is 1), therefore the other components will be @@ -194,7 +193,7 @@ public void actionPerformed(ActionEvent ae) { } if (src instanceof JComboBox) { - estimatedCost.setText(formatCost()); + estimatedCostLabel.setText(formatCost()); } } @@ -236,16 +235,16 @@ public void removeUpdate(DocumentEvent event) { } public String getSLA() { - return SLA_list.getSelectedItem().toString(); + return responseTimeObjectiveComboBox.getSelectedItem().toString(); } public String getPIversion() { - return PIV_list.getSelectedItem().toString(); + return versionsComboBox.getSelectedItem().toString(); } // convenience method to use the selected SLA to return a cost private String formatCost() { - String currentSelection = SLA_list.getSelectedItem().toString(); - return String.format("$%.2f", SLAs.get(currentSelection)); + String currentSelection = responseTimeObjectiveComboBox.getSelectedItem().toString(); + return String.format("$%.2f", responseTimeObjectives.get(currentSelection)); } } From 3b9275a21f0b42a9f6b13004e09cb15e12090c62 Mon Sep 17 00:00:00 2001 From: Adam Tenderholt Date: Mon, 18 Jan 2016 14:57:58 -0800 Subject: [PATCH 7/8] PIInitDialog: don't impelement DocumentListener & remove its methods * DocumentListener seems unnecessary, since we only need notifications when a combobox changes. --- .../veritomyx/PeakInvestigatorInitDialog.java | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java b/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java index 7c875d91a..d6fb8b0fe 100644 --- a/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java +++ b/src/main/java/com/veritomyx/PeakInvestigatorInitDialog.java @@ -30,10 +30,6 @@ import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - - //import net.sf.mzmine.main.MZmineCore; import net.sf.mzmine.util.ExitCode; @@ -49,8 +45,7 @@ * The first SLA and the highest version of PI are automatically selected to start. * */ -public class PeakInvestigatorInitDialog extends JDialog implements ActionListener, - DocumentListener { +public class PeakInvestigatorInitDialog extends JDialog implements ActionListener { private static final long serialVersionUID = 1L; @@ -218,22 +213,7 @@ public void closeDialog(ExitCode exitCode) { dispose(); } - - @Override - public void changedUpdate(DocumentEvent event) { - System.out.println("changeUpdate called"); - } - @Override - public void insertUpdate(DocumentEvent event) { - - } - - @Override - public void removeUpdate(DocumentEvent event) { - - } - public String getSLA() { return responseTimeObjectiveComboBox.getSelectedItem().toString(); } From b415d9f462987b199303ca90e54f4cc5b72ac468 Mon Sep 17 00:00:00 2001 From: Adam Tenderholt Date: Mon, 18 Jan 2016 17:28:43 -0800 Subject: [PATCH 8/8] PeakInvestigatorTask: minor fixes when downloading results * Filenames are no longer *.vcent.txt but now *.scan.mass_list.txt * Checksum is broken because of changes elsewhere * Verbage fix (i.e. "Extracting" instead of "Reading to") --- .../PeakInvestigator/PeakInvestigatorTask.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorTask.java b/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorTask.java index c01621c33..81d92888a 100644 --- a/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorTask.java +++ b/src/main/java/net/sf/mzmine/modules/rawdatamethods/peakpicking/massdetection/PeakInvestigator/PeakInvestigatorTask.java @@ -362,7 +362,7 @@ private void startRetrieve() while ((tf = tis.getNextEntry()) != null) { if (tf.isDirectory()) continue; - logger.info("Reading peaks data to " + tf.getName() + " - " + tf.getSize() + " bytes"); + logger.info("Extracting peaks data to " + tf.getName() + " - " + tf.getSize() + " bytes"); outputStream = new FileOutputStream(tf.getName()); while ((bytesRead = tis.read(buf, 0, 1024)) > -1) outputStream.write(buf, 0, bytesRead); @@ -400,14 +400,16 @@ private DataPoint[] processScanRetrieve(int scan_num) // read in the peaks for this scan // convert filename to expected peak file name - String pfilename = "scan_" + String.format("%04d", scan_num) + ".vcent.txt"; + String pfilename = "scan_" + String.format("%04d", scan_num) + ".scan.mass_list.txt"; logger.info("Parsing peaks data from " + pfilename); try { File centfile = new File(pfilename); FileChecksum fchksum = new FileChecksum(centfile); - if (!fchksum.verify(false)) - throw new IOException("Invalid checksum"); + fchksum.verify(false); +// TODO: handle checksums +// if (!fchksum.verify(false)) +// throw new IOException("Invalid checksum"); List lines = fchksum.getFileStrings(); mzPeaks = new ArrayList(); @@ -432,7 +434,7 @@ private DataPoint[] processScanRetrieve(int scan_num) } desc = "scan " + scan_num + " parsed"; - return (mzPeaks == null) ? null : mzPeaks.toArray(new DataPoint[0]); + return (mzPeaks == null) ? null : mzPeaks.toArray(new DataPoint[mzPeaks.size()]); } /**