From 3fee991506fbe5e65ceef29f941e1b6660cc9c13 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Thu, 6 Jul 2023 12:57:48 -0400 Subject: [PATCH 01/58] Added Logging Support for Multiple Tools #132 Added logging for BAIIndexer, MergeBAM, and SortBED. A bit unsure about the getCLIcommand arguments for SortBED but it seems to work the way it is. --- .../cli/BAM_Manipulation/BAIIndexerCLI.java | 9 +++++ .../cli/BAM_Manipulation/MergeBAMCLI.java | 13 +++++++- .../BED_Manipulation/SortBEDCLI.java | 11 +++++++ .../scriptmanager/main/ScriptManagerGUI.java | 33 +++++++++++++++++++ .../BAM_Manipulation/BAIIndexerWindow.java | 19 ++++++++++- .../BAM_Manipulation/MergeBAMWindow.java | 19 ++++++++++- .../BED_Manipulation/SortBEDWindow.java | 17 ++++++++++ 7 files changed, 118 insertions(+), 3 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java index 798e75900..410818430 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java @@ -3,6 +3,7 @@ import picocli.CommandLine.Command; import java.util.concurrent.Callable; +import java.io.File; import scriptmanager.objects.ToolDescriptions; @@ -27,4 +28,12 @@ public Integer call() throws Exception { System.exit(1); return(1); } + + public static String getCLIcommand(File BAM) { + String command = "java -jar $PICARD BuildBamIndex"; + command += " INPUT=" + BAM.getAbsolutePath(); + command += " OUTPUT=" + BAM.getAbsolutePath() + ".bai"; + return command; + } + } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/MergeBAMCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/MergeBAMCLI.java index 10e87bbd9..3a59f329f 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/MergeBAMCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/MergeBAMCLI.java @@ -2,7 +2,9 @@ import picocli.CommandLine.Command; +import java.util.ArrayList; import java.util.concurrent.Callable; +import java.io.File; import scriptmanager.objects.ToolDescriptions; @@ -10,7 +12,7 @@ * Print a message redirecting user to the original CLI tool. * * @author Olivia Lang - * @see scriptmanager.scripts.BAM_Manipulation.MergeSamFiles + * @see scriptmanager.scripts.BAM_Manipulation.MergeBAM */ @Command(name = "merge-bam", mixinStandardHelpOptions = true, description = ToolDescriptions.merge_bam_description + "\n"+ @@ -27,4 +29,13 @@ public Integer call() throws Exception { System.exit(1); return(1); } + + public static String getCLIcommand(ArrayList BAMFiles, File OUTPUT) { + String command = "java -jar $PICARD MergeSamFiles"; + for (File input : BAMFiles) { + command += "INPUT=" + input.getAbsolutePath(); + } + command += "OUTPUT=" + OUTPUT.getAbsolutePath(); + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java index 1e211ca19..011c264b3 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java @@ -119,4 +119,15 @@ else if( center<0 ){ return(r); } + + public static String getCLIcommand(File OUTPUT, File BED, File CDT, int startidx, int stopidx, boolean gzOutput) { + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation sortBEDbyCDT"; + command += " " + BED.getAbsolutePath(); + command += " " + CDT.getAbsolutePath(); + command += " " + startidx; + command += " " + stopidx; + command += gzOutput ? " -z" : ""; + command += " -o " + OUTPUT; + return command; + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 422eb6467..af270c57b 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -270,6 +270,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { BAIIndexerWindow frame = new BAIIndexerWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); @@ -365,6 +376,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { MergeBAMWindow frame = new MergeBAMWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); @@ -1035,6 +1057,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { SortBEDWindow frame = new SortBEDWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java index 27dee2d46..1e0dbc3d4 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java @@ -11,6 +11,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.DefaultListModel; @@ -27,6 +29,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import jdk.internal.net.http.common.Log; +import scriptmanager.objects.LogItem; +import scriptmanager.cli.BAM_Manipulation.BAIIndexerCLI; import scriptmanager.util.FileSelection; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; @@ -49,14 +54,24 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws IOException { setProgress(0); + LogItem old_li = null; try { for(int x = 0; x < BAMFiles.size(); x++) { + // Initialize LogItem + String command = BAIIndexerCLI.getCLIcommand(BAMFiles.get(x)); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute Picard wrapper BAIIndexer.generateIndex(BAMFiles.get(x)); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; // Update progress int percentComplete = (int)(((double)(x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } + firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Indexing Complete"); } catch (SAMException se) { @@ -156,7 +171,9 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); - } + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } } public void massXable(Container con, boolean status) { diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java index 3d20bdf4f..9ca222451 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java @@ -30,6 +30,11 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import java.sql.Timestamp; +import java.util.Date; +import scriptmanager.cli.BAM_Manipulation.BAIIndexerCLI; +import scriptmanager.cli.BAM_Manipulation.MergeBAMCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; import scriptmanager.scripts.BAM_Manipulation.MergeBAM; @@ -60,16 +65,26 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws Exception { setProgress(0); + LogItem old_li = null; try { // Build output filepath if(OUT_DIR != null) { OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + txtOutput.getText()); } else { OUTPUT = new File(txtOutput.getText()); } + // Initialize LogItem + String command = MergeBAMCLI.getCLIcommand(BAMFiles, OUTPUT); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute Picard wrapper MergeBAM.run(BAMFiles, OUTPUT, chckbxUseMultipleCpus.isSelected()); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; // Index if checkbox selected if(chckbxGenerateBaiindex.isSelected()) { BAIIndexer.generateIndex(OUTPUT); } + firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Merging Complete"); } catch (SAMException se) { @@ -220,7 +235,9 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); - } + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } } public void massXable(Container con, boolean status) { diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java index fcf13edf4..7e63d00ad 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java @@ -14,6 +14,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.ButtonGroup; import javax.swing.JButton; @@ -31,6 +33,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.BEDtoGFFCLI; +import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.SortBEDCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.CDTUtilities; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -112,7 +117,17 @@ public Void doInBackground() throws IOException { } setProgress(0); + LogItem old_li = new LogItem(""); + // Initialize LogItem + String command = SortBEDCLI.getCLIcommand(new File(OUTPUT), BED_File, CDT_File, START_INDEX, STOP_INDEX, chckbxGzipOutput.isSelected()); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); SortBED.sortBEDbyCDT(OUTPUT, BED_File, CDT_File, START_INDEX, STOP_INDEX, chckbxGzipOutput.isSelected()); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Sort Complete"); } @@ -393,6 +408,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From e002b29f30fe115c9183a239ae9befff7f501cf8 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Tue, 11 Jul 2023 17:52:16 -0400 Subject: [PATCH 02/58] Added Logging Support for BAMtoscIDX #132 Added the logging feature into BAMtoscIDX --- .../BAM_Format_Converter/BAMtoscIDXCLI.java | 15 ++++++++++++++- .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++++++++ .../BAM_Format_Converter/BAMtoscIDXWindow.java | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java index d4b558f3e..8b7c9f5b9 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java @@ -133,7 +133,20 @@ private String validateInput() throws IOException { if( MAX_INSERT Date: Fri, 14 Jul 2023 13:33:35 -0400 Subject: [PATCH 03/58] Added logging to 3 tools #132 Added logging to the 3 remaining BAM Format Converter tools. Still working on adding logging to ExpandBED. --- .../cli/BAM_Format_Converter/BAMtoBEDCLI.java | 14 ++++++++ .../cli/BAM_Format_Converter/BAMtoGFFCLI.java | 14 ++++++++ .../BAMtobedGraphCLI.java | 14 ++++++++ .../BAM_Format_Converter/BAMtoscIDXCLI.java | 2 +- .../BED_Manipulation/ExpandBEDCLI.java | 10 ++++++ .../BED_Manipulation/SortBEDCLI.java | 3 +- .../scriptmanager/main/ScriptManagerGUI.java | 33 +++++++++++++++++++ .../BAM_Format_Converter/BAMtoBEDWindow.java | 17 ++++++++++ .../BAM_Format_Converter/BAMtoGFFWindow.java | 17 ++++++++++ .../BAMtobedGraphWindow.java | 20 +++++++++-- .../BED_Manipulation/ExpandBEDWindow.java | 9 ++++- 11 files changed, 147 insertions(+), 6 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java index 5e0410633..161c0de7a 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java @@ -139,4 +139,18 @@ private String validateInput() throws IOException { return(r); } + public static String getCLIcommand(File BAM, File output, int pair, int strand, int min, int max){ + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-bed"; + command += " " + BAM.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + if (strand != 0) { + command += " -s"; + } + if (pair != 0) { + command += " -p"; + } + command += " -n " + min; + command += " -x " + max; + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java index 5aa923f3a..2468084bb 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java @@ -139,4 +139,18 @@ private String validateInput() throws IOException { return(r); } + public static String getCLIcommand(File BAM, File output, int pair, int strand, int min, int max){ + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-gff"; + command += " " + BAM.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + if (strand != 0) { + command += " -s"; + } + if (pair != 0) { + command += " -p"; + } + command += " -n " + min; + command += " -x " + max; + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java index cb8098f85..492272b68 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java @@ -127,4 +127,18 @@ private String validateInput() throws IOException { return(r); } + public static String getCLIcommand(File BAM, File output, int pair, int strand, int min, int max){ + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-bedGraph"; + command += " " + BAM.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + if (strand != 0) { + command += " -s"; + } + if (pair != 0) { + command += " -p"; + } + command += " -n " + min; + command += " -x " + max; + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java index 8b7c9f5b9..861cceddd 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java @@ -136,7 +136,7 @@ private String validateInput() throws IOException { return(r); } public static String getCLIcommand(File BAM, File output, int pair, int strand, int min, int max){ - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bed-to-scIDX"; + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-scIDX"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); if (strand != 0) { diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java index dc2bda830..169cd4ffd 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java @@ -120,4 +120,14 @@ private String validateInput() throws IOException { return(r); } + public static String getCLIcommand(File bedFile, File output, boolean stdout, boolean gzOutput, int center, int border) { + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation expand-bed"; + command += " " + bedFile.getAbsolutePath(); + command += stdout ? " -s " : ""; + command += gzOutput ? " -z " : ""; + command += " -o " + output.getAbsolutePath(); + command += " -c " + center; + command += " -b " + border; + return command; + } } diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java index 011c264b3..1acfeddfd 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java @@ -124,8 +124,7 @@ public static String getCLIcommand(File OUTPUT, File BED, File CDT, int startidx String command = "java -jar $SCRIPTMANAGER coordinate-manipulation sortBEDbyCDT"; command += " " + BED.getAbsolutePath(); command += " " + CDT.getAbsolutePath(); - command += " " + startidx; - command += " " + stopidx; + command += " -x " + startidx + " " + stopidx; command += gzOutput ? " -z" : ""; command += " -o " + OUTPUT; return command; diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 92b893013..d05910e11 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -492,6 +492,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { BAMtoGFFWindow frame = new BAMtoGFFWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); @@ -521,6 +532,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { BAMtoBEDWindow frame = new BAMtoBEDWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); @@ -550,6 +572,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { BAMtobedGraphWindow frame = new BAMtobedGraphWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java index b9a5da1a2..d38426d29 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java @@ -13,6 +13,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.ButtonGroup; @@ -35,6 +37,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import jdk.internal.net.http.common.Log; +import scriptmanager.cli.BAM_Format_Converter.BAMtoBEDCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") @@ -82,6 +87,7 @@ public Void doInBackground() throws IOException, InterruptedException { "Invalid Maximum & Minimum Insert Sizes!!! Maximum must be larger/equal to Minimum!"); } else { setProgress(0); + LogItem old_li = null; if (rdbtnRead1.isSelected()) { STRAND = 0; } else if (rdbtnRead2.isSelected()) { @@ -108,12 +114,21 @@ public Void doInBackground() throws IOException, InterruptedException { } for (int x = 0; x < BAMFiles.size(); x++) { + // Initialize LogItem + String command = BAMtoBEDCLI.getCLIcommand(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); BAMtoBEDOutput convert = new BAMtoBEDOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); convert.setVisible(true); convert.run(); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } + firePropertyChange("log", old_li, null); setProgress(100); return null; } @@ -369,6 +384,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java index 48b0e9fe1..ba1fdd8b9 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java @@ -13,6 +13,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.ButtonGroup; @@ -35,6 +37,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.cli.BAM_Format_Converter.BAMtoBEDCLI; +import scriptmanager.cli.BAM_Format_Converter.BAMtoGFFCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") @@ -82,6 +87,7 @@ public Void doInBackground() throws IOException, InterruptedException { "Invalid Maximum & Minimum Insert Sizes!!! Maximum must be larger/equal to Minimum!"); } else { setProgress(0); + LogItem old_li = null; if (rdbtnRead1.isSelected()) { STRAND = 0; } else if (rdbtnRead2.isSelected()) { @@ -108,12 +114,21 @@ public Void doInBackground() throws IOException, InterruptedException { } for (int x = 0; x < BAMFiles.size(); x++) { + // Initialize LogItem + String command = BAMtoGFFCLI.getCLIcommand(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); BAMtoGFFOutput convert = new BAMtoGFFOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); convert.setVisible(true); convert.run(); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } + firePropertyChange("log", old_li, null); setProgress(100); return null; } @@ -369,6 +384,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java index 6270f4e1b..a53b6ec56 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java @@ -13,6 +13,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.ButtonGroup; @@ -35,6 +37,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.cli.BAM_Format_Converter.BAMtoGFFCLI; +import scriptmanager.cli.BAM_Format_Converter.BAMtobedGraphCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") @@ -81,6 +86,7 @@ public Void doInBackground() throws IOException, InterruptedException { "Invalid Maximum & Minimum Insert Sizes!!! Maximum must be larger/equal to Minimum!"); } else { setProgress(0); + LogItem old_li = null; if (rdbtnRead1.isSelected()) { STRAND = 0; } else if (rdbtnRead2.isSelected()) { @@ -105,13 +111,21 @@ public Void doInBackground() throws IOException, InterruptedException { } for (int x = 0; x < BAMFiles.size(); x++) { - BAMtobedGraphOutput convert = new BAMtobedGraphOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, - MIN, MAX); + // Initialize LogItem + String command = BAMtobedGraphCLI.getCLIcommand(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + BAMtobedGraphOutput convert = new BAMtobedGraphOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); convert.setVisible(true); convert.run(); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } + firePropertyChange("log", old_li, null); setProgress(100); return null; } @@ -349,6 +363,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java index ca487fb24..d8e86b35b 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java @@ -34,6 +34,9 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.ExpandBEDCLI; +import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.SortBEDCLI; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Coordinate_Manipulation.BED_Manipulation.ExpandBED; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -80,6 +83,7 @@ public Void doInBackground() throws IOException { JOptionPane.showMessageDialog(null, "Invalid Expansion Size!!! Must be larger than 0 bp"); } else { setProgress(0); + LogItem old_li = new LogItem(""); for (int x = 0; x < BEDFiles.size(); x++) { // Save current BED to temp variable File XBED = BEDFiles.get(x); @@ -96,7 +100,10 @@ public Void doInBackground() throws IOException { // Add suffix OUTPUT += "_" + Integer.toString(SIZE) + "bp.bed"; OUTPUT += chckbxGzipOutput.isSelected() ? ".gz" : ""; - + // Initialize LogItem + /*String command = ExpandBEDCLI.getCLIcommand(XBED, OUTPUT, ) + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li);*/ // Execute expansion and update progress ExpandBED.expandBEDBorders(new File(OUTPUT), XBED, SIZE, rdbtnExpandFromCenter.isSelected(), chckbxGzipOutput.isSelected()); int percentComplete = (int) (((double) (x + 1) / BEDFiles.size()) * 100); From 44a08c4426e66f7be7b8abd56c2eb8a1ed33730a Mon Sep 17 00:00:00 2001 From: Erikpav Date: Mon, 17 Jul 2023 14:29:18 -0400 Subject: [PATCH 04/58] Added Logging Support to SortBAM #132 Added logging to SortBAM --- .../cli/BAM_Manipulation/SortBAMCLI.java | 8 ++++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 ++++++++++ .../BAM_Manipulation/SortBAMWindow.java | 20 ++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/SortBAMCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/SortBAMCLI.java index 76f50c409..5e791a277 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/SortBAMCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/SortBAMCLI.java @@ -3,6 +3,7 @@ import picocli.CommandLine.Command; import java.util.concurrent.Callable; +import java.io.File; import scriptmanager.objects.ToolDescriptions; @@ -27,4 +28,11 @@ public Integer call() throws Exception { System.exit(1); return(1); } + + public static String getCLIcommand(File BAM, File output) { + String command = "java -jar $PICARD SortSam"; + command += " INPUT=" + BAM.getAbsolutePath(); + command += " OUTPUT=" + output.getAbsolutePath(); + return(command); + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index d05910e11..08e0fb145 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -309,6 +309,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { SortBAMWindow frame = new SortBAMWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java index 2cf424940..5a9441fec 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java @@ -12,7 +12,9 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.swing.DefaultListModel; @@ -30,6 +32,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.cli.BAM_Manipulation.BAIIndexerCLI; +import scriptmanager.cli.BAM_Manipulation.SortBAMCLI; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Manipulation.BAMFileSort; import scriptmanager.util.FileSelection; @@ -56,6 +61,8 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws Exception { setProgress(0); + LogItem old_li = null; + try { for(int x = 0; x < BAMFiles.size(); x++) { // Build output filepath @@ -63,13 +70,22 @@ public Void doInBackground() throws Exception { File OUTPUT = null; if(OUT_DIR != null) { OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME[0] + "_sorted.bam"); } else { OUTPUT = new File(NAME[0] + "_sorted.bam"); } + // Initialize LogItem + String command = SortBAMCLI.getCLIcommand(BAMFiles.get(x), OUTPUT); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute Picard wrapper BAMFileSort.sort(BAMFiles.get(x), OUTPUT); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; // Update progress int percentComplete = (int)(((double)(x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } + firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Sorting Complete"); } catch (SAMException se) { @@ -195,7 +211,9 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); - } + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } } public void massXable(Container con, boolean status) { From d59fec5f8b58f5683417b8235fb51bb98ac27b71 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Tue, 18 Jul 2023 16:13:13 -0400 Subject: [PATCH 05/58] Added Logging Support for FilterforPIPseq #132 Added the logging feature to FilterforPIPseq --- .../BAM_Manipulation/FilterforPIPseqCLI.java | 8 +++++++ .../BED_Manipulation/SortBEDCLI.java | 2 +- .../scriptmanager/main/ScriptManagerGUI.java | 11 ++++++++++ .../FilterforPIPseqWindow.java | 21 +++++++++++++++++-- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java index be926e6ef..90caa15f4 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java @@ -126,4 +126,12 @@ private String validateInput() throws IOException { return (r); } + public static String getCLIcommand(File BAM, File GENOME, File OUTPUT, String txtSeq) { + String command = "java -jar $SCRIPTMANAGER bam-manipulation filterforPIPseq"; + command += " " + GENOME.getAbsolutePath(); + command += " " + BAM.getAbsolutePath(); + command += " -o " + OUTPUT.getAbsolutePath(); + command += " -f " + txtSeq; + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java index 1acfeddfd..836658b06 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java @@ -126,7 +126,7 @@ public static String getCLIcommand(File OUTPUT, File BED, File CDT, int startidx command += " " + CDT.getAbsolutePath(); command += " -x " + startidx + " " + stopidx; command += gzOutput ? " -z" : ""; - command += " -o " + OUTPUT; + command += " -o " + OUTPUT.getAbsolutePath(); return command; } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 08e0fb145..77bfd1c8b 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -429,6 +429,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { FilterforPIPseqWindow frame = new FilterforPIPseqWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java index 0cf64b8d1..0014bc2f2 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java @@ -11,7 +11,9 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.swing.DefaultListModel; @@ -32,6 +34,9 @@ import javax.swing.JTextField; import javax.swing.SwingConstants; +import scriptmanager.cli.BAM_Manipulation.FilterforPIPseqCLI; +import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.SortBEDCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; @@ -64,6 +69,7 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws Exception { setProgress(0); + LogItem old_li = new LogItem(""); try { for (int x = 0; x < BAMFiles.size(); x++) { String[] NAME = BAMFiles.get(x).getName().split("\\."); @@ -73,8 +79,16 @@ public Void doInBackground() throws Exception { } else { OUTPUT = new File(NAME[0] + "_PSfilter.bam"); } - FilterforPIPseqOutput filter = new FilterforPIPseqOutput(BAMFiles.get(x), GENOME, OUTPUT, - txtSeq.getText()); + // Initialize LogItem + String command = FilterforPIPseqCLI.getCLIcommand(BAMFiles.get(x), GENOME, OUTPUT, txtSeq.getText()); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute Wrapper + FilterforPIPseqOutput filter = new FilterforPIPseqOutput(BAMFiles.get(x), GENOME, OUTPUT, txtSeq.getText()); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; filter.setVisible(true); filter.run(); @@ -85,6 +99,7 @@ public Void doInBackground() throws Exception { int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } + firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Permanganate-Seq Filtering Complete"); } catch (IOException ioe) { @@ -250,6 +265,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From 19582254a961fc70b03e4bf786fce339b729e60b Mon Sep 17 00:00:00 2001 From: Erikpav Date: Wed, 19 Jul 2023 18:15:06 -0400 Subject: [PATCH 06/58] Added Logging to MergeHeatMap #132 Added logging support to MergeHeatMap. I am unsure about this implementation due to the differing inputs/outputs when comparing the window class to the flags. I grabbed the Arraylist to File conversion from MergeHeatMap output and it seems to work fine. Along with this all BAM format converter strain flags were replaced with the proper if else statements and outputs rather than just an -s flag. --- .../cli/BAM_Format_Converter/BAMtoBEDCLI.java | 12 ++++++++-- .../cli/BAM_Format_Converter/BAMtoGFFCLI.java | 12 ++++++++-- .../BAMtobedGraphCLI.java | 10 +++++++-- .../BAM_Format_Converter/BAMtoscIDXCLI.java | 14 ++++++++---- .../BED_Manipulation/ExpandBEDCLI.java | 3 +-- .../Figure_Generation/MergeHeatMapCLI.java | 22 +++++++++++++++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 ++++++++++ .../BAM_Manipulation/BAMMarkDupWindow.java | 1 - .../BED_Manipulation/ExpandBEDWindow.java | 7 ++++-- .../Figure_Generation/MergeHeatMapWindow.java | 20 ++++++++++++++--- 10 files changed, 94 insertions(+), 18 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java index 161c0de7a..16794487e 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java @@ -143,8 +143,16 @@ public static String getCLIcommand(File BAM, File output, int pair, int strand, String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-bed"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); - if (strand != 0) { - command += " -s"; + if (strand == 0) { + command += " -1 "; + } else if (strand == 1) { + command += " -2 "; + } else if (strand == 2) { + command += " -a "; + } else if (strand == 3 ) { + command += " -m "; + } else if (strand == 4) { + command += " -f "; } if (pair != 0) { command += " -p"; diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java index 2468084bb..a62795ace 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java @@ -143,8 +143,16 @@ public static String getCLIcommand(File BAM, File output, int pair, int strand, String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-gff"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); - if (strand != 0) { - command += " -s"; + if (strand == 0) { + command += " -1 "; + } else if (strand == 1) { + command += " -2 "; + } else if (strand == 2) { + command += " -a "; + } else if (strand == 3 ) { + command += " -m "; + } else if (strand == 4) { + command += " -f "; } if (pair != 0) { command += " -p"; diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java index 492272b68..5aa14dd5f 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java @@ -131,8 +131,14 @@ public static String getCLIcommand(File BAM, File output, int pair, int strand, String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-bedGraph"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); - if (strand != 0) { - command += " -s"; + if (strand == 0) { + command += " -1 "; + } else if (strand == 1) { + command += " -2 "; + } else if (strand == 2) { + command += " -a "; + } else if (strand == 3 ) { + command += " -m "; } if (pair != 0) { command += " -p"; diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java index 861cceddd..023fca3c9 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java @@ -139,11 +139,17 @@ public static String getCLIcommand(File BAM, File output, int pair, int strand, String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-scIDX"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); - if (strand != 0) { - command += " -s"; + if (strand == 0) { + command += " -1 "; + } else if (strand == 1) { + command += " -2 "; + } else if (strand == 2) { + command += " -a "; + } else if (strand == 3 ) { + command += " -m "; } - if (pair != 0) { - command += " -p"; + if (pair != 0) { + command += " -p "; } command += " -n " + min; command += " -x " + max; diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java index 169cd4ffd..c02ea1a74 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java @@ -120,10 +120,9 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File bedFile, File output, boolean stdout, boolean gzOutput, int center, int border) { + public static String getCLIcommand(File bedFile, File output, boolean gzOutput, int center, int border) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation expand-bed"; command += " " + bedFile.getAbsolutePath(); - command += stdout ? " -s " : ""; command += gzOutput ? " -z " : ""; command += " -o " + output.getAbsolutePath(); command += " -c " + center; diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java index 10e527045..9dc6ecaad 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java @@ -7,6 +7,7 @@ import java.lang.NullPointerException; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.concurrent.Callable; import scriptmanager.objects.ToolDescriptions; @@ -98,4 +99,25 @@ private String validateInput() throws IOException { return (r); } + public static String getCLIcommand(ArrayList pngFiles, File outdir) { + String command = "java -jar $SCRIPTMANAGER figure-generation MergeHeatMap"; + File antiFile = null; + File senseFile = null; + for (int x = 0; x < pngFiles.size(); x++) { + if (pngFiles.get(x).getName().toLowerCase().contains("sense")) { + senseFile = (pngFiles.get(x)); + } else if (pngFiles.get(x).getName().toLowerCase().contains("anti")) { + antiFile = (pngFiles.get(x)); + } + } + if (antiFile != null) { + command += " " + antiFile.getAbsolutePath(); + } + if (senseFile != null) { + command += " " + senseFile.getAbsolutePath(); + } + command += " -o " + outdir.getAbsolutePath() + "merge.png"; + return command; + } + } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 77bfd1c8b..9a7ba3a41 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1558,6 +1558,17 @@ public void actionPerformed(ActionEvent arg0) { public void run() { try { MergeHeatMapWindow frame = new MergeHeatMapWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java index 24f51b46e..fa013691e 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java @@ -229,7 +229,6 @@ public void propertyChange(PropertyChangeEvent evt) { progressBar.setValue(progress); } else if ("log" == evt.getPropertyName()) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); - } } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java index d8e86b35b..4fef2e3f2 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java @@ -100,10 +100,13 @@ public Void doInBackground() throws IOException { // Add suffix OUTPUT += "_" + Integer.toString(SIZE) + "bp.bed"; OUTPUT += chckbxGzipOutput.isSelected() ? ".gz" : ""; + /* // Initialize LogItem - /*String command = ExpandBEDCLI.getCLIcommand(XBED, OUTPUT, ) + String command = ExpandBEDCLI.getCLIcommand(XBED, OUTPUT, chckbxGzipOutput.isSelected(), SIZE); LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li);*/ + firePropertyChange("log", old_li, new_li); + + */ // Execute expansion and update progress ExpandBED.expandBEDBorders(new File(OUTPUT), XBED, SIZE, rdbtnExpandFromCenter.isSelected(), chckbxGzipOutput.isSelected()); int percentComplete = (int) (((double) (x + 1) / BEDFiles.size()) * 100); diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java index ff37e4f62..095d9e7c0 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java @@ -11,7 +11,9 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import javax.swing.DefaultListModel; import javax.swing.JButton; @@ -27,6 +29,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.cli.BAM_Manipulation.BAMRemoveDupCLI; +import scriptmanager.cli.Figure_Generation.MergeHeatMapCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") @@ -52,9 +57,12 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws IOException { setProgress(0); - + LogItem old_li = null; + // Initialize LogItem + String command = MergeHeatMapCLI.getCLIcommand(pngFiles, OUT_DIR); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); MergeHeatMapOutput heat = new MergeHeatMapOutput(pngFiles, OUT_DIR); - heat.addPropertyChangeListener("merge", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); @@ -65,7 +73,11 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { heat.setVisible(true); heat.run(); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + firePropertyChange("log", old_li, null); setProgress(100); return null; } @@ -191,6 +203,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From fee8205f683366e2fd317ac090a080e0903a60fd Mon Sep 17 00:00:00 2001 From: Erikpav Date: Sat, 22 Jul 2023 14:56:09 -0400 Subject: [PATCH 07/58] Added Logging to ExpandBED #132 Added logging support to ExpandBED --- .../BED_Manipulation/ExpandBEDCLI.java | 5 ++--- .../java/scriptmanager/main/ScriptManagerGUI.java | 11 +++++++++++ .../BED_Manipulation/ExpandBEDWindow.java | 15 +++++++++++---- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java index c02ea1a74..391509b83 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java @@ -120,13 +120,12 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File bedFile, File output, boolean gzOutput, int center, int border) { + public static String getCLIcommand(File bedFile, File output, boolean gzOutput, boolean byCenter) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation expand-bed"; command += " " + bedFile.getAbsolutePath(); command += gzOutput ? " -z " : ""; command += " -o " + output.getAbsolutePath(); - command += " -c " + center; - command += " -b " + border; + command += byCenter ? " -c " : " -b "; return command; } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 9a7ba3a41..a66daf391 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1030,6 +1030,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { ExpandBEDWindow frame = new ExpandBEDWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java index 4fef2e3f2..8598ca318 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java @@ -2,6 +2,8 @@ import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.JFileChooser; @@ -100,18 +102,21 @@ public Void doInBackground() throws IOException { // Add suffix OUTPUT += "_" + Integer.toString(SIZE) + "bp.bed"; OUTPUT += chckbxGzipOutput.isSelected() ? ".gz" : ""; - /* + // Initialize LogItem - String command = ExpandBEDCLI.getCLIcommand(XBED, OUTPUT, chckbxGzipOutput.isSelected(), SIZE); + String command = ExpandBEDCLI.getCLIcommand(XBED, new File(OUTPUT), chckbxGzipOutput.isSelected(), rdbtnExpandFromCenter.isSelected()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); - - */ // Execute expansion and update progress ExpandBED.expandBEDBorders(new File(OUTPUT), XBED, SIZE, rdbtnExpandFromCenter.isSelected(), chckbxGzipOutput.isSelected()); int percentComplete = (int) (((double) (x + 1) / BEDFiles.size()) * 100); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; setProgress(percentComplete); } + firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Conversion Complete"); } @@ -275,6 +280,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From 52c097344680ab7b46e95ad59623743c71ababb9 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Sat, 22 Jul 2023 18:34:14 -0400 Subject: [PATCH 08/58] Added Logging to GFFtoBED #132 Adding the logging feature to GFFtoBED --- .../GFF_Manipulation/GFFtoBEDCLI.java | 6 ++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++++++++ .../GFF_Manipulation/GFFtoBEDWindow.java | 18 +++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java index 0470f055b..88e475d09 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java @@ -74,4 +74,10 @@ private String validateInput() throws IOException { return(r); } + public static String getCLIcommand(File GFF, File output) { + String command = "java -jar $SCRIPTMANAGER gff-manipulation gff-to-bed"; + command += " " + GFF.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + return command; + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index a66daf391..bfba04519 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1112,6 +1112,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { GFFtoBEDWindow frame = new GFFtoBEDWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java index 062f84324..5ff266900 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java @@ -11,6 +11,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.DefaultListModel; @@ -28,6 +30,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.cli.BAM_Format_Converter.BAMtoGFFCLI; +import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.GFFtoBEDCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; import scriptmanager.scripts.Coordinate_Manipulation.GFF_Manipulation.GFFtoBED; @@ -54,6 +59,7 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws IOException { setProgress(0); + LogItem old_li = null; for (int x = 0; x < BEDFiles.size(); x++) { File XGFF = BEDFiles.get(x); // Set outfilepath @@ -61,12 +67,20 @@ public Void doInBackground() throws IOException { if (OUT_DIR != null) { OUTPUT = OUT_DIR + File.separator + OUTPUT; } - + // Initialize LogItem + String command = GFFtoBEDCLI.getCLIcommand(XGFF, new File(OUTPUT)); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute conversion and update progress GFFtoBED.convertGFFtoBED(new File(OUTPUT), XGFF); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; int percentComplete = (int) (((double) (x + 1) / BEDFiles.size()) * 100); setProgress(percentComplete); } + firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Conversion Complete"); return null; @@ -189,6 +203,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From af1f6885baedd1f364c80eb1d148cac13639fe30 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Mon, 24 Jul 2023 14:50:59 -0400 Subject: [PATCH 09/58] Added Logging to ExpandGFF and SortGFF #132 Added the logging feature to ExpandGFF and SortGFF. Did some minor tweaking to ExpandBED and SortBED. --- .../BED_Manipulation/BEDtoGFFCLI.java | 2 +- .../BED_Manipulation/ExpandBEDCLI.java | 6 ++--- .../BED_Manipulation/SortBEDCLI.java | 2 +- .../GFF_Manipulation/ExpandGFFCLI.java | 7 ++++++ .../GFF_Manipulation/SortGFFCLI.java | 8 +++++++ .../scriptmanager/main/ScriptManagerGUI.java | 22 +++++++++++++++++++ .../BED_Manipulation/ExpandBEDWindow.java | 2 +- .../BED_Manipulation/SortBEDWindow.java | 1 + .../GFF_Manipulation/ExpandGFFWindow.java | 18 ++++++++++++++- .../GFF_Manipulation/SortGFFWindow.java | 18 +++++++++++++++ 10 files changed, 79 insertions(+), 7 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java index 9822b2f70..1a2772333 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java @@ -84,7 +84,7 @@ private String validateInput() throws IOException { } public static String getCLIcommand(File OUTPUT, File BED, boolean gzOutput) { - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bed-to-gff"; + String command = "java -jar $SCRIPTMANAGER bed-manipulation bed-to-gff"; command += " " + BED.getAbsolutePath(); command += gzOutput ? " -z" : ""; command += " -o " + OUTPUT; diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java index 391509b83..d08ff094d 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java @@ -120,12 +120,12 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File bedFile, File output, boolean gzOutput, boolean byCenter) { - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation expand-bed"; + public static String getCLIcommand(File bedFile, File output, int size, boolean gzOutput, boolean byCenter) { + String command = "java -jar $SCRIPTMANAGER bed-manipulation expand-bed"; command += " " + bedFile.getAbsolutePath(); command += gzOutput ? " -z " : ""; command += " -o " + output.getAbsolutePath(); - command += byCenter ? " -c " : " -b "; + command += byCenter ? " -c " + size : " -b " + size; return command; } } diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java index 836658b06..a14eefce9 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java @@ -121,7 +121,7 @@ else if( center<0 ){ } public static String getCLIcommand(File OUTPUT, File BED, File CDT, int startidx, int stopidx, boolean gzOutput) { - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation sortBEDbyCDT"; + String command = "java -jar $SCRIPTMANAGER bed-manipulation sortBED"; command += " " + BED.getAbsolutePath(); command += " " + CDT.getAbsolutePath(); command += " -x " + startidx + " " + stopidx; diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java index 16d9c0009..836658808 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java @@ -117,4 +117,11 @@ private String validateInput() throws IOException { return(r); } + public static String getCLIcommand(File bedFile, File output, int size, boolean byCenter) { + String command = "java -jar $SCRIPTMANAGER gff-manipulation expand-gff"; + command += " " + bedFile.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + command += byCenter ? " -c " + size : " -b " + size; + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java index a277e4aad..9ca304aed 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java @@ -121,4 +121,12 @@ else if( center<0 ){ return(r); } + public static String getCLIcommand(File OUTPUT, File BED, File CDT, int startidx, int stopidx) { + String command = "java -jar $SCRIPTMANAGER gff-manipulation sortGFF"; + command += " " + BED.getAbsolutePath(); + command += " " + CDT.getAbsolutePath(); + command += " -x " + startidx + " " + stopidx; + command += " -o " + OUTPUT.getAbsolutePath(); + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index bfba04519..628cea01d 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1060,6 +1060,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { ExpandGFFWindow frame = new ExpandGFFWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); @@ -1175,6 +1186,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { SortGFFWindow frame = new SortGFFWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java index 8598ca318..a699fd631 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java @@ -104,7 +104,7 @@ public Void doInBackground() throws IOException { OUTPUT += chckbxGzipOutput.isSelected() ? ".gz" : ""; // Initialize LogItem - String command = ExpandBEDCLI.getCLIcommand(XBED, new File(OUTPUT), chckbxGzipOutput.isSelected(), rdbtnExpandFromCenter.isSelected()); + String command = ExpandBEDCLI.getCLIcommand(XBED, new File(OUTPUT), SIZE, chckbxGzipOutput.isSelected(), rdbtnExpandFromCenter.isSelected()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute expansion and update progress diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java index 7e63d00ad..081279bcd 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java @@ -122,6 +122,7 @@ public Void doInBackground() throws IOException { String command = SortBEDCLI.getCLIcommand(new File(OUTPUT), BED_File, CDT_File, START_INDEX, STOP_INDEX, chckbxGzipOutput.isSelected()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); + // Execute Wrapper SortBED.sortBEDbyCDT(OUTPUT, BED_File, CDT_File, START_INDEX, STOP_INDEX, chckbxGzipOutput.isSelected()); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java index 8886018eb..d9638f449 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java @@ -2,6 +2,8 @@ import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.JFileChooser; @@ -33,6 +35,9 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.ExpandBEDCLI; +import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.ExpandGFFCLI; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Coordinate_Manipulation.GFF_Manipulation.ExpandGFF; import scriptmanager.util.FileSelection; @@ -69,6 +74,7 @@ public Void doInBackground() throws IOException { JOptionPane.showMessageDialog(null, "Invalid Expansion Size!!! Must be larger than 0 bp"); } else { setProgress(0); + LogItem old_li = new LogItem(""); for (int x = 0; x < GFFFiles.size(); x++) { File XGFF = GFFFiles.get(x); @@ -78,12 +84,20 @@ public Void doInBackground() throws IOException { if (OUT_DIR != null) { OUTPUT = OUT_DIR + File.separator + OUTPUT; } - + // Initialize LogItem + String command = ExpandGFFCLI.getCLIcommand(XGFF, new File(OUTPUT), SIZE, rdbtnExpandFromCenter.isSelected()); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute expansion and update progress ExpandGFF.expandGFFBorders(new File(OUTPUT), XGFF, SIZE, rdbtnExpandFromCenter.isSelected()); int percentComplete = (int) (((double) (x + 1) / GFFFiles.size()) * 100); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; setProgress(percentComplete); } + firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Conversion Complete"); } @@ -239,6 +253,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java index 0ece0b3ef..a2e88772f 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java @@ -14,6 +14,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.ButtonGroup; import javax.swing.JButton; @@ -30,6 +32,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.SortBEDCLI; +import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.SortGFFCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.CDTUtilities; import scriptmanager.util.FileSelection; import scriptmanager.scripts.Coordinate_Manipulation.GFF_Manipulation.SortGFF; @@ -98,7 +103,18 @@ public Void doInBackground() throws IOException { } setProgress(0); + LogItem old_li = new LogItem(""); + // Initialize LogItem + String command = SortGFFCLI.getCLIcommand(new File(OUTPUT), GFF_File, CDT_File, START_INDEX, STOP_INDEX); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute Wrapper SortGFF.sortGFFbyCDT(OUTPUT, GFF_File, CDT_File, START_INDEX, STOP_INDEX); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Sort Complete"); } @@ -349,6 +365,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From 563c0f8dddfe96a3318015cf621d9f205b30ffe0 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Tue, 25 Jul 2023 14:19:27 -0400 Subject: [PATCH 10/58] Added Logging to LabelHeatMap #132 Added logging support to LabelHeatMap. Refactored logging for MergeHeatMap. I am unsure about these two tools as I believe the logging works but I am not familiar with these tools so if something is not working properly I am not aware of it. --- .../Figure_Generation/LabelHeatMapCLI.java | 21 +++++++++++++++++++ .../Figure_Generation/MergeHeatMapCLI.java | 19 +++-------------- .../scriptmanager/main/ScriptManagerGUI.java | 11 ++++++++++ .../Figure_Generation/LabelHeatMapOutput.java | 20 +++++++++++++++--- .../Figure_Generation/LabelHeatMapWindow.java | 7 +++++++ .../Figure_Generation/MergeHeatMapOutput.java | 16 ++++++++++++-- .../Figure_Generation/MergeHeatMapWindow.java | 16 +++++--------- 7 files changed, 78 insertions(+), 32 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java index df3d72fad..c8e4f4406 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java @@ -7,6 +7,7 @@ import java.awt.Color; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.concurrent.Callable; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -112,5 +113,25 @@ private String validateInput() throws IOException { } return(r); } + + public static String getCLIcommand(File input, File output, Color color, int borderWidth, + int xTickHeight, int fontSize, String llabel, String mlabel, + String rlabel, String xlabel, String ylabel) { + String command = "java -jar $SCRIPTMANAGER figure-generation LabelHeatMap"; + command += " " + input.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + // Converts RGB format color to hexadecimal + String hex = "#"+Integer.toHexString(color.getRGB()).substring(2); + command += " -c " + hex; + command += " -w " + borderWidth; + command += " -t " + xTickHeight; + command += " -f " + fontSize; + command += " -l " + llabel; + command += " -m " + mlabel; + command += " -r " + rlabel; + command += " -x " + xlabel; + command += " -y " + ylabel; + return command; + } } diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java index 9dc6ecaad..f731236a3 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java @@ -99,23 +99,10 @@ private String validateInput() throws IOException { return (r); } - public static String getCLIcommand(ArrayList pngFiles, File outdir) { + public static String getCLIcommand(File senseFile, File antiFile, File outdir) { String command = "java -jar $SCRIPTMANAGER figure-generation MergeHeatMap"; - File antiFile = null; - File senseFile = null; - for (int x = 0; x < pngFiles.size(); x++) { - if (pngFiles.get(x).getName().toLowerCase().contains("sense")) { - senseFile = (pngFiles.get(x)); - } else if (pngFiles.get(x).getName().toLowerCase().contains("anti")) { - antiFile = (pngFiles.get(x)); - } - } - if (antiFile != null) { - command += " " + antiFile.getAbsolutePath(); - } - if (senseFile != null) { - command += " " + senseFile.getAbsolutePath(); - } + command += " " + antiFile.getAbsolutePath(); + command += " " + senseFile.getAbsolutePath(); command += " -o " + outdir.getAbsolutePath() + "merge.png"; return command; } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 628cea01d..14c10f287 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1642,6 +1642,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { LabelHeatMapWindow frame = new LabelHeatMapWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java index bfbab2911..a779640b2 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java @@ -13,8 +13,11 @@ import javax.swing.JTabbedPane; import javax.swing.JTextArea; +import scriptmanager.cli.Figure_Generation.LabelHeatMapCLI; +import scriptmanager.cli.Figure_Generation.MergeHeatMapCLI; import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Figure_Generation.LabelHeatMap; @SuppressWarnings("serial") @@ -66,26 +69,37 @@ public LabelHeatMapOutput(ArrayList in, File out_dir, Color c, } public void run() throws IOException, OptionException { + LogItem old_li = null; for (int x = 0; x < SAMPLE.size(); x++) { File OUTPUT = new File(SAMPLE.get(x).getName().split("\\.")[0] + "_label.svg"); if (OUT_DIR != null) { OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + OUTPUT.getName()); } - + old_li = new LogItem(""); JTextArea textArea = new JTextArea(); // Output image/error to GUI newpane.addTab(OUTPUT.getName(), new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); PrintStream jtxtPrintStream = new PrintStream(new CustomOutputStream(textArea)); - + // Initialize LogItem + String command = LabelHeatMapCLI.getCLIcommand(SAMPLE.get(x), OUTPUT, color, + borderWidth, xTickHeight, fontSize, + xLeftLabel, xMidLabel, xRightLabel, + xLabel, yLabel); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute script LabelHeatMap script_obj = new LabelHeatMap(SAMPLE.get(x), OUTPUT, color, borderWidth, xTickHeight, fontSize, xLeftLabel, xMidLabel, xRightLabel, xLabel, yLabel, jtxtPrintStream); script_obj.run(); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; firePropertyChange("heat", x, x + 1); } + firePropertyChange("log", old_li, null); System.out.println("Program Complete"); System.out.println(getTimeStamp()); } diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java index 95cb20f03..0c23d5f31 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java @@ -98,6 +98,11 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { setProgress(percentComplete); } }); + out_win.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); out_win.setVisible(true); out_win.run(); @@ -452,6 +457,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapOutput.java index b869c217e..fcb6cffc4 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapOutput.java @@ -9,8 +9,12 @@ import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; +import scriptmanager.cli.Figure_Generation.MergeHeatMapCLI; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Figure_Generation.MergeHeatMapPlot; @SuppressWarnings("serial") @@ -44,7 +48,7 @@ public void run() throws IOException { antiFile.add(pngFiles.get(x)); } } - + LogItem old_li = new LogItem(""); for (int x = 0; x < senseFile.size(); x++) { String name = senseFile.get(x).getName(); String out = name.substring(0, name.lastIndexOf("sense")); @@ -58,7 +62,10 @@ public void run() throws IOException { if (OUT_DIR != null) { OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + OUTPUT.getName()); } - + // Initialize LogItem + String command = MergeHeatMapCLI.getCLIcommand(senseFile.get(x), antiFile.get(x), OUTPUT); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Store results in JFrame window if (matchIndex != -999) { // Execute script @@ -68,8 +75,13 @@ public void run() throws IOException { JLabel pic = MergeHeatMapPlot.mergePNG(senseFile.get(x), null, OUTPUT); addImage(OUTPUT.getName(), pic); } + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; firePropertyChange("merge", x, x + 1); } + firePropertyChange("log", old_li, null); } private void addImage(String name, JLabel pic) { diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java index 095d9e7c0..55f554334 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java @@ -57,11 +57,6 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws IOException { setProgress(0); - LogItem old_li = null; - // Initialize LogItem - String command = MergeHeatMapCLI.getCLIcommand(pngFiles, OUT_DIR); - LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); MergeHeatMapOutput heat = new MergeHeatMapOutput(pngFiles, OUT_DIR); heat.addPropertyChangeListener("merge", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { @@ -70,14 +65,13 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { setProgress(percentComplete); } }); - + heat.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); heat.setVisible(true); heat.run(); - // Update log item - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; - firePropertyChange("log", old_li, null); setProgress(100); return null; } From b9e81a54816808a50c471de2130597c394312eef Mon Sep 17 00:00:00 2001 From: Erikpav Date: Tue, 25 Jul 2023 23:10:18 -0400 Subject: [PATCH 11/58] Added Logging to TwoColorHeatMap #132 Added logging support to TwoColorHeatMap using similar code to the other two figure generation tools to get logging support. I am still unsure if the functionality is perfect. --- .../Figure_Generation/TwoColorHeatMapCLI.java | 27 +++++++++++++++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 ++++++++ .../TwoColorHeatMapOutput.java | 17 ++++++++++-- .../TwoColorHeatMapWindow.java | 8 +++++- 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java index 18307dca8..01e0653aa 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java @@ -165,4 +165,31 @@ private String validateInput() throws IOException { return (r); } + + public static String getCLIcommand(File input, File output, Color color, int startROW, + int startCOL, int pixelHeight, int pixelWidth, + String scaleType, double absolute, double quant, boolean trans) { + String command = "java -jar $SCRIPTMANAGER figure-generation TwoColorHeatMap"; + command += " " + input.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + if (color == Color.BLACK) { + command += " --black "; + } else if (color == Color.RED) { + command += " --red "; + } else if (color == Color.BLUE) { + command += " --blue "; + } else { + String hex = "#"+Integer.toHexString(color.getRGB()).substring(2); + command += " -c " + hex; + } + command += " -r " + startROW; + command += " -l " + startCOL; + command += " -y " + pixelHeight; + command += " -x " + pixelWidth; + command += " -z " + scaleType; + command += " -a " + absolute; + command += " -p " + quant; + command += " -t " + trans; + return command; + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 14c10f287..7c92d47d2 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1539,6 +1539,17 @@ public void actionPerformed(ActionEvent arg0) { public void run() { try { TwoColorHeatMapWindow frame = new TwoColorHeatMapWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java index df565140c..445ca14a8 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java @@ -12,6 +12,9 @@ import javax.swing.JScrollPane; import javax.swing.JTabbedPane; +import scriptmanager.cli.Figure_Generation.LabelHeatMapCLI; +import scriptmanager.cli.Figure_Generation.TwoColorHeatMapCLI; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Figure_Generation.TwoColorHeatMap; import scriptmanager.util.ExtensionFileFilter; @@ -65,23 +68,33 @@ public TwoColorHeatMapOutput(ArrayList in, Color c, int startR, int startC } public void run() throws IOException { + LogItem old_li = null; for (int x = 0; x < SAMPLE.size(); x++) { File OUTPUT = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(SAMPLE.get(x)) + "_" + scaleType + ".png"); if (OUT_DIR != null) { OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + OUTPUT.getName()); } - + old_li = new LogItem(""); + // Initialize LogItem + String command = TwoColorHeatMapCLI.getCLIcommand(SAMPLE.get(x), OUTPUT, MAXCOLOR, startROW, startCOL, + pixelHeight, pixelWidth, scaleType, absolute, quantile, transparentBackground); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute script TwoColorHeatMap script_object = new TwoColorHeatMap(SAMPLE.get(x), MAXCOLOR, startROW, startCOL, pixelHeight, pixelWidth, scaleType, absolute, quantile, OUTPUT, OUTPUTSTATUS, transparentBackground); script_object.run(); JLabel picLabel = script_object.getImg(); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; // Output image/error to GUI newpane.addTab(OUTPUT.getName(), new JScrollPane(picLabel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); firePropertyChange("heat", x, x + 1); } + firePropertyChange("log", old_li, null); System.out.println("Program Complete"); System.out.println(getTimeStamp()); } diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java index 612d06713..3919f6130 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java @@ -135,7 +135,11 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { setProgress(percentComplete); } }); - + heat.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); heat.setVisible(true); heat.run(); @@ -537,6 +541,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From 13724474a44265899188811fdca3e1656c48647e Mon Sep 17 00:00:00 2001 From: Erikpav Date: Sun, 30 Jul 2023 14:53:41 -0400 Subject: [PATCH 12/58] Added Logging to BEDPeakAlignToRef #132 Added the logging feature to BEDPeakAlignToRef. --- .../Peak_Analysis/BEDPeakAligntoRefCLI.java | 8 ++++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++++++++ .../Peak_Analysis/BEDPeakAligntoRefOutput.java | 18 ++++++++++++++++-- .../Peak_Analysis/BEDPeakAligntoRefWindow.java | 11 +++++++++-- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java index 11251074b..f407c2d37 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java @@ -88,4 +88,12 @@ private String validateInput() throws IOException { return(r); } + + public static String getCLIcommand(File peakBED, File refBED, File output) { + String command = "java -jar $SCRIPTMANAGER peak-analysis BEDPeakAlignToRef"; + command += " " + peakBED.getAbsolutePath(); + command += " " + refBED.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 7c92d47d2..af44efd45 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -868,6 +868,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { BEDPeakAligntoRefWindow frame = new BEDPeakAligntoRefWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java index 340f39741..cd89dde94 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java @@ -4,12 +4,17 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import scriptmanager.cli.Figure_Generation.TwoColorHeatMapCLI; +import scriptmanager.cli.Peak_Analysis.BEDPeakAligntoRefCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Peak_Analysis.BEDPeakAligntoRef; @SuppressWarnings("serial") @@ -43,12 +48,21 @@ public BEDPeakAligntoRefOutput(File ref, File peak, File outpath) throws IOExcep } public void run() throws IOException, InterruptedException { - + LogItem old_li = new LogItem(""); + // Initialize LogItem + String command = BEDPeakAligntoRefCLI.getCLIcommand(PEAK, REF, OUTFILE); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); BEDPeakAligntoRef script_obj = new BEDPeakAligntoRef(REF, PEAK, OUTFILE, PS); script_obj.run(); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; Thread.sleep(2000); dispose(); + firePropertyChange("log", old_li, null); } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java index d41d3c5a2..104512f37 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java @@ -68,7 +68,12 @@ public Void doInBackground() throws IOException, InterruptedException { { for(int p=0; p < PeakFiles.size(); p++) { - align = new BEDPeakAligntoRefOutput(RefFiles.get(r), PeakFiles.get(p), OUTPUT_PATH); + align = new BEDPeakAligntoRefOutput(RefFiles.get(r), PeakFiles.get(p), OUTPUT_PATH); + align.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); align.setVisible(true); align.run(); counter++; @@ -251,7 +256,9 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); - } + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } } public void massXable(Container con, boolean status) { From ebcf54dd035fffe44d8d12972432d8a38c1c0e80 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Mon, 31 Jul 2023 21:31:20 -0400 Subject: [PATCH 13/58] Added Logging to SearchMotif and FASTAExtract #132 Added logging support into SearchMotif and FASTAExtract. --- .../Sequence_Analysis/FASTAExtractCLI.java | 10 +++++++++ .../cli/Sequence_Analysis/SearchMotifCLI.java | 10 +++++++++ .../scriptmanager/main/ScriptManagerGUI.java | 22 +++++++++++++++++++ .../Sequence_Analysis/FASTAExtractOutput.java | 17 +++++++++++++- .../Sequence_Analysis/FASTAExtractWindow.java | 7 ++++++ .../Sequence_Analysis/SearchMotifOutput.java | 18 +++++++++++++-- .../Sequence_Analysis/SearchMotifWindow.java | 7 ++++++ 7 files changed, 88 insertions(+), 3 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java index ecb4af9ba..94b483be2 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java @@ -89,4 +89,14 @@ private String validateInput() throws IOException { return (r); } + public static String getCLIcommand(File FASTA, File BED, File output, boolean header, boolean forceStrand, boolean gzOutput) { + String command = "java -jar $SCRIPTMANAGER sequence-analysis FASTAExtract"; + command += " " + FASTA.getAbsolutePath(); + command += " " + BED.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + command += " -c " + header; + command += " -n " + forceStrand; + command += gzOutput ? " -z" : ""; + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java index 9ca47ce78..069ef0f2a 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java @@ -112,4 +112,14 @@ private String validateInput() throws IOException { return (r); } + + public static String getCLIcommand(File input, File output, String motif, int mismatch, boolean gzOutput) { + String command = "java -jar $SCRIPTMANAGER sequence-analysis SearchMotif"; + command += " " + input.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + command += " -m " + motif; + command += " -n " + mismatch; + command += gzOutput ? " -z" : ""; + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index af44efd45..6c0947404 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1457,6 +1457,17 @@ public void actionPerformed(ActionEvent arg0) { public void run() { try { SearchMotifWindow frame = new SearchMotifWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); @@ -1516,6 +1527,17 @@ public void actionPerformed(ActionEvent arg0) { public void run() { try { DNAShapefromFASTAWindow frame = new DNAShapefromFASTAWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java index ce92c952d..147caac80 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java @@ -7,13 +7,18 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import scriptmanager.cli.Sequence_Analysis.FASTAExtractCLI; +import scriptmanager.cli.Sequence_Analysis.SearchMotifCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Sequence_Analysis.FASTAExtract; /** @@ -75,9 +80,11 @@ public FASTAExtractOutput(File gen, ArrayList b, File out_dir, boolean str * @throws InterruptedException */ public void run() throws IOException, InterruptedException { + LogItem old_li = null; PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); try { for (int x = 0; x < BED.size(); x++) { + old_li = new LogItem(""); // Open Output File File OUTFILE; String NAME = BED.get(x).getName().split("\\.")[0] + ".fa"; @@ -87,13 +94,21 @@ public void run() throws IOException, InterruptedException { NAME += gzOutput ? ".gz" : ""; OUTFILE = new File(NAME); PS.println("Proccessing File: " + BED.get(x).getName()); - + // Initialize LogItem + String command = FASTAExtractCLI.getCLIcommand(GENOME, BED.get(x), OUTFILE, HEADER, STRAND, gzOutput); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute Script object FASTAExtract script_obj = new FASTAExtract(GENOME, BED.get(x), OUTFILE, STRAND, HEADER, PS, gzOutput); script_obj.run(); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; // Update progress firePropertyChange("fa", x, x + 1); } + firePropertyChange("log", old_li, null); PS.println("Extraction Complete"); } catch (IllegalArgumentException e) { PS.println(e.getMessage()); diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java index 504d56a01..7ba19eb35 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java @@ -89,6 +89,11 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { setProgress(percentComplete); } }); + signal.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); signal.setVisible(true); signal.run(); @@ -276,6 +281,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java index 7c34688e5..7d1415deb 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java @@ -4,12 +4,17 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import scriptmanager.cli.Figure_Generation.TwoColorHeatMapCLI; +import scriptmanager.cli.Sequence_Analysis.SearchMotifCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Sequence_Analysis.SearchMotif; import scriptmanager.util.ExtensionFileFilter; @@ -72,6 +77,7 @@ public SearchMotifOutput(File input, String mot, int num, File out_dir, boolean * @throws InterruptedException */ public void run() throws IOException, InterruptedException { + LogItem old_li = null; PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); String BASENAME = motif + "_" + Integer.toString(ALLOWED_MISMATCH) + "Mismatch_" + ExtensionFileFilter.stripExtension(INPUTFILE) + ".bed"; @@ -79,11 +85,19 @@ public void run() throws IOException, InterruptedException { BASENAME = OUT_DIR.getCanonicalPath() + File.separator + BASENAME; } BASENAME += gzOutput ? ".gz" : ""; - + old_li = new LogItem(""); + // Initialize LogItem + String command = SearchMotifCLI.getCLIcommand(INPUTFILE, new File(BASENAME), motif, ALLOWED_MISMATCH, gzOutput); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); SearchMotif script_obj = new SearchMotif(INPUTFILE, motif, ALLOWED_MISMATCH, new File(BASENAME), PS, gzOutput); script_obj.run(); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; Thread.sleep(2000); + firePropertyChange("log", old_li, null); dispose(); } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java index 4f9ca4353..34be47b91 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java @@ -78,6 +78,11 @@ public Void doInBackground() throws IOException, InterruptedException { for (int gfile = 0; gfile < GenomeFiles.size(); gfile++) { SearchMotifOutput search = new SearchMotifOutput(GenomeFiles.get(gfile), txtMotif.getText(), Integer.parseInt(txtMismatch.getText()), OUT_DIR, chckbxGzipOutput.isSelected()); + search.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); search.setVisible(true); search.run(); int percentComplete = (int) (((double) (gfile + 1) / (GenomeFiles.size())) * 100); @@ -249,6 +254,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From 940a1e3be205b2998d8ca7aa9db396d5fdb22989 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Tue, 1 Aug 2023 14:54:56 -0400 Subject: [PATCH 14/58] Added Logging to ShiftCoord #132 Added the logging feature to ShiftCoord --- .../ShiftCoordCLI.java | 10 +++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 ++++++++ .../ShiftIntervalWindow.java | 28 +++++++++++++++++-- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java index 6d5fb56ed..da652363f 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java @@ -89,4 +89,14 @@ private String validateInput() throws IOException { } return(r); } + public static String getCLIcommand(File input, File output, int shift, boolean stranded, boolean gzOutput, boolean isGFF) { + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation ShiftCoord"; + command += " " + input.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + command += " -t " + shift; + command += " -u " + stranded; + command += " --gff " + isGFF; + command += gzOutput ? " -z " : ""; + return command; + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 6c0947404..982d98f5c 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1226,6 +1226,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { ShiftIntervalWindow frame = new ShiftIntervalWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java index 5096dec4e..73e2f18ea 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; import javax.swing.border.EmptyBorder; @@ -36,7 +37,11 @@ import java.awt.event.ItemListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.Date; +import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.SortGFFCLI; +import scriptmanager.cli.Coordinate_Manipulation.ShiftCoordCLI; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Coordinate_Manipulation.ShiftCoord; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -90,6 +95,7 @@ public Void doInBackground() throws IOException { JOptionPane.showMessageDialog(null, "These shifts of 0 bp will generate identical files..."); } setProgress(0); + LogItem old_li = new LogItem(""); if (rdbtnBed.isSelected()) { for (int x = 0; x < BEDFiles.size(); x++) { // Save current BED to temp variable @@ -107,13 +113,21 @@ public Void doInBackground() throws IOException { OUTPUT = ExtensionFileFilter.stripExtensionPath(new File(OUTPUT)) ; } System.out.println("Input: " + XBED.getName()); + // Initialize LogItem + String command = ShiftCoordCLI.getCLIcommand(XBED, new File(OUTPUT + SUFFIX), SHIFT, chckbxStranded.isSelected(), chckbxGzipOutput.isSelected(), false); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute expansion and update progress ShiftCoord.shiftBEDInterval(new File(OUTPUT + SUFFIX), XBED, SHIFT, chckbxStranded.isSelected(), chckbxGzipOutput.isSelected()); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; // Update progress bar int percentComplete = (int) (((double) (x + 1) / BEDFiles.size()) * 100); setProgress(percentComplete); } + firePropertyChange("log", old_li, null); } else { for (int x = 0; x < GFFFiles.size(); x++) { // Save current BED to temp variable @@ -131,13 +145,21 @@ public Void doInBackground() throws IOException { OUTPUT = ExtensionFileFilter.stripExtensionPath(new File(OUTPUT)) ; } System.out.println("Input: " + XGFF.getName()); + // Initialize LogItem + String command = ShiftCoordCLI.getCLIcommand(XGFF, new File(OUTPUT + SUFFIX), SHIFT, chckbxStranded.isSelected(), chckbxGzipOutput.isSelected(), true); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute expansion and update progress ShiftCoord.shiftGFFInterval(new File(OUTPUT + SUFFIX), XGFF, SHIFT, chckbxStranded.isSelected(), chckbxGzipOutput.isSelected()); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; // Update progress bar int percentComplete = (int) (((double) (x + 1) / GFFFiles.size()) * 100); setProgress(percentComplete); } + firePropertyChange("log", old_li, null); } setProgress(100); JOptionPane.showMessageDialog(null, "Shift Complete"); @@ -388,6 +410,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From ed4454a32a75e78d4b0c8549d2c96ededf135ab3 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Wed, 2 Aug 2023 11:08:13 -0400 Subject: [PATCH 15/58] Added Logging to FilterBEDbyProximity #132 Added Logging Support to FilterBEDbyProximity. Also, did some editing on all CLI's with booleans and hex colors to get a proper output. --- .../Coordinate_Manipulation/ShiftCoordCLI.java | 4 ++-- .../cli/Figure_Generation/LabelHeatMapCLI.java | 2 +- .../Figure_Generation/TwoColorHeatMapCLI.java | 4 ++-- .../Peak_Analysis/FilterBEDbyProximityCLI.java | 9 ++++++++- .../cli/Sequence_Analysis/FASTAExtractCLI.java | 4 ++-- .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++++++++ .../FilterBEDbyProximityOutput.java | 18 ++++++++++++++++-- .../FilterBEDbyProximityWindow.java | 11 +++++++++-- 8 files changed, 51 insertions(+), 12 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java index da652363f..e3948beec 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java @@ -94,8 +94,8 @@ public static String getCLIcommand(File input, File output, int shift, boolean s command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); command += " -t " + shift; - command += " -u " + stranded; - command += " --gff " + isGFF; + command += stranded ? " -u " : ""; + command += isGFF ? " --gff " : ""; command += gzOutput ? " -z " : ""; return command; } diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java index c8e4f4406..00a580dd1 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java @@ -121,7 +121,7 @@ public static String getCLIcommand(File input, File output, Color color, int bor command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); // Converts RGB format color to hexadecimal - String hex = "#"+Integer.toHexString(color.getRGB()).substring(2); + String hex = Integer.toHexString(color.getRGB()).substring(2); command += " -c " + hex; command += " -w " + borderWidth; command += " -t " + xTickHeight; diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java index 01e0653aa..ce095bc72 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java @@ -179,7 +179,7 @@ public static String getCLIcommand(File input, File output, Color color, int sta } else if (color == Color.BLUE) { command += " --blue "; } else { - String hex = "#"+Integer.toHexString(color.getRGB()).substring(2); + String hex = Integer.toHexString(color.getRGB()).substring(2); command += " -c " + hex; } command += " -r " + startROW; @@ -189,7 +189,7 @@ public static String getCLIcommand(File input, File output, Color color, int sta command += " -z " + scaleType; command += " -a " + absolute; command += " -p " + quant; - command += " -t " + trans; + command += trans ? " -t " : ""; return command; } } diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java index 2f364470f..37c921c8a 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java @@ -83,5 +83,12 @@ private String validateInput() throws IOException { return(r); - } + } + public static String getCLIcommand(File input, String outputBasename, int exclusion) { + String command = "java -jar $SCRIPTMANAGER peak-analysis FilterBEDbyProximity"; + command += " " + input.getAbsolutePath(); + command += " -o " + outputBasename; + command += " -e " + exclusion; + return command; + } } diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java index 94b483be2..1a8cd0a25 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java @@ -94,8 +94,8 @@ public static String getCLIcommand(File FASTA, File BED, File output, boolean he command += " " + FASTA.getAbsolutePath(); command += " " + BED.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); - command += " -c " + header; - command += " -n " + forceStrand; + command += header ? " -c " : ""; + command += forceStrand ? " -n " : ""; command += gzOutput ? " -z" : ""; return command; } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 982d98f5c..f84b6eb17 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -910,6 +910,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { FilterBEDbyProximityWindow frame = new FilterBEDbyProximityWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java index 1360f5350..90812cff6 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java @@ -4,12 +4,17 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import scriptmanager.cli.Peak_Analysis.BEDPeakAligntoRefCLI; +import scriptmanager.cli.Peak_Analysis.FilterBEDbyProximityCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Peak_Analysis.FilterBEDbyProximity; @SuppressWarnings({"serial"}) @@ -46,12 +51,21 @@ public FilterBEDbyProximityOutput(File input, int cutoff, File output) throws IO public void run() throws IOException, InterruptedException { + LogItem old_li = new LogItem(""); + // Initialize LogItem + String command = FilterBEDbyProximityCLI.getCLIcommand(INPUT, OUTBASE, CUTOFF); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); - FilterBEDbyProximity script_obj = new FilterBEDbyProximity(INPUT, CUTOFF, OUTBASE, PS); script_obj.run(); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; Thread.sleep(1000); dispose(); + firePropertyChange("log", old_li, null); } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java index 017a12371..ece85cf3c 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java @@ -60,7 +60,12 @@ public Void doInBackground() throws IOException, InterruptedException { setProgress(0); FilterBEDbyProximityOutput filter; for(int gfile = 0; gfile < BEDFiles.size(); gfile++) { - filter = new FilterBEDbyProximityOutput(BEDFiles.get(gfile), Integer.parseInt(txtCutoff.getText()), OUTPUT_PATH); + filter = new FilterBEDbyProximityOutput(BEDFiles.get(gfile), Integer.parseInt(txtCutoff.getText()), OUTPUT_PATH); + filter.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); filter.setVisible(true); filter.run(); int percentComplete = (int)(((double)(gfile + 1) / (BEDFiles.size())) * 100); @@ -204,7 +209,9 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); - } + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } } public void massXable(Container con, boolean status) { From ee892209369ad132ec786e9b5b30664e2c90fce4 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Wed, 2 Aug 2023 12:10:57 -0400 Subject: [PATCH 16/58] Removed unused imports #132 Removed unused imports across all classes with logging support. --- .../scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java | 1 - .../scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java | 1 - .../window_interface/BAM_Format_Converter/BAMtoBEDWindow.java | 1 - .../window_interface/BAM_Format_Converter/BAMtoGFFWindow.java | 1 - .../BAM_Format_Converter/BAMtobedGraphWindow.java | 1 - .../window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java | 1 - .../window_interface/BAM_Manipulation/BAIIndexerWindow.java | 1 - .../window_interface/BAM_Manipulation/FilterforPIPseqWindow.java | 1 - .../window_interface/BAM_Manipulation/MergeBAMWindow.java | 1 - .../window_interface/BAM_Manipulation/SortBAMWindow.java | 1 - .../BED_Manipulation/ExpandBEDWindow.java | 1 - .../Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java | 1 - .../GFF_Manipulation/ExpandGFFWindow.java | 1 - .../Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java | 1 - .../Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java | 1 - .../window_interface/Figure_Generation/LabelHeatMapOutput.java | 1 - .../Figure_Generation/TwoColorHeatMapOutput.java | 1 - .../window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java | 1 - .../Peak_Analysis/FilterBEDbyProximityOutput.java | 1 - .../window_interface/Sequence_Analysis/FASTAExtractOutput.java | 1 - .../window_interface/Sequence_Analysis/SearchMotifOutput.java | 1 - 21 files changed, 21 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java index 00a580dd1..8ab68b966 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java @@ -7,7 +7,6 @@ import java.awt.Color; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.concurrent.Callable; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java index f731236a3..2428e2d41 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java @@ -7,7 +7,6 @@ import java.lang.NullPointerException; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.concurrent.Callable; import scriptmanager.objects.ToolDescriptions; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java index d38426d29..9dcb60927 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java @@ -37,7 +37,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import jdk.internal.net.http.common.Log; import scriptmanager.cli.BAM_Format_Converter.BAMtoBEDCLI; import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java index ba1fdd8b9..76e3da555 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java @@ -37,7 +37,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.cli.BAM_Format_Converter.BAMtoBEDCLI; import scriptmanager.cli.BAM_Format_Converter.BAMtoGFFCLI; import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java index a53b6ec56..d713b890c 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java @@ -37,7 +37,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.cli.BAM_Format_Converter.BAMtoGFFCLI; import scriptmanager.cli.BAM_Format_Converter.BAMtobedGraphCLI; import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java index 7e8fa0de4..df65c22cd 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java @@ -38,7 +38,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import jdk.internal.net.http.common.Log; import scriptmanager.objects.LogItem; import scriptmanager.cli.BAM_Format_Converter.BAMtoscIDXCLI; import scriptmanager.util.FileSelection; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java index 1e0dbc3d4..dfe359aa9 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java @@ -29,7 +29,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import jdk.internal.net.http.common.Log; import scriptmanager.objects.LogItem; import scriptmanager.cli.BAM_Manipulation.BAIIndexerCLI; import scriptmanager.util.FileSelection; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java index 0014bc2f2..7586a46dc 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java @@ -35,7 +35,6 @@ import javax.swing.SwingConstants; import scriptmanager.cli.BAM_Manipulation.FilterforPIPseqCLI; -import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.SortBEDCLI; import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java index 9ca222451..22cb52bd9 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java @@ -32,7 +32,6 @@ import java.sql.Timestamp; import java.util.Date; -import scriptmanager.cli.BAM_Manipulation.BAIIndexerCLI; import scriptmanager.cli.BAM_Manipulation.MergeBAMCLI; import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java index 5a9441fec..b5faa6b0b 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java @@ -32,7 +32,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.cli.BAM_Manipulation.BAIIndexerCLI; import scriptmanager.cli.BAM_Manipulation.SortBAMCLI; import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Manipulation.BAMFileSort; diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java index a699fd631..68cd29e93 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java @@ -37,7 +37,6 @@ import java.beans.PropertyChangeListener; import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.ExpandBEDCLI; -import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.SortBEDCLI; import scriptmanager.objects.LogItem; import scriptmanager.scripts.Coordinate_Manipulation.BED_Manipulation.ExpandBED; import scriptmanager.util.ExtensionFileFilter; diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java index 081279bcd..db8563426 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java @@ -33,7 +33,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.BEDtoGFFCLI; import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.SortBEDCLI; import scriptmanager.objects.LogItem; import scriptmanager.util.CDTUtilities; diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java index d9638f449..8244b5fc1 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java @@ -35,7 +35,6 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.ExpandBEDCLI; import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.ExpandGFFCLI; import scriptmanager.objects.LogItem; import scriptmanager.scripts.Coordinate_Manipulation.GFF_Manipulation.ExpandGFF; diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java index 5ff266900..6ae228266 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java @@ -30,7 +30,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.cli.BAM_Format_Converter.BAMtoGFFCLI; import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.GFFtoBEDCLI; import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java index a2e88772f..80f50ed03 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java @@ -32,7 +32,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.SortBEDCLI; import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.SortGFFCLI; import scriptmanager.objects.LogItem; import scriptmanager.util.CDTUtilities; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java index a779640b2..d4ec05303 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java @@ -14,7 +14,6 @@ import javax.swing.JTextArea; import scriptmanager.cli.Figure_Generation.LabelHeatMapCLI; -import scriptmanager.cli.Figure_Generation.MergeHeatMapCLI; import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.objects.LogItem; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java index 445ca14a8..25239879a 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java @@ -12,7 +12,6 @@ import javax.swing.JScrollPane; import javax.swing.JTabbedPane; -import scriptmanager.cli.Figure_Generation.LabelHeatMapCLI; import scriptmanager.cli.Figure_Generation.TwoColorHeatMapCLI; import scriptmanager.objects.LogItem; import scriptmanager.scripts.Figure_Generation.TwoColorHeatMap; diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java index cd89dde94..9f4238e64 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java @@ -11,7 +11,6 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; -import scriptmanager.cli.Figure_Generation.TwoColorHeatMapCLI; import scriptmanager.cli.Peak_Analysis.BEDPeakAligntoRefCLI; import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java index 90812cff6..ec21522ce 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java @@ -11,7 +11,6 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; -import scriptmanager.cli.Peak_Analysis.BEDPeakAligntoRefCLI; import scriptmanager.cli.Peak_Analysis.FilterBEDbyProximityCLI; import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java index 147caac80..6b3f6a961 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java @@ -16,7 +16,6 @@ import javax.swing.JTextArea; import scriptmanager.cli.Sequence_Analysis.FASTAExtractCLI; -import scriptmanager.cli.Sequence_Analysis.SearchMotifCLI; import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; import scriptmanager.scripts.Sequence_Analysis.FASTAExtract; diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java index 7d1415deb..7a1d80128 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java @@ -11,7 +11,6 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; -import scriptmanager.cli.Figure_Generation.TwoColorHeatMapCLI; import scriptmanager.cli.Sequence_Analysis.SearchMotifCLI; import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; From 5bfc364ea5b629c414dd8301fc8e0e0d83926bb0 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Mon, 14 Aug 2023 22:22:59 -0400 Subject: [PATCH 17/58] Added Logging to RandomCoordinate #132 Added Logging support to random coordinate. --- .../cli/BAM_Manipulation/BAIIndexerCLI.java | 4 ++-- .../cli/Peak_Analysis/RandomCoordinateCLI.java | 9 +++++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++++++++ .../Peak_Analysis/RandomCoordinateWindow.java | 16 ++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java index 410818430..6ab15a597 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java @@ -31,8 +31,8 @@ public Integer call() throws Exception { public static String getCLIcommand(File BAM) { String command = "java -jar $PICARD BuildBamIndex"; - command += " INPUT=" + BAM.getAbsolutePath(); - command += " OUTPUT=" + BAM.getAbsolutePath() + ".bai"; + command += "INPUT=" + BAM.getAbsolutePath(); + command += "OUTPUT=" + BAM.getAbsolutePath() + ".bai"; return command; } diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java index 3ad83064f..7686a0dfb 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java @@ -87,4 +87,13 @@ private String validateInput() throws IOException { return(r); } + public static String getCLIcommand(String genomeName, File output, boolean formatIsBed, int numSites, int window) { + String command = "java -jar $SCRIPTMANAGER peak-analysis RandomCoordinate"; + command += " " + genomeName; + command += " -o " + output.getAbsolutePath(); + command += formatIsBed ? "" : " -f "; + command += " -n " + numSites; + command += " -w " + window; + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index f84b6eb17..005ffa3e2 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -985,6 +985,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { RandomCoordinateWindow frame = new RandomCoordinateWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java index d6b5fc6a8..10512194e 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java @@ -10,6 +10,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.ButtonGroup; import javax.swing.JButton; @@ -26,6 +28,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; + +import scriptmanager.cli.Peak_Analysis.RandomCoordinateCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; import scriptmanager.scripts.Peak_Analysis.RandomCoordinate; @@ -55,6 +60,7 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws IOException, InterruptedException { try { + LogItem old_li = new LogItem(""); if(txtSites.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "No Sites Entered!!!"); } else if(Integer.parseInt(txtSites.getText()) < 0) { @@ -74,9 +80,19 @@ public Void doInBackground() throws IOException, InterruptedException { }else{ OUTFILE = new File(randomName); } + // Initialize LogItem + String command = RandomCoordinateCLI.getCLIcommand((String)cmbGenome.getSelectedItem(), OUTFILE, bedStatus, Integer.parseInt(txtSites.getText()), Integer.parseInt(txtSize.getText())); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute Script and update progress RandomCoordinate.execute((String)cmbGenome.getSelectedItem(), Integer.parseInt(txtSites.getText()), Integer.parseInt(txtSize.getText()), bedStatus, OUTFILE); JOptionPane.showMessageDialog(null, "Random Coordinate Generation Complete"); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; } + firePropertyChange("log", old_li, null); } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (IllegalArgumentException iae) { From 3ff2111e828929e084df4db826d3aa7e742a6be4 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Tue, 5 Sep 2023 16:04:00 -0400 Subject: [PATCH 18/58] Adding Logging to PEStats #132 Added Logging to Paired-End Statistics. --- .../cli/BAM_Statistics/PEStatsCLI.java | 11 +++++++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++++++++ .../BAM_Statistics/PEStatOutput.java | 17 ++++++++++++++++- .../BAM_Statistics/PEStatWindow.java | 9 ++++++++- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java index 73a87f4de..f86d51be7 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java @@ -93,4 +93,15 @@ private String validateInput() throws IOException { return(r); } + public static String getCLIcommand(File BAMFile, File outputBasename, int min, int max, boolean dup, boolean sum) { + String command = "java -jar $SCRIPTMANAGER bam-statistics PEStats"; + command += " " + BAMFile.getAbsolutePath(); + command += " -o " + outputBasename.getAbsolutePath(); + command += " -n " + min; + command += " -x " + max; + command += sum ? " -s " : ""; + command += dup ? " -d " : ""; + return command; + } + } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 005ffa3e2..5ec3e71f7 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -178,6 +178,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { PEStatWindow frame = new PEStatWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java index 9e3c1f333..2e44440fb 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java @@ -5,6 +5,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.JFrame; @@ -17,7 +19,10 @@ import org.jfree.chart.ChartPanel; +import scriptmanager.cli.BAM_Statistics.PEStatsCLI; +import scriptmanager.cli.Figure_Generation.LabelHeatMapCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Statistics.PEStats; @SuppressWarnings("serial") @@ -75,6 +80,7 @@ public PEStatOutput(Vector input, File o, boolean out, boolean dup, int mi } public void run() throws IOException { + LogItem old_li = null; // Check if BAI index file exists for all BAM files boolean[] BAMvalid = new boolean[bamFiles.size()]; for (int z = 0; z < bamFiles.size(); z++) { @@ -91,6 +97,7 @@ public void run() throws IOException { //Iterate through all BAM files in Vector for(int x = 0; x < bamFiles.size(); x++) { if (BAMvalid[x]) { + old_li = new LogItem(""); // Construct Basename File OUT_BASENAME = null; if(OUTPUT_STATUS){ @@ -113,10 +120,17 @@ public void run() throws IOException { DUP_STATS.setEditable(false); ps_dup = new PrintStream(new CustomOutputStream( DUP_STATS )); } + // Initialize LogItem + String command = PEStatsCLI.getCLIcommand(bamFiles.get(x), OUT_BASENAME, MIN_INSERT, MAX_INSERT, DUP_STATUS, false); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); //Call public static method from scripts Vector charts = PEStats.getPEStats( OUT_BASENAME, bamFiles.get(x), DUP_STATUS, MIN_INSERT, MAX_INSERT, ps_insert, ps_dup, false ); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; //Add pe stats to tabbed pane PE_STATS.setCaretPosition(0); JScrollPane pe_pane = new JScrollPane(PE_STATS, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); @@ -136,6 +150,7 @@ public void run() throws IOException { firePropertyChange("bam",x, x + 1); } + firePropertyChange("log", old_li, null); } } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java index 28e9cf2c6..9720b2bf0 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java @@ -79,6 +79,11 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { setProgress(percentComplete); } }); + stat.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); stat.setVisible(true); stat.run(); } @@ -271,7 +276,9 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); - } + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } } public void massXable(Container con, boolean status) { From 3617ecad5f99aec96feb22bb68823ed9427ed33e Mon Sep 17 00:00:00 2001 From: Erikpav Date: Tue, 5 Sep 2023 16:53:41 -0400 Subject: [PATCH 19/58] Added Logging to SEStats #132 Added Logging Support to SEStats. --- .../cli/BAM_Statistics/SEStatsCLI.java | 6 ++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++++++++ .../BAM_Statistics/PEStatOutput.java | 1 - .../BAM_Statistics/SEStatOutput.java | 17 ++++++++++++++++- .../BAM_Statistics/SEStatWindow.java | 7 +++++++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java index e714b74a2..4fd4a76d4 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java @@ -79,4 +79,10 @@ private String validateInput() throws IOException { return(r); } + public static String getCLIcommand(File BAMFile, File outputBasename) { + String command = "java -jar $SCRIPTMANAGER bam-statistics PEStats"; + command += " " + BAMFile.getAbsolutePath(); + command += " -o " + outputBasename.getAbsolutePath(); + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 5ec3e71f7..3651d3c63 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -149,6 +149,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { SEStatWindow frame = new SEStatWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java index 2e44440fb..96b86ccfe 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java @@ -20,7 +20,6 @@ import org.jfree.chart.ChartPanel; import scriptmanager.cli.BAM_Statistics.PEStatsCLI; -import scriptmanager.cli.Figure_Generation.LabelHeatMapCLI; import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Statistics.PEStats; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java index 57f7b9af9..1ea7c80f3 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java @@ -5,13 +5,17 @@ import java.io.FileNotFoundException; import java.io.PrintStream; import java.net.URISyntaxException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import scriptmanager.cli.BAM_Statistics.SEStatsCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Statistics.SEStats; @SuppressWarnings("serial") @@ -42,6 +46,7 @@ public SEStatOutput(Vector input, File o) { } public void run() { + LogItem old_li = null; if(output != null) { try { OUT = new PrintStream(output); @@ -52,13 +57,23 @@ public void run() { } // Execute on each BAM file in the list for(int x = 0; x < bamFiles.size(); x++) { + old_li = new LogItem(""); + // Initialize LogItem + String command = SEStatsCLI.getCLIcommand(bamFiles.get(x), output); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Use script and pass PrintStream object that sends to JTextArea SEStats.getSEStats( output, bamFiles.get(x), jtxtPrintStream ); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; } if(output != null) OUT.close(); //BAMIndexMetaData.printIndexStats(bamFiles.get(x)) + firePropertyChange("log", old_li, null); } - + public static void main(String[] args) { System.out.print("java -cp "); //Output full path of ScriptManager diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java index 737d32a57..6ef4ebde9 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java @@ -6,6 +6,8 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.Font; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.io.File; import java.util.Vector; @@ -170,6 +172,11 @@ public void actionPerformed(ActionEvent e) { if(OUTPUT_PATH != null) { stat = new SEStatOutput(BAMFiles, new File(OUTPUT_PATH + File.separator + txtOutputName.getText())); } else { stat = new SEStatOutput(BAMFiles, new File(txtOutputName.getText())); } } else { stat = new SEStatOutput(BAMFiles, null); } + stat.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); stat.setVisible(true); stat.run(); } From 0d6e49f2ae7f01477903ffb942320746af529794 Mon Sep 17 00:00:00 2001 From: Erikpav Date: Sat, 16 Sep 2023 19:41:28 -0400 Subject: [PATCH 20/58] Added Logging to CrossCorrelation #132 Added Logging support to CrossCorrelation --- .../BAM_Statistics/CrossCorrelationCLI.java | 10 ++++++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++++++++ .../BAM_Statistics/CrossCorrelationOutput.java | 18 ++++++++++++++++-- .../BAM_Statistics/CrossCorrelationWindow.java | 7 +++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/CrossCorrelationCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/CrossCorrelationCLI.java index 4aeedf3a5..ac6d7f0e9 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/CrossCorrelationCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/CrossCorrelationCLI.java @@ -123,4 +123,14 @@ private String validateInput() throws IOException { return(r); } + public static String getCLIcommand(File OUTPUT, File bamFile, CorrParameter param) { + String command = "java -jar $SCRIPTMANAGER bam-statistics CrossCorrelation"; + command += " " + bamFile.getAbsolutePath(); + command += " -o " + OUTPUT.getAbsolutePath(); + command += param.getCorrType() ? " -g " : " -r "; + command += " -t " + param.getThreads(); + command += param.getCorrType() ? " -w " + param.getCorrWindow() : ""; + command += param.getCorrType() ? " -i " + param.getIterations() : ""; + return command; + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 3651d3c63..e82182d8f 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -258,6 +258,17 @@ public void actionPerformed(ActionEvent arg0) { public void run() { try { CrossCorrelationWindow frame = new CrossCorrelationWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationOutput.java index 7b7c515a8..e66ac3633 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationOutput.java @@ -6,6 +6,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.JFrame; @@ -16,8 +18,10 @@ import javax.swing.JTextArea; import javax.swing.SpringLayout; +import scriptmanager.cli.BAM_Statistics.CrossCorrelationCLI; import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.ArchTEx.CorrParameter; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Statistics.CrossCorrelation; import scriptmanager.util.ExtensionFileFilter; @@ -88,6 +92,7 @@ public CrossCorrelationOutput(File o, Vector input, CorrParameter param, b * @throws IOException */ public void run() throws IOException { + LogItem old_li = null; // Check if BAI index file exists for all BAM files boolean[] BAMvalid = new boolean[bamFiles.size()]; for (int z = 0; z < bamFiles.size(); z++) { @@ -106,6 +111,7 @@ public void run() throws IOException { System.out.println("Cross-Correlation: " + bamFiles.get(x).getName()); if (BAMvalid[x]) { + old_li = new LogItem(""); // Construct Basename File OUT_FILEPATH = null; if(OUTPUT_STATUS){ @@ -125,14 +131,22 @@ public void run() throws IOException { CC_DATA.setEditable(false); ps_ccdata = new PrintStream(new CustomOutputStream( CC_DATA )); tabbedPane_CCData.add(bamFiles.get(x).getName(), new JScrollPane(CC_DATA, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); - + + // Initialize LogItem + String command = CrossCorrelationCLI.getCLIcommand(OUT_FILEPATH, bamFiles.get(x), PARAM); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); //Call public static method from scripts Component chart = CrossCorrelation.correlate(OUT_FILEPATH, bamFiles.get(x), PARAM, ps_ccdata); tabbedPane_CCPlots.add(bamFiles.get(x).getName(), chart); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; ps_ccdata.close(); firePropertyChange("bam",x, x + 1); } + firePropertyChange("log", old_li, null); } } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java index 9bfd5a8a2..be6de4360 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java @@ -119,6 +119,11 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { setProgress(percentComplete); } }); + script_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); script_obj.setVisible(true); script_obj.run(); } @@ -402,6 +407,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From b970e86ed6b2ac9c3345fac5fb31531e484b6070 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 17 Oct 2023 18:55:45 -0400 Subject: [PATCH 21/58] bugfix BAM Format Converter logging Move LogItem construction to *Output class for BAM Format Converter tools so that it can access the output filepath. Adjust *Window accordingly Also fix incorrect ordering of getCLIcommand parameter order (correct in call from *Output). Also adjust flag options logic in command construction to account for default/unset `-m` and `-x` values. --- .../cli/BAM_Format_Converter/BAMtoBEDCLI.java | 12 +++++++----- .../cli/BAM_Format_Converter/BAMtoGFFCLI.java | 12 +++++++----- .../BAMtobedGraphCLI.java | 14 ++++++++------ .../BAM_Format_Converter/BAMtoscIDXCLI.java | 16 ++++++++++------ .../BAM_Format_Converter/BAMtoBEDOutput.java | 16 ++++++++++++++++ .../BAM_Format_Converter/BAMtoBEDWindow.java | 16 ++++++---------- .../BAM_Format_Converter/BAMtoGFFOutput.java | 16 ++++++++++++++++ .../BAM_Format_Converter/BAMtoGFFWindow.java | 16 ++++++---------- .../BAMtobedGraphOutput.java | 16 ++++++++++++++++ .../BAMtobedGraphWindow.java | 16 ++++++---------- .../BAMtoscIDXOutput.java | 16 ++++++++++++++++ .../BAMtoscIDXWindow.java | 19 +++++++------------ 12 files changed, 121 insertions(+), 64 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java index 16794487e..d7bc61fcf 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java @@ -9,6 +9,7 @@ import java.io.File; import java.io.IOException; +import java.io.PrintStream; import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; @@ -139,7 +140,7 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File BAM, File output, int pair, int strand, int min, int max){ + public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-bed"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); @@ -154,11 +155,12 @@ public static String getCLIcommand(File BAM, File output, int pair, int strand, } else if (strand == 4) { command += " -f "; } - if (pair != 0) { - command += " -p"; + command += pair != 0 ? " -p" : ""; + if (min != -9999) { + command += " -n " + min; + } else if (max != -9999) { + command += " -x " + max; } - command += " -n " + min; - command += " -x " + max; return command; } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java index a62795ace..fca0d6bb2 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java @@ -9,6 +9,7 @@ import java.io.File; import java.io.IOException; +import java.io.PrintStream; import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; @@ -139,7 +140,7 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File BAM, File output, int pair, int strand, int min, int max){ + public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-gff"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); @@ -154,11 +155,12 @@ public static String getCLIcommand(File BAM, File output, int pair, int strand, } else if (strand == 4) { command += " -f "; } - if (pair != 0) { - command += " -p"; + command += pair != 0 ? " -p" : ""; + if (min != -9999) { + command += " -n " + min; + } else if (max != -9999) { + command += " -x " + max; } - command += " -n " + min; - command += " -x " + max; return command; } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java index 5aa14dd5f..2b618f749 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java @@ -9,6 +9,7 @@ import java.io.File; import java.io.IOException; +import java.io.PrintStream; import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; @@ -127,8 +128,8 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File BAM, File output, int pair, int strand, int min, int max){ - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-bedGraph"; + public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max){ + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-bedgraph"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); if (strand == 0) { @@ -140,11 +141,12 @@ public static String getCLIcommand(File BAM, File output, int pair, int strand, } else if (strand == 3 ) { command += " -m "; } - if (pair != 0) { - command += " -p"; + command += pair != 0 ? " -p" : ""; + if (min != -9999) { + command += " -n " + min; + } else if (max != -9999) { + command += " -x " + max; } - command += " -n " + min; - command += " -x " + max; return command; } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java index 023fca3c9..492265732 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java @@ -9,6 +9,7 @@ import java.io.File; import java.io.IOException; +import java.io.PrintStream; import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; @@ -135,8 +136,10 @@ private String validateInput() throws IOException { PAIR = matePair ? 1 : 0; return(r); } - public static String getCLIcommand(File BAM, File output, int pair, int strand, int min, int max){ - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-scIDX"; + public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max) { + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-scidx"; + System.out.println(output); + System.out.println(BAM); command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); if (strand == 0) { @@ -148,11 +151,12 @@ public static String getCLIcommand(File BAM, File output, int pair, int strand, } else if (strand == 3 ) { command += " -m "; } - if (pair != 0) { - command += " -p "; + command += pair != 0 ? " -p" : ""; + if (min != -9999) { + command += " -n " + min; + } else if (max != -9999) { + command += " -x " + max; } - command += " -n " + min; - command += " -x " + max; return command; } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java index 9ec4fb281..fcddc458d 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java @@ -4,12 +4,16 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import scriptmanager.cli.BAM_Format_Converter.BAMtoBEDCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Format_Converter.BAMtoBED; @SuppressWarnings("serial") @@ -66,9 +70,21 @@ public void run() throws IOException, InterruptedException { // Call script here, pass in ps and OUT PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); PS.println(OUTPUT); + + // Initialize LogItem + String command = BAMtoBEDCLI.getCLIcommand(BAM, new File(OUTPUT), STRAND, PAIR, MIN_INSERT, MAX_INSERT); + LogItem new_li = new LogItem(command); + firePropertyChange("log", null, new_li); + + // Execute script BAMtoBED script_obj = new BAMtoBED(BAM, new File(OUTPUT), STRAND, PAIR, MIN_INSERT, MAX_INSERT, PS); script_obj.run(); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + firePropertyChange("log", new_li, null); + Thread.sleep(2000); dispose(); } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java index 9dcb60927..47e381705 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java @@ -86,7 +86,6 @@ public Void doInBackground() throws IOException, InterruptedException { "Invalid Maximum & Minimum Insert Sizes!!! Maximum must be larger/equal to Minimum!"); } else { setProgress(0); - LogItem old_li = null; if (rdbtnRead1.isSelected()) { STRAND = 0; } else if (rdbtnRead2.isSelected()) { @@ -113,21 +112,18 @@ public Void doInBackground() throws IOException, InterruptedException { } for (int x = 0; x < BAMFiles.size(); x++) { - // Initialize LogItem - String command = BAMtoBEDCLI.getCLIcommand(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); - LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); BAMtoBEDOutput convert = new BAMtoBEDOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); + convert.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); convert.setVisible(true); convert.run(); - // Update LogItem - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; + int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } - firePropertyChange("log", old_li, null); setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java index a130f9bba..18596b340 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java @@ -4,12 +4,16 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import scriptmanager.cli.BAM_Format_Converter.BAMtoGFFCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Format_Converter.BAMtoGFF; @SuppressWarnings("serial") @@ -66,9 +70,21 @@ public void run() throws IOException, InterruptedException { // Call script here, pass in ps and OUT PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); PS.println(OUTPUT); + + // Initialize LogItem + String command = BAMtoGFFCLI.getCLIcommand(BAM, new File(OUTPUT), STRAND, PAIR, MIN_INSERT, MAX_INSERT); + LogItem new_li = new LogItem(command); + firePropertyChange("log", null, new_li); + + // Execute script BAMtoGFF script_obj = new BAMtoGFF(BAM, new File(OUTPUT), STRAND, PAIR, MIN_INSERT, MAX_INSERT, PS); script_obj.run(); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + firePropertyChange("log", new_li, null); + Thread.sleep(2000); dispose(); } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java index 76e3da555..48c09b09e 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java @@ -86,7 +86,6 @@ public Void doInBackground() throws IOException, InterruptedException { "Invalid Maximum & Minimum Insert Sizes!!! Maximum must be larger/equal to Minimum!"); } else { setProgress(0); - LogItem old_li = null; if (rdbtnRead1.isSelected()) { STRAND = 0; } else if (rdbtnRead2.isSelected()) { @@ -113,21 +112,18 @@ public Void doInBackground() throws IOException, InterruptedException { } for (int x = 0; x < BAMFiles.size(); x++) { - // Initialize LogItem - String command = BAMtoGFFCLI.getCLIcommand(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); - LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); BAMtoGFFOutput convert = new BAMtoGFFOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); + convert.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); convert.setVisible(true); convert.run(); - // Update LogItem - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; + int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } - firePropertyChange("log", old_li, null); setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphOutput.java index e2611c99f..c9b8934f1 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphOutput.java @@ -4,12 +4,16 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import scriptmanager.cli.BAM_Format_Converter.BAMtobedGraphCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Format_Converter.BAMtobedGraph; @SuppressWarnings("serial") @@ -64,9 +68,21 @@ public void run() throws IOException, InterruptedException { // Call script here, pass in ps and OUT PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); PS.println(OUTBASENAME); + + // Initialize LogItem + String command = BAMtobedGraphCLI.getCLIcommand(BAM, new File(OUTBASENAME), STRAND, PAIR, MIN_INSERT, MAX_INSERT); + LogItem new_li = new LogItem(command); + firePropertyChange("log", null, new_li); + + // Execute script BAMtobedGraph script_obj = new BAMtobedGraph(BAM, OUTBASENAME, STRAND, PAIR, MIN_INSERT, MAX_INSERT, PS); script_obj.run(); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + firePropertyChange("log", new_li, null); + Thread.sleep(2000); dispose(); } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java index d713b890c..1a3fd83fd 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java @@ -85,7 +85,6 @@ public Void doInBackground() throws IOException, InterruptedException { "Invalid Maximum & Minimum Insert Sizes!!! Maximum must be larger/equal to Minimum!"); } else { setProgress(0); - LogItem old_li = null; if (rdbtnRead1.isSelected()) { STRAND = 0; } else if (rdbtnRead2.isSelected()) { @@ -110,21 +109,18 @@ public Void doInBackground() throws IOException, InterruptedException { } for (int x = 0; x < BAMFiles.size(); x++) { - // Initialize LogItem - String command = BAMtobedGraphCLI.getCLIcommand(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); - LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); BAMtobedGraphOutput convert = new BAMtobedGraphOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); + convert.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); convert.setVisible(true); convert.run(); - // Update LogItem - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; + int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } - firePropertyChange("log", old_li, null); setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java index f6639949c..0b9c6e852 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java @@ -4,12 +4,16 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import scriptmanager.cli.BAM_Format_Converter.BAMtoscIDXCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Format_Converter.BAMtoscIDX; @SuppressWarnings("serial") @@ -64,9 +68,21 @@ public void run() throws IOException, InterruptedException { // Call script here, pass in ps and OUT PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); PS.println(OUTPUT); + + // Initialize LogItem + String command = BAMtoscIDXCLI.getCLIcommand(BAM, new File(OUTPUT), STRAND, PAIR, MIN_INSERT, MAX_INSERT); + LogItem new_li = new LogItem(command); + firePropertyChange("log", null, new_li); + + // Execute script BAMtoscIDX script_obj = new BAMtoscIDX(BAM, new File(OUTPUT), STRAND, PAIR, MIN_INSERT, MAX_INSERT, PS); script_obj.run(); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + firePropertyChange("log", new_li, null); + Thread.sleep(2000); dispose(); } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java index df65c22cd..f3770145e 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java @@ -86,7 +86,6 @@ public Void doInBackground() throws IOException, InterruptedException { "Invalid Maximum & Minimum Insert Sizes!!! Maximum must be larger/equal to Minimum!"); } else { setProgress(0); - LogItem old_li = null; if (rdbtnRead1.isSelected()) { STRAND = 0; } else if (rdbtnRead2.isSelected()) { @@ -111,22 +110,18 @@ public Void doInBackground() throws IOException, InterruptedException { } for (int x = 0; x < BAMFiles.size(); x++) { - // Initialize LogItem - String command = BAMtoscIDXCLI.getCLIcommand(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); - LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); - BAMtoscIDXOutput convert = new BAMtoscIDXOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, - MAX); + BAMtoscIDXOutput convert = new BAMtoscIDXOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX); + convert.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); convert.setVisible(true); convert.run(); - // Update LogItem - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; + int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } - firePropertyChange("log", old_li, null); setProgress(100); return null; } From de9f826f836395f9adb09c5fc0bc27c3616e2c42 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 17 Oct 2023 19:38:31 -0400 Subject: [PATCH 22/58] bugfix Peak Analysis tools Fix subcommand string in command string construction in getCLIcommand across CLI classes Add missing propertyChange method to fire log property from Window to main. --- sacCer3_1000SITES_200bp.bed | 1000 +++++++++++++++++ .../Peak_Analysis/BEDPeakAligntoRefCLI.java | 2 +- .../FilterBEDbyProximityCLI.java | 2 +- .../Peak_Analysis/RandomCoordinateCLI.java | 6 +- .../Peak_Analysis/RandomCoordinateWindow.java | 14 +- 5 files changed, 1012 insertions(+), 12 deletions(-) create mode 100644 sacCer3_1000SITES_200bp.bed diff --git a/sacCer3_1000SITES_200bp.bed b/sacCer3_1000SITES_200bp.bed new file mode 100644 index 000000000..181a0ab12 --- /dev/null +++ b/sacCer3_1000SITES_200bp.bed @@ -0,0 +1,1000 @@ +chrIII 109157 109357 chrIII_109157_109357_+ 0.0 + +chrIV 703703 703903 chrIV_703703_703903_- 0.0 - +chrXI 386706 386906 chrXI_386706_386906_- 0.0 - +chrIII 259288 259488 chrIII_259288_259488_- 0.0 - +chrII 203586 203786 chrII_203586_203786_+ 0.0 + +chrVIII 384468 384668 chrVIII_384468_384668_- 0.0 - +chrII 808941 809141 chrII_808941_809141_+ 0.0 + +chrII 385035 385235 chrII_385035_385235_+ 0.0 + +chrV 176612 176812 chrV_176612_176812_- 0.0 - +chrIV 594204 594404 chrIV_594204_594404_- 0.0 - +chrXII 765966 766166 chrXII_765966_766166_+ 0.0 + +chrIV 820878 821078 chrIV_820878_821078_- 0.0 - +chrVIII 28008 28208 chrVIII_28008_28208_- 0.0 - +chrIV 773183 773383 chrIV_773183_773383_+ 0.0 + +chrVII 453412 453612 chrVII_453412_453612_+ 0.0 + +chrXVI 818398 818598 chrXVI_818398_818598_- 0.0 - +chrIII 177582 177782 chrIII_177582_177782_+ 0.0 + +chrXVI 779825 780025 chrXVI_779825_780025_+ 0.0 + +chrIX 32570 32770 chrIX_32570_32770_+ 0.0 + +chrXIV 287321 287521 chrXIV_287321_287521_+ 0.0 + +chrXII 538472 538672 chrXII_538472_538672_- 0.0 - +chrIV 1108552 1108752 chrIV_1108552_1108752_- 0.0 - +chrVI 14505 14705 chrVI_14505_14705_- 0.0 - +chrXVI 811727 811927 chrXVI_811727_811927_+ 0.0 + +chrVII 477657 477857 chrVII_477657_477857_- 0.0 - +chrX 288601 288801 chrX_288601_288801_- 0.0 - +chrI 16554 16754 chrI_16554_16754_- 0.0 - +chrXIV 169439 169639 chrXIV_169439_169639_+ 0.0 + +chrXII 225062 225262 chrXII_225062_225262_+ 0.0 + +chrV 457028 457228 chrV_457028_457228_- 0.0 - +chrIV 410468 410668 chrIV_410468_410668_- 0.0 - +chrII 799318 799518 chrII_799318_799518_- 0.0 - +chrXIII 875581 875781 chrXIII_875581_875781_+ 0.0 + +chrIV 982530 982730 chrIV_982530_982730_- 0.0 - +chrXII 937585 937785 chrXII_937585_937785_+ 0.0 + +chrXII 561624 561824 chrXII_561624_561824_- 0.0 - +chrVII 786023 786223 chrVII_786023_786223_- 0.0 - +chrIII 80385 80585 chrIII_80385_80585_- 0.0 - +chrXV 970004 970204 chrXV_970004_970204_+ 0.0 + +chrIV 958616 958816 chrIV_958616_958816_- 0.0 - +chrXI 397373 397573 chrXI_397373_397573_- 0.0 - +chrXIV 456269 456469 chrXIV_456269_456469_- 0.0 - +chrXIII 646143 646343 chrXIII_646143_646343_+ 0.0 + +chrIII 253221 253421 chrIII_253221_253421_- 0.0 - +chrVIII 113530 113730 chrVIII_113530_113730_+ 0.0 + +chrXVI 903565 903765 chrXVI_903565_903765_+ 0.0 + +chrXIII 753521 753721 chrXIII_753521_753721_+ 0.0 + +chrXVI 25492 25692 chrXVI_25492_25692_- 0.0 - +chrXV 377567 377767 chrXV_377567_377767_- 0.0 - +chrIII 121223 121423 chrIII_121223_121423_+ 0.0 + +chrXII 440175 440375 chrXII_440175_440375_- 0.0 - +chrII 706761 706961 chrII_706761_706961_- 0.0 - +chrXI 189611 189811 chrXI_189611_189811_+ 0.0 + +chrIV 677604 677804 chrIV_677604_677804_- 0.0 - +chrVII 444213 444413 chrVII_444213_444413_+ 0.0 + +chrVIII 270964 271164 chrVIII_270964_271164_+ 0.0 + +chrVIII 5626 5826 chrVIII_5626_5826_+ 0.0 + +chrVII 414253 414453 chrVII_414253_414453_+ 0.0 + +chrXVI 585967 586167 chrXVI_585967_586167_+ 0.0 + +chrXIV 580056 580256 chrXIV_580056_580256_+ 0.0 + +chrII 702831 703031 chrII_702831_703031_- 0.0 - +chrVII 363856 364056 chrVII_363856_364056_- 0.0 - +chrIII 36082 36282 chrIII_36082_36282_+ 0.0 + +chrII 489864 490064 chrII_489864_490064_+ 0.0 + +chrXIII 108300 108500 chrXIII_108300_108500_+ 0.0 + +chrX 95551 95751 chrX_95551_95751_- 0.0 - +chrX 117653 117853 chrX_117653_117853_- 0.0 - +chrXII 1022416 1022616 chrXII_1022416_1022616_+ 0.0 + +chrXV 760985 761185 chrXV_760985_761185_- 0.0 - +chrVIII 342279 342479 chrVIII_342279_342479_+ 0.0 + +chrXVI 229295 229495 chrXVI_229295_229495_- 0.0 - +chrXIV 27883 28083 chrXIV_27883_28083_- 0.0 - +chrXVI 832406 832606 chrXVI_832406_832606_+ 0.0 + +chrXII 195609 195809 chrXII_195609_195809_+ 0.0 + +chrI 94844 95044 chrI_94844_95044_- 0.0 - +chrXV 1004529 1004729 chrXV_1004529_1004729_- 0.0 - +chrV 73300 73500 chrV_73300_73500_- 0.0 - +chrXII 974467 974667 chrXII_974467_974667_+ 0.0 + +chrV 84848 85048 chrV_84848_85048_+ 0.0 + +chrV 509283 509483 chrV_509283_509483_- 0.0 - +chrXV 125918 126118 chrXV_125918_126118_+ 0.0 + +chrXV 224492 224692 chrXV_224492_224692_+ 0.0 + +chrXV 247572 247772 chrXV_247572_247772_- 0.0 - +chrXVI 787088 787288 chrXVI_787088_787288_- 0.0 - +chrX 659251 659451 chrX_659251_659451_+ 0.0 + +chrXII 124711 124911 chrXII_124711_124911_- 0.0 - +chrXVI 462460 462660 chrXVI_462460_462660_- 0.0 - +chrIV 940529 940729 chrIV_940529_940729_- 0.0 - +chrXV 1035431 1035631 chrXV_1035431_1035631_- 0.0 - +chrII 308186 308386 chrII_308186_308386_+ 0.0 + +chrXIV 301395 301595 chrXIV_301395_301595_- 0.0 - +chrVI 254445 254645 chrVI_254445_254645_+ 0.0 + +chrX 662601 662801 chrX_662601_662801_+ 0.0 + +chrIV 832987 833187 chrIV_832987_833187_- 0.0 - +chrII 536156 536356 chrII_536156_536356_+ 0.0 + +chrVIII 463719 463919 chrVIII_463719_463919_- 0.0 - +chrXI 127238 127438 chrXI_127238_127438_- 0.0 - +chrXV 965700 965900 chrXV_965700_965900_- 0.0 - +chrVII 100242 100442 chrVII_100242_100442_+ 0.0 + +chrXV 462207 462407 chrXV_462207_462407_+ 0.0 + +chrVII 978462 978662 chrVII_978462_978662_+ 0.0 + +chrXVI 68651 68851 chrXVI_68651_68851_- 0.0 - +chrIV 529328 529528 chrIV_529328_529528_+ 0.0 + +chrXIII 298421 298621 chrXIII_298421_298621_+ 0.0 + +chrXIII 274888 275088 chrXIII_274888_275088_+ 0.0 + +chrX 528771 528971 chrX_528771_528971_- 0.0 - +chrI 200182 200382 chrI_200182_200382_+ 0.0 + +chrIX 68828 69028 chrIX_68828_69028_+ 0.0 + +chrX 170982 171182 chrX_170982_171182_- 0.0 - +chrXIII 914753 914953 chrXIII_914753_914953_+ 0.0 + +chrIV 581913 582113 chrIV_581913_582113_- 0.0 - +chrXII 34428 34628 chrXII_34428_34628_- 0.0 - +chrIV 1428004 1428204 chrIV_1428004_1428204_- 0.0 - +chrII 577600 577800 chrII_577600_577800_+ 0.0 + +chrXIV 137427 137627 chrXIV_137427_137627_+ 0.0 + +chrII 520846 521046 chrII_520846_521046_- 0.0 - +chrXVI 688832 689032 chrXVI_688832_689032_+ 0.0 + +chrXV 258413 258613 chrXV_258413_258613_- 0.0 - +chrVIII 31562 31762 chrVIII_31562_31762_- 0.0 - +chrII 597958 598158 chrII_597958_598158_+ 0.0 + +chrXI 245718 245918 chrXI_245718_245918_- 0.0 - +chrXVI 158312 158512 chrXVI_158312_158512_+ 0.0 + +chrXV 900233 900433 chrXV_900233_900433_+ 0.0 + +chrXV 262148 262348 chrXV_262148_262348_+ 0.0 + +chrXV 404254 404454 chrXV_404254_404454_+ 0.0 + +chrIV 259029 259229 chrIV_259029_259229_- 0.0 - +chrVII 208342 208542 chrVII_208342_208542_+ 0.0 + +chrV 567554 567754 chrV_567554_567754_+ 0.0 + +chrIV 1169395 1169595 chrIV_1169395_1169595_- 0.0 - +chrXVI 615993 616193 chrXVI_615993_616193_+ 0.0 + +chrXV 118618 118818 chrXV_118618_118818_- 0.0 - +chrI 74673 74873 chrI_74673_74873_+ 0.0 + +chrVII 263478 263678 chrVII_263478_263678_- 0.0 - +chrII 520347 520547 chrII_520347_520547_- 0.0 - +chrXII 618599 618799 chrXII_618599_618799_+ 0.0 + +chrIX 72650 72850 chrIX_72650_72850_+ 0.0 + +chrII 442471 442671 chrII_442471_442671_- 0.0 - +chrIV 592515 592715 chrIV_592515_592715_+ 0.0 + +chrXII 399553 399753 chrXII_399553_399753_- 0.0 - +chrVII 705998 706198 chrVII_705998_706198_+ 0.0 + +chrI 94266 94466 chrI_94266_94466_- 0.0 - +chrXIII 43818 44018 chrXIII_43818_44018_+ 0.0 + +chrVIII 346169 346369 chrVIII_346169_346369_+ 0.0 + +chrXII 972351 972551 chrXII_972351_972551_+ 0.0 + +chrX 119524 119724 chrX_119524_119724_- 0.0 - +chrV 313229 313429 chrV_313229_313429_- 0.0 - +chrXVI 695590 695790 chrXVI_695590_695790_- 0.0 - +chrXVI 357136 357336 chrXVI_357136_357336_+ 0.0 + +chrXII 240282 240482 chrXII_240282_240482_+ 0.0 + +chrXII 601854 602054 chrXII_601854_602054_- 0.0 - +chrXII 443281 443481 chrXII_443281_443481_- 0.0 - +chrVI 202790 202990 chrVI_202790_202990_+ 0.0 + +chrXV 942208 942408 chrXV_942208_942408_- 0.0 - +chrXIV 662559 662759 chrXIV_662559_662759_+ 0.0 + +chrIV 1185719 1185919 chrIV_1185719_1185919_+ 0.0 + +chrIX 14814 15014 chrIX_14814_15014_+ 0.0 + +chrII 419321 419521 chrII_419321_419521_+ 0.0 + +chrII 524563 524763 chrII_524563_524763_- 0.0 - +chrII 704883 705083 chrII_704883_705083_+ 0.0 + +chrIV 576925 577125 chrIV_576925_577125_- 0.0 - +chrX 450549 450749 chrX_450549_450749_+ 0.0 + +chrXII 1030887 1031087 chrXII_1030887_1031087_- 0.0 - +chrV 71734 71934 chrV_71734_71934_+ 0.0 + +chrIV 1384787 1384987 chrIV_1384787_1384987_- 0.0 - +chrXII 452613 452813 chrXII_452613_452813_+ 0.0 + +chrIV 1068295 1068495 chrIV_1068295_1068495_- 0.0 - +chrXIII 457469 457669 chrXIII_457469_457669_- 0.0 - +chrIV 976407 976607 chrIV_976407_976607_- 0.0 - +chrVIII 202047 202247 chrVIII_202047_202247_- 0.0 - +chrIX 347722 347922 chrIX_347722_347922_- 0.0 - +chrXI 66702 66902 chrXI_66702_66902_- 0.0 - +chrVII 48100 48300 chrVII_48100_48300_+ 0.0 + +chrVII 57547 57747 chrVII_57547_57747_+ 0.0 + +chrII 645904 646104 chrII_645904_646104_- 0.0 - +chrV 386613 386813 chrV_386613_386813_+ 0.0 + +chrIV 248093 248293 chrIV_248093_248293_- 0.0 - +chrIV 547017 547217 chrIV_547017_547217_- 0.0 - +chrXIII 582823 583023 chrXIII_582823_583023_+ 0.0 + +chrVII 572191 572391 chrVII_572191_572391_- 0.0 - +chrI 34966 35166 chrI_34966_35166_+ 0.0 + +chrII 798201 798401 chrII_798201_798401_+ 0.0 + +chrXIII 7072 7272 chrXIII_7072_7272_- 0.0 - +chrIX 216025 216225 chrIX_216025_216225_- 0.0 - +chrXV 236914 237114 chrXV_236914_237114_- 0.0 - +chrXII 712606 712806 chrXII_712606_712806_- 0.0 - +chrXI 446532 446732 chrXI_446532_446732_+ 0.0 + +chrXVI 235458 235658 chrXVI_235458_235658_- 0.0 - +chrIV 542368 542568 chrIV_542368_542568_+ 0.0 + +chrVII 46664 46864 chrVII_46664_46864_+ 0.0 + +chrXVI 326093 326293 chrXVI_326093_326293_+ 0.0 + +chrXIV 406609 406809 chrXIV_406609_406809_- 0.0 - +chrIII 206328 206528 chrIII_206328_206528_- 0.0 - +chrXVI 835271 835471 chrXVI_835271_835471_+ 0.0 + +chrXVI 596120 596320 chrXVI_596120_596320_- 0.0 - +chrI 200177 200377 chrI_200177_200377_- 0.0 - +chrX 547215 547415 chrX_547215_547415_- 0.0 - +chrV 409537 409737 chrV_409537_409737_+ 0.0 + +chrXV 139566 139766 chrXV_139566_139766_+ 0.0 + +chrXVI 791681 791881 chrXVI_791681_791881_+ 0.0 + +chrIV 1350110 1350310 chrIV_1350110_1350310_- 0.0 - +chrXIV 506749 506949 chrXIV_506749_506949_- 0.0 - +chrXIII 696131 696331 chrXIII_696131_696331_+ 0.0 + +chrXII 848260 848460 chrXII_848260_848460_- 0.0 - +chrXII 941173 941373 chrXII_941173_941373_- 0.0 - +chrIV 1516558 1516758 chrIV_1516558_1516758_+ 0.0 + +chrXI 223178 223378 chrXI_223178_223378_- 0.0 - +chrXVI 659534 659734 chrXVI_659534_659734_+ 0.0 + +chrV 105429 105629 chrV_105429_105629_- 0.0 - +chrXV 200837 201037 chrXV_200837_201037_+ 0.0 + +chrVII 789915 790115 chrVII_789915_790115_- 0.0 - +chrII 565257 565457 chrII_565257_565457_+ 0.0 + +chrVII 420033 420233 chrVII_420033_420233_+ 0.0 + +chrV 407387 407587 chrV_407387_407587_- 0.0 - +chrXIV 351198 351398 chrXIV_351198_351398_+ 0.0 + +chrXII 622663 622863 chrXII_622663_622863_+ 0.0 + +chrIX 164072 164272 chrIX_164072_164272_- 0.0 - +chrIII 190729 190929 chrIII_190729_190929_- 0.0 - +chrIV 572910 573110 chrIV_572910_573110_+ 0.0 + +chrXV 917156 917356 chrXV_917156_917356_+ 0.0 + +chrIX 102824 103024 chrIX_102824_103024_- 0.0 - +chrIV 1021962 1022162 chrIV_1021962_1022162_+ 0.0 + +chrXVI 352446 352646 chrXVI_352446_352646_- 0.0 - +chrVII 761783 761983 chrVII_761783_761983_- 0.0 - +chrIII 54175 54375 chrIII_54175_54375_+ 0.0 + +chrIX 408090 408290 chrIX_408090_408290_- 0.0 - +chrXVI 477186 477386 chrXVI_477186_477386_+ 0.0 + +chrII 185696 185896 chrII_185696_185896_- 0.0 - +chrVIII 384896 385096 chrVIII_384896_385096_+ 0.0 + +chrX 187575 187775 chrX_187575_187775_+ 0.0 + +chrXIV 508713 508913 chrXIV_508713_508913_- 0.0 - +chrIX 362537 362737 chrIX_362537_362737_+ 0.0 + +chrXV 616946 617146 chrXV_616946_617146_+ 0.0 + +chrXIV 407801 408001 chrXIV_407801_408001_+ 0.0 + +chrXII 1062349 1062549 chrXII_1062349_1062549_+ 0.0 + +chrXIII 207334 207534 chrXIII_207334_207534_- 0.0 - +chrXI 498736 498936 chrXI_498736_498936_+ 0.0 + +chrXV 275357 275557 chrXV_275357_275557_+ 0.0 + +chrVII 859604 859804 chrVII_859604_859804_- 0.0 - +chrXVI 837497 837697 chrXVI_837497_837697_- 0.0 - +chrXI 504274 504474 chrXI_504274_504474_- 0.0 - +chrXVI 395519 395719 chrXVI_395519_395719_- 0.0 - +chrIV 871039 871239 chrIV_871039_871239_+ 0.0 + +chrXII 793282 793482 chrXII_793282_793482_- 0.0 - +chrXIII 212977 213177 chrXIII_212977_213177_+ 0.0 + +chrIX 87491 87691 chrIX_87491_87691_- 0.0 - +chrVII 275412 275612 chrVII_275412_275612_- 0.0 - +chrXV 700465 700665 chrXV_700465_700665_+ 0.0 + +chrIV 584377 584577 chrIV_584377_584577_+ 0.0 + +chrX 492319 492519 chrX_492319_492519_- 0.0 - +chrII 485205 485405 chrII_485205_485405_- 0.0 - +chrXIII 295923 296123 chrXIII_295923_296123_+ 0.0 + +chrIV 1111510 1111710 chrIV_1111510_1111710_+ 0.0 + +chrXI 36677 36877 chrXI_36677_36877_- 0.0 - +chrXII 372997 373197 chrXII_372997_373197_- 0.0 - +chrXII 193894 194094 chrXII_193894_194094_- 0.0 - +chrXV 1088091 1088291 chrXV_1088091_1088291_+ 0.0 + +chrXIV 650255 650455 chrXIV_650255_650455_- 0.0 - +chrX 696994 697194 chrX_696994_697194_+ 0.0 + +chrII 275625 275825 chrII_275625_275825_+ 0.0 + +chrVII 175029 175229 chrVII_175029_175229_+ 0.0 + +chrXI 239868 240068 chrXI_239868_240068_+ 0.0 + +chrXI 644048 644248 chrXI_644048_644248_+ 0.0 + +chrXIII 112021 112221 chrXIII_112021_112221_+ 0.0 + +chrIV 1416720 1416920 chrIV_1416720_1416920_+ 0.0 + +chrIX 164111 164311 chrIX_164111_164311_+ 0.0 + +chrI 59812 60012 chrI_59812_60012_- 0.0 - +chrVII 1015610 1015810 chrVII_1015610_1015810_+ 0.0 + +chrXIII 429353 429553 chrXIII_429353_429553_- 0.0 - +chrVIII 494180 494380 chrVIII_494180_494380_- 0.0 - +chrVII 196203 196403 chrVII_196203_196403_- 0.0 - +chrXVI 245849 246049 chrXVI_245849_246049_- 0.0 - +chrXV 121499 121699 chrXV_121499_121699_+ 0.0 + +chrXIV 211892 212092 chrXIV_211892_212092_- 0.0 - +chrXIII 86626 86826 chrXIII_86626_86826_+ 0.0 + +chrVII 969724 969924 chrVII_969724_969924_- 0.0 - +chrXVI 799836 800036 chrXVI_799836_800036_+ 0.0 + +chrXIII 389593 389793 chrXIII_389593_389793_+ 0.0 + +chrIX 303121 303321 chrIX_303121_303321_+ 0.0 + +chrXIV 465240 465440 chrXIV_465240_465440_- 0.0 - +chrVIII 364008 364208 chrVIII_364008_364208_- 0.0 - +chrXIII 66875 67075 chrXIII_66875_67075_- 0.0 - +chrII 703840 704040 chrII_703840_704040_+ 0.0 + +chrXII 732421 732621 chrXII_732421_732621_- 0.0 - +chrX 339035 339235 chrX_339035_339235_- 0.0 - +chrVIII 282891 283091 chrVIII_282891_283091_+ 0.0 + +chrX 742585 742785 chrX_742585_742785_- 0.0 - +chrXIV 662175 662375 chrXIV_662175_662375_+ 0.0 + +chrIV 1456955 1457155 chrIV_1456955_1457155_- 0.0 - +chrXV 798270 798470 chrXV_798270_798470_+ 0.0 + +chrXIV 293687 293887 chrXIV_293687_293887_+ 0.0 + +chrXI 40998 41198 chrXI_40998_41198_- 0.0 - +chrVI 119444 119644 chrVI_119444_119644_- 0.0 - +chrX 465056 465256 chrX_465056_465256_- 0.0 - +chrI 137837 138037 chrI_137837_138037_+ 0.0 + +chrIX 69193 69393 chrIX_69193_69393_+ 0.0 + +chrIII 287554 287754 chrIII_287554_287754_+ 0.0 + +chrII 675292 675492 chrII_675292_675492_+ 0.0 + +chrM 59428 59628 chrM_59428_59628_- 0.0 - +chrIX 294705 294905 chrIX_294705_294905_- 0.0 - +chrVII 969433 969633 chrVII_969433_969633_+ 0.0 + +chrI 227773 227973 chrI_227773_227973_+ 0.0 + +chrVII 694742 694942 chrVII_694742_694942_+ 0.0 + +chrII 135716 135916 chrII_135716_135916_- 0.0 - +chrIV 1296602 1296802 chrIV_1296602_1296802_+ 0.0 + +chrXI 444772 444972 chrXI_444772_444972_- 0.0 - +chrXIV 157416 157616 chrXIV_157416_157616_- 0.0 - +chrXVI 711583 711783 chrXVI_711583_711783_- 0.0 - +chrXIV 43628 43828 chrXIV_43628_43828_+ 0.0 + +chrIV 871891 872091 chrIV_871891_872091_+ 0.0 + +chrXVI 941788 941988 chrXVI_941788_941988_- 0.0 - +chrXIII 226515 226715 chrXIII_226515_226715_- 0.0 - +chrVII 938722 938922 chrVII_938722_938922_+ 0.0 + +chrVII 794043 794243 chrVII_794043_794243_+ 0.0 + +chrX 603819 604019 chrX_603819_604019_+ 0.0 + +chrXI 3446 3646 chrXI_3446_3646_- 0.0 - +chrXIV 214081 214281 chrXIV_214081_214281_- 0.0 - +chrXIV 163039 163239 chrXIV_163039_163239_- 0.0 - +chrIV 325057 325257 chrIV_325057_325257_- 0.0 - +chrXVI 50155 50355 chrXVI_50155_50355_+ 0.0 + +chrXII 1023181 1023381 chrXII_1023181_1023381_+ 0.0 + +chrVII 590826 591026 chrVII_590826_591026_+ 0.0 + +chrVI 216420 216620 chrVI_216420_216620_- 0.0 - +chrIII 114308 114508 chrIII_114308_114508_- 0.0 - +chrXIV 178182 178382 chrXIV_178182_178382_- 0.0 - +chrIX 403785 403985 chrIX_403785_403985_- 0.0 - +chrM 12259 12459 chrM_12259_12459_- 0.0 - +chrIII 163080 163280 chrIII_163080_163280_+ 0.0 + +chrIV 1006990 1007190 chrIV_1006990_1007190_- 0.0 - +chrVII 644775 644975 chrVII_644775_644975_+ 0.0 + +chrIV 742060 742260 chrIV_742060_742260_- 0.0 - +chrVII 737760 737960 chrVII_737760_737960_- 0.0 - +chrV 555445 555645 chrV_555445_555645_+ 0.0 + +chrII 639979 640179 chrII_639979_640179_+ 0.0 + +chrXIII 518884 519084 chrXIII_518884_519084_- 0.0 - +chrX 347946 348146 chrX_347946_348146_+ 0.0 + +chrXVI 246934 247134 chrXVI_246934_247134_+ 0.0 + +chrVII 306498 306698 chrVII_306498_306698_- 0.0 - +chrXVI 797747 797947 chrXVI_797747_797947_- 0.0 - +chrXIII 413476 413676 chrXIII_413476_413676_+ 0.0 + +chrXII 758450 758650 chrXII_758450_758650_+ 0.0 + +chrXII 301449 301649 chrXII_301449_301649_- 0.0 - +chrIII 61405 61605 chrIII_61405_61605_+ 0.0 + +chrXII 135137 135337 chrXII_135137_135337_- 0.0 - +chrV 189576 189776 chrV_189576_189776_- 0.0 - +chrVI 25699 25899 chrVI_25699_25899_- 0.0 - +chrXVI 121414 121614 chrXVI_121414_121614_- 0.0 - +chrVIII 217874 218074 chrVIII_217874_218074_- 0.0 - +chrIV 328899 329099 chrIV_328899_329099_+ 0.0 + +chrVII 67013 67213 chrVII_67013_67213_+ 0.0 + +chrXII 39720 39920 chrXII_39720_39920_- 0.0 - +chrXIII 508065 508265 chrXIII_508065_508265_- 0.0 - +chrXIII 376997 377197 chrXIII_376997_377197_+ 0.0 + +chrX 101066 101266 chrX_101066_101266_+ 0.0 + +chrVII 607038 607238 chrVII_607038_607238_- 0.0 - +chrXIV 659532 659732 chrXIV_659532_659732_- 0.0 - +chrXII 1071948 1072148 chrXII_1071948_1072148_- 0.0 - +chrXI 635928 636128 chrXI_635928_636128_- 0.0 - +chrVII 594892 595092 chrVII_594892_595092_+ 0.0 + +chrVI 123068 123268 chrVI_123068_123268_+ 0.0 + +chrXIV 263933 264133 chrXIV_263933_264133_+ 0.0 + +chrXII 664573 664773 chrXII_664573_664773_- 0.0 - +chrXII 86380 86580 chrXII_86380_86580_- 0.0 - +chrXV 735073 735273 chrXV_735073_735273_+ 0.0 + +chrIV 1460545 1460745 chrIV_1460545_1460745_+ 0.0 + +chrXII 160505 160705 chrXII_160505_160705_- 0.0 - +chrXI 405165 405365 chrXI_405165_405365_+ 0.0 + +chrXV 791215 791415 chrXV_791215_791415_- 0.0 - +chrVIII 37316 37516 chrVIII_37316_37516_- 0.0 - +chrX 98498 98698 chrX_98498_98698_- 0.0 - +chrXII 430988 431188 chrXII_430988_431188_- 0.0 - +chrXV 285579 285779 chrXV_285579_285779_+ 0.0 + +chrVII 162961 163161 chrVII_162961_163161_+ 0.0 + +chrVII 591898 592098 chrVII_591898_592098_+ 0.0 + +chrV 79979 80179 chrV_79979_80179_- 0.0 - +chrIV 1069327 1069527 chrIV_1069327_1069527_- 0.0 - +chrIV 249080 249280 chrIV_249080_249280_- 0.0 - +chrXII 240534 240734 chrXII_240534_240734_+ 0.0 + +chrXIII 582905 583105 chrXIII_582905_583105_+ 0.0 + +chrXIII 589141 589341 chrXIII_589141_589341_- 0.0 - +chrXV 598996 599196 chrXV_598996_599196_+ 0.0 + +chrXII 615605 615805 chrXII_615605_615805_- 0.0 - +chrVII 844584 844784 chrVII_844584_844784_+ 0.0 + +chrXVI 647449 647649 chrXVI_647449_647649_- 0.0 - +chrVII 449840 450040 chrVII_449840_450040_- 0.0 - +chrX 417908 418108 chrX_417908_418108_- 0.0 - +chrX 686176 686376 chrX_686176_686376_+ 0.0 + +chrXIV 367059 367259 chrXIV_367059_367259_- 0.0 - +chrVII 911496 911696 chrVII_911496_911696_+ 0.0 + +chrXIII 524377 524577 chrXIII_524377_524577_- 0.0 - +chrI 222652 222852 chrI_222652_222852_- 0.0 - +chrII 461799 461999 chrII_461799_461999_+ 0.0 + +chrXI 395537 395737 chrXI_395537_395737_- 0.0 - +chrII 771211 771411 chrII_771211_771411_- 0.0 - +chrX 469714 469914 chrX_469714_469914_- 0.0 - +chrXVI 7394 7594 chrXVI_7394_7594_- 0.0 - +chrIV 1266361 1266561 chrIV_1266361_1266561_+ 0.0 + +chrIV 1143885 1144085 chrIV_1143885_1144085_+ 0.0 + +chrXII 515246 515446 chrXII_515246_515446_+ 0.0 + +chrIX 270976 271176 chrIX_270976_271176_+ 0.0 + +chrXIV 228702 228902 chrXIV_228702_228902_- 0.0 - +chrX 153691 153891 chrX_153691_153891_- 0.0 - +chrIII 68500 68700 chrIII_68500_68700_+ 0.0 + +chrIII 167442 167642 chrIII_167442_167642_- 0.0 - +chrIV 422001 422201 chrIV_422001_422201_+ 0.0 + +chrXII 760574 760774 chrXII_760574_760774_- 0.0 - +chrXV 766497 766697 chrXV_766497_766697_+ 0.0 + +chrIX 181199 181399 chrIX_181199_181399_- 0.0 - +chrXI 268992 269192 chrXI_268992_269192_- 0.0 - +chrXIII 889546 889746 chrXIII_889546_889746_- 0.0 - +chrII 504676 504876 chrII_504676_504876_- 0.0 - +chrXV 1089495 1089695 chrXV_1089495_1089695_+ 0.0 + +chrXV 1081036 1081236 chrXV_1081036_1081236_- 0.0 - +chrXI 348354 348554 chrXI_348354_348554_- 0.0 - +chrIV 599617 599817 chrIV_599617_599817_+ 0.0 + +chrVIII 530697 530897 chrVIII_530697_530897_+ 0.0 + +chrXIV 593809 594009 chrXIV_593809_594009_- 0.0 - +chrV 153903 154103 chrV_153903_154103_+ 0.0 + +chrIX 369771 369971 chrIX_369771_369971_- 0.0 - +chrIV 10450 10650 chrIV_10450_10650_+ 0.0 + +chrXIII 467538 467738 chrXIII_467538_467738_- 0.0 - +chrVII 295144 295344 chrVII_295144_295344_- 0.0 - +chrIV 648048 648248 chrIV_648048_648248_+ 0.0 + +chrV 493813 494013 chrV_493813_494013_+ 0.0 + +chrVIII 110022 110222 chrVIII_110022_110222_- 0.0 - +chrVIII 423861 424061 chrVIII_423861_424061_- 0.0 - +chrVII 394090 394290 chrVII_394090_394290_+ 0.0 + +chrIV 1335150 1335350 chrIV_1335150_1335350_- 0.0 - +chrXI 157617 157817 chrXI_157617_157817_- 0.0 - +chrVII 14653 14853 chrVII_14653_14853_+ 0.0 + +chrXVI 772959 773159 chrXVI_772959_773159_- 0.0 - +chrV 76025 76225 chrV_76025_76225_- 0.0 - +chrXIV 436259 436459 chrXIV_436259_436459_- 0.0 - +chrV 132703 132903 chrV_132703_132903_- 0.0 - +chrXIII 870920 871120 chrXIII_870920_871120_+ 0.0 + +chrVII 4134 4334 chrVII_4134_4334_+ 0.0 + +chrX 470832 471032 chrX_470832_471032_- 0.0 - +chrV 503052 503252 chrV_503052_503252_- 0.0 - +chrXV 971203 971403 chrXV_971203_971403_- 0.0 - +chrIV 366949 367149 chrIV_366949_367149_- 0.0 - +chrIV 827484 827684 chrIV_827484_827684_+ 0.0 + +chrV 307918 308118 chrV_307918_308118_- 0.0 - +chrIX 192773 192973 chrIX_192773_192973_+ 0.0 + +chrIII 19246 19446 chrIII_19246_19446_+ 0.0 + +chrXV 599915 600115 chrXV_599915_600115_+ 0.0 + +chrXVI 936028 936228 chrXVI_936028_936228_+ 0.0 + +chrXI 539474 539674 chrXI_539474_539674_- 0.0 - +chrXIV 294800 295000 chrXIV_294800_295000_+ 0.0 + +chrXII 875670 875870 chrXII_875670_875870_+ 0.0 + +chrXVI 78634 78834 chrXVI_78634_78834_- 0.0 - +chrXIII 734613 734813 chrXIII_734613_734813_- 0.0 - +chrII 809453 809653 chrII_809453_809653_+ 0.0 + +chrXVI 308087 308287 chrXVI_308087_308287_+ 0.0 + +chrVIII 411667 411867 chrVIII_411667_411867_+ 0.0 + +chrVI 37939 38139 chrVI_37939_38139_- 0.0 - +chrIX 142431 142631 chrIX_142431_142631_- 0.0 - +chrIV 559236 559436 chrIV_559236_559436_+ 0.0 + +chrXI 139874 140074 chrXI_139874_140074_- 0.0 - +chrVIII 18188 18388 chrVIII_18188_18388_+ 0.0 + +chrIV 545401 545601 chrIV_545401_545601_- 0.0 - +chrVII 317315 317515 chrVII_317315_317515_+ 0.0 + +chrXIII 59634 59834 chrXIII_59634_59834_+ 0.0 + +chrX 68700 68900 chrX_68700_68900_+ 0.0 + +chrI 57935 58135 chrI_57935_58135_- 0.0 - +chrIV 326593 326793 chrIV_326593_326793_- 0.0 - +chrV 448739 448939 chrV_448739_448939_+ 0.0 + +chrXI 343460 343660 chrXI_343460_343660_- 0.0 - +chrVIII 355073 355273 chrVIII_355073_355273_+ 0.0 + +chrIV 971837 972037 chrIV_971837_972037_- 0.0 - +chrXVI 306982 307182 chrXVI_306982_307182_+ 0.0 + +chrIV 66485 66685 chrIV_66485_66685_- 0.0 - +chrXII 513415 513615 chrXII_513415_513615_- 0.0 - +chrXII 369412 369612 chrXII_369412_369612_+ 0.0 + +chrIV 684908 685108 chrIV_684908_685108_- 0.0 - +chrI 79261 79461 chrI_79261_79461_+ 0.0 + +chrVIII 21714 21914 chrVIII_21714_21914_- 0.0 - +chrXVI 580804 581004 chrXVI_580804_581004_- 0.0 - +chrIV 671836 672036 chrIV_671836_672036_- 0.0 - +chrVII 720038 720238 chrVII_720038_720238_- 0.0 - +chrVIII 73081 73281 chrVIII_73081_73281_+ 0.0 + +chrXIII 470928 471128 chrXIII_470928_471128_- 0.0 - +chrXVI 593513 593713 chrXVI_593513_593713_- 0.0 - +chrXII 969611 969811 chrXII_969611_969811_- 0.0 - +chrX 613432 613632 chrX_613432_613632_- 0.0 - +chrXVI 62865 63065 chrXVI_62865_63065_- 0.0 - +chrIII 182530 182730 chrIII_182530_182730_- 0.0 - +chrXV 314399 314599 chrXV_314399_314599_- 0.0 - +chrVIII 196473 196673 chrVIII_196473_196673_+ 0.0 + +chrIX 432367 432567 chrIX_432367_432567_+ 0.0 + +chrIX 120252 120452 chrIX_120252_120452_- 0.0 - +chrVI 30062 30262 chrVI_30062_30262_+ 0.0 + +chrIX 109214 109414 chrIX_109214_109414_- 0.0 - +chrI 101347 101547 chrI_101347_101547_+ 0.0 + +chrXI 435860 436060 chrXI_435860_436060_+ 0.0 + +chrXIV 306624 306824 chrXIV_306624_306824_+ 0.0 + +chrXIII 388140 388340 chrXIII_388140_388340_- 0.0 - +chrXV 68999 69199 chrXV_68999_69199_- 0.0 - +chrXV 650884 651084 chrXV_650884_651084_- 0.0 - +chrM 62935 63135 chrM_62935_63135_- 0.0 - +chrX 535107 535307 chrX_535107_535307_+ 0.0 + +chrXVI 649311 649511 chrXVI_649311_649511_+ 0.0 + +chrXI 323377 323577 chrXI_323377_323577_- 0.0 - +chrXI 432106 432306 chrXI_432106_432306_- 0.0 - +chrXI 628310 628510 chrXI_628310_628510_+ 0.0 + +chrIII 313884 314084 chrIII_313884_314084_+ 0.0 + +chrI 81881 82081 chrI_81881_82081_+ 0.0 + +chrIV 1261940 1262140 chrIV_1261940_1262140_+ 0.0 + +chrXII 1043783 1043983 chrXII_1043783_1043983_+ 0.0 + +chrXV 17210 17410 chrXV_17210_17410_- 0.0 - +chrXIV 153102 153302 chrXIV_153102_153302_- 0.0 - +chrII 595906 596106 chrII_595906_596106_+ 0.0 + +chrIV 597902 598102 chrIV_597902_598102_+ 0.0 + +chrVII 267491 267691 chrVII_267491_267691_+ 0.0 + +chrX 135354 135554 chrX_135354_135554_+ 0.0 + +chrXIII 233462 233662 chrXIII_233462_233662_+ 0.0 + +chrXIII 475902 476102 chrXIII_475902_476102_- 0.0 - +chrV 105501 105701 chrV_105501_105701_+ 0.0 + +chrVIII 537208 537408 chrVIII_537208_537408_- 0.0 - +chrXIV 604685 604885 chrXIV_604685_604885_+ 0.0 + +chrXV 900253 900453 chrXV_900253_900453_+ 0.0 + +chrIX 253323 253523 chrIX_253323_253523_- 0.0 - +chrI 27556 27756 chrI_27556_27756_- 0.0 - +chrVIII 414446 414646 chrVIII_414446_414646_- 0.0 - +chrX 379124 379324 chrX_379124_379324_- 0.0 - +chrVII 303145 303345 chrVII_303145_303345_- 0.0 - +chrXVI 896925 897125 chrXVI_896925_897125_- 0.0 - +chrXIII 914158 914358 chrXIII_914158_914358_- 0.0 - +chrIV 522986 523186 chrIV_522986_523186_- 0.0 - +chrXIII 189330 189530 chrXIII_189330_189530_+ 0.0 + +chrXV 936501 936701 chrXV_936501_936701_- 0.0 - +chrV 421025 421225 chrV_421025_421225_+ 0.0 + +chrXIV 758338 758538 chrXIV_758338_758538_- 0.0 - +chrIV 1011096 1011296 chrIV_1011096_1011296_- 0.0 - +chrV 472640 472840 chrV_472640_472840_+ 0.0 + +chrXIV 512463 512663 chrXIV_512463_512663_- 0.0 - +chrXVI 239918 240118 chrXVI_239918_240118_+ 0.0 + +chrII 328749 328949 chrII_328749_328949_- 0.0 - +chrIV 797903 798103 chrIV_797903_798103_+ 0.0 + +chrXIV 490482 490682 chrXIV_490482_490682_- 0.0 - +chrIV 730265 730465 chrIV_730265_730465_+ 0.0 + +chrVII 153723 153923 chrVII_153723_153923_+ 0.0 + +chrXIV 476489 476689 chrXIV_476489_476689_+ 0.0 + +chrXII 166142 166342 chrXII_166142_166342_+ 0.0 + +chrIV 1001975 1002175 chrIV_1001975_1002175_+ 0.0 + +chrIV 845309 845509 chrIV_845309_845509_+ 0.0 + +chrXII 13682 13882 chrXII_13682_13882_- 0.0 - +chrVII 684986 685186 chrVII_684986_685186_- 0.0 - +chrXV 888807 889007 chrXV_888807_889007_+ 0.0 + +chrXII 688633 688833 chrXII_688633_688833_- 0.0 - +chrIV 317780 317980 chrIV_317780_317980_+ 0.0 + +chrXVI 616444 616644 chrXVI_616444_616644_+ 0.0 + +chrXIV 754827 755027 chrXIV_754827_755027_+ 0.0 + +chrVII 656062 656262 chrVII_656062_656262_- 0.0 - +chrIV 209630 209830 chrIV_209630_209830_- 0.0 - +chrXVI 408250 408450 chrXVI_408250_408450_- 0.0 - +chrIV 189264 189464 chrIV_189264_189464_+ 0.0 + +chrXV 916640 916840 chrXV_916640_916840_+ 0.0 + +chrIV 687221 687421 chrIV_687221_687421_+ 0.0 + +chrXV 621736 621936 chrXV_621736_621936_+ 0.0 + +chrXVI 408160 408360 chrXVI_408160_408360_+ 0.0 + +chrII 566642 566842 chrII_566642_566842_- 0.0 - +chrVII 240738 240938 chrVII_240738_240938_- 0.0 - +chrII 639693 639893 chrII_639693_639893_+ 0.0 + +chrXV 332851 333051 chrXV_332851_333051_- 0.0 - +chrIV 1208686 1208886 chrIV_1208686_1208886_- 0.0 - +chrVIII 340684 340884 chrVIII_340684_340884_- 0.0 - +chrVIII 225004 225204 chrVIII_225004_225204_- 0.0 - +chrII 632810 633010 chrII_632810_633010_- 0.0 - +chrVIII 417161 417361 chrVIII_417161_417361_+ 0.0 + +chrXII 255818 256018 chrXII_255818_256018_+ 0.0 + +chrV 117196 117396 chrV_117196_117396_+ 0.0 + +chrVIII 229677 229877 chrVIII_229677_229877_- 0.0 - +chrV 532621 532821 chrV_532621_532821_- 0.0 - +chrIX 388575 388775 chrIX_388575_388775_+ 0.0 + +chrIII 303740 303940 chrIII_303740_303940_- 0.0 - +chrXVI 924016 924216 chrXVI_924016_924216_+ 0.0 + +chrX 191513 191713 chrX_191513_191713_+ 0.0 + +chrIX 302039 302239 chrIX_302039_302239_- 0.0 - +chrII 470550 470750 chrII_470550_470750_- 0.0 - +chrVII 90318 90518 chrVII_90318_90518_- 0.0 - +chrVIII 149317 149517 chrVIII_149317_149517_+ 0.0 + +chrVII 774404 774604 chrVII_774404_774604_- 0.0 - +chrXII 572545 572745 chrXII_572545_572745_+ 0.0 + +chrVII 457665 457865 chrVII_457665_457865_+ 0.0 + +chrXIII 582711 582911 chrXIII_582711_582911_- 0.0 - +chrX 167905 168105 chrX_167905_168105_+ 0.0 + +chrI 156667 156867 chrI_156667_156867_- 0.0 - +chrII 800158 800358 chrII_800158_800358_+ 0.0 + +chrVII 665489 665689 chrVII_665489_665689_- 0.0 - +chrXII 1018113 1018313 chrXII_1018113_1018313_+ 0.0 + +chrVIII 141790 141990 chrVIII_141790_141990_- 0.0 - +chrXVI 617991 618191 chrXVI_617991_618191_- 0.0 - +chrXI 383939 384139 chrXI_383939_384139_- 0.0 - +chrIV 586754 586954 chrIV_586754_586954_- 0.0 - +chrXI 116161 116361 chrXI_116161_116361_- 0.0 - +chrVII 811602 811802 chrVII_811602_811802_+ 0.0 + +chrXI 92006 92206 chrXI_92006_92206_- 0.0 - +chrXVI 482817 483017 chrXVI_482817_483017_- 0.0 - +chrVIII 186507 186707 chrVIII_186507_186707_- 0.0 - +chrII 564478 564678 chrII_564478_564678_- 0.0 - +chrII 136590 136790 chrII_136590_136790_- 0.0 - +chrXIV 66485 66685 chrXIV_66485_66685_+ 0.0 + +chrXIII 568273 568473 chrXIII_568273_568473_- 0.0 - +chrIX 253646 253846 chrIX_253646_253846_- 0.0 - +chrXIV 536867 537067 chrXIV_536867_537067_+ 0.0 + +chrVII 954320 954520 chrVII_954320_954520_+ 0.0 + +chrI 166874 167074 chrI_166874_167074_+ 0.0 + +chrIII 138181 138381 chrIII_138181_138381_- 0.0 - +chrXV 310816 311016 chrXV_310816_311016_+ 0.0 + +chrIII 307497 307697 chrIII_307497_307697_- 0.0 - +chrVII 601817 602017 chrVII_601817_602017_- 0.0 - +chrXIII 411414 411614 chrXIII_411414_411614_- 0.0 - +chrVII 630697 630897 chrVII_630697_630897_- 0.0 - +chrVIII 423364 423564 chrVIII_423364_423564_- 0.0 - +chrXII 48393 48593 chrXII_48393_48593_+ 0.0 + +chrV 294003 294203 chrV_294003_294203_+ 0.0 + +chrVII 864698 864898 chrVII_864698_864898_- 0.0 - +chrVIII 124316 124516 chrVIII_124316_124516_- 0.0 - +chrXII 1032981 1033181 chrXII_1032981_1033181_+ 0.0 + +chrX 581795 581995 chrX_581795_581995_+ 0.0 + +chrVII 35399 35599 chrVII_35399_35599_- 0.0 - +chrXII 918342 918542 chrXII_918342_918542_+ 0.0 + +chrXIV 182221 182421 chrXIV_182221_182421_- 0.0 - +chrV 511599 511799 chrV_511599_511799_- 0.0 - +chrIV 346870 347070 chrIV_346870_347070_+ 0.0 + +chrXVI 141263 141463 chrXVI_141263_141463_- 0.0 - +chrVIII 259145 259345 chrVIII_259145_259345_- 0.0 - +chrVIII 345835 346035 chrVIII_345835_346035_- 0.0 - +chrVII 17649 17849 chrVII_17649_17849_- 0.0 - +chrX 563099 563299 chrX_563099_563299_- 0.0 - +chrXV 288275 288475 chrXV_288275_288475_- 0.0 - +chrIV 50308 50508 chrIV_50308_50508_- 0.0 - +chrIX 72151 72351 chrIX_72151_72351_- 0.0 - +chrXIV 215531 215731 chrXIV_215531_215731_- 0.0 - +chrXV 278481 278681 chrXV_278481_278681_- 0.0 - +chrXII 473363 473563 chrXII_473363_473563_- 0.0 - +chrVII 71075 71275 chrVII_71075_71275_+ 0.0 + +chrIV 1420850 1421050 chrIV_1420850_1421050_- 0.0 - +chrXV 1727 1927 chrXV_1727_1927_+ 0.0 + +chrXII 729779 729979 chrXII_729779_729979_- 0.0 - +chrXIII 555914 556114 chrXIII_555914_556114_- 0.0 - +chrXIV 336985 337185 chrXIV_336985_337185_+ 0.0 + +chrII 241038 241238 chrII_241038_241238_+ 0.0 + +chrVII 137088 137288 chrVII_137088_137288_+ 0.0 + +chrXII 353150 353350 chrXII_353150_353350_- 0.0 - +chrXV 595853 596053 chrXV_595853_596053_+ 0.0 + +chrX 228708 228908 chrX_228708_228908_- 0.0 - +chrXV 593548 593748 chrXV_593548_593748_- 0.0 - +chrX 493587 493787 chrX_493587_493787_- 0.0 - +chrV 296382 296582 chrV_296382_296582_- 0.0 - +chrXV 656718 656918 chrXV_656718_656918_+ 0.0 + +chrVII 455263 455463 chrVII_455263_455463_- 0.0 - +chrXII 376864 377064 chrXII_376864_377064_- 0.0 - +chrX 558431 558631 chrX_558431_558631_+ 0.0 + +chrIV 1273912 1274112 chrIV_1273912_1274112_- 0.0 - +chrVII 93997 94197 chrVII_93997_94197_- 0.0 - +chrXV 232958 233158 chrXV_232958_233158_- 0.0 - +chrXI 424649 424849 chrXI_424649_424849_+ 0.0 + +chrVIII 50594 50794 chrVIII_50594_50794_- 0.0 - +chrVII 912478 912678 chrVII_912478_912678_+ 0.0 + +chrVIII 502082 502282 chrVIII_502082_502282_+ 0.0 + +chrXIV 461520 461720 chrXIV_461520_461720_- 0.0 - +chrXII 324370 324570 chrXII_324370_324570_+ 0.0 + +chrIX 34846 35046 chrIX_34846_35046_+ 0.0 + +chrIV 1159212 1159412 chrIV_1159212_1159412_- 0.0 - +chrII 328340 328540 chrII_328340_328540_- 0.0 - +chrXIII 775547 775747 chrXIII_775547_775747_+ 0.0 + +chrIV 568851 569051 chrIV_568851_569051_- 0.0 - +chrXIII 437360 437560 chrXIII_437360_437560_- 0.0 - +chrXIV 727758 727958 chrXIV_727758_727958_+ 0.0 + +chrIX 110792 110992 chrIX_110792_110992_+ 0.0 + +chrXI 559438 559638 chrXI_559438_559638_- 0.0 - +chrIII 71856 72056 chrIII_71856_72056_- 0.0 - +chrIX 390193 390393 chrIX_390193_390393_+ 0.0 + +chrXIII 780442 780642 chrXIII_780442_780642_- 0.0 - +chrXI 22771 22971 chrXI_22771_22971_+ 0.0 + +chrVIII 111280 111480 chrVIII_111280_111480_+ 0.0 + +chrXII 181396 181596 chrXII_181396_181596_- 0.0 - +chrXI 316785 316985 chrXI_316785_316985_- 0.0 - +chrXVI 443972 444172 chrXVI_443972_444172_- 0.0 - +chrXVI 885593 885793 chrXVI_885593_885793_+ 0.0 + +chrV 37062 37262 chrV_37062_37262_- 0.0 - +chrXIII 97778 97978 chrXIII_97778_97978_+ 0.0 + +chrXII 136910 137110 chrXII_136910_137110_+ 0.0 + +chrVI 59904 60104 chrVI_59904_60104_- 0.0 - +chrXII 133683 133883 chrXII_133683_133883_+ 0.0 + +chrXII 479344 479544 chrXII_479344_479544_- 0.0 - +chrIX 408477 408677 chrIX_408477_408677_- 0.0 - +chrXVI 337750 337950 chrXVI_337750_337950_+ 0.0 + +chrXIII 413869 414069 chrXIII_413869_414069_- 0.0 - +chrVI 119992 120192 chrVI_119992_120192_- 0.0 - +chrVII 149066 149266 chrVII_149066_149266_- 0.0 - +chrXI 433049 433249 chrXI_433049_433249_- 0.0 - +chrVIII 483105 483305 chrVIII_483105_483305_+ 0.0 + +chrXI 3447 3647 chrXI_3447_3647_- 0.0 - +chrXIII 656801 657001 chrXIII_656801_657001_+ 0.0 + +chrXV 848350 848550 chrXV_848350_848550_+ 0.0 + +chrX 604918 605118 chrX_604918_605118_- 0.0 - +chrII 784847 785047 chrII_784847_785047_- 0.0 - +chrIV 1047304 1047504 chrIV_1047304_1047504_+ 0.0 + +chrIV 751038 751238 chrIV_751038_751238_- 0.0 - +chrIX 346076 346276 chrIX_346076_346276_- 0.0 - +chrXV 967887 968087 chrXV_967887_968087_- 0.0 - +chrVI 165264 165464 chrVI_165264_165464_+ 0.0 + +chrXVI 190066 190266 chrXVI_190066_190266_- 0.0 - +chrIX 45459 45659 chrIX_45459_45659_+ 0.0 + +chrVII 281946 282146 chrVII_281946_282146_- 0.0 - +chrXII 875552 875752 chrXII_875552_875752_- 0.0 - +chrXI 623781 623981 chrXI_623781_623981_+ 0.0 + +chrXI 306498 306698 chrXI_306498_306698_+ 0.0 + +chrM 25241 25441 chrM_25241_25441_+ 0.0 + +chrXIII 205770 205970 chrXIII_205770_205970_- 0.0 - +chrXVI 61064 61264 chrXVI_61064_61264_- 0.0 - +chrVII 112087 112287 chrVII_112087_112287_- 0.0 - +chrXIII 486531 486731 chrXIII_486531_486731_- 0.0 - +chrVII 494104 494304 chrVII_494104_494304_+ 0.0 + +chrXV 871133 871333 chrXV_871133_871333_+ 0.0 + +chrXIII 317060 317260 chrXIII_317060_317260_- 0.0 - +chrXV 384569 384769 chrXV_384569_384769_- 0.0 - +chrX 628462 628662 chrX_628462_628662_- 0.0 - +chrVII 633038 633238 chrVII_633038_633238_- 0.0 - +chrXIII 802289 802489 chrXIII_802289_802489_- 0.0 - +chrXVI 200426 200626 chrXVI_200426_200626_+ 0.0 + +chrX 404702 404902 chrX_404702_404902_- 0.0 - +chrXVI 127164 127364 chrXVI_127164_127364_+ 0.0 + +chrXVI 175536 175736 chrXVI_175536_175736_- 0.0 - +chrXIII 296030 296230 chrXIII_296030_296230_+ 0.0 + +chrVIII 342537 342737 chrVIII_342537_342737_- 0.0 - +chrIV 990801 991001 chrIV_990801_991001_+ 0.0 + +chrIV 13066 13266 chrIV_13066_13266_- 0.0 - +chrIV 1242131 1242331 chrIV_1242131_1242331_- 0.0 - +chrIV 206428 206628 chrIV_206428_206628_- 0.0 - +chrIV 667038 667238 chrIV_667038_667238_- 0.0 - +chrX 109479 109679 chrX_109479_109679_- 0.0 - +chrXII 300806 301006 chrXII_300806_301006_+ 0.0 + +chrIX 398854 399054 chrIX_398854_399054_- 0.0 - +chrII 704088 704288 chrII_704088_704288_+ 0.0 + +chrII 392190 392390 chrII_392190_392390_- 0.0 - +chrXIV 82286 82486 chrXIV_82286_82486_- 0.0 - +chrX 119537 119737 chrX_119537_119737_- 0.0 - +chrIX 78822 79022 chrIX_78822_79022_+ 0.0 + +chrV 463315 463515 chrV_463315_463515_- 0.0 - +chrIV 1185216 1185416 chrIV_1185216_1185416_- 0.0 - +chrVIII 191779 191979 chrVIII_191779_191979_- 0.0 - +chrXIII 290964 291164 chrXIII_290964_291164_+ 0.0 + +chrIV 254911 255111 chrIV_254911_255111_+ 0.0 + +chrIV 874009 874209 chrIV_874009_874209_+ 0.0 + +chrVII 858489 858689 chrVII_858489_858689_+ 0.0 + +chrXII 962957 963157 chrXII_962957_963157_+ 0.0 + +chrXV 199829 200029 chrXV_199829_200029_+ 0.0 + +chrVII 93522 93722 chrVII_93522_93722_+ 0.0 + +chrVIII 468127 468327 chrVIII_468127_468327_+ 0.0 + +chrII 357560 357760 chrII_357560_357760_+ 0.0 + +chrXII 510417 510617 chrXII_510417_510617_+ 0.0 + +chrII 520795 520995 chrII_520795_520995_- 0.0 - +chrVIII 447072 447272 chrVIII_447072_447272_+ 0.0 + +chrVIII 521591 521791 chrVIII_521591_521791_- 0.0 - +chrXII 33377 33577 chrXII_33377_33577_- 0.0 - +chrVIII 361428 361628 chrVIII_361428_361628_+ 0.0 + +chrXV 67230 67430 chrXV_67230_67430_+ 0.0 + +chrIV 423524 423724 chrIV_423524_423724_+ 0.0 + +chrXI 268307 268507 chrXI_268307_268507_+ 0.0 + +chrVII 210310 210510 chrVII_210310_210510_- 0.0 - +chrVII 854539 854739 chrVII_854539_854739_+ 0.0 + +chrXVI 429790 429990 chrXVI_429790_429990_+ 0.0 + +chrIV 518748 518948 chrIV_518748_518948_- 0.0 - +chrXIII 314778 314978 chrXIII_314778_314978_+ 0.0 + +chrVI 202978 203178 chrVI_202978_203178_+ 0.0 + +chrVII 706006 706206 chrVII_706006_706206_+ 0.0 + +chrVIII 113562 113762 chrVIII_113562_113762_- 0.0 - +chrVIII 380143 380343 chrVIII_380143_380343_- 0.0 - +chrVII 142792 142992 chrVII_142792_142992_+ 0.0 + +chrVII 434383 434583 chrVII_434383_434583_- 0.0 - +chrXII 561527 561727 chrXII_561527_561727_+ 0.0 + +chrIII 252773 252973 chrIII_252773_252973_+ 0.0 + +chrX 649672 649872 chrX_649672_649872_- 0.0 - +chrV 265644 265844 chrV_265644_265844_- 0.0 - +chrXI 324552 324752 chrXI_324552_324752_- 0.0 - +chrV 537207 537407 chrV_537207_537407_- 0.0 - +chrXVI 269709 269909 chrXVI_269709_269909_+ 0.0 + +chrIV 966528 966728 chrIV_966528_966728_+ 0.0 + +chrIX 163847 164047 chrIX_163847_164047_+ 0.0 + +chrVII 579979 580179 chrVII_579979_580179_- 0.0 - +chrVII 684969 685169 chrVII_684969_685169_+ 0.0 + +chrXIV 340456 340656 chrXIV_340456_340656_+ 0.0 + +chrXIII 802820 803020 chrXIII_802820_803020_+ 0.0 + +chrXVI 426855 427055 chrXVI_426855_427055_+ 0.0 + +chrXV 612045 612245 chrXV_612045_612245_- 0.0 - +chrXII 1074131 1074331 chrXII_1074131_1074331_- 0.0 - +chrV 282158 282358 chrV_282158_282358_+ 0.0 + +chrIV 478391 478591 chrIV_478391_478591_- 0.0 - +chrIX 158717 158917 chrIX_158717_158917_- 0.0 - +chrIV 1319331 1319531 chrIV_1319331_1319531_+ 0.0 + +chrXII 731949 732149 chrXII_731949_732149_- 0.0 - +chrVII 724513 724713 chrVII_724513_724713_+ 0.0 + +chrX 572781 572981 chrX_572781_572981_- 0.0 - +chrXI 221040 221240 chrXI_221040_221240_+ 0.0 + +chrIV 572563 572763 chrIV_572563_572763_- 0.0 - +chrVII 1001912 1002112 chrVII_1001912_1002112_+ 0.0 + +chrXIII 607700 607900 chrXIII_607700_607900_+ 0.0 + +chrVII 429014 429214 chrVII_429014_429214_+ 0.0 + +chrXIII 606298 606498 chrXIII_606298_606498_- 0.0 - +chrVII 1063139 1063339 chrVII_1063139_1063339_+ 0.0 + +chrX 688860 689060 chrX_688860_689060_+ 0.0 + +chrXVI 420939 421139 chrXVI_420939_421139_- 0.0 - +chrV 443394 443594 chrV_443394_443594_- 0.0 - +chrIV 1106495 1106695 chrIV_1106495_1106695_- 0.0 - +chrII 599832 600032 chrII_599832_600032_- 0.0 - +chrXII 709758 709958 chrXII_709758_709958_- 0.0 - +chrXIII 502889 503089 chrXIII_502889_503089_- 0.0 - +chrVII 610815 611015 chrVII_610815_611015_- 0.0 - +chrVII 358295 358495 chrVII_358295_358495_- 0.0 - +chrXVI 838801 839001 chrXVI_838801_839001_- 0.0 - +chrXIV 81760 81960 chrXIV_81760_81960_+ 0.0 + +chrXII 178247 178447 chrXII_178247_178447_+ 0.0 + +chrIX 71756 71956 chrIX_71756_71956_+ 0.0 + +chrXVI 375659 375859 chrXVI_375659_375859_- 0.0 - +chrII 622997 623197 chrII_622997_623197_+ 0.0 + +chrXIII 417083 417283 chrXIII_417083_417283_+ 0.0 + +chrV 375109 375309 chrV_375109_375309_- 0.0 - +chrV 292825 293025 chrV_292825_293025_+ 0.0 + +chrXV 1089071 1089271 chrXV_1089071_1089271_- 0.0 - +chrX 173867 174067 chrX_173867_174067_+ 0.0 + +chrVIII 98431 98631 chrVIII_98431_98631_- 0.0 - +chrVI 146330 146530 chrVI_146330_146530_- 0.0 - +chrXV 95702 95902 chrXV_95702_95902_- 0.0 - +chrV 446958 447158 chrV_446958_447158_+ 0.0 + +chrVII 554583 554783 chrVII_554583_554783_+ 0.0 + +chrXVI 64971 65171 chrXVI_64971_65171_+ 0.0 + +chrXII 508321 508521 chrXII_508321_508521_+ 0.0 + +chrXII 351404 351604 chrXII_351404_351604_+ 0.0 + +chrXII 797381 797581 chrXII_797381_797581_+ 0.0 + +chrVIII 467552 467752 chrVIII_467552_467752_+ 0.0 + +chrXV 76845 77045 chrXV_76845_77045_- 0.0 - +chrIV 1016685 1016885 chrIV_1016685_1016885_- 0.0 - +chrXIV 225135 225335 chrXIV_225135_225335_- 0.0 - +chrXI 481637 481837 chrXI_481637_481837_+ 0.0 + +chrXII 76804 77004 chrXII_76804_77004_- 0.0 - +chrVII 463458 463658 chrVII_463458_463658_+ 0.0 + +chrXII 431316 431516 chrXII_431316_431516_+ 0.0 + +chrII 179978 180178 chrII_179978_180178_- 0.0 - +chrXIV 413077 413277 chrXIV_413077_413277_+ 0.0 + +chrVII 446688 446888 chrVII_446688_446888_- 0.0 - +chrXI 310384 310584 chrXI_310384_310584_- 0.0 - +chrV 351712 351912 chrV_351712_351912_+ 0.0 + +chrXIV 36306 36506 chrXIV_36306_36506_- 0.0 - +chrII 701831 702031 chrII_701831_702031_- 0.0 - +chrXII 926097 926297 chrXII_926097_926297_- 0.0 - +chrXV 788043 788243 chrXV_788043_788243_+ 0.0 + +chrXV 212914 213114 chrXV_212914_213114_- 0.0 - +chrV 62784 62984 chrV_62784_62984_- 0.0 - +chrXII 240962 241162 chrXII_240962_241162_+ 0.0 + +chrII 664866 665066 chrII_664866_665066_+ 0.0 + +chrXII 738804 739004 chrXII_738804_739004_+ 0.0 + +chrX 258231 258431 chrX_258231_258431_+ 0.0 + +chrXV 554964 555164 chrXV_554964_555164_+ 0.0 + +chrXV 173384 173584 chrXV_173384_173584_- 0.0 - +chrXV 1023547 1023747 chrXV_1023547_1023747_+ 0.0 + +chrXV 213364 213564 chrXV_213364_213564_- 0.0 - +chrIX 236240 236440 chrIX_236240_236440_- 0.0 - +chrVII 1006728 1006928 chrVII_1006728_1006928_+ 0.0 + +chrXIV 82943 83143 chrXIV_82943_83143_- 0.0 - +chrXV 980922 981122 chrXV_980922_981122_- 0.0 - +chrXIII 189423 189623 chrXIII_189423_189623_+ 0.0 + +chrII 675335 675535 chrII_675335_675535_+ 0.0 + +chrVIII 182999 183199 chrVIII_182999_183199_+ 0.0 + +chrX 122433 122633 chrX_122433_122633_- 0.0 - +chrXII 468135 468335 chrXII_468135_468335_- 0.0 - +chrX 24937 25137 chrX_24937_25137_+ 0.0 + +chrII 93048 93248 chrII_93048_93248_+ 0.0 + +chrXIV 218843 219043 chrXIV_218843_219043_+ 0.0 + +chrXIII 513339 513539 chrXIII_513339_513539_- 0.0 - +chrXII 144647 144847 chrXII_144647_144847_+ 0.0 + +chrXI 613221 613421 chrXI_613221_613421_+ 0.0 + +chrXV 402058 402258 chrXV_402058_402258_- 0.0 - +chrIV 827654 827854 chrIV_827654_827854_+ 0.0 + +chrXII 711366 711566 chrXII_711366_711566_+ 0.0 + +chrV 491005 491205 chrV_491005_491205_- 0.0 - +chrIV 1233508 1233708 chrIV_1233508_1233708_- 0.0 - +chrV 75951 76151 chrV_75951_76151_- 0.0 - +chrXII 776965 777165 chrXII_776965_777165_- 0.0 - +chrII 15374 15574 chrII_15374_15574_+ 0.0 + +chrXI 439531 439731 chrXI_439531_439731_- 0.0 - +chrV 432091 432291 chrV_432091_432291_+ 0.0 + +chrXII 790208 790408 chrXII_790208_790408_- 0.0 - +chrIII 106931 107131 chrIII_106931_107131_+ 0.0 + +chrVII 984513 984713 chrVII_984513_984713_- 0.0 - +chrXVI 219595 219795 chrXVI_219595_219795_- 0.0 - +chrXIII 849836 850036 chrXIII_849836_850036_+ 0.0 + +chrV 104349 104549 chrV_104349_104549_+ 0.0 + +chrIX 407878 408078 chrIX_407878_408078_+ 0.0 + +chrX 167247 167447 chrX_167247_167447_- 0.0 - +chrIV 638582 638782 chrIV_638582_638782_+ 0.0 + +chrVII 1001770 1001970 chrVII_1001770_1001970_- 0.0 - +chrIV 1217412 1217612 chrIV_1217412_1217612_+ 0.0 + +chrII 514184 514384 chrII_514184_514384_+ 0.0 + +chrXIII 797367 797567 chrXIII_797367_797567_- 0.0 - +chrVIII 119538 119738 chrVIII_119538_119738_+ 0.0 + +chrVIII 138077 138277 chrVIII_138077_138277_+ 0.0 + +chrIV 1434292 1434492 chrIV_1434292_1434492_- 0.0 - +chrXV 842436 842636 chrXV_842436_842636_- 0.0 - +chrXI 322870 323070 chrXI_322870_323070_+ 0.0 + +chrVII 66936 67136 chrVII_66936_67136_- 0.0 - +chrXI 471347 471547 chrXI_471347_471547_- 0.0 - +chrIV 1415139 1415339 chrIV_1415139_1415339_- 0.0 - +chrXVI 918391 918591 chrXVI_918391_918591_- 0.0 - +chrVII 299737 299937 chrVII_299737_299937_- 0.0 - +chrXII 148388 148588 chrXII_148388_148588_- 0.0 - +chrII 287232 287432 chrII_287232_287432_+ 0.0 + +chrIV 26221 26421 chrIV_26221_26421_+ 0.0 + +chrX 256693 256893 chrX_256693_256893_- 0.0 - +chrX 240297 240497 chrX_240297_240497_+ 0.0 + +chrXI 94173 94373 chrXI_94173_94373_+ 0.0 + +chrII 606765 606965 chrII_606765_606965_+ 0.0 + +chrXII 76085 76285 chrXII_76085_76285_- 0.0 - +chrIV 1445591 1445791 chrIV_1445591_1445791_+ 0.0 + +chrXIII 826566 826766 chrXIII_826566_826766_- 0.0 - +chrXIV 621728 621928 chrXIV_621728_621928_- 0.0 - +chrV 378540 378740 chrV_378540_378740_- 0.0 - +chrXVI 336738 336938 chrXVI_336738_336938_- 0.0 - +chrIX 246266 246466 chrIX_246266_246466_+ 0.0 + +chrXII 661176 661376 chrXII_661176_661376_+ 0.0 + +chrI 39784 39984 chrI_39784_39984_+ 0.0 + +chrVII 1022658 1022858 chrVII_1022658_1022858_+ 0.0 + +chrXI 266125 266325 chrXI_266125_266325_- 0.0 - +chrXV 630885 631085 chrXV_630885_631085_- 0.0 - +chrXIII 346049 346249 chrXIII_346049_346249_+ 0.0 + +chrIX 384824 385024 chrIX_384824_385024_+ 0.0 + +chrXII 1009912 1010112 chrXII_1009912_1010112_- 0.0 - +chrII 355294 355494 chrII_355294_355494_+ 0.0 + +chrXIV 596107 596307 chrXIV_596107_596307_- 0.0 - +chrVIII 148321 148521 chrVIII_148321_148521_- 0.0 - +chrIV 1383610 1383810 chrIV_1383610_1383810_- 0.0 - +chrXIII 229630 229830 chrXIII_229630_229830_+ 0.0 + +chrXIV 222990 223190 chrXIV_222990_223190_+ 0.0 + +chrXVI 115150 115350 chrXVI_115150_115350_- 0.0 - +chrXI 504976 505176 chrXI_504976_505176_- 0.0 - +chrII 251935 252135 chrII_251935_252135_- 0.0 - +chrV 353814 354014 chrV_353814_354014_+ 0.0 + +chrXV 525620 525820 chrXV_525620_525820_+ 0.0 + +chrXII 136505 136705 chrXII_136505_136705_+ 0.0 + +chrXII 650884 651084 chrXII_650884_651084_- 0.0 - +chrXIV 602798 602998 chrXIV_602798_602998_- 0.0 - +chrIV 330177 330377 chrIV_330177_330377_+ 0.0 + +chrVII 216831 217031 chrVII_216831_217031_- 0.0 - +chrVII 64931 65131 chrVII_64931_65131_+ 0.0 + +chrXIII 623953 624153 chrXIII_623953_624153_+ 0.0 + +chrXII 532151 532351 chrXII_532151_532351_+ 0.0 + +chrXVI 778965 779165 chrXVI_778965_779165_- 0.0 - +chrXII 722435 722635 chrXII_722435_722635_+ 0.0 + +chrXIV 104586 104786 chrXIV_104586_104786_+ 0.0 + +chrXVI 470237 470437 chrXVI_470237_470437_- 0.0 - +chrI 50153 50353 chrI_50153_50353_- 0.0 - +chrIV 185269 185469 chrIV_185269_185469_+ 0.0 + +chrXII 377335 377535 chrXII_377335_377535_- 0.0 - +chrVIII 292565 292765 chrVIII_292565_292765_+ 0.0 + +chrXVI 90726 90926 chrXVI_90726_90926_- 0.0 - +chrX 679794 679994 chrX_679794_679994_- 0.0 - +chrXVI 3502 3702 chrXVI_3502_3702_+ 0.0 + +chrXII 383631 383831 chrXII_383631_383831_+ 0.0 + +chrIV 374103 374303 chrIV_374103_374303_+ 0.0 + +chrXI 522764 522964 chrXI_522764_522964_- 0.0 - +chrVII 816156 816356 chrVII_816156_816356_- 0.0 - +chrVI 266740 266940 chrVI_266740_266940_- 0.0 - +chrVII 14268 14468 chrVII_14268_14468_- 0.0 - +chrII 659508 659708 chrII_659508_659708_+ 0.0 + +chrXII 222410 222610 chrXII_222410_222610_+ 0.0 + +chrI 73916 74116 chrI_73916_74116_+ 0.0 + +chrXV 441787 441987 chrXV_441787_441987_+ 0.0 + +chrIX 70856 71056 chrIX_70856_71056_- 0.0 - +chrIV 1375777 1375977 chrIV_1375777_1375977_- 0.0 - +chrX 493513 493713 chrX_493513_493713_+ 0.0 + +chrXV 711381 711581 chrXV_711381_711581_+ 0.0 + +chrXV 1043186 1043386 chrXV_1043186_1043386_+ 0.0 + +chrXIV 565365 565565 chrXIV_565365_565565_+ 0.0 + +chrXV 1015346 1015546 chrXV_1015346_1015546_- 0.0 - +chrVIII 425343 425543 chrVIII_425343_425543_+ 0.0 + +chrIV 108485 108685 chrIV_108485_108685_+ 0.0 + +chrXII 365867 366067 chrXII_365867_366067_- 0.0 - +chrXIII 815126 815326 chrXIII_815126_815326_- 0.0 - +chrII 794370 794570 chrII_794370_794570_- 0.0 - +chrIV 927592 927792 chrIV_927592_927792_+ 0.0 + +chrXI 270832 271032 chrXI_270832_271032_- 0.0 - +chrII 698862 699062 chrII_698862_699062_- 0.0 - +chrXVI 919025 919225 chrXVI_919025_919225_- 0.0 - +chrXIII 235473 235673 chrXIII_235473_235673_- 0.0 - +chrM 12231 12431 chrM_12231_12431_+ 0.0 + +chrXIV 767308 767508 chrXIV_767308_767508_- 0.0 - +chrIV 325608 325808 chrIV_325608_325808_- 0.0 - +chrXI 494741 494941 chrXI_494741_494941_+ 0.0 + +chrXIII 347116 347316 chrXIII_347116_347316_+ 0.0 + +chrXV 574569 574769 chrXV_574569_574769_- 0.0 - +chrXIV 505344 505544 chrXIV_505344_505544_+ 0.0 + +chrXII 1015070 1015270 chrXII_1015070_1015270_+ 0.0 + +chrIV 754806 755006 chrIV_754806_755006_- 0.0 - +chrXII 933165 933365 chrXII_933165_933365_- 0.0 - +chrVII 499255 499455 chrVII_499255_499455_- 0.0 - +chrII 561690 561890 chrII_561690_561890_- 0.0 - +chrIX 351101 351301 chrIX_351101_351301_- 0.0 - +chrIX 310367 310567 chrIX_310367_310567_- 0.0 - +chrXV 4654 4854 chrXV_4654_4854_- 0.0 - diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java index f407c2d37..02b622cd8 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java @@ -90,7 +90,7 @@ private String validateInput() throws IOException { } public static String getCLIcommand(File peakBED, File refBED, File output) { - String command = "java -jar $SCRIPTMANAGER peak-analysis BEDPeakAlignToRef"; + String command = "java -jar $SCRIPTMANAGER peak-analysis peak-align-ref"; command += " " + peakBED.getAbsolutePath(); command += " " + refBED.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java index 37c921c8a..7f91027d5 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java @@ -85,7 +85,7 @@ private String validateInput() throws IOException { } public static String getCLIcommand(File input, String outputBasename, int exclusion) { - String command = "java -jar $SCRIPTMANAGER peak-analysis FilterBEDbyProximity"; + String command = "java -jar $SCRIPTMANAGER peak-analysis filter-bed"; command += " " + input.getAbsolutePath(); command += " -o " + outputBasename; command += " -e " + exclusion; diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java index 7686a0dfb..d94ef4ca0 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java @@ -26,7 +26,7 @@ public class RandomCoordinateCLI implements Callable { @Parameters( index = "0", description = "reference genome [sacCer3|sacCer3_cegr|hg38|hg38_contigs|hg19|hg19_contigs|mm10]") private String genomeName; - + @Option(names = {"-o", "--output"}, description = "Specify output directory (default = current working directory), file name will be random_coordinates__bp.") private File output = null; @Option(names = {"-f", "--gff"}, description = "file format output as GFF (default format as BED)") @@ -88,10 +88,10 @@ private String validateInput() throws IOException { return(r); } public static String getCLIcommand(String genomeName, File output, boolean formatIsBed, int numSites, int window) { - String command = "java -jar $SCRIPTMANAGER peak-analysis RandomCoordinate"; + String command = "java -jar $SCRIPTMANAGER peak-analysis rand-coord"; command += " " + genomeName; command += " -o " + output.getAbsolutePath(); - command += formatIsBed ? "" : " -f "; + command += formatIsBed ? "" : " --gff"; command += " -n " + numSites; command += " -w " + window; return command; diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java index 10512194e..277fd5df6 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java @@ -60,7 +60,6 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws IOException, InterruptedException { try { - LogItem old_li = new LogItem(""); if(txtSites.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "No Sites Entered!!!"); } else if(Integer.parseInt(txtSites.getText()) < 0) { @@ -83,16 +82,15 @@ public Void doInBackground() throws IOException, InterruptedException { // Initialize LogItem String command = RandomCoordinateCLI.getCLIcommand((String)cmbGenome.getSelectedItem(), OUTFILE, bedStatus, Integer.parseInt(txtSites.getText()), Integer.parseInt(txtSize.getText())); LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); + firePropertyChange("log", null, new_li); // Execute Script and update progress RandomCoordinate.execute((String)cmbGenome.getSelectedItem(), Integer.parseInt(txtSites.getText()), Integer.parseInt(txtSize.getText()), bedStatus, OUTFILE); JOptionPane.showMessageDialog(null, "Random Coordinate Generation Complete"); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); - old_li = new_li; + firePropertyChange("log", new_li, null); } - firePropertyChange("log", old_li, null); } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (IllegalArgumentException iae) { @@ -223,10 +221,12 @@ public void actionPerformed(ActionEvent arg0) { task.addPropertyChangeListener(this); task.execute(); } - - public void propertyChange(PropertyChangeEvent evt) { - } + public void propertyChange(PropertyChangeEvent evt) { + if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + } public void massXable(Container con, boolean status) { for(Component c : con.getComponents()) { From 4921c8704aee4491c62c74e6104a9a2002a50f7b Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 17 Oct 2023 19:52:03 -0400 Subject: [PATCH 23/58] bugfix Figure Generation logging Fix subcommand string in command string construction in getCLIcommand across CLI classes Only write command in TwoColorHeatmap if OUTPUTSTATUS is true Also fix incorrect ordering of getCLIcommand parameter order. Also adjust flag options logic in command construction to interpret compression method string. --- .../Figure_Generation/LabelHeatMapCLI.java | 2 +- .../Figure_Generation/MergeHeatMapCLI.java | 2 +- .../Figure_Generation/TwoColorHeatMapCLI.java | 52 ++++++++++++------- .../TwoColorHeatMapOutput.java | 11 ++-- .../TwoColorHeatMapWindow.java | 3 ++ 5 files changed, 44 insertions(+), 26 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java index 8ab68b966..084cec4b4 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java @@ -116,7 +116,7 @@ private String validateInput() throws IOException { public static String getCLIcommand(File input, File output, Color color, int borderWidth, int xTickHeight, int fontSize, String llabel, String mlabel, String rlabel, String xlabel, String ylabel) { - String command = "java -jar $SCRIPTMANAGER figure-generation LabelHeatMap"; + String command = "java -jar $SCRIPTMANAGER figure-generation label-heatmap"; command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); // Converts RGB format color to hexadecimal diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java index 2428e2d41..cab0069b8 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java @@ -99,7 +99,7 @@ private String validateInput() throws IOException { } public static String getCLIcommand(File senseFile, File antiFile, File outdir) { - String command = "java -jar $SCRIPTMANAGER figure-generation MergeHeatMap"; + String command = "java -jar $SCRIPTMANAGER figure-generation merge-heatmap"; command += " " + antiFile.getAbsolutePath(); command += " " + senseFile.getAbsolutePath(); command += " -o " + outdir.getAbsolutePath() + "merge.png"; diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java index ce095bc72..413185ca1 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java @@ -14,6 +14,7 @@ import java.util.regex.Pattern; import scriptmanager.objects.ToolDescriptions; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.scripts.Figure_Generation.TwoColorHeatMap; @@ -32,8 +33,7 @@ public class TwoColorHeatMapCLI implements Callable { @Parameters(index = "0", description = "") private File CDT; - @Option(names = { "-o", - "--output" }, description = "specify output filename, please use PNG extension\n(default=CDT filename with \"_.png\" appended to the name in working directory of ScriptManager") + @Option(names = { "-o", "--output" }, description = "specify output filename, please use PNG extension\n(default=CDT filename with \"_.png\" appended to the name in working directory of ScriptManager") private File output = null; @Option(names = { "-r", "--start-row" }, description = "") private int startROW = 1; @@ -43,8 +43,7 @@ public class TwoColorHeatMapCLI implements Callable { private int pixelWidth = 200; @Option(names = { "-y", "--height" }, description = "indicate a pixel height for the heatmap (default=600)") private int pixelHeight = 600; - @Option(names = { "-z", - "--compression" }, description = "choose an image compression type: 1=Treeview, 2=Bicubic, 3=Bilinear, 4=Nearest Neighbor (default=1Treeview)") + @Option(names = { "-z", "--compression" }, description = "choose an image compression type: 1=Treeview, 2=Bicubic, 3=Bilinear, 4=Nearest Neighbor (default=1Treeview)") private int compression = 1; @Option(names = { "-a", "--absolute-threshold" }, description = "use the specified value for contrast thresholding in the heatmap (default=10)") @@ -62,8 +61,7 @@ static class ColorGroup { private boolean red = false; @Option(names = { "--blue" }, description = "Use the color blue for generating the heatmap") private boolean blue = false; - @Option(names = { "-c", - "--color" }, description = "For custom color: type hexadecimal string to represent colors (e.g. \"FF0000\" is hexadecimal for red).\n See for some color options with their corresponding hex strings.\n") + @Option(names = { "-c", "--color" }, description = "For custom color: type hexadecimal string to represent colors (e.g. \"FF0000\" is hexadecimal for red).\n See for some color options with their corresponding hex strings.\n") private String custom = null; } @Option(names = { "-t", "--transparent" }, description = "Value indicating transparency of heatmap, 0 to 255 (default=255)\n") @@ -71,7 +69,6 @@ static class ColorGroup { @Option(names = { "-b", "--background" }, description = "Set a transparent background for the heatmap minimum values (default=white)\n") private boolean transparentBackground = false; - String scaleType = "treeview"; Color MAXCOLOR = Color.BLACK; @@ -166,10 +163,9 @@ private String validateInput() throws IOException { return (r); } - public static String getCLIcommand(File input, File output, Color color, int startROW, - int startCOL, int pixelHeight, int pixelWidth, - String scaleType, double absolute, double quant, boolean trans) { - String command = "java -jar $SCRIPTMANAGER figure-generation TwoColorHeatMap"; + public static String getCLIcommand(File input, Color color, int startR, int startC, int pHeight, int pWidth, String scale, + double abs, double quant, File output, boolean trans) throws OptionException { + String command = "java -jar $SCRIPTMANAGER figure-generation heatmap"; command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); if (color == Color.BLACK) { @@ -182,14 +178,32 @@ public static String getCLIcommand(File input, File output, Color color, int sta String hex = Integer.toHexString(color.getRGB()).substring(2); command += " -c " + hex; } - command += " -r " + startROW; - command += " -l " + startCOL; - command += " -y " + pixelHeight; - command += " -x " + pixelWidth; - command += " -z " + scaleType; - command += " -a " + absolute; - command += " -p " + quant; + command += " -r " + startR; + command += " -l " + startC; + command += " -y " + pHeight; + command += " -x " + pWidth; + switch (scale) { + case "treeview": + command += " -z 1"; + break; + case "bicubic": + command += " -z 2"; + break; + case "bilinear": + command += " -z 3"; + break; + case "neighbor": + command += " -z 4"; + break; + default: + throw new OptionException("invalid compression string"); + } + if (abs == -999) { + command += " -a " + abs; + } else { + command += " -p " + quant; + } command += trans ? " -t " : ""; return command; } -} +} \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java index 25239879a..2d3bf02e6 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java @@ -14,6 +14,7 @@ import scriptmanager.cli.Figure_Generation.TwoColorHeatMapCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.scripts.Figure_Generation.TwoColorHeatMap; import scriptmanager.util.ExtensionFileFilter; @@ -66,7 +67,7 @@ public TwoColorHeatMapOutput(ArrayList in, Color c, int startR, int startC OUTPUTSTATUS = outstatus; } - public void run() throws IOException { + public void run() throws IOException, OptionException { LogItem old_li = null; for (int x = 0; x < SAMPLE.size(); x++) { File OUTPUT = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(SAMPLE.get(x)) + "_" + scaleType + ".png"); @@ -75,10 +76,10 @@ public void run() throws IOException { } old_li = new LogItem(""); // Initialize LogItem - String command = TwoColorHeatMapCLI.getCLIcommand(SAMPLE.get(x), OUTPUT, MAXCOLOR, startROW, startCOL, - pixelHeight, pixelWidth, scaleType, absolute, quantile, transparentBackground); + String command = TwoColorHeatMapCLI.getCLIcommand(SAMPLE.get(x), MAXCOLOR, startROW, startCOL, + pixelHeight, pixelWidth, scaleType, absolute, quantile, OUTPUT, transparentBackground); LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); + if (OUTPUTSTATUS) { firePropertyChange("log", old_li, new_li); } // Execute script TwoColorHeatMap script_object = new TwoColorHeatMap(SAMPLE.get(x), MAXCOLOR, startROW, startCOL, pixelHeight, pixelWidth, scaleType, absolute, quantile, OUTPUT, OUTPUTSTATUS, transparentBackground); @@ -93,7 +94,7 @@ public void run() throws IOException { JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); firePropertyChange("heat", x, x + 1); } - firePropertyChange("log", old_li, null); + if (OUTPUTSTATUS) { firePropertyChange("log", old_li, null); } System.out.println("Program Complete"); System.out.println(getTimeStamp()); } diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java index 3919f6130..851355201 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java @@ -37,6 +37,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") @@ -147,6 +148,8 @@ public void propertyChange(PropertyChangeEvent evt) { return null; } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (OptionException oe) { + JOptionPane.showMessageDialog(null, oe.getMessage()); } return null; } From b575bea2b405253d69aef2fa437afdc726de0993 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 17 Oct 2023 19:54:25 -0400 Subject: [PATCH 24/58] bugfix BAM Manipulation logging (just FilterPIP) Fix subcommand string in command string construction in getCLIcommand for filter-pip-seq --- .../scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java index 90caa15f4..6b74e74f9 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java @@ -127,7 +127,7 @@ private String validateInput() throws IOException { return (r); } public static String getCLIcommand(File BAM, File GENOME, File OUTPUT, String txtSeq) { - String command = "java -jar $SCRIPTMANAGER bam-manipulation filterforPIPseq"; + String command = "java -jar $SCRIPTMANAGER bam-manipulation filter-pip-seq"; command += " " + GENOME.getAbsolutePath(); command += " " + BAM.getAbsolutePath(); command += " -o " + OUTPUT.getAbsolutePath(); From 94763ec6aadafe601e60cbb615827b2d5d0898b7 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 17 Oct 2023 19:55:08 -0400 Subject: [PATCH 25/58] bugfix Coordinate Manipulation logging Fix subcommand string in command string construction in getCLIcommand across CLI classes --- .../Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java | 2 +- .../Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java | 2 +- .../Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java | 2 +- .../Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java | 2 +- .../Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java | 2 +- .../Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java | 2 +- .../cli/Coordinate_Manipulation/ShiftCoordCLI.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java index 1a2772333..9822b2f70 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java @@ -84,7 +84,7 @@ private String validateInput() throws IOException { } public static String getCLIcommand(File OUTPUT, File BED, boolean gzOutput) { - String command = "java -jar $SCRIPTMANAGER bed-manipulation bed-to-gff"; + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bed-to-gff"; command += " " + BED.getAbsolutePath(); command += gzOutput ? " -z" : ""; command += " -o " + OUTPUT; diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java index d08ff094d..e06b92fe5 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java @@ -121,7 +121,7 @@ private String validateInput() throws IOException { return(r); } public static String getCLIcommand(File bedFile, File output, int size, boolean gzOutput, boolean byCenter) { - String command = "java -jar $SCRIPTMANAGER bed-manipulation expand-bed"; + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation expand-bed"; command += " " + bedFile.getAbsolutePath(); command += gzOutput ? " -z " : ""; command += " -o " + output.getAbsolutePath(); diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java index a14eefce9..93574310b 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java @@ -121,7 +121,7 @@ else if( center<0 ){ } public static String getCLIcommand(File OUTPUT, File BED, File CDT, int startidx, int stopidx, boolean gzOutput) { - String command = "java -jar $SCRIPTMANAGER bed-manipulation sortBED"; + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation sort-bed"; command += " " + BED.getAbsolutePath(); command += " " + CDT.getAbsolutePath(); command += " -x " + startidx + " " + stopidx; diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java index 836658808..61c8380c2 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java @@ -118,7 +118,7 @@ private String validateInput() throws IOException { return(r); } public static String getCLIcommand(File bedFile, File output, int size, boolean byCenter) { - String command = "java -jar $SCRIPTMANAGER gff-manipulation expand-gff"; + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation expand-gff"; command += " " + bedFile.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); command += byCenter ? " -c " + size : " -b " + size; diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java index 88e475d09..4efe60cdd 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java @@ -75,7 +75,7 @@ private String validateInput() throws IOException { return(r); } public static String getCLIcommand(File GFF, File output) { - String command = "java -jar $SCRIPTMANAGER gff-manipulation gff-to-bed"; + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation gff-to-bed"; command += " " + GFF.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); return command; diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java index 9ca304aed..8ecf8401b 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java @@ -122,7 +122,7 @@ else if( center<0 ){ return(r); } public static String getCLIcommand(File OUTPUT, File BED, File CDT, int startidx, int stopidx) { - String command = "java -jar $SCRIPTMANAGER gff-manipulation sortGFF"; + String command = "java -jar $SCRIPTMANAGER coordinatesort-manipulation sort-gff"; command += " " + BED.getAbsolutePath(); command += " " + CDT.getAbsolutePath(); command += " -x " + startidx + " " + stopidx; diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java index e3948beec..c47bf381b 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java @@ -90,7 +90,7 @@ private String validateInput() throws IOException { return(r); } public static String getCLIcommand(File input, File output, int shift, boolean stranded, boolean gzOutput, boolean isGFF) { - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation ShiftCoord"; + String command = "java -jar $SCRIPTMANAGER coordinate-manipulation shift-coord"; command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); command += " -t " + shift; From 7b122b9953e726ab81cfe9584adeedbf3cc46a1a Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Fri, 20 Oct 2023 10:33:49 -0400 Subject: [PATCH 26/58] fix tool group subcommand on BAM Format Converters fix `coordinate-manipulation` --> `bam-format-converter` copy-paste error --- .../scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java | 2 +- .../scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java | 2 +- .../cli/BAM_Format_Converter/BAMtobedGraphCLI.java | 2 +- .../scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java index d7bc61fcf..490f68081 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java @@ -141,7 +141,7 @@ private String validateInput() throws IOException { return(r); } public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max) { - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-bed"; + String command = "java -jar $SCRIPTMANAGER bam-format-converter bam-to-bed"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); if (strand == 0) { diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java index fca0d6bb2..929a79c4e 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java @@ -141,7 +141,7 @@ private String validateInput() throws IOException { return(r); } public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max) { - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-gff"; + String command = "java -jar $SCRIPTMANAGER bam-format-converter bam-to-gff"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); if (strand == 0) { diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java index 2b618f749..974441f73 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java @@ -129,7 +129,7 @@ private String validateInput() throws IOException { return(r); } public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max){ - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-bedgraph"; + String command = "java -jar $SCRIPTMANAGER bam-format-converter bam-to-bedgraph"; command += " " + BAM.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); if (strand == 0) { diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java index 492265732..d57eb8661 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java @@ -137,7 +137,7 @@ private String validateInput() throws IOException { return(r); } public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max) { - String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bam-to-scidx"; + String command = "java -jar $SCRIPTMANAGER bam-format-converter bam-to-scidx"; System.out.println(output); System.out.println(BAM); command += " " + BAM.getAbsolutePath(); From 0925f4c5540152760000cc21fae89d86e8b21da3 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Fri, 27 Oct 2023 15:25:48 -0400 Subject: [PATCH 27/58] bugfix Sequence Analysis logging FASTAExtractCLI - fix subcommand string in command string construction in getCLIcommand() - add javadocs to getCLIcommand() - fix parameter structure in getCLIcommand() from FASTAExtractCLI to match argument order in script class call FASTAExtractOutput and FASTAExtractWindow - change fireProperty for progress bar updates to match format of other *Output.java classes - adjust getCLIcommand() call to use proper argument order (booleans swapped) - add final progress bar update to 100% SearchMotifCLI - fix subcommand string in command string construction in getCLIcommand() - add javadocs to getCLIcommand() SearchMotifOutput and SearchMotifWindow - restructure log item update (use only one b/c for loop handled in Window) - add final progress bar update to 100% ScriptManagerGUI - add missing property change listener to main class for extract fasta tool --- .../Sequence_Analysis/FASTAExtractCLI.java | 27 +++++++++++++++---- .../cli/Sequence_Analysis/SearchMotifCLI.java | 12 ++++++++- .../scriptmanager/main/ScriptManagerGUI.java | 11 ++++++++ .../Sequence_Analysis/FASTAExtractOutput.java | 5 ++-- .../Sequence_Analysis/FASTAExtractWindow.java | 5 ++-- .../Sequence_Analysis/SearchMotifOutput.java | 16 +++++------ .../Sequence_Analysis/SearchMotifWindow.java | 3 +++ 7 files changed, 59 insertions(+), 20 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java index 1a8cd0a25..a8ee671f6 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java @@ -7,6 +7,7 @@ import java.util.concurrent.Callable; import java.io.File; import java.io.IOException; +import java.io.PrintStream; import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; @@ -89,14 +90,30 @@ private String validateInput() throws IOException { return (r); } - public static String getCLIcommand(File FASTA, File BED, File output, boolean header, boolean forceStrand, boolean gzOutput) { - String command = "java -jar $SCRIPTMANAGER sequence-analysis FASTAExtract"; - command += " " + FASTA.getAbsolutePath(); - command += " " + BED.getAbsolutePath(); + + /** + * Reconstruct CLI command + * + * @param gen the reference genome sequence in FASTA-format (FAI will be + * automatically generated) + * @param input the BED-formatted coordinate intervals to extract sequence + * from + * @param output the FASTA-formatted subsequences that were extracted from + * the genomic sequence + * @param forceStrand force strandedness (true = force, false = don't force) + * @param header the style of FASTA-header to use for the output (true = + * BED coord name, false = use Genomic Coordinate) + * @param gzOutput If this is true, the output file will be gzipped. + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File gen, File input, File output, boolean forceStrand, boolean header, boolean gzOutput) { + String command = "java -jar $SCRIPTMANAGER sequence-analysis fasta-extract"; + command += " " + gen.getAbsolutePath(); + command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); command += header ? " -c " : ""; command += forceStrand ? " -n " : ""; - command += gzOutput ? " -z" : ""; + command += gzOutput ? " --gzip" : ""; return command; } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java index 069ef0f2a..ecb987560 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java @@ -113,8 +113,18 @@ private String validateInput() throws IOException { return (r); } + /** + * Reconstruct CLI command + * + * @param input the FASTA sequence (often genomic) to look for motifs in + * @param output the coordinates of motif instances found + * @param motif the IUPAC formated motif to search for + * @param mismatch the number of allowed mismatches in motif search + * @param gzOutput whether or not to output the coordinate file gzip compressed + * @return command line to execute with formatted inputs + */ public static String getCLIcommand(File input, File output, String motif, int mismatch, boolean gzOutput) { - String command = "java -jar $SCRIPTMANAGER sequence-analysis SearchMotif"; + String command = "java -jar $SCRIPTMANAGER sequence-analysis search-motif"; command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); command += " -m " + motif; diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index e82182d8f..79c339749 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1465,6 +1465,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { FASTAExtractWindow frame = new FASTAExtractWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java index 6b3f6a961..f5bf96a7e 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractOutput.java @@ -83,7 +83,6 @@ public void run() throws IOException, InterruptedException { PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); try { for (int x = 0; x < BED.size(); x++) { - old_li = new LogItem(""); // Open Output File File OUTFILE; String NAME = BED.get(x).getName().split("\\.")[0] + ".fa"; @@ -94,7 +93,7 @@ public void run() throws IOException, InterruptedException { OUTFILE = new File(NAME); PS.println("Proccessing File: " + BED.get(x).getName()); // Initialize LogItem - String command = FASTAExtractCLI.getCLIcommand(GENOME, BED.get(x), OUTFILE, HEADER, STRAND, gzOutput); + String command = FASTAExtractCLI.getCLIcommand(GENOME, BED.get(x), OUTFILE, STRAND, HEADER, gzOutput); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute Script object @@ -105,7 +104,7 @@ public void run() throws IOException, InterruptedException { new_li.setStatus(0); old_li = new_li; // Update progress - firePropertyChange("fa", x, x + 1); + firePropertyChange("progress", x, x + 1); } firePropertyChange("log", old_li, null); PS.println("Extraction Complete"); diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java index 7ba19eb35..b3637edc1 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java @@ -82,7 +82,7 @@ public Void doInBackground() throws IOException { FASTAExtractOutput signal = new FASTAExtractOutput(INPUT, BEDFiles, OUT_DIR, chckbxStrand.isSelected(), rdbtnBedName.isSelected(), chckbxGzipOutput.isSelected()); - signal.addPropertyChangeListener("fa", new PropertyChangeListener() { + signal.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int) (((double) (temp) / BEDFiles.size()) * 100); @@ -94,16 +94,15 @@ public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - signal.setVisible(true); signal.run(); - } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (InterruptedException e) { e.printStackTrace(); } + setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java index 7a1d80128..20364f15d 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifOutput.java @@ -76,27 +76,27 @@ public SearchMotifOutput(File input, String mot, int num, File out_dir, boolean * @throws InterruptedException */ public void run() throws IOException, InterruptedException { - LogItem old_li = null; PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); + // Construct output filename String BASENAME = motif + "_" + Integer.toString(ALLOWED_MISMATCH) + "Mismatch_" + ExtensionFileFilter.stripExtension(INPUTFILE) + ".bed"; if (OUT_DIR != null) { BASENAME = OUT_DIR.getCanonicalPath() + File.separator + BASENAME; } BASENAME += gzOutput ? ".gz" : ""; - old_li = new LogItem(""); // Initialize LogItem String command = SearchMotifCLI.getCLIcommand(INPUTFILE, new File(BASENAME), motif, ALLOWED_MISMATCH, gzOutput); - LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); + LogItem li = new LogItem(command); + firePropertyChange("log", null, li); + // Execute script SearchMotif script_obj = new SearchMotif(INPUTFILE, motif, ALLOWED_MISMATCH, new File(BASENAME), PS, gzOutput); script_obj.run(); // Update log item - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; + li.setStopTime(new Timestamp(new Date().getTime())); + li.setStatus(0); + firePropertyChange("log", li, null); + // Sleep and dispose Thread.sleep(2000); - firePropertyChange("log", old_li, null); dispose(); } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java index 34be47b91..f150bdd3a 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java @@ -85,14 +85,17 @@ public void propertyChange(PropertyChangeEvent evt) { }); search.setVisible(true); search.run(); + // Update progress int percentComplete = (int) (((double) (gfile + 1) / (GenomeFiles.size())) * 100); setProgress(percentComplete); } + setProgress(100); JOptionPane.showMessageDialog(null, "Search Complete"); } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } + setProgress(100); return null; } From 6c3cd79b609fc1b31c8d37f1a3c2307a3de1753c Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Fri, 27 Oct 2023 16:51:42 -0400 Subject: [PATCH 28/58] add logging to DNAShape tools (BED and FASTA) DNAShapefromBEDCLI -add getCLIcommand() with javadocs DNAShapefromFASTACLI -add getCLIcommand() with javadocs ScriptManagerGUI - add property change listener for DNAShapefromBED (DNAShapefromFASTA already there) DNAShapefromBEDOutput and Window - add logitem creation and update steps - add logging propertyChange listener - add final progress bar update to 100% - rename output_obj for consistency - rename progress property change - restructure try-catch statements to handle exceptions in Window DNAShapefromFASTAOutput and Window - add logitem creation and update steps - add logging propertyChange listeners - add final progress bar update to 100% - rename output_obj for consistency - rename progress property change - restructure try-catch statements to handle exceptions in Window --- .../Sequence_Analysis/DNAShapefromBEDCLI.java | 29 ++++++++++++- .../DNAShapefromFASTACLI.java | 24 ++++++++++- .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++ .../DNAShapefromBEDOutput.java | 43 +++++++++---------- .../DNAShapefromBEDWindow.java | 21 +++++---- .../DNAShapefromFASTAOutput.java | 29 ++++++++----- .../DNAShapefromFASTAWindow.java | 22 +++++++--- 7 files changed, 128 insertions(+), 51 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java index d919aec39..442619590 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java @@ -53,8 +53,7 @@ static class ShapeType { private boolean propeller = false; @Option(names = { "-l", "--helical" }, description = "output helical twist") private boolean helical = false; - @Option(names = { "-a", - "--all" }, description = "output groove, roll, propeller twist, and helical twist (equivalent to -grpl).") + @Option(names = { "-a", "--all" }, description = "output groove, roll, propeller twist, and helical twist (equivalent to -grpl).") private boolean all = false; } @@ -173,4 +172,30 @@ private String validateInput() throws IOException { return (r); } + + /** + * Reconstruct CLI command + * + * @param gen the reference genome sequence in FASTA-format (FAI will be + * automatically generated) + * @param input the BED-formatted coordinate intervals to extract sequence from + * @param out the output file name base (to add _<shapetype>.cdt suffix + * to) + * @param type a four-element boolean list for specifying shape type to output + * (no enforcement on size) + * @param str force strandedness (true=forced, false=not forced) + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File gen, File input, String out, boolean[] type, boolean str) { + String command = "java -jar $SCRIPTMANAGER sequence-analysis dna-shape-bed"; + command += " -o " + out; + command += type[0] ? " --groove" : ""; + command += type[1] ? " --propeller" : ""; + command += type[2] ? " --helical" : ""; + command += type[3] ? " --roll" : ""; + command += str ? "" : "--no-force"; + command += " " + gen; + command += " " + input; + return (command); + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java index ee3850a9a..160d95ff4 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java @@ -31,8 +31,7 @@ public class DNAShapefromFASTACLI implements Callable { @Parameters(index = "0", description = "FASTA sequence file") private File fastaFile; - @Option(names = { "-o", - "--output" }, description = "Specify basename for output files, files for each shape indicated will share this name with a different suffix") + @Option(names = { "-o", "--output" }, description = "Specify basename for output files, files for each shape indicated will share this name with a different suffix") private String outputBasename = null; @Option(names = { "--avg-composite" }, description = "Save average composite") private boolean avgComposite = false; @@ -160,4 +159,25 @@ private String validateInput() throws IOException { return (r); } + + /** + * Reconstruct CLI command + * + * @param fa the FASTA-formatted file with a fixed sequence length + * @param out the output file name base (to add _<shapetype>.cdt suffix + * to) + * @param type a four-element boolean list for specifying shape type to output + * (no enforcement on size) + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File fa, String out, boolean[] type) { + String command = "java -jar $SCRIPTMANAGER sequence-analysis dna-shape-fasta"; + command += " -o " + out; + command += type[0] ? " --groove" : ""; + command += type[1] ? " --propeller" : ""; + command += type[2] ? " --helical" : ""; + command += type[3] ? " --roll" : ""; + command += " " + fa; + return (command); + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 79c339749..bd71b61ca 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1574,6 +1574,17 @@ public void actionPerformed(ActionEvent arg0) { public void run() { try { DNAShapefromBEDWindow frame = new DNAShapefromBEDWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDOutput.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDOutput.java index 3a7bd7e76..8aad229d3 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDOutput.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDOutput.java @@ -7,7 +7,9 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JLayeredPane; @@ -17,7 +19,9 @@ import javax.swing.JTextArea; import javax.swing.SpringLayout; +import scriptmanager.cli.Sequence_Analysis.DNAShapefromBEDCLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Sequence_Analysis.DNAShapefromBED; /** @@ -91,7 +95,7 @@ public DNAShapefromBEDOutput(File gen, ArrayList b, File out_dir, boolean[ * @throws InterruptedException */ public void run() throws IOException, InterruptedException { - try { + LogItem old_li = null; // Move through each BED File for (int x = 0; x < BED.size(); x++) { // Initialize TextAreas and PrintStream wrappers @@ -120,20 +124,16 @@ public void run() throws IOException, InterruptedException { STATS_Roll.setEditable(false); PS[3] = new PrintStream(new CustomOutputStream(STATS_Roll)); } - // Open Output File String BASENAME = BED.get(x).getName().split("\\.")[0]; - try { - if (OUT_DIR != null) { - BASENAME = OUT_DIR.getCanonicalPath() + File.separator + BASENAME; - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); + if (OUT_DIR != null) { + BASENAME = OUT_DIR.getCanonicalPath() + File.separator + BASENAME; } - - // Initialize Script Object and execute calculations + // Initialize LogItem + String command = DNAShapefromBEDCLI.getCLIcommand(GENOME, BED.get(x), BASENAME, OUTPUT_TYPE, STRAND); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script DNAShapefromBED script_obj = new DNAShapefromBED(GENOME, BED.get(x), BASENAME, OUTPUT_TYPE, STRAND, PS); script_obj.run(); @@ -142,7 +142,10 @@ public void run() throws IOException, InterruptedException { JOptionPane.showMessageDialog(null, "Genome FASTA file contains invalid lines!!!\n"); break; } - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; // Convert average and statistics to output tabs panes if (OUTPUT_TYPE[0]) { tabbedPane_Scatterplot.add("MGW", script_obj.getChartM()); @@ -172,14 +175,10 @@ public void run() throws IOException, InterruptedException { JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tabbedPane_Statistics.add("Roll", Rollpane); } - firePropertyChange("fa", x, x + 1); - } - } catch (IllegalArgumentException e) { - JOptionPane.showMessageDialog(null, e.getMessage()); - } catch (FileNotFoundException e) { - JOptionPane.showMessageDialog(null, e.getMessage()); - } catch (SAMException e) { - JOptionPane.showMessageDialog(null, e.getMessage()); + + // Update progress + firePropertyChange("progress", x, x + 1); } + firePropertyChange("log", old_li, null); } -} \ No newline at end of file +} diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDWindow.java index f30e87977..e4cfc36bc 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDWindow.java @@ -92,26 +92,28 @@ public Void doInBackground() throws IOException { OUTPUT_TYPE[2] = chckbxHelicalTwist.isSelected(); OUTPUT_TYPE[3] = chckbxRoll.isSelected(); - DNAShapefromBEDOutput signal = new DNAShapefromBEDOutput(INPUT, BEDFiles, OUT_DIR, OUTPUT_TYPE, - chckbxStrand.isSelected()); - - signal.addPropertyChangeListener("fa", new PropertyChangeListener() { + DNAShapefromBEDOutput output_obj = new DNAShapefromBEDOutput(INPUT, BEDFiles, OUT_DIR, OUTPUT_TYPE, chckbxStrand.isSelected()); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int) (((double) (temp) / BEDFiles.size()) * 100); setProgress(percentComplete); } }); - - signal.setVisible(true); - signal.run(); - + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); + output_obj.setVisible(true); + output_obj.run(); } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (InterruptedException e) { e.printStackTrace(); } + setProgress(100); return null; } @@ -321,10 +323,13 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAOutput.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAOutput.java index 567b168c8..d1267092f 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAOutput.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAOutput.java @@ -5,7 +5,9 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JLayeredPane; @@ -14,8 +16,11 @@ import javax.swing.JTextArea; import javax.swing.SpringLayout; +import scriptmanager.cli.Sequence_Analysis.DNAShapefromFASTACLI; import scriptmanager.objects.CustomOutputStream; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Sequence_Analysis.DNAShapefromFASTA; +import scriptmanager.util.ExtensionFileFilter; /** * Graphical window for displaying the DNA shape scores and charts for the set @@ -82,6 +87,7 @@ public DNAShapefromFASTAOutput(ArrayList fa, File out_dir, boolean[] type) */ public void run() throws IOException, InterruptedException { + LogItem old_li = null; for (int x = 0; x < FASTA.size(); x++) { JTextArea STATS_MGW = null; JTextArea STATS_PropT = null; @@ -110,21 +116,24 @@ public void run() throws IOException, InterruptedException { } // Open Output File - String BASENAME = FASTA.get(x).getName().split("\\.")[0]; - try { - if (OUT_DIR != null) { - BASENAME = OUT_DIR.getCanonicalPath() + File.separator + BASENAME; - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); + String BASENAME = ExtensionFileFilter.stripExtension(FASTA.get(x)); + if (OUT_DIR != null) { + BASENAME = OUT_DIR.getCanonicalPath() + File.separator + BASENAME; } + // Initialize LogItem + String command = DNAShapefromFASTACLI.getCLIcommand(FASTA.get(x), BASENAME, OUTPUT_TYPE); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Initialize Script Object and execute calculations DNAShapefromFASTA script_obj = new DNAShapefromFASTA(FASTA.get(x), BASENAME, OUTPUT_TYPE, PS); script_obj.run(); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Convert average and statistics to output tabs panes if (OUTPUT_TYPE[0]) { tabbedPane_Scatterplot.add("MGW", script_obj.getChartM()); @@ -154,7 +163,7 @@ public void run() throws IOException, InterruptedException { JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tabbedPane_Statistics.add("Roll", Rollpane); } - firePropertyChange("fa", x, x + 1); + firePropertyChange("progress", x, x + 1); } } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAWindow.java index ffcf6ca9b..e2a482353 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAWindow.java @@ -86,23 +86,28 @@ public Void doInBackground() throws IOException { OUTPUT_TYPE[2] = chckbxHelicalTwist.isSelected(); OUTPUT_TYPE[3] = chckbxRoll.isSelected(); - DNAShapefromFASTAOutput signal = new DNAShapefromFASTAOutput(FASTAFiles, OUT_DIR, OUTPUT_TYPE); - - signal.addPropertyChangeListener("fa", new PropertyChangeListener() { + DNAShapefromFASTAOutput output_obj = new DNAShapefromFASTAOutput(FASTAFiles, OUT_DIR, OUTPUT_TYPE); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int) (((double) (temp) / FASTAFiles.size()) * 100); setProgress(percentComplete); } }); - - signal.setVisible(true); - signal.run(); - + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); + output_obj.setVisible(true); + output_obj.run(); } + } catch (NumberFormatException nfe) { + JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (InterruptedException e) { e.printStackTrace(); } + setProgress(100); return null; } @@ -287,10 +292,13 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From 7d6a74b4259ee897db25e0123bc73db4d322b3dc Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Fri, 27 Oct 2023 16:55:21 -0400 Subject: [PATCH 29/58] add logging to RandomizeFASTA RandomizeFASTACLI -add getCLIcommand() with javadocs ScriptManagerGUI - add property change listener ScriptManagerGUI - add property change listener RandomizeFASTA - rename input and output parameters RandomizeFASTAWindow - add logitem creation and update steps - add logging propertyChange listeners - add final progress bar update to 100% - restructure try-catch statements to handle exceptions in Window --- .../Sequence_Analysis/RandomizeFASTACLI.java | 15 +++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 ++++ .../Sequence_Analysis/RandomizeFASTA.java | 18 ++--- .../RandomizeFASTAWindow.java | 66 ++++++++++++------- 4 files changed, 78 insertions(+), 32 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java index 86296e6e0..14986d697 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java @@ -95,4 +95,19 @@ private String validateInput() throws IOException { return (r); } + + /** + * Reconstruct CLI command + * + * @param input filepath to FASTA-formatted sequences to randomize + * @param output filepath to write randomized sequences to + * @param seed set a random seed + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, File output, Integer seed) { + String command = "java -jar $SCRIPTMANAGER sequence-analysis randomize-fasta"; + command += " -o " + output.getAbsolutePath(); + command += " " + input.getAbsolutePath(); + return (command); + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index bd71b61ca..2fef9fba0 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1504,6 +1504,17 @@ public void actionPerformed(ActionEvent arg0) { public void run() { try { RandomizeFASTAWindow frame = new RandomizeFASTAWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/scripts/Sequence_Analysis/RandomizeFASTA.java b/src/main/java/scriptmanager/scripts/Sequence_Analysis/RandomizeFASTA.java index a6341f5ac..dee9919c4 100644 --- a/src/main/java/scriptmanager/scripts/Sequence_Analysis/RandomizeFASTA.java +++ b/src/main/java/scriptmanager/scripts/Sequence_Analysis/RandomizeFASTA.java @@ -20,20 +20,20 @@ public class RandomizeFASTA { /** * Static method to call for randomizing FASTA sequences. * - * @param FASTA filepath to FASTA-formatted sequences to randomize - * @param RANDOUT filepath to write randomized sequences to - * @param seed set a random seed + * @param input filepath to FASTA-formatted sequences to randomize + * @param output filepath to write randomized sequences to + * @param seed set a random seed * @return name of output filename * @throws IOException */ - public static File randomizeFASTA(File FASTA, File RANDOUT, Integer seed) throws IOException { + public static File randomizeFASTA(File input, File output, Integer seed) throws IOException { Random randnum = new Random(); - if( seed != null) { + if (seed != null) { System.err.println("Set Seed=" + seed); randnum.setSeed(seed); } - PrintStream OUT = new PrintStream(RANDOUT); - Scanner scan = new Scanner(FASTA); + PrintStream OUT = new PrintStream(output); + Scanner scan = new Scanner(input); while (scan.hasNextLine()) { String HEADER = scan.nextLine(); OUT.println(HEADER); @@ -57,7 +57,7 @@ public static File randomizeFASTA(File FASTA, File RANDOUT, Integer seed) throws OUT.close(); scan.close(); - return RANDOUT; + return output; } - + } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/RandomizeFASTAWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/RandomizeFASTAWindow.java index cf748dbff..7ed39f47d 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/RandomizeFASTAWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/RandomizeFASTAWindow.java @@ -13,7 +13,9 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import javax.swing.DefaultListModel; import javax.swing.JButton; @@ -35,6 +37,8 @@ import scriptmanager.util.FileSelection; import scriptmanager.util.ExtensionFileFilter; +import scriptmanager.cli.Sequence_Analysis.RandomizeFASTACLI; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Sequence_Analysis.RandomizeFASTA; /** @@ -72,35 +76,48 @@ public class RandomizeFASTAWindow extends JFrame implements ActionListener, Prop class Task extends SwingWorker { @Override public Void doInBackground() throws IOException, InterruptedException { - if (FASTAFiles.size() < 1) { - JOptionPane.showMessageDialog(null, "No FASTA Files Loaded!!!"); - } else { - setProgress(0); + try { + if (FASTAFiles.size() < 1) { + JOptionPane.showMessageDialog(null, "No FASTA Files Loaded!!!"); + } else { + setProgress(0); + LogItem old_li = null; + for (int x = 0; x < FASTAFiles.size(); x++) { + String OUTPUT = ExtensionFileFilter.stripExtension(FASTAFiles.get(x)) + "_RAND.fa"; + Integer SEED = null; + if(chckbxSetSeed.isSelected()) { + SEED = Integer.valueOf(txtSeed.getText()); + OUTPUT = ExtensionFileFilter.stripExtension(FASTAFiles.get(x)) + "_s" + SEED + "_RAND.fa"; + } - try { - for (int x = 0; x < FASTAFiles.size(); x++) { - String OUTPUT = ExtensionFileFilter.stripExtension(FASTAFiles.get(x)) + "_RAND.fa"; - Integer SEED = null; - if(chckbxSetSeed.isSelected()) { - SEED = Integer.valueOf(txtSeed.getText()); - OUTPUT = ExtensionFileFilter.stripExtension(FASTAFiles.get(x)) + "_s" + SEED + "_RAND.fa"; - } + if (OUT_DIR != null) { + OUTPUT = OUT_DIR + File.separator + OUTPUT; + } - if (OUT_DIR != null) { - OUTPUT = OUT_DIR + File.separator + OUTPUT; - } + // Initialize LogItem + String command = RandomizeFASTACLI.getCLIcommand(FASTAFiles.get(x), new File(OUTPUT), SEED); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); - RandomizeFASTA.randomizeFASTA(FASTAFiles.get(x), new File(OUTPUT), SEED); + // Execute script + RandomizeFASTA.randomizeFASTA(FASTAFiles.get(x), new File(OUTPUT), SEED); - int percentComplete = (int) (((double) (x + 1) / FASTAFiles.size()) * 100); - setProgress(percentComplete); - } - setProgress(100); - JOptionPane.showMessageDialog(null, "Randomization Complete"); - } catch (NumberFormatException nfe) { - JOptionPane.showMessageDialog(null, "Invalid Seed!!!"); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + firePropertyChange("log", old_li, null); + + int percentComplete = (int) (((double) (x + 1) / FASTAFiles.size()) * 100); + setProgress(percentComplete); + } + setProgress(100); + JOptionPane.showMessageDialog(null, "Randomization Complete"); } + } catch (NumberFormatException nfe) { + JOptionPane.showMessageDialog(null, "Invalid Seed!!!"); } + setProgress(100); return null; } @@ -248,10 +265,13 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From 550de8908caddfbd5c4749b74581b9de7f3a3575 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Sun, 29 Oct 2023 13:46:57 -0400 Subject: [PATCH 30/58] restructure SEStats tool and output #148 - reorder input/output file in script signature (input first, output second to follow other tool signatures) - also change script signature to use boolean OUTPUT_STATUS variable to track if output should be written to a file or not - add progress bar to SEStatWindow - restructure script call in SEStatWindow to use the SwingWorker Task structure - remove single-output filename option from window (switch to a per-bam file statistics text file output with "SE-stats.txt" suffix) - reduce try-catches within Output and script objects and instead have them throw them down to the Window class to be caught --- .../cli/BAM_Statistics/SEStatsCLI.java | 2 +- .../scripts/BAM_Statistics/SEStats.java | 31 +-- .../BAM_Statistics/SEStatOutput.java | 76 +++--- .../BAM_Statistics/SEStatWindow.java | 233 +++++++++++------- 4 files changed, 206 insertions(+), 136 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java index 4fd4a76d4..dbecafb91 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java @@ -39,7 +39,7 @@ public Integer call() throws Exception { System.exit(1); } - SEStats.getSEStats( output, bamFile, null ); + SEStats.getSEStats(bamFile, output, true, null); System.err.println("Calculations Complete"); return(0); diff --git a/src/main/java/scriptmanager/scripts/BAM_Statistics/SEStats.java b/src/main/java/scriptmanager/scripts/BAM_Statistics/SEStats.java index 9e3daec56..29fa669a1 100644 --- a/src/main/java/scriptmanager/scripts/BAM_Statistics/SEStats.java +++ b/src/main/java/scriptmanager/scripts/BAM_Statistics/SEStats.java @@ -7,7 +7,6 @@ import htsjdk.samtools.ValidationStringency; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; import java.sql.Timestamp; @@ -15,20 +14,15 @@ public class SEStats { - public static void getSEStats( File out_filepath, File bamFile, PrintStream ps ) { + public static void getSEStats(File bamFile, File output, boolean OUTPUT_STATUS, PrintStream ps ) throws IOException { final SamReaderFactory factory = SamReaderFactory.makeDefault().enable(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS, SamReaderFactory.Option.VALIDATE_CRC_CHECKSUMS).validationStringency(ValidationStringency.SILENT); //Check and set output files (STDOUT if not specified) PrintStream OUT = null; - if(out_filepath != null) { - try { - OUT = new PrintStream(out_filepath); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - }else{ OUT = System.out; } + if (OUTPUT_STATUS) { + OUT = new PrintStream(output); + } //Print TimeStamp String time = getTimeStamp(); @@ -71,27 +65,22 @@ public static void getSEStats( File out_filepath, File bamFile, PrintStream ps ) } printBoth( ps, OUT, "" ); - - try { - reader.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + // Close streams + reader.close(); bai.close(); //Print message reminder to index BAM files } else { printBoth( ps, OUT, "BAI Index File does not exist for: " + bamFile.getName() + "\n" ); } - - if(out_filepath != null) OUT.close(); + + if (OUTPUT_STATUS) { OUT.close(); } //BAMIndexMetaData.printIndexStats(bamFiles.get(x)) } //Helper method to de-clutter method above: //Prints output to both pop-up window (for GUI) and output file (GUI and CLI) private static void printBoth( PrintStream p, PrintStream out, String line ){ - out.println( line ); - if( p != null ){ p.println( line ); } + if (p != null) { p.println( line ); } + if (out != null) { out.println( line ); } } //Returns Timestamp for printing to the output diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java index 1ea7c80f3..6880afd3c 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java @@ -2,7 +2,7 @@ import java.awt.BorderLayout; import java.io.File; -import java.io.FileNotFoundException; +import java.io.IOException; import java.io.PrintStream; import java.net.URISyntaxException; import java.sql.Timestamp; @@ -10,66 +10,86 @@ import java.util.Vector; import javax.swing.JFrame; +import javax.swing.JLayeredPane; import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; import javax.swing.JTextArea; +import javax.swing.SpringLayout; import scriptmanager.cli.BAM_Statistics.SEStatsCLI; import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Statistics.SEStats; +import scriptmanager.util.ExtensionFileFilter; @SuppressWarnings("serial") public class SEStatOutput extends JFrame { Vector bamFiles = null; - File output = null; - - PrintStream OUT = null; - - private JTextArea textArea; - private PrintStream jtxtPrintStream; + File OUT_DIR = null; + + private boolean OUTPUT_STATUS; + + final JLayeredPane layeredPane; + final JTabbedPane tabbedPane; - public SEStatOutput(Vector input, File o) { + public SEStatOutput(Vector input, File o, boolean o_status) { setTitle("BAM File Statistics"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(150, 150, 600, 800); bamFiles = input; - output = o; - - JScrollPane scrollPane = new JScrollPane(); - getContentPane().add(scrollPane, BorderLayout.CENTER); + OUT_DIR = o; + OUTPUT_STATUS = o_status; + + layeredPane = new JLayeredPane(); + getContentPane().add(layeredPane, BorderLayout.CENTER); + SpringLayout sl_layeredPane = new SpringLayout(); + layeredPane.setLayout(sl_layeredPane); - textArea = new JTextArea(); - textArea.setEditable(false); - scrollPane.setViewportView(textArea); - jtxtPrintStream = new PrintStream( new CustomOutputStream(textArea) ); + tabbedPane = new JTabbedPane(JTabbedPane.TOP); + sl_layeredPane.putConstraint(SpringLayout.NORTH, tabbedPane, 6, SpringLayout.NORTH, layeredPane); + sl_layeredPane.putConstraint(SpringLayout.WEST, tabbedPane, 6, SpringLayout.WEST, layeredPane); + sl_layeredPane.putConstraint(SpringLayout.SOUTH, tabbedPane, -6, SpringLayout.SOUTH, layeredPane); + sl_layeredPane.putConstraint(SpringLayout.EAST, tabbedPane, -6, SpringLayout.EAST, layeredPane); + layeredPane.add(tabbedPane); } - public void run() { + public void run() throws IOException { LogItem old_li = null; - if(output != null) { - try { - OUT = new PrintStream(output); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } // Execute on each BAM file in the list for(int x = 0; x < bamFiles.size(); x++) { + // Construct output filename + String NAME = ExtensionFileFilter.stripExtension(bamFiles.get(x).getName()) + "_SE-stats.txt"; + File OUT_FILEPATH = new File(NAME); + if (OUT_DIR != null) { + OUT_FILEPATH = new File( OUT_DIR.getCanonicalPath() + File.separator + NAME); + } + // Initialize PrintStream and TextArea for SE stats + PrintStream ps_stats = null; + JTextArea txtArea_Statistics = new JTextArea(); + txtArea_Statistics.setEditable(false); + ps_stats = new PrintStream(new CustomOutputStream( txtArea_Statistics )); old_li = new LogItem(""); // Initialize LogItem - String command = SEStatsCLI.getCLIcommand(bamFiles.get(x), output); + String command = SEStatsCLI.getCLIcommand(bamFiles.get(x), OUT_FILEPATH); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Use script and pass PrintStream object that sends to JTextArea - SEStats.getSEStats( output, bamFiles.get(x), jtxtPrintStream ); + SEStats.getSEStats(bamFiles.get(x), OUT_FILEPATH, OUTPUT_STATUS, ps_stats ); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); old_li = new_li; + // Add JTextArea to JScrollPane in JTabbedPane + JScrollPane se_pane = new JScrollPane(txtArea_Statistics, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + tabbedPane.add(bamFiles.get(x).getName(), se_pane); + // Execute script + SEStats.getSEStats(bamFiles.get(x), OUT_FILEPATH, OUTPUT_STATUS, ps_stats); + // Close stats PrintStream + ps_stats.close(); + // Update progress + firePropertyChange("progress", x-1, x); } - if(output != null) OUT.close(); //BAMIndexMetaData.printIndexStats(bamFiles.get(x)) firePropertyChange("log", old_li, null); } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java index 6ef4ebde9..2c63a8be4 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java @@ -1,6 +1,9 @@ package scriptmanager.window_interface.BAM_Statistics; import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Cursor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -9,6 +12,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; +import java.io.IOException; import java.util.Vector; import javax.swing.DefaultListModel; @@ -18,28 +22,76 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; +import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.JProgressBar; import javax.swing.JScrollPane; -import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.SpringLayout; +import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") -public class SEStatWindow extends JFrame { +public class SEStatWindow extends JFrame implements ActionListener, PropertyChangeListener { private JPanel contentPane; - protected JFileChooser fc = new JFileChooser(new File(System.getProperty("user.dir"))); - - private JTextField txtOutputName; - private JLabel lblOutputName; + protected JFileChooser fc = new JFileChooser(new File(System.getProperty("user.dir"))); private JCheckBox chckbxOutputStatistics; - + private JButton btnLoad; + private JButton btnRemoveBam; + private JButton btnOutputDirectory; + private JButton btnRun; + + private JLabel lblCurrentOutput; + private JLabel lblDefaultToLocal; + final DefaultListModel expList; Vector BAMFiles = new Vector(); - private File OUTPUT_PATH = null; + private File OUT_DIR = new File(System.getProperty("user.dir")); + + JProgressBar progressBar; + public Task task; + + class Task extends SwingWorker { + @Override + public Void doInBackground() throws IOException { + setProgress(0); + try { + if (expList.size() < 1) { + JOptionPane.showMessageDialog(null, "Must load at least one BAM file"); + } else { + SEStatOutput output_obj = new SEStatOutput(BAMFiles, OUT_DIR, chckbxOutputStatistics.isSelected()); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent propertyChangeEvent) { + int temp = (Integer) propertyChangeEvent.getNewValue(); + int percentComplete = (int)(((double)(temp) / BAMFiles.size()) * 100); + setProgress(percentComplete); + } + }); + output_obj.setVisible(true); + output_obj.run(); + } + } catch (NumberFormatException nfe){ + JOptionPane.showMessageDialog(null, "Input Fields Must Contain Integers"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } + + setProgress(100); + return null; + } + public void done() { + massXable(contentPane, true); + setCursor(null); //turn off the wait cursor + } + } + + /** + * Instantiate window with graphical interface design. + */ public SEStatWindow() { setTitle("BAM File Statistics"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); @@ -60,12 +112,12 @@ public SEStatWindow() { final JList listExp = new JList(expList); listExp.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); scrollPane.setViewportView(listExp); - - JButton btnLoad = new JButton("Load BAM Files"); + + btnLoad = new JButton("Load BAM Files"); sl_contentPane.putConstraint(SpringLayout.NORTH, scrollPane, 6, SpringLayout.SOUTH, btnLoad); sl_contentPane.putConstraint(SpringLayout.WEST, btnLoad, 0, SpringLayout.WEST, scrollPane); btnLoad.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(ActionEvent e) { File[] newBAMFiles = FileSelection.getFiles(fc,"bam"); if(newBAMFiles != null) { for(int x = 0; x < newBAMFiles.length; x++) { @@ -76,8 +128,8 @@ public void actionPerformed(ActionEvent e) { } }); contentPane.add(btnLoad); - - JButton btnRemoveBam = new JButton("Remove BAM"); + + btnRemoveBam = new JButton("Remove BAM"); sl_contentPane.putConstraint(SpringLayout.NORTH, btnRemoveBam, 0, SpringLayout.NORTH, contentPane); sl_contentPane.putConstraint(SpringLayout.NORTH, btnLoad, 0, SpringLayout.NORTH, btnRemoveBam); sl_contentPane.putConstraint(SpringLayout.EAST, btnRemoveBam, 0, SpringLayout.EAST, scrollPane); @@ -88,99 +140,108 @@ public void actionPerformed(ActionEvent arg0) { expList.remove(listExp.getSelectedIndex()); } } - }); + }); contentPane.add(btnRemoveBam); - - lblOutputName = new JLabel("Output File Name:"); - lblOutputName.setFont(new Font("Lucida Grande", Font.BOLD, 13)); - sl_contentPane.putConstraint(SpringLayout.WEST, lblOutputName, 0, SpringLayout.WEST, scrollPane); - lblOutputName.setEnabled(false); - contentPane.add(lblOutputName); chckbxOutputStatistics = new JCheckBox("Output Statistics"); sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxOutputStatistics, 199, SpringLayout.NORTH, contentPane); - sl_contentPane.putConstraint(SpringLayout.SOUTH, scrollPane, -6, SpringLayout.NORTH, chckbxOutputStatistics); + sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxOutputStatistics, 6, SpringLayout.SOUTH, scrollPane); sl_contentPane.putConstraint(SpringLayout.WEST, chckbxOutputStatistics, 0, SpringLayout.WEST, scrollPane); + chckbxOutputStatistics.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + if(chckbxOutputStatistics.isSelected()) { + btnOutputDirectory.setEnabled(true); + lblCurrentOutput.setEnabled(true); + lblDefaultToLocal.setEnabled(true); + } else { + btnOutputDirectory.setEnabled(false); + lblCurrentOutput.setEnabled(false); + lblDefaultToLocal.setEnabled(false); + } + } + }); contentPane.add(chckbxOutputStatistics); - - txtOutputName = new JTextField(); - sl_contentPane.putConstraint(SpringLayout.NORTH, txtOutputName, -2, SpringLayout.NORTH, lblOutputName); - sl_contentPane.putConstraint(SpringLayout.WEST, txtOutputName, 6, SpringLayout.EAST, lblOutputName); - txtOutputName.setText("output_bam_stats.txt"); - txtOutputName.setColumns(10); - txtOutputName.setEnabled(false); - contentPane.add(txtOutputName); - - JLabel lblCurrentOutput = new JLabel("Current Output:"); - sl_contentPane.putConstraint(SpringLayout.NORTH, lblOutputName, 10, SpringLayout.SOUTH, lblCurrentOutput); + + btnOutputDirectory = new JButton("Output Directory"); + sl_contentPane.putConstraint(SpringLayout.NORTH, btnOutputDirectory, 6, SpringLayout.SOUTH, scrollPane); + sl_contentPane.putConstraint(SpringLayout.WEST, btnOutputDirectory, 150, SpringLayout.WEST, contentPane); + sl_contentPane.putConstraint(SpringLayout.EAST, btnOutputDirectory, -150, SpringLayout.EAST, contentPane); + btnOutputDirectory.setEnabled(false); + btnOutputDirectory.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + OUT_DIR = FileSelection.getOutputDir(fc); + if(OUT_DIR != null) { + lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); + } + } + }); + contentPane.add(btnOutputDirectory); + + lblCurrentOutput = new JLabel("Current Output:"); sl_contentPane.putConstraint(SpringLayout.NORTH, lblCurrentOutput, 10, SpringLayout.SOUTH, chckbxOutputStatistics); sl_contentPane.putConstraint(SpringLayout.WEST, lblCurrentOutput, 0, SpringLayout.WEST, scrollPane); lblCurrentOutput.setFont(new Font("Lucida Grande", Font.BOLD, 13)); lblCurrentOutput.setEnabled(false); contentPane.add(lblCurrentOutput); - - JLabel lblDefaultToLocal = new JLabel("Default to Local Directory"); + + lblDefaultToLocal = new JLabel("Default to Local Directory"); sl_contentPane.putConstraint(SpringLayout.NORTH, lblDefaultToLocal, 1, SpringLayout.NORTH, lblCurrentOutput); sl_contentPane.putConstraint(SpringLayout.WEST, lblDefaultToLocal, 6, SpringLayout.EAST, lblCurrentOutput); lblDefaultToLocal.setFont(new Font("Dialog", Font.PLAIN, 12)); lblDefaultToLocal.setBackground(Color.WHITE); lblDefaultToLocal.setEnabled(false); contentPane.add(lblDefaultToLocal); - - JButton btnOutput = new JButton("Output Directory"); - sl_contentPane.putConstraint(SpringLayout.EAST, txtOutputName, 56, SpringLayout.EAST, btnOutput); - sl_contentPane.putConstraint(SpringLayout.NORTH, btnOutput, 6, SpringLayout.SOUTH, scrollPane); - sl_contentPane.putConstraint(SpringLayout.WEST, btnOutput, 150, SpringLayout.WEST, contentPane); - sl_contentPane.putConstraint(SpringLayout.EAST, btnOutput, -150, SpringLayout.EAST, contentPane); - btnOutput.setEnabled(false); - btnOutput.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - OUTPUT_PATH = FileSelection.getOutputDir(fc); - if(OUTPUT_PATH != null) { - lblDefaultToLocal.setText(OUTPUT_PATH.getAbsolutePath()); - } - } - }); - contentPane.add(btnOutput); - - chckbxOutputStatistics.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(chckbxOutputStatistics.isSelected()) { - btnOutput.setEnabled(true); - lblOutputName.setEnabled(true); - txtOutputName.setEnabled(true); - lblCurrentOutput.setEnabled(true); - lblDefaultToLocal.setEnabled(true); - } else { - btnOutput.setEnabled(false); - lblOutputName.setEnabled(false); - txtOutputName.setEnabled(false); - lblCurrentOutput.setEnabled(false); - lblDefaultToLocal.setEnabled(false); - } - } - }); - - JButton btnRun = new JButton("Run"); + + btnRun = new JButton("Run"); sl_contentPane.putConstraint(SpringLayout.NORTH, btnRun, 90, SpringLayout.SOUTH, scrollPane); sl_contentPane.putConstraint(SpringLayout.WEST, btnRun, 171, SpringLayout.WEST, contentPane); sl_contentPane.putConstraint(SpringLayout.EAST, btnRun, -171, SpringLayout.EAST, contentPane); - btnRun.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - SEStatOutput stat; - if(chckbxOutputStatistics.isSelected()) { - if(OUTPUT_PATH != null) { stat = new SEStatOutput(BAMFiles, new File(OUTPUT_PATH + File.separator + txtOutputName.getText())); } - else { stat = new SEStatOutput(BAMFiles, new File(txtOutputName.getText())); } - } else { stat = new SEStatOutput(BAMFiles, null); } - stat.addPropertyChangeListener("log", new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); - } - }); - stat.setVisible(true); - stat.run(); - } - }); contentPane.add(btnRun); + + progressBar = new JProgressBar(); + sl_contentPane.putConstraint(SpringLayout.SOUTH, progressBar, -8, SpringLayout.SOUTH, contentPane); + sl_contentPane.putConstraint(SpringLayout.EAST, progressBar, -5, SpringLayout.EAST, contentPane); + sl_contentPane.putConstraint(SpringLayout.NORTH, btnRun, -3, SpringLayout.NORTH, progressBar); + sl_contentPane.putConstraint(SpringLayout.EAST, btnRun, -18, SpringLayout.WEST, progressBar); + progressBar.setStringPainted(true); + contentPane.add(progressBar); + + btnRun.addActionListener(this); + btnRun.setActionCommand("start"); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + massXable(contentPane, false); + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + task = new Task(); + task.addPropertyChangeListener(this); + task.execute(); + } + + /** + * Invoked when task's progress property changes. + */ + @Override + public void propertyChange(PropertyChangeEvent evt) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } + } + + public void massXable(Container con, boolean status) { + for(Component c : con.getComponents()) { + c.setEnabled(status); + if(c instanceof Container) { massXable((Container)c, status); } + } + if(status) { + if(!chckbxOutputStatistics.isSelected()) { + btnOutputDirectory.setEnabled(false); + lblCurrentOutput.setEnabled(false); + lblDefaultToLocal.setEnabled(false); + } + } } } \ No newline at end of file From 106551ab71528bff9d36e217f1a11761151ba6f3 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Sun, 29 Oct 2023 14:32:33 -0400 Subject: [PATCH 31/58] bugfix BAM Statistics logging adjust logging for BAM Statistics to fix bugs CrossCorrelationCLI and PEStatsCLI and SEStatsCLI - fix subcommand string and option construction in command string construction in getCLIcommand() - add javadocs to getCLIcommand() - fix parameter structure in getCLIcommand() to match argument order in script class call CrossCorrelation and PEStats - reorder input/output file in script signature (input first, output second to follow other tool signatures) - reduce try-catches within Output and script objects and instead have them throw them down to the Window class to be caught CrossCorrelationOutput and PEStatOutput and SEStatOutput plus *Window - standardize output filename construction - standardize `output_obj` instantiation variable names - add missing or adjust property change events with "log" and "progress" naming as appropriate - more try-catch reduction --- .../BAM_Statistics/CrossCorrelationCLI.java | 29 ++++++--- .../cli/BAM_Statistics/PEStatsCLI.java | 18 +++++- .../cli/BAM_Statistics/SEStatsCLI.java | 16 +++-- .../BAM_Statistics/CrossCorrelation.java | 14 ++--- .../scripts/BAM_Statistics/PEStats.java | 15 ++--- .../CrossCorrelationOutput.java | 46 ++++++-------- .../CrossCorrelationWindow.java | 10 +-- .../BAM_Statistics/PEStatOutput.java | 44 ++++++------- .../BAM_Statistics/PEStatWindow.java | 63 ++++++++++--------- .../BAM_Statistics/SEStatOutput.java | 32 +++++----- .../BAM_Statistics/SEStatWindow.java | 27 +++++--- 11 files changed, 171 insertions(+), 143 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/CrossCorrelationCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/CrossCorrelationCLI.java index ac6d7f0e9..786942959 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/CrossCorrelationCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/CrossCorrelationCLI.java @@ -47,7 +47,7 @@ static class CorrType { @Option(names = {"-t", "--cpu"}, description = "set number of threads for performance tuning (default=1)") private int cpu = 1; - @ArgGroup(exclusive = true, multiplicity = "0..1", heading = "%nRandom Sampling Options:%n\t@|fg(red) (ignored if full genome correlation method selected)|@%n") + @ArgGroup(exclusive = false, multiplicity = "0..1", heading = "%nRandom Sampling Options:%n\t@|fg(red) (ignored if full genome correlation method selected)|@%n") SamplingParams samplingParams = new SamplingParams(); static class SamplingParams { @Option(names = {"-w", "--window"}, description = "set window frame size for each extraction (default=50kb)") @@ -123,14 +123,27 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File OUTPUT, File bamFile, CorrParameter param) { - String command = "java -jar $SCRIPTMANAGER bam-statistics CrossCorrelation"; + + /** + * Reconstruct CLI command + * + * @param bamFile BAM file to get statistics on + * @param output text file to write output to + * @param param cross correlation parameters + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File bamFile, File output, CorrParameter param) { + String command = "java -jar $SCRIPTMANAGER bam-statistics cross-corr"; command += " " + bamFile.getAbsolutePath(); - command += " -o " + OUTPUT.getAbsolutePath(); - command += param.getCorrType() ? " -g " : " -r "; - command += " -t " + param.getThreads(); - command += param.getCorrType() ? " -w " + param.getCorrWindow() : ""; - command += param.getCorrType() ? " -i " + param.getIterations() : ""; + command += " -o " + output.getAbsolutePath(); + command += " --cpu " + param.getThreads(); + if (param.getCorrType()) { + command += " -g"; + } else { + command += " -r"; + command += " -w " + param.getCorrWindow(); + command += " -i " + param.getIterations(); + } return command; } } diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java index f86d51be7..fd1947cbc 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java @@ -93,9 +93,21 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File BAMFile, File outputBasename, int min, int max, boolean dup, boolean sum) { - String command = "java -jar $SCRIPTMANAGER bam-statistics PEStats"; - command += " " + BAMFile.getAbsolutePath(); + + /** + * Reconstruct CLI command + * + * @param bamFile BAM file to get statistics on + * @param outputBasename basename of output files (without extensions) + * @param DUP_STATUS specifies if duplication statistics and chart should be + * generated + * @param MIN_INSERT maximum histogram range + * @param MAX_INSERT minimum histogram range + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File bamFile, File outputBasename, boolean dup, int min, int max, boolean sum) { + String command = "java -jar $SCRIPTMANAGER bam-statistics pe-stat"; + command += " " + bamFile.getAbsolutePath(); command += " -o " + outputBasename.getAbsolutePath(); command += " -n " + min; command += " -x " + max; diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java index dbecafb91..12672a2b5 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java @@ -79,10 +79,18 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File BAMFile, File outputBasename) { - String command = "java -jar $SCRIPTMANAGER bam-statistics PEStats"; - command += " " + BAMFile.getAbsolutePath(); - command += " -o " + outputBasename.getAbsolutePath(); + + /** + * Reconstruct CLI command + * + * @param bamFile the BAM file to get statistics on (from header) + * @param output text file to write output to + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File bamFile, File output) { + String command = "java -jar $SCRIPTMANAGER bam-statistics se-stats"; + command += " " + bamFile.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); return command; } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/scripts/BAM_Statistics/CrossCorrelation.java b/src/main/java/scriptmanager/scripts/BAM_Statistics/CrossCorrelation.java index 340012f0d..f5968ab31 100644 --- a/src/main/java/scriptmanager/scripts/BAM_Statistics/CrossCorrelation.java +++ b/src/main/java/scriptmanager/scripts/BAM_Statistics/CrossCorrelation.java @@ -39,10 +39,10 @@ public class CrossCorrelation { * correlating forward and reverse strand pileups at various tag shifts to * determine the tag shift with the strongest correlation between strands. * - * @param outfilepath the output file to write TagShift-->Correlation score - * pair results * @param bamFile the BAM file to determine the best strand correlated tag * shift for + * @param output the output file to write TagShift-->Correlation score + * pair results * @param param the object for storing user-defined parameters for the * cross-correlation * @param PS_CCDATA where progress updates and raw correlation scores are @@ -50,7 +50,7 @@ public class CrossCorrelation { * @return the JFreeChart-based line plot of corrlation (y-axis) scores for a * range of shifts (x-axis) */ - public static Component correlate(File outfilepath, File bamFile, CorrParameter param, PrintStream PS_CCDATA){ + public static Component correlate(File bamFile, File output, CorrParameter param, PrintStream PS_CCDATA) { //Check if BAI index file exists File f = new File(bamFile + ".bai"); if(!f.exists() || f.isDirectory()) { @@ -58,16 +58,16 @@ public static Component correlate(File outfilepath, File bamFile, CorrParameter System.err.println("BAI Index File does not exist for: " + bamFile.getName()); return(null); } + System.out.println("Cross-Correlation: " + bamFile); // Output files to be saved PrintStream OUT_CCDATA = null; // Set output file printstream - if( outfilepath!=null ) { + if( output!=null ) { try { - OUT_CCDATA = new PrintStream(outfilepath); - } - catch (IOException ioe) { ioe.printStackTrace(); } + OUT_CCDATA = new PrintStream(output); + } catch (IOException ioe) { ioe.printStackTrace(); } } // Start timestamp diff --git a/src/main/java/scriptmanager/scripts/BAM_Statistics/PEStats.java b/src/main/java/scriptmanager/scripts/BAM_Statistics/PEStats.java index 6bc2b9e73..068720aa5 100644 --- a/src/main/java/scriptmanager/scripts/BAM_Statistics/PEStats.java +++ b/src/main/java/scriptmanager/scripts/BAM_Statistics/PEStats.java @@ -24,8 +24,8 @@ import scriptmanager.charts.LineChart; public class PEStats { - - public static Vector getPEStats( File out_basename, File bamFile, boolean DUP_STATUS, int MIN_INSERT, int MAX_INSERT, PrintStream PS_INSERT, PrintStream PS_DUP, boolean SUM_STATUS ){ + + public static Vector getPEStats(File bamFile, File out_basename, boolean DUP_STATUS, int MIN_INSERT, int MAX_INSERT, PrintStream PS_INSERT, PrintStream PS_DUP, boolean SUM_STATUS ) throws IOException { final SamReaderFactory factory = SamReaderFactory.makeDefault().enable(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS, SamReaderFactory.Option.VALIDATE_CRC_CHECKSUMS).validationStringency(ValidationStringency.SILENT); // Output Vector of Charts to be returned @@ -50,8 +50,7 @@ public static Vector getPEStats( File out_basename, File bamFile, bo if( SUM_STATUS ){ OUT_INSERT_SUM = new PrintStream(new File( out_basename.getCanonicalPath() + "_InsertSummary.out")); } - } - catch (IOException e) { e.printStackTrace(); } + } catch (IOException e) { e.printStackTrace(); } } //Print TimeStamp @@ -192,9 +191,7 @@ public static Vector getPEStats( File out_basename, File bamFile, bo } //Generate Insert Chart - try{ - charts.add( 0, Histogram.createBarChart(HIST, DOMAIN, OUT_INSPNG) ); - }catch( IOException e ){ e.printStackTrace(); } + charts.add( 0, Histogram.createBarChart(HIST, DOMAIN, OUT_INSPNG) ); //Duplication statistics if(DUP_STATUS) { @@ -217,9 +214,7 @@ public static Vector getPEStats( File out_basename, File bamFile, bo printBoth( PS_DUP, OUT_DUP, "Unique Molecules:\n" + UNIQUE_MOLECULES); //Generate Duplicates Chart - try{ - charts.add( 1, LineChart.createLineChart(BIN, BIN_NAME, OUT_DUPPNG) ); - }catch( IOException e ){ e.printStackTrace(); } + charts.add( 1, LineChart.createLineChart(BIN, BIN_NAME, OUT_DUPPNG) ); } } else { charts.add(0, new ChartPanel(null)); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationOutput.java index e66ac3633..69aff8ddd 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationOutput.java @@ -52,12 +52,13 @@ public class CrossCorrelationOutput extends JFrame { * Initialize tab frames for scrollable JTextArea and charts as well as save * inputs for calling the script. * - * @param o the output directory to write output to * @param input the list of input BAM files to process - * @param param the custom parameter storing object for running the ArchTEx script - * @param ostats whether to output results to a file or not + * @param o the output directory to write output to + * @param out whether to output results to a file or not + * @param param the custom parameter storing object for running the ArchTEx + * script */ - public CrossCorrelationOutput(File o, Vector input, CorrParameter param, boolean ostats) { + public CrossCorrelationOutput(Vector input, File o, boolean out, CorrParameter param) { setTitle("BAM File Cross Correlation Plots and Statistics"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(150, 150, 800, 600); @@ -76,7 +77,7 @@ public CrossCorrelationOutput(File o, Vector input, CorrParameter param, b bamFiles = input; OUT_DIR = o; - OUTPUT_STATUS = ostats; + OUTPUT_STATUS = out; PARAM = param; tabbedPane_CCPlots = new JTabbedPane(JTabbedPane.TOP); @@ -92,7 +93,6 @@ public CrossCorrelationOutput(File o, Vector input, CorrParameter param, b * @throws IOException */ public void run() throws IOException { - LogItem old_li = null; // Check if BAI index file exists for all BAM files boolean[] BAMvalid = new boolean[bamFiles.size()]; for (int z = 0; z < bamFiles.size(); z++) { @@ -106,23 +106,16 @@ public void run() throws IOException { BAMvalid[z] = true; } } + LogItem old_li = null; //Iterate through all BAM files in Vector for(int x = 0; x < bamFiles.size(); x++) { - System.out.println("Cross-Correlation: " + bamFiles.get(x).getName()); - if (BAMvalid[x]) { - old_li = new LogItem(""); - // Construct Basename - File OUT_FILEPATH = null; - if(OUTPUT_STATUS){ - try{ - String NAME = ExtensionFileFilter.stripExtension(bamFiles.get(x).getName()) + "_CrossCorrelation.txt"; - if(OUT_DIR == null) { OUT_FILEPATH = new File(NAME); } - else { OUT_FILEPATH = new File( OUT_DIR.getCanonicalPath() + File.separator + NAME); } - } - catch (FileNotFoundException e) { e.printStackTrace(); } + // Construct output filename + String NAME = ExtensionFileFilter.stripExtension(bamFiles.get(x).getName()) + "_CrossCorrelation.txt"; + File OUT_FILEPATH = new File(NAME); + if (OUT_DIR != null) { + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } - // Initialize PrintStream and TextArea for C-C Data PrintStream ps_ccdata = null; JTextArea CC_DATA = new JTextArea(); @@ -131,23 +124,24 @@ public void run() throws IOException { CC_DATA.setEditable(false); ps_ccdata = new PrintStream(new CustomOutputStream( CC_DATA )); tabbedPane_CCData.add(bamFiles.get(x).getName(), new JScrollPane(CC_DATA, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); - // Initialize LogItem - String command = CrossCorrelationCLI.getCLIcommand(OUT_FILEPATH, bamFiles.get(x), PARAM); + String command = CrossCorrelationCLI.getCLIcommand(bamFiles.get(x), OUT_FILEPATH, PARAM); LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, new_li); } //Call public static method from scripts - Component chart = CrossCorrelation.correlate(OUT_FILEPATH, bamFiles.get(x), PARAM, ps_ccdata); + Component chart = CrossCorrelation.correlate(bamFiles.get(x), OUT_FILEPATH, PARAM, ps_ccdata); tabbedPane_CCPlots.add(bamFiles.get(x).getName(), chart); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); old_li = new_li; + // Close PrintStream ps_ccdata.close(); - firePropertyChange("bam",x, x + 1); + // Update progress + firePropertyChange("progress",x, x + 1); } - firePropertyChange("log", old_li, null); } + // Update log after final input + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, null); } } - } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java index be6de4360..3fcfd30fd 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java @@ -111,21 +111,21 @@ public Void doInBackground() { } System.out.println("Parameters Loaded.\n"); // Initialize output window and run - CrossCorrelationOutput script_obj = new CrossCorrelationOutput(OUT_DIR, BAMFiles, param, chckbxOutputStatistics.isSelected()); - script_obj.addPropertyChangeListener("bam", new PropertyChangeListener() { + CrossCorrelationOutput output_obj = new CrossCorrelationOutput(BAMFiles, OUT_DIR, chckbxOutputStatistics.isSelected(), param); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int)(((double)(temp) / BAMFiles.size()) * 100); setProgress(percentComplete); } }); - script_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - script_obj.setVisible(true); - script_obj.run(); + output_obj.setVisible(true); + output_obj.run(); } } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Input Fields Must Contain Integers"); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java index 96b86ccfe..46e6448da 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatOutput.java @@ -23,6 +23,7 @@ import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Statistics.PEStats; +import scriptmanager.util.ExtensionFileFilter; @SuppressWarnings("serial") public class PEStatOutput extends JFrame { @@ -78,8 +79,7 @@ public PEStatOutput(Vector input, File o, boolean out, boolean dup, int mi } } - public void run() throws IOException { - LogItem old_li = null; + public void run() throws FileNotFoundException, IOException { // Check if BAI index file exists for all BAM files boolean[] BAMvalid = new boolean[bamFiles.size()]; for (int z = 0; z < bamFiles.size(); z++) { @@ -93,20 +93,16 @@ public void run() throws IOException { BAMvalid[z] = true; } } + LogItem old_li = null; //Iterate through all BAM files in Vector for(int x = 0; x < bamFiles.size(); x++) { if (BAMvalid[x]) { - old_li = new LogItem(""); - // Construct Basename - File OUT_BASENAME = null; - if(OUTPUT_STATUS){ - try{ - if(OUT_DIR == null) { OUT_BASENAME = new File(bamFiles.get(x).getName().split("\\.")[0]); } - else { OUT_BASENAME = new File( OUT_DIR.getCanonicalPath() + File.separator + bamFiles.get(x).getName().split("\\.")[0] ); } - } - catch (FileNotFoundException e) { e.printStackTrace(); } + // Construct output basename + String NAME = ExtensionFileFilter.stripExtension(bamFiles.get(x).getName()); + File OUT_BASENAME = new File(NAME); + if (OUT_DIR != null) { + OUT_BASENAME = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } - // Initialize PrintStream and TextArea for PE stats (insert sizes) PrintStream ps_insert = null; JTextArea PE_STATS = new JTextArea(); @@ -115,27 +111,26 @@ public void run() throws IOException { // Initialize PrintStream and TextArea for DUP stats PrintStream ps_dup = null; JTextArea DUP_STATS = new JTextArea(); - if(DUP_STATUS) { + if (DUP_STATUS) { DUP_STATS.setEditable(false); ps_dup = new PrintStream(new CustomOutputStream( DUP_STATS )); } // Initialize LogItem - String command = PEStatsCLI.getCLIcommand(bamFiles.get(x), OUT_BASENAME, MIN_INSERT, MAX_INSERT, DUP_STATUS, false); + String command = PEStatsCLI.getCLIcommand(bamFiles.get(x), OUT_BASENAME, DUP_STATUS, MIN_INSERT, MAX_INSERT, false); LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); - + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, new_li); } //Call public static method from scripts - Vector charts = PEStats.getPEStats( OUT_BASENAME, bamFiles.get(x), DUP_STATUS, MIN_INSERT, MAX_INSERT, ps_insert, ps_dup, false ); + Vector charts = PEStats.getPEStats(bamFiles.get(x), OUT_BASENAME, DUP_STATUS, MIN_INSERT, MAX_INSERT, ps_insert, ps_dup, false ); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); old_li = new_li; - //Add pe stats to tabbed pane + // Add pe stats to tabbed pane PE_STATS.setCaretPosition(0); JScrollPane pe_pane = new JScrollPane(PE_STATS, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tabbedPane_InsertStats.add(bamFiles.get(x).getName(), pe_pane); tabbedPane_Histogram.add(bamFiles.get(x).getName(), charts.get(0)); - + // Set-up duplication statistics if flagged if(DUP_STATUS) { //Add duplication stats to tabbed pane DUP_STATS.setCaretPosition(0); @@ -143,13 +138,14 @@ public void run() throws IOException { tabbedPane_DupStats.add(bamFiles.get(x).getName(), dup_pane); tabbedPane_Duplication.add(bamFiles.get(x).getName(), charts.get(1)); } - - if(ps_dup!=null) { ps_dup.close(); } + // Close streams ps_insert.close(); - - firePropertyChange("bam",x, x + 1); + if (ps_dup!=null) { ps_dup.close(); } + // Update progress + firePropertyChange("progress",x, x + 1); } - firePropertyChange("log", old_li, null); } + // Update log after final input + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, null); } } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java index 9720b2bf0..83737b443 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java @@ -12,6 +12,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.util.Vector; @@ -71,35 +72,39 @@ public Void doInBackground() { } else if (expList.size() < 1) { JOptionPane.showMessageDialog(null, "Must load at least one BAM file"); } else { - PEStatOutput stat = new PEStatOutput(BAMFiles, OUTPUT_PATH, chckbxOutputStatistics.isSelected(), chckbxDup.isSelected(), MIN, MAX); - stat.addPropertyChangeListener("bam", new PropertyChangeListener() { + PEStatOutput output_obj = new PEStatOutput(BAMFiles, OUTPUT_PATH, chckbxOutputStatistics.isSelected(), chckbxDup.isSelected(), MIN, MAX); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int)(((double)(temp) / BAMFiles.size()) * 100); setProgress(percentComplete); } }); - stat.addPropertyChangeListener("log", new PropertyChangeListener() { + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - stat.setVisible(true); - stat.run(); + output_obj.setVisible(true); + output_obj.run(); } - } catch(NumberFormatException nfe){ + } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Input Fields Must Contain Integers"); - } catch (IOException e) { - e.printStackTrace(); + } catch (FileNotFoundException fnfe) { + fnfe.printStackTrace(); + JOptionPane.showMessageDialog(null, "Could not find file: " + fnfe.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } - setProgress(100); - return null; - } + setProgress(100); + return null; + } - public void done() { - massXable(contentPane, true); - setCursor(null); //turn off the wait cursor - } + public void done() { + massXable(contentPane, true); + setCursor(null); //turn off the wait cursor + } } /** @@ -157,13 +162,16 @@ public void actionPerformed(ActionEvent arg0) { expList.remove(listExp.getSelectedIndex()); } } - }); + }); contentPane.add(btnRemoveBam); btnRun = new JButton("Run"); sl_contentPane.putConstraint(SpringLayout.WEST, btnRun, 171, SpringLayout.WEST, contentPane); contentPane.add(btnRun); + btnRun.addActionListener(this); + btnRun.setActionCommand("start"); + JLabel lblHistogramRange = new JLabel("Histogram Range:"); sl_contentPane.putConstraint(SpringLayout.NORTH, lblHistogramRange, 201, SpringLayout.NORTH, contentPane); sl_contentPane.putConstraint(SpringLayout.SOUTH, scrollPane, -10, SpringLayout.NORTH, lblHistogramRange); @@ -219,8 +227,6 @@ public void itemStateChanged(ItemEvent e) { } }); - btnRun.setActionCommand("start"); - btnOutputDirectory = new JButton("Output Directory"); sl_contentPane.putConstraint(SpringLayout.NORTH, btnOutputDirectory, 35, SpringLayout.SOUTH, txtMin); btnOutputDirectory.addActionListener(new ActionListener() { @@ -256,7 +262,6 @@ public void actionPerformed(ActionEvent e) { sl_contentPane.putConstraint(SpringLayout.SOUTH, chckbxDup, -8, SpringLayout.NORTH, chckbxOutputStatistics); sl_contentPane.putConstraint(SpringLayout.WEST, chckbxDup, 0, SpringLayout.WEST, scrollPane); contentPane.add(chckbxDup); - btnRun.addActionListener(this); } @Override @@ -268,19 +273,19 @@ public void actionPerformed(ActionEvent arg0) { task.addPropertyChangeListener(this); task.execute(); } - + /** - * Invoked when task's progress property changes. - */ - public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } else if ("log" == evt.getPropertyName()) { + * Invoked when task's progress property changes. + */ + public void propertyChange(PropertyChangeEvent evt) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } - } - + } + public void massXable(Container con, boolean status) { for(Component c : con.getComponents()) { c.setEnabled(status); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java index 6880afd3c..4f4dd35a0 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java @@ -2,6 +2,7 @@ import java.awt.BorderLayout; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; import java.net.URISyntaxException; @@ -37,10 +38,6 @@ public SEStatOutput(Vector input, File o, boolean o_status) { setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(150, 150, 600, 800); - bamFiles = input; - OUT_DIR = o; - OUTPUT_STATUS = o_status; - layeredPane = new JLayeredPane(); getContentPane().add(layeredPane, BorderLayout.CENTER); SpringLayout sl_layeredPane = new SpringLayout(); @@ -52,6 +49,10 @@ public SEStatOutput(Vector input, File o, boolean o_status) { sl_layeredPane.putConstraint(SpringLayout.SOUTH, tabbedPane, -6, SpringLayout.SOUTH, layeredPane); sl_layeredPane.putConstraint(SpringLayout.EAST, tabbedPane, -6, SpringLayout.EAST, layeredPane); layeredPane.add(tabbedPane); + + bamFiles = input; + OUT_DIR = o; + OUTPUT_STATUS = o_status; } public void run() throws IOException { @@ -62,36 +63,33 @@ public void run() throws IOException { String NAME = ExtensionFileFilter.stripExtension(bamFiles.get(x).getName()) + "_SE-stats.txt"; File OUT_FILEPATH = new File(NAME); if (OUT_DIR != null) { - OUT_FILEPATH = new File( OUT_DIR.getCanonicalPath() + File.separator + NAME); + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } // Initialize PrintStream and TextArea for SE stats PrintStream ps_stats = null; JTextArea txtArea_Statistics = new JTextArea(); txtArea_Statistics.setEditable(false); ps_stats = new PrintStream(new CustomOutputStream( txtArea_Statistics )); - old_li = new LogItem(""); + // Add JTextArea to JScrollPane in JTabbedPane + JScrollPane se_pane = new JScrollPane(txtArea_Statistics, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + tabbedPane.add(bamFiles.get(x).getName(), se_pane); // Initialize LogItem String command = SEStatsCLI.getCLIcommand(bamFiles.get(x), OUT_FILEPATH); LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); - // Use script and pass PrintStream object that sends to JTextArea - SEStats.getSEStats(bamFiles.get(x), OUT_FILEPATH, OUTPUT_STATUS, ps_stats ); + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, new_li); } + // Execute script + SEStats.getSEStats(bamFiles.get(x), new File(OUT_DIR + File.separator + NAME), OUTPUT_STATUS, ps_stats); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); old_li = new_li; - // Add JTextArea to JScrollPane in JTabbedPane - JScrollPane se_pane = new JScrollPane(txtArea_Statistics, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - tabbedPane.add(bamFiles.get(x).getName(), se_pane); - // Execute script - SEStats.getSEStats(bamFiles.get(x), OUT_FILEPATH, OUTPUT_STATUS, ps_stats); - // Close stats PrintStream + // Close streams ps_stats.close(); // Update progress firePropertyChange("progress", x-1, x); } - //BAMIndexMetaData.printIndexStats(bamFiles.get(x)) - firePropertyChange("log", old_li, null); + // Update log after final input + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, null); } } public static void main(String[] args) { diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java index 2c63a8be4..c8330564b 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java @@ -26,6 +26,7 @@ import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JScrollPane; +import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.SpringLayout; import javax.swing.SwingWorker; @@ -48,20 +49,20 @@ public class SEStatWindow extends JFrame implements ActionListener, PropertyChan final DefaultListModel expList; Vector BAMFiles = new Vector(); - private File OUT_DIR = new File(System.getProperty("user.dir")); + private File OUTPUT_DIR = new File(System.getProperty("user.dir")); JProgressBar progressBar; public Task task; class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { setProgress(0); try { if (expList.size() < 1) { JOptionPane.showMessageDialog(null, "Must load at least one BAM file"); } else { - SEStatOutput output_obj = new SEStatOutput(BAMFiles, OUT_DIR, chckbxOutputStatistics.isSelected()); + SEStatOutput output_obj = new SEStatOutput(BAMFiles, OUTPUT_DIR, chckbxOutputStatistics.isSelected()); output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); @@ -69,16 +70,20 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { setProgress(percentComplete); } }); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); output_obj.setVisible(true); output_obj.run(); } - } catch (NumberFormatException nfe){ + } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Input Fields Must Contain Integers"); } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } - setProgress(100); return null; } @@ -107,8 +112,8 @@ public SEStatWindow() { sl_contentPane.putConstraint(SpringLayout.WEST, scrollPane, 5, SpringLayout.WEST, contentPane); sl_contentPane.putConstraint(SpringLayout.EAST, scrollPane, -5, SpringLayout.EAST, contentPane); contentPane.add(scrollPane); - - expList = new DefaultListModel(); + + expList = new DefaultListModel(); final JList listExp = new JList(expList); listExp.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); scrollPane.setViewportView(listExp); @@ -169,9 +174,9 @@ public void itemStateChanged(ItemEvent e) { btnOutputDirectory.setEnabled(false); btnOutputDirectory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - OUT_DIR = FileSelection.getOutputDir(fc); - if(OUT_DIR != null) { - lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); + OUTPUT_DIR = FileSelection.getOutputDir(fc); + if(OUTPUT_DIR != null) { + lblDefaultToLocal.setText(OUTPUT_DIR.getAbsolutePath()); } } }); @@ -228,6 +233,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From cb5af1a953d3485c02c3471dd286835be0cf022b Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Sun, 29 Oct 2023 15:20:12 -0400 Subject: [PATCH 32/58] add logging to BAMGenomeCorrelation BAMGenomeCorrelationCLI -add getCLIcommand() with javadocs ScriptManagerGUI - add property change listener BAMGenomeCorrelation - adjust script to throw OptionException when validating BAM file BAMGenomeCorrelationOutput and Window - add logitem creation and update steps - add logging propertyChange listeners - rename Output and script object instantiations to match format of other tools - restructure try-catch statements to handle exceptions in Window --- .../BAMGenomeCorrelationCLI.java | 59 ++++++++++++++++++- .../scriptmanager/main/ScriptManagerGUI.java | 11 ++++ .../BAM_Statistics/BAMGenomeCorrelation.java | 19 ++---- .../BAMGenomeCorrelationOutput.java | 44 ++++++++------ .../BAMGenomeCorrelationWindow.java | 30 +++++++--- 5 files changed, 122 insertions(+), 41 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java index af564d7ef..3b071221c 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java @@ -8,12 +8,14 @@ import java.util.Scanner; import java.util.Vector; import java.util.concurrent.Callable; - +import java.util.stream.Collectors; import java.io.File; import java.io.IOException; import scriptmanager.charts.HeatMap; import scriptmanager.objects.ToolDescriptions; +import scriptmanager.objects.ArchTEx.CorrParameter; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.scripts.BAM_Statistics.BAMGenomeCorrelation; @@ -162,4 +164,59 @@ private String validateInput() throws IOException { return(r); } + + /** + * Reconstruct CLI command + * + * @param input list of BAM files to correlate + * @param output file basename to write correlation matrix values and image + * to + * @param SHIFT read shift to apply + * @param BIN bin size + * @param CPU num threads + * @param READ read encoding to use + * @param COLORSCALE color scale to use + * @return command line to execute with formatted inputs + * @throws OptionException + */ + public static String getCLIcommand(Vector input, File output, int SHIFT, int BIN, int CPU, int READ, short COLORSCALE) throws OptionException { + String command = "java -jar $SCRIPTMANAGER bam-statistics bam-correlation"; + command += " -o " + output; + command += " -t " + SHIFT; + command += " -b " + BIN; + command += " --cpu " + CPU; + + switch (READ) { + case 0: + command += " -1"; + break; + case 1: + command += " -2"; + break; + case 2: + command += " -a"; + break; + case 3: + command += " -m"; + break; + default: + throw new OptionException("invalid strand value"); + } + + switch (COLORSCALE) { + case HeatMap.BLUEWHITERED: + command += " --classic"; + break; + case HeatMap.JETLIKE: + command += " --jet-like"; + break; + default: + throw new OptionException("Unexpected colorscale value"); + } + + for (int x = 0; x input, File o, int s, int b, int c, int COLORSCALE = cs; } - public void getBAMGenomeCorrelation(boolean GUI) throws IOException { + public void getBAMGenomeCorrelation(boolean GUI) throws IOException, OptionException { System.err.println(getTimeStamp()); // Check BAMs first if(!validateBAM()) { @@ -186,7 +185,7 @@ public double correlate(File exp1, File exp2) { return correlation; } - private boolean validateBAM() throws IOException { + private boolean validateBAM() throws IOException, OptionException { //Check if BAI index file exists for all BAM files before we process any of them ArrayList chrName = new ArrayList(); ArrayList chrSize = new ArrayList(); @@ -194,9 +193,7 @@ private boolean validateBAM() throws IOException { File XBAM = bamFiles.get(x); File f = new File(XBAM + ".bai"); if(!f.exists() || f.isDirectory()) { - if(GUI){ JOptionPane.showMessageDialog(null, "BAI Index File does not exist for: " + XBAM.getName()); } - else{ System.err.println("BAI Index File does not exist for: " + XBAM.getName()); } - return false; + throw new OptionException("BAI Index File does not exist for: " + XBAM.getName()); } else { reader = factory.open(XBAM); AbstractBAMFileIndex bai = (AbstractBAMFileIndex) reader.indexing().getIndex(); @@ -206,11 +203,9 @@ private boolean validateBAM() throws IOException { chrSize.add(reader.getFileHeader().getSequence(z).getSequenceLength()); } } else if(bai.getNumberOfReferences() != chrName.size()) { - if(GUI){ JOptionPane.showMessageDialog(null, "Unequal number of chromosomes from previous: " + XBAM.getName()); } - else{ System.err.println("BAI Index File does not exist for: " + XBAM.getName()); } reader.close(); bai.close(); - return false; + throw new OptionException("Unequal number of chromosomes from previous: " + XBAM.getName()); } else { boolean MATCH = true; for (int z = 0; z < bai.getNumberOfReferences(); z++) { @@ -218,11 +213,9 @@ private boolean validateBAM() throws IOException { if(!chrSize.get(z).equals(reader.getFileHeader().getSequence(z).getSequenceLength())) { MATCH = false; } } if(!MATCH) { - if(GUI){ JOptionPane.showMessageDialog(null, "File contains chromosome size/name which does not match previous: " + XBAM.getName()); } - else{ System.err.println("BAI Index File does not exist for: " + XBAM.getName()); } reader.close(); bai.close(); - return false; + throw new OptionException("File contains chromosome size/name which does not match previous: " + XBAM.getName()); } } bai.close(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationOutput.java index 3f8bfc377..e74244ba8 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationOutput.java @@ -5,8 +5,9 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.JFrame; @@ -16,6 +17,9 @@ import javax.swing.JTable; import javax.swing.SpringLayout; +import scriptmanager.cli.BAM_Statistics.BAMGenomeCorrelationCLI; +import scriptmanager.objects.LogItem; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.scripts.BAM_Statistics.BAMGenomeCorrelation; // Output Window wrapper for executing the script and displaying output @@ -24,9 +28,8 @@ public class BAMGenomeCorrelationOutput extends JFrame { Vector bamFiles = null; String[] fileID = null; - private File OUTPUT_PATH = null; + private File OUT_DIR = null; private boolean OUTPUT_STATUS = false; - File OUT = null; private int SHIFT; private int BIN; private int CPU; @@ -55,7 +58,7 @@ public BAMGenomeCorrelationOutput(Vector input, File o, boolean out, int s bamFiles = input; fileID = new String[bamFiles.size()]; - OUTPUT_PATH = o; + OUT_DIR = o; OUTPUT_STATUS = out; SHIFT = s; BIN = b; @@ -64,21 +67,20 @@ public BAMGenomeCorrelationOutput(Vector input, File o, boolean out, int s COLORSCALE = cs; } - public void run() throws IOException { - //Open Output File - if(OUTPUT_STATUS) { - String NAME = "correlation_matrix"; - if(OUTPUT_PATH != null) { - try { OUT = new File(OUTPUT_PATH.getCanonicalPath() + File.separator + NAME); } - catch (FileNotFoundException e) { e.printStackTrace(); } - catch (IOException e) { e.printStackTrace(); } - } else { - OUT = new File(NAME); - } - } else { - OUTPUT_PATH = null; + public void run() throws IOException, OptionException { + // Construct output filename + String NAME = "correlation_matrix.txt"; + File OUT_FILEPATH = new File(NAME); + if (OUT_DIR != null) { + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } - BAMGenomeCorrelation script_obj = new BAMGenomeCorrelation( bamFiles, OUT, SHIFT, BIN, CPU, READ, COLORSCALE ); + + // Initialize LogItem + String command = BAMGenomeCorrelationCLI.getCLIcommand(bamFiles, OUT_FILEPATH, SHIFT, BIN, CPU, READ, COLORSCALE ); + LogItem li = new LogItem(command); + if (OUTPUT_STATUS) { firePropertyChange("log", null, li); } + // Execute script + BAMGenomeCorrelation script_obj = new BAMGenomeCorrelation(bamFiles, OUT_FILEPATH, SHIFT, BIN, CPU, READ, COLORSCALE ); script_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { @@ -88,11 +90,17 @@ public void propertyChange(PropertyChangeEvent evt) { }); script_obj.getBAMGenomeCorrelation(true); + // Update log item + li.setStopTime(new Timestamp(new Date().getTime())); + li.setStatus(0); + // Add plot and data to tabs tabbedPane.addTab("Correlation Plot", script_obj.getHeatMap()); tabbedPane.addTab("Correlation Data", makeTablePanel(script_obj.getMatrix())); //Make frame visible at completion of correlations this.setVisible(true); + // Update log at completion + if (OUTPUT_STATUS) { firePropertyChange("log", li, null); } } public JScrollPane makeTablePanel(double[][] MATRIX) { diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java index d67a96efa..7afbdc6bf 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java @@ -41,6 +41,7 @@ import javax.swing.border.TitledBorder; import scriptmanager.charts.HeatMap; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") @@ -97,25 +98,34 @@ public Void doInBackground() { else if(rdbtnAllReads.isSelected()) { READ = 2; } else if(rdbtnMidpoint.isSelected()) { READ = 3; } - short COLORSCALE = 0; - if (rdbtnClassicCS.isSelected()) { COLORSCALE = HeatMap.BLUEWHITERED; } - else if (rdbtnJetLikeCS.isSelected()) { COLORSCALE = HeatMap.JETLIKE; } + short COLORSCALE = 0; + if (rdbtnClassicCS.isSelected()) { COLORSCALE = HeatMap.BLUEWHITERED; } + else if (rdbtnJetLikeCS.isSelected()) { COLORSCALE = HeatMap.JETLIKE; } - BAMGenomeCorrelationOutput corr = new BAMGenomeCorrelationOutput(BAMFiles, OUTPUT_PATH, chckbxOutputStatistics.isSelected(), SHIFT, BIN, CPU, READ, COLORSCALE); - corr.addPropertyChangeListener("progress", new PropertyChangeListener() { + BAMGenomeCorrelationOutput output_obj = new BAMGenomeCorrelationOutput(BAMFiles, OUTPUT_PATH, chckbxOutputStatistics.isSelected(), SHIFT, BIN, CPU, READ, COLORSCALE); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int) (((double)(temp) / (((BAMFiles.size() * BAMFiles.size()) - BAMFiles.size()) / 2)) * 100); setProgress(percentComplete); } }); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); - corr.run(); + output_obj.run(); } } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Input Fields Must Contain Integers"); - } catch (IOException e) { - e.printStackTrace(); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (OptionException oe) { + oe.printStackTrace(); + JOptionPane.showMessageDialog(null, oe.getMessage()); } setProgress(100); return null; @@ -394,15 +404,17 @@ public void actionPerformed(ActionEvent arg0) { task.addPropertyChangeListener(this); task.execute(); } - /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From 496be9bd1c3a7681d9733a410176637b5ed46c61 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Sun, 29 Oct 2023 17:25:11 -0400 Subject: [PATCH 33/58] bugfix BAM Manipulation logging adjust logging for BAM Manipulation to fix bugs CLI classes - add javadocs to getCLIcommand() - add missing spaces between arguments - MergeBAMCLI: add missing useMultipleCpus option Window classes - add try-catch to BAMMarkDupWindow - standardize output filename/basename construction (reduce line count) with consistent variable naming - add catch statements for various exceptions --- .../cli/BAM_Manipulation/BAIIndexerCLI.java | 12 +++- .../cli/BAM_Manipulation/BAMRemoveDupCLI.java | 20 ++++-- .../BAM_Manipulation/FilterforPIPseqCLI.java | 10 +++ .../cli/BAM_Manipulation/MergeBAMCLI.java | 20 ++++-- .../cli/BAM_Manipulation/SortBAMCLI.java | 15 +++- .../BAM_Manipulation/BAIIndexerWindow.java | 27 +++++--- .../BAM_Manipulation/BAMMarkDupWindow.java | 69 +++++++++++-------- .../FilterforPIPseqWindow.java | 42 ++++++----- .../BAM_Manipulation/MergeBAMWindow.java | 41 +++++++---- .../BAM_Manipulation/SortBAMWindow.java | 38 ++++++---- 10 files changed, 191 insertions(+), 103 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java index 6ab15a597..26d3e5095 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/BAIIndexerCLI.java @@ -29,10 +29,16 @@ public Integer call() throws Exception { return(1); } - public static String getCLIcommand(File BAM) { + /** + * Reconstruct CLI command + * + * @param input the BAM file to index + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input) { String command = "java -jar $PICARD BuildBamIndex"; - command += "INPUT=" + BAM.getAbsolutePath(); - command += "OUTPUT=" + BAM.getAbsolutePath() + ".bai"; + command += " INPUT=" + input.getAbsolutePath(); + command += " OUTPUT=" + input.getAbsolutePath() + ".bai"; return command; } diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/BAMRemoveDupCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/BAMRemoveDupCLI.java index dd0fd669e..7618a198c 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/BAMRemoveDupCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/BAMRemoveDupCLI.java @@ -31,12 +31,22 @@ public Integer call() throws Exception { return(1); } - public static String getCLIcommand(File BAM, boolean removeDuplicates, File OUTPUT, File METRICS) { + /** + * Reconstruct CLI command + * + * @param input the BAM file to mark/remove duplicates for + * @param removeDuplicates whether to remove or just mark duplicates + * @param output the marked/filtered BAM output file + * @param metrics the output metrics file with information about the + * deduplicates + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, boolean removeDuplicates, File output, File metrics) { String command = "java -jar $PICARD MarkDuplicates"; - command += " INPUT=" + BAM.getAbsolutePath(); - command += " OUTPUT=" + OUTPUT.getAbsolutePath(); - command += " METRICS_FILE=" + METRICS.getAbsolutePath(); - command += removeDuplicates ? "REMOVE_DUPLICATES=true" : "REMOVE_DUPLICATES=false"; + command += " INPUT=" + input.getAbsolutePath(); + command += " OUTPUT=" + output.getAbsolutePath(); + command += " METRICS_FILE=" + metrics.getAbsolutePath(); + command += removeDuplicates ? " REMOVE_DUPLICATES=true" : " REMOVE_DUPLICATES=false"; return(command); } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java index 6b74e74f9..58ef93956 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java @@ -126,6 +126,16 @@ private String validateInput() throws IOException { return (r); } + + /** + * Reconstruct CLI command + * + * @param BAM the BAM file to filter + * @param GENOME the genomic FASTA reference file (should match BAM header) + * @param OUTPUT the output BAM file + * @param txtSeq the IUPAC string to filter by + * @return command line to execute with formatted inputs + */ public static String getCLIcommand(File BAM, File GENOME, File OUTPUT, String txtSeq) { String command = "java -jar $SCRIPTMANAGER bam-manipulation filter-pip-seq"; command += " " + GENOME.getAbsolutePath(); diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/MergeBAMCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/MergeBAMCLI.java index 3a59f329f..7fa5587d6 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/MergeBAMCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/MergeBAMCLI.java @@ -30,12 +30,24 @@ public Integer call() throws Exception { return(1); } - public static String getCLIcommand(ArrayList BAMFiles, File OUTPUT) { + /** + * Reconstruct CLI command + * + * @param inputs the list of input BAM files to merge (corresponds to + * several INPUT values) + * @param output the output file for the merged BAM file (corresponds + * to OUTPUT) + * @param useMultipleCpus whether or not to parallelize (corresponds to + * USE_THREADING) + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(ArrayList inputs, File output, boolean useMultipleCpus) { String command = "java -jar $PICARD MergeSamFiles"; - for (File input : BAMFiles) { - command += "INPUT=" + input.getAbsolutePath(); + for (File in : inputs) { + command += " INPUT=" + in.getAbsolutePath(); } - command += "OUTPUT=" + OUTPUT.getAbsolutePath(); + command += " OUTPUT=" + output.getAbsolutePath(); + command += useMultipleCpus ? " USE_THREADING=true" : " USE_THREADING=false"; return command; } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/SortBAMCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/SortBAMCLI.java index 5e791a277..06e23341b 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/SortBAMCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/SortBAMCLI.java @@ -3,6 +3,9 @@ import picocli.CommandLine.Command; import java.util.concurrent.Callable; + +import htsjdk.samtools.SAMFileHeader; + import java.io.File; import scriptmanager.objects.ToolDescriptions; @@ -29,10 +32,18 @@ public Integer call() throws Exception { return(1); } - public static String getCLIcommand(File BAM, File output) { + /** + * Reconstruct CLI command + * + * @param input the BAM file to be sorted (corresponds to INPUT) + * @param output the file to write the sorted BAM to (corresponds to OUTPUT) + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, File output) { String command = "java -jar $PICARD SortSam"; - command += " INPUT=" + BAM.getAbsolutePath(); + command += " INPUT=" + input.getAbsolutePath(); command += " OUTPUT=" + output.getAbsolutePath(); + command += " SORT_ORDER=" + SAMFileHeader.SortOrder.coordinate; return(command); } } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java index dfe359aa9..896f24b8b 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java @@ -51,10 +51,10 @@ public class BAIIndexerWindow extends JFrame implements ActionListener, Property class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - setProgress(0); - LogItem old_li = null; + public Void doInBackground() { try { + setProgress(0); + LogItem old_li = null; for(int x = 0; x < BAMFiles.size(); x++) { // Initialize LogItem String command = BAIIndexerCLI.getCLIcommand(BAMFiles.get(x)); @@ -73,9 +73,13 @@ public Void doInBackground() throws IOException { firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Indexing Complete"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (SAMException se) { JOptionPane.showMessageDialog(null, se.getMessage()); - } + } + setProgress(100); return null; } @@ -164,13 +168,14 @@ public void actionPerformed(ActionEvent arg0) { } /** - * Invoked when task's progress property changes. - */ - public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } else if ("log" == evt.getPropertyName()) { + * Invoked when task's progress property changes. + */ + @Override + public void propertyChange(PropertyChangeEvent evt) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java index fa013691e..7cdea9007 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java @@ -10,6 +10,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; +import java.io.IOException; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; @@ -32,6 +33,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.LogItem; +import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; import scriptmanager.cli.BAM_Manipulation.BAMRemoveDupCLI; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; @@ -43,7 +45,7 @@ public class BAMMarkDupWindow extends JFrame implements ActionListener, Property protected JFileChooser fc = new JFileChooser(new File(System.getProperty("user.dir"))); final DefaultListModel expList; - private File OUTPUT_PATH = null; + private File OUT_DIR = null; List BAMFiles = new ArrayList(); private JButton btnLoad; @@ -59,42 +61,46 @@ public class BAMMarkDupWindow extends JFrame implements ActionListener, Property private JCheckBox chckbxRemoveDuplicates; class Task extends SwingWorker { - @Override - public Void doInBackground() throws Exception { + @Override + public Void doInBackground() { + try { setProgress(0); LogItem old_li = null; - for(int x = 0; x < BAMFiles.size(); x++) { - String[] NAME = BAMFiles.get(x).getName().split("\\."); - File OUTPUT = null; - File METRICS = null; - if(OUTPUT_PATH != null) { - OUTPUT = new File(OUTPUT_PATH.getCanonicalPath() + File.separator + NAME[0] + "_dedup.bam"); - METRICS = new File(OUTPUT_PATH.getCanonicalPath() + File.separator + NAME[0] + "_dedup.metrics"); - } else { - OUTPUT = new File(NAME[0] + "_dedup.bam"); - METRICS = new File(NAME[0] + "_dedup.metrics"); - } - + for (int x = 0; x < BAMFiles.size(); x++) { + // Construct output filenames + String NAME = ExtensionFileFilter.stripExtension(BAMFiles.get(x).getName()); + File OUTPUT = new File(NAME + "_dedup.bam"); + File METRICS = new File(NAME + "_dedup.metrics"); + if (OUT_DIR != null) { + OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME + "_dedup.bam"); + METRICS = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME + "_dedup.metrics"); + } // Initialize LogItem String command = BAMRemoveDupCLI.getCLIcommand(BAMFiles.get(x), chckbxRemoveDuplicates.isSelected(), OUTPUT, METRICS); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); - BAMMarkDuplicates dedup = new BAMMarkDuplicates(BAMFiles.get(x), chckbxRemoveDuplicates.isSelected(), OUTPUT, METRICS); - dedup.run(); + BAMMarkDuplicates script_obj = new BAMMarkDuplicates(BAMFiles.get(x), chckbxRemoveDuplicates.isSelected(), OUTPUT, METRICS); + script_obj.run(); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); old_li = new_li; - - if(chckbxGenerateBaiIndex.isSelected()) { BAIIndexer.generateIndex(OUTPUT); } - - int percentComplete = (int)(((double)(x + 1) / BAMFiles.size()) * 100); - setProgress(percentComplete); - } + // Generate index on output + if (chckbxGenerateBaiIndex.isSelected()) { + BAIIndexer.generateIndex(OUTPUT); + } + // Update progress + int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); + setProgress(percentComplete); + } firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Mark Duplicates Complete"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } return null; } @@ -176,9 +182,9 @@ public void actionPerformed(ActionEvent arg0) { sl_contentPane.putConstraint(SpringLayout.SOUTH, scrollPane, -72, SpringLayout.NORTH, btnOutput); btnOutput.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - OUTPUT_PATH = FileSelection.getOutputDir(fc); - if(OUTPUT_PATH != null) { - lblDefaultToLocal.setText(OUTPUT_PATH.getAbsolutePath()); + OUT_DIR = FileSelection.getOutputDir(fc); + if(OUT_DIR != null) { + lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); } } }); @@ -221,12 +227,15 @@ public void actionPerformed(ActionEvent arg0) { task.addPropertyChangeListener(this); task.execute(); } - + + /** + * Invoked when task's progress property changes. + */ @Override public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); } else if ("log" == evt.getPropertyName()) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java index 7586a46dc..57f118a8f 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java @@ -36,6 +36,7 @@ import scriptmanager.cli.BAM_Manipulation.FilterforPIPseqCLI; import scriptmanager.objects.LogItem; +import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; @@ -45,7 +46,7 @@ public class FilterforPIPseqWindow extends JFrame implements ActionListener, Pro protected JFileChooser fc = new JFileChooser(new File(System.getProperty("user.dir"))); final DefaultListModel expList; - private File OUTPUT_PATH = null; + private File OUT_DIR = null; private File GENOME = null; List BAMFiles = new ArrayList(); @@ -66,35 +67,34 @@ public class FilterforPIPseqWindow extends JFrame implements ActionListener, Pro class Task extends SwingWorker { @Override - public Void doInBackground() throws Exception { - setProgress(0); - LogItem old_li = new LogItem(""); + public Void doInBackground() { try { + setProgress(0); + LogItem old_li = null; for (int x = 0; x < BAMFiles.size(); x++) { - String[] NAME = BAMFiles.get(x).getName().split("\\."); - File OUTPUT = null; - if (OUTPUT_PATH != null) { - OUTPUT = new File(OUTPUT_PATH.getCanonicalPath() + File.separator + NAME[0] + "_PSfilter.bam"); - } else { - OUTPUT = new File(NAME[0] + "_PSfilter.bam"); + // Construct output filename + String NAME = ExtensionFileFilter.stripExtension(BAMFiles.get(x).getName()); + File OUTPUT = new File(NAME + "_PSfilter.bam"); + if (OUT_DIR != null) { + OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME + "_PSfilter.bam"); } // Initialize LogItem String command = FilterforPIPseqCLI.getCLIcommand(BAMFiles.get(x), GENOME, OUTPUT, txtSeq.getText()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute Wrapper - FilterforPIPseqOutput filter = new FilterforPIPseqOutput(BAMFiles.get(x), GENOME, OUTPUT, txtSeq.getText()); + FilterforPIPseqOutput output_obj = new FilterforPIPseqOutput(BAMFiles.get(x), GENOME, OUTPUT, txtSeq.getText()); + output_obj.setVisible(true); + output_obj.run(); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); old_li = new_li; - filter.setVisible(true); - filter.run(); - + // Generate BAI on output if selected if (chckbxGenerateBaiIndex.isSelected()) { BAIIndexer.generateIndex(OUTPUT); } - + // Update progress int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } @@ -103,9 +103,12 @@ public Void doInBackground() throws Exception { JOptionPane.showMessageDialog(null, "Permanganate-Seq Filtering Complete"); } catch (IOException ioe) { ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (InterruptedException ie) { ie.printStackTrace(); + JOptionPane.showMessageDialog(null, "InterruptedException - " + ie.getMessage()); } + setProgress(100); return null; } @@ -186,9 +189,9 @@ public void actionPerformed(ActionEvent arg0) { sl_contentPane.putConstraint(SpringLayout.SOUTH, btnOutput, -55, SpringLayout.SOUTH, contentPane); btnOutput.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - OUTPUT_PATH = FileSelection.getOutputDir(fc); - if (OUTPUT_PATH != null) { - lblDefaultToLocal.setText(OUTPUT_PATH.getAbsolutePath()); + OUT_DIR = FileSelection.getOutputDir(fc); + if (OUT_DIR != null) { + lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); } } }); @@ -259,6 +262,9 @@ public void actionPerformed(ActionEvent arg0) { task.execute(); } + /** + * Invoked when task's progress property changes. + */ @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java index 22cb52bd9..48eafbebb 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java @@ -11,6 +11,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import javax.swing.DefaultListModel; @@ -45,7 +46,6 @@ public class MergeBAMWindow extends JFrame implements ActionListener, PropertyCh final DefaultListModel expList; ArrayList BAMFiles = new ArrayList(); - private File OUTPUT = null; private File OUT_DIR = null; private JButton btnLoad; @@ -61,16 +61,18 @@ public class MergeBAMWindow extends JFrame implements ActionListener, PropertyCh public Task task; class Task extends SwingWorker { - @Override - public Void doInBackground() throws Exception { - setProgress(0); + @Override + public Void doInBackground() { + setProgress(0); LogItem old_li = null; try { - // Build output filepath - if(OUT_DIR != null) { OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + txtOutput.getText()); } - else { OUTPUT = new File(txtOutput.getText()); } + // Construct output filename + File OUTPUT = new File(txtOutput.getText()); + if(OUT_DIR != null) { + OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + txtOutput.getText()); + } // Initialize LogItem - String command = MergeBAMCLI.getCLIcommand(BAMFiles, OUTPUT); + String command = MergeBAMCLI.getCLIcommand(BAMFiles, OUTPUT, chckbxUseMultipleCpus.isSelected()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute Picard wrapper @@ -83,12 +85,18 @@ public Void doInBackground() throws Exception { if(chckbxGenerateBaiindex.isSelected()) { BAIIndexer.generateIndex(OUTPUT); } + // Update log after final input firePropertyChange("log", old_li, null); + // Update progress setProgress(100); JOptionPane.showMessageDialog(null, "Merging Complete"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (SAMException se) { JOptionPane.showMessageDialog(null, se.getMessage()); } + setProgress(100); return null; } @@ -228,15 +236,18 @@ public void actionPerformed(ActionEvent arg0) { task.addPropertyChangeListener(this); task.execute(); } - + + /** + * Invoked when task's progress property changes. + */ @Override public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } else if ("log" == evt.getPropertyName()) { - firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); - } + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } } public void massXable(Container con, boolean status) { diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java index b5faa6b0b..ad15c8643 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java @@ -12,6 +12,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; +import java.io.IOException; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; @@ -35,6 +36,7 @@ import scriptmanager.cli.BAM_Manipulation.SortBAMCLI; import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Manipulation.BAMFileSort; +import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") @@ -58,17 +60,17 @@ public class SortBAMWindow extends JFrame implements ActionListener, PropertyCha class Task extends SwingWorker { @Override - public Void doInBackground() throws Exception { - setProgress(0); - LogItem old_li = null; - + public Void doInBackground() { try { - for(int x = 0; x < BAMFiles.size(); x++) { - // Build output filepath - String[] NAME = BAMFiles.get(x).getName().split("\\."); - File OUTPUT = null; - if(OUT_DIR != null) { OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME[0] + "_sorted.bam"); } - else { OUTPUT = new File(NAME[0] + "_sorted.bam"); } + setProgress(0); + LogItem old_li = null; + for (int x = 0; x < BAMFiles.size(); x++) { + // Construct output filename + String NAME = ExtensionFileFilter.stripExtension(BAMFiles.get(x).getName()) + "_sorted.bam"; + File OUTPUT = new File(NAME); + if (OUT_DIR != null) { + OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); + } // Initialize LogItem String command = SortBAMCLI.getCLIcommand(BAMFiles.get(x), OUTPUT); LogItem new_li = new LogItem(command); @@ -87,6 +89,9 @@ public Void doInBackground() throws Exception { firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Sorting Complete"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (SAMException se) { JOptionPane.showMessageDialog(null, se.getMessage()); } @@ -204,13 +209,16 @@ public void actionPerformed(ActionEvent arg0) { task.addPropertyChangeListener(this); task.execute(); } - + + /** + * Invoked when task's progress property changes. + */ @Override public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } else if ("log" == evt.getPropertyName()) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From bcbea24e5df2eed184a09033cf9e538226099a00 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 31 Oct 2023 18:52:39 -0400 Subject: [PATCH 34/58] bugfix Peak Analysis logging adjust logging for Peak Analysis to fix bugs and add javadocs to getCLIcommand() BEDPeakAligntoRefCLI - correct parameter order to match script class (ref and peak swapped) FilterBEDbyProximityCLI - adjust to script constructor signature change (File type and reorder inputs) RandomCoordinateCLI - adjust to script constructor signature change (reorder inputs) - reduce extension string builder to a one-liner BEDPeakAligntoRef - restructure run() to create the PrintStream objects from Files (moved from constructor) - add close statement for PrintStream OUT - adjust bracket style for a few lines FilterBEDbyProximity - restructure run() to create the PrintStream objects from Files (moved from constructor) - reorder constructor params for consistency with other tools (input files, output opts, other opts, gui-specific opts) RandomCoordinate - reorder constructor params for consistency with other tools (input files, output opts, other opts, gui-specific opts) - clean-up/reduce code for constructing default output filename - throw OptionException instead of using JOptionPane GUI element (not good for CLI) Output and Window for all three tools - adjust inputs/script call structures to account for changes in script class signature - add GUI handling of various exceptions thrown by script class for consistency with other tools - rename *Output object as output_obj for consistency with other tools - standardize output filename construction for consistency with other tools - rename OUTPUT_PATH to OUT_DIR for consistency with other tools - adjust some indentation for formatting consistency - rename LogItem li to demonstrate tracking one log item at a time --- .../Peak_Analysis/BEDPeakAligntoRefCLI.java | 10 +- .../FilterBEDbyProximityCLI.java | 29 +++-- .../Peak_Analysis/RandomCoordinateCLI.java | 16 ++- .../Peak_Analysis/BEDPeakAligntoRef.java | 90 ++++++++-------- .../Peak_Analysis/FilterBEDbyProximity.java | 40 +++---- .../Peak_Analysis/RandomCoordinate.java | 36 +++---- .../BEDPeakAligntoRefOutput.java | 18 ++-- .../BEDPeakAligntoRefWindow.java | 96 +++++++++-------- .../FilterBEDbyProximityOutput.java | 42 ++++---- .../FilterBEDbyProximityWindow.java | 76 +++++++------ .../Peak_Analysis/RandomCoordinateWindow.java | 100 ++++++++++-------- 11 files changed, 305 insertions(+), 248 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java index 02b622cd8..5a464705d 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java @@ -89,7 +89,15 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File peakBED, File refBED, File output) { + /** + * Reconstruct CLI command + * + * @param refBED the reference BED windows to align to + * @param peakBED the BED coordinate signal to mark the reference windows with + * @param output the aligned output matrix file + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File refBED, File peakBED, File output) { String command = "java -jar $SCRIPTMANAGER peak-analysis peak-align-ref"; command += " " + peakBED.getAbsolutePath(); command += " " + refBED.getAbsolutePath(); diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java index 7f91027d5..4f34d89e0 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java @@ -28,7 +28,7 @@ public class FilterBEDbyProximityCLI implements Callable { private File bedFile; @Option(names = {"-o", "--output"}, description = "Specify basename for output files (default = _bp)") - private String outputBasename = null; + private File outputBasename = null; @Option(names = {"-e", "--exclusion"}, description = "exclusion distance in bp (default=100)") private int exclusion = 100; @@ -42,7 +42,7 @@ public Integer call() throws Exception { System.exit(1); } - FilterBEDbyProximity script_obj = new FilterBEDbyProximity(bedFile, exclusion, outputBasename, null); + FilterBEDbyProximity script_obj = new FilterBEDbyProximity(bedFile, outputBasename, exclusion, null); script_obj.run(); System.err.println( "Filter Complete." ); @@ -62,17 +62,16 @@ private String validateInput() throws IOException { r += "(!)Is this a BED file? Check extension: " + bedFile.getName() + "\n"; } //set default output filename - if(outputBasename==null){ - outputBasename = ExtensionFileFilter.stripExtension(bedFile) + "_" + Integer.toString(exclusion) + "bp"; + if (outputBasename==null) { + outputBasename = new File(ExtensionFileFilter.stripExtension(bedFile) + "_" + Integer.toString(exclusion) + "bp"); //check output filename is valid }else{ //no check ext //check directory - File tmpOut = new File(outputBasename); - if(tmpOut.getParent()==null){ + if (outputBasename.getParent()==null){ // System.err.println("default to current directory"); - } else if(!new File(tmpOut.getParent()).exists()){ - r += "(!)Check output directory exists: " + tmpOut.getParent() + "\n"; + } else if(! new File(outputBasename.getParent()).exists()){ + r += "(!)Check output directory exists: " + outputBasename.getParent() + "\n"; } } @@ -82,12 +81,20 @@ private String validateInput() throws IOException { } return(r); - } - public static String getCLIcommand(File input, String outputBasename, int exclusion) { + + /** + * Reconstruct CLI command + * + * @param input the BED file to filter using an exclusion distance + * @param outputBasename the basename for output BED-formatted *-FILTER.bed and *-CLUSTER.bed files + * @param exclusion the number of bp distance to filter by/size of exclusion zone + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, File output, int exclusion) { String command = "java -jar $SCRIPTMANAGER peak-analysis filter-bed"; command += " " + input.getAbsolutePath(); - command += " -o " + outputBasename; + command += " -o " + output.getAbsolutePath(); command += " -e " + exclusion; return command; } diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java index d94ef4ca0..00f9366c6 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java @@ -46,7 +46,7 @@ public Integer call() throws Exception { System.exit(1); } - RandomCoordinate.execute(genomeName, numSites, window, formatIsBed, output); + RandomCoordinate.execute(genomeName, output, formatIsBed, numSites, window); System.err.println( "Random Coordinate Generation Complete." ); return(0); @@ -55,8 +55,7 @@ public Integer call() throws Exception { private String validateInput() throws IOException { String r = ""; - String ext = "gff"; - if(formatIsBed){ ext = "bed"; } + String ext = formatIsBed ? "bed" : "gff"; //set default output filename if(output==null){ output = new File("random_coordinates_" + genomeName + "_" + numSites + "sites_" + window + "bp." + ext); @@ -87,6 +86,17 @@ private String validateInput() throws IOException { return(r); } + + /** + * Reconstruct CLI command + * + * @param genomeName the genome build to randomly sample genomic coordinates from + * @param output the text file of the sampled coordinates + * @param formatIsBed the format of the coordinate output (BED or GFF) + * @param numSites the number of sites to sample + * @param window the size of the coordinates sampled + * @return command line to execute with formatted inputs + */ public static String getCLIcommand(String genomeName, File output, boolean formatIsBed, int numSites, int window) { String command = "java -jar $SCRIPTMANAGER peak-analysis rand-coord"; command += " " + genomeName; diff --git a/src/main/java/scriptmanager/scripts/Peak_Analysis/BEDPeakAligntoRef.java b/src/main/java/scriptmanager/scripts/Peak_Analysis/BEDPeakAligntoRef.java index 51a243485..55d794d1b 100644 --- a/src/main/java/scriptmanager/scripts/Peak_Analysis/BEDPeakAligntoRef.java +++ b/src/main/java/scriptmanager/scripts/Peak_Analysis/BEDPeakAligntoRef.java @@ -17,21 +17,21 @@ import java.util.Map; public class BEDPeakAligntoRef { - private String peakPath = null; - private String refPath = null; - private PrintStream OUT = null; + private File refPath = null; + private File peakPath = null; + private File OUT_FILEPATH = null; private PrintStream PS = null; - - public BEDPeakAligntoRef(File ref, File peak, File output, PrintStream ps) throws IOException { - refPath = ref.getCanonicalPath(); - peakPath = peak.getCanonicalPath(); + + public BEDPeakAligntoRef(File ref, File peak, File output, PrintStream ps) { + refPath = ref; + peakPath = peak; + OUT_FILEPATH = output; PS = ps; - - try {OUT = new PrintStream(output); } - catch (FileNotFoundException e) { e.printStackTrace(); } } - - public void run() throws IOException, InterruptedException { + + public void run() throws FileNotFoundException, IOException, InterruptedException { + PrintStream OUT = new PrintStream(OUT_FILEPATH); + printPS("Mapping: " + peakPath + " to " + refPath); printPS("Starting: " + getTimeStamp()); @@ -48,9 +48,7 @@ public void run() throws IOException, InterruptedException { if(!peakMap.containsKey(key)) { peakMap.put(key, new ArrayList()); peakMap.get(key).add(line); - } - else - { + } else { peakMap.get(key).add(line + "\t"); } } @@ -59,56 +57,64 @@ public void run() throws IOException, InterruptedException { //============ inputStream = new FileInputStream(refPath); - buff = new BufferedReader(new InputStreamReader(inputStream), 100); - - for (String line; (line = buff.readLine()) != null; ) { - String[] str = line.split("\t"); - String chr = str[0]; + buff = new BufferedReader(new InputStreamReader(inputStream), 100); + + for (String line; (line = buff.readLine()) != null;) { + String[] str = line.split("\t"); + String chr = str[0]; String[] peakLine; int cdtLength = (Integer.parseInt(str[2])) - (Integer.parseInt(str[1])); int cdtArr[] = new int[cdtLength]; - if(peakMap.containsKey(chr)) - { - for(int i = 0; i < peakMap.get(chr).size(); i++) - { - peakLine = peakMap.get(chr).get(i).split("\t"); - if(Integer.parseInt(peakLine[1]) <= Integer.parseInt(str[2]) && Integer.parseInt(peakLine[1]) >= Integer.parseInt(str[1])) { + if (peakMap.containsKey(chr)) { + for (int i = 0; i < peakMap.get(chr).size(); i++) { + peakLine = peakMap.get(chr).get(i).split("\t"); + if (Integer.parseInt(peakLine[1]) <= Integer.parseInt(str[2]) && Integer.parseInt(peakLine[1]) >= Integer.parseInt(str[1])) { int START = Integer.parseInt(peakLine[1]) - Integer.parseInt(str[1]); int STOP = START + (Integer.parseInt(peakLine[2]) - Integer.parseInt(peakLine[1])); for(int x = START; x <= STOP; x++) { if(x >= 0 && x < cdtLength) { cdtArr[x]++; } - } } - else if(Integer.parseInt(peakLine[2]) >= Integer.parseInt(str[1]) && Integer.parseInt(peakLine[2]) <= Integer.parseInt(str[2])) - { + } else if (Integer.parseInt(peakLine[2]) >= Integer.parseInt(str[1]) && Integer.parseInt(peakLine[2]) <= Integer.parseInt(str[2])) { int START = Integer.parseInt(peakLine[1]) - Integer.parseInt(str[1]); int STOP = START + (Integer.parseInt(peakLine[2]) - Integer.parseInt(peakLine[1])); - for(int c = START; c <= STOP; c++) { - if(c >= 0 && c < cdtLength) { cdtArr[c]++; } + for (int c = START; c <= STOP; c++) { + if (c >= 0 && c < cdtLength) { + cdtArr[c]++; } } } + } } - - if(counter == 0) { + if (counter == 0) { OUT.print("YORF" + "\t" + "NAME"); - for(int j = 0; j < cdtLength; j++) { OUT.print("\t" + j); } - OUT.print("\n");} + for (int j = 0; j < cdtLength; j++) { + OUT.print("\t" + j); + } + OUT.print("\n"); + } OUT.print(str[3] + "\t" + str[3]); - if(str[5].equalsIgnoreCase("+")) { for(int i = 0; i < cdtLength; i++) { OUT.print("\t" + cdtArr[i]); } } - else { for(int j = cdtLength-1; j >= 0; j--) { OUT.print("\t" + cdtArr[j]); } } + if (str[5].equalsIgnoreCase("+")) { + for (int i = 0; i < cdtLength; i++) { + OUT.print("\t" + cdtArr[i]); + } + } else { + for (int j = cdtLength - 1; j >= 0; j--) { + OUT.print("\t" + cdtArr[j]); + } + } OUT.print("\n"); counter++; if(counter % 1000 == 0) { printPS("Reference rows processed: " + counter); } - } - buff.close(); - inputStream.close(); - + } + buff.close(); + inputStream.close(); + OUT.close(); + // Print update printPS("Completing: " + getTimeStamp()); - } + } private static String getTimeStamp() { Date date= new Date(); diff --git a/src/main/java/scriptmanager/scripts/Peak_Analysis/FilterBEDbyProximity.java b/src/main/java/scriptmanager/scripts/Peak_Analysis/FilterBEDbyProximity.java index 7e874ce89..3012971f8 100644 --- a/src/main/java/scriptmanager/scripts/Peak_Analysis/FilterBEDbyProximity.java +++ b/src/main/java/scriptmanager/scripts/Peak_Analysis/FilterBEDbyProximity.java @@ -15,35 +15,34 @@ import java.util.List; import scriptmanager.objects.CoordinateObjects.BEDCoord; +import scriptmanager.util.ExtensionFileFilter; public class FilterBEDbyProximity{ + private File INPUT; + private File OUT_BASENAME = null; private int CUTOFF; - private InputStream inputStream; - private String INPUTNAME = null; - private PrintStream OUT_Filter = null; - private PrintStream OUT_Cluster = null; private PrintStream PS = null; - public FilterBEDbyProximity(File input, int cutoff, String outputBase, PrintStream ps) throws IOException { + public FilterBEDbyProximity(File input, File output, int cutoff, PrintStream ps) { + INPUT = input; + OUT_BASENAME = output; CUTOFF = cutoff; PS = ps; - inputStream = new FileInputStream(input); - INPUTNAME = input.getName(); - try{ - if(outputBase == null) { - outputBase = INPUTNAME.substring(0, input.getName().lastIndexOf('.')) + "_" + Integer.toString(CUTOFF) + "bp"; - } - OUT_Filter = new PrintStream(new File(outputBase + "-FILTER" + ".bed")); - OUT_Cluster = new PrintStream(new File(outputBase + "-CLUSTER" + ".bed")); - }catch (FileNotFoundException e) { e.printStackTrace(); } } - public void run() throws IOException, InterruptedException - { - printPS("Filtering BED file with a cutoff: " + CUTOFF + " in " + INPUTNAME); + public void run() throws FileNotFoundException, IOException, InterruptedException { + // Construct output name + if(OUT_BASENAME == null) { + OUT_BASENAME = new File(ExtensionFileFilter.stripExtension(INPUT) + "_" + Integer.toString(CUTOFF) + "bp"); + } + PrintStream OUT_Filter = new PrintStream(new File(OUT_BASENAME.getAbsoluteFile() + "-FILTER" + ".bed")); + PrintStream OUT_Cluster = new PrintStream(new File(OUT_BASENAME.getAbsoluteFile() + "-CLUSTER" + ".bed")); + // Print update + printPS("Filtering BED file with a cutoff: " + CUTOFF + " in " + INPUT.getName()); printPS("Starting: " + getTimeStamp()); - + // Open input file as stream + InputStream inputStream = new FileInputStream(INPUT); BufferedReader lines = new BufferedReader(new InputStreamReader(inputStream), 100); List bedArray = new ArrayList(); List failArray = new ArrayList(); @@ -111,10 +110,11 @@ else if((bedArray.get(i).getScore() == bedArray.get(INDEX).getScore()) && (bedAr OUT_Cluster.println(bedArray.get(x).toString()); } } + // close streams + inputStream.close(); OUT_Filter.close(); OUT_Cluster.close(); - - inputStream.close(); + // Print update printPS("Completing: " + getTimeStamp()); } diff --git a/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java b/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java index 10e855617..44b04ce29 100644 --- a/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java +++ b/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java @@ -4,11 +4,10 @@ import java.io.IOException; import java.io.PrintStream; -import javax.swing.JOptionPane; - import scriptmanager.objects.CoordinateObjects.BEDCoord; import scriptmanager.objects.CoordinateObjects.GFFCoord; import scriptmanager.objects.CoordinateObjects.GenericCoord; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.GenomeSizeReference; /** @@ -30,33 +29,30 @@ public class RandomCoordinate { * * @param GENOME the String encoding the genome build to tile (matches * util.GenomeSizeReference) - * @param numSites the number of random coordinate sites to sample - * @param windowSize the base-pair length of each coordinate interval - * @param BEDout coordinate file format of output where BED-format is used - * if true and GFF-format used if false * @param OUTPUT the file to write the coordinate tile output to (if null, a * default filename is determined using * <GENOME>_<numSites>SITES_<windowSize>bp.<ext>) + * @param BEDout coordinate file format of output where BED-format is used + * if true and GFF-format used if false + * @param numSites the number of random coordinate sites to sample + * @param windowSize the base-pair length of each coordinate interval * @throws IOException * @throws IllegalArgumentException */ - public static void execute(String GENOME, int numSites, int windowSize, boolean BEDout, File OUTPUT) throws IOException, IllegalArgumentException { + public static void execute(String GENOME, File OUTPUT, boolean BEDout, int numSites, int windowSize) throws IOException, IllegalArgumentException, OptionException { GenomeSizeReference coord = new GenomeSizeReference(GENOME); - if(!coord.isSmaller(windowSize)) { - System.err.println("Window size is too large for selected genome!!!\n"); - JOptionPane.showMessageDialog(null, "Invalid Window Size Entered!!!"); - } else { - String EXTENSION = ".gff"; - if (BEDout) { - EXTENSION = ".bed"; - } - String randomName = GENOME + "_" + numSites + "SITES_" + windowSize + "bp" + EXTENSION; - PrintStream OUT = null; + String EXTENSION = BEDout ? ".bed" : ".gff"; + String fileName = GENOME + "_" + numSites + "SITES_" + windowSize + "bp" + EXTENSION; + if (!coord.isSmaller(windowSize)) { + throw new OptionException("Invalid Window Size Entered - window size is too large for selected genome!!!"); + } else { + PrintStream OUT = null; if (OUTPUT == null) { - OUT = new PrintStream(randomName); + OUT = new PrintStream(fileName); } else { OUT = new PrintStream(OUTPUT); } + // Iterate each random sample for(int x = 0; x < numSites; x++) { GenericCoord temp = coord.generateRandomCoord(windowSize); if(BEDout) { @@ -66,8 +62,8 @@ public static void execute(String GENOME, int numSites, int windowSize, boolean GFFCoord outcoord = new GFFCoord(temp.getChrom(), temp.getStart(), temp.getStop(), temp.getDir(), temp.getName()); OUT.println(outcoord.toString()); } - } + } OUT.close(); - } + } } } diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java index 9f4238e64..00fe4cc88 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefOutput.java @@ -47,21 +47,21 @@ public BEDPeakAligntoRefOutput(File ref, File peak, File outpath) throws IOExcep } public void run() throws IOException, InterruptedException { - LogItem old_li = new LogItem(""); // Initialize LogItem - String command = BEDPeakAligntoRefCLI.getCLIcommand(PEAK, REF, OUTFILE); - LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); - // Execute script + String command = BEDPeakAligntoRefCLI.getCLIcommand(REF, PEAK, OUTFILE); + LogItem li = new LogItem(command); + firePropertyChange("log", null, li); + // Set-up display stream PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); + // Execute script BEDPeakAligntoRef script_obj = new BEDPeakAligntoRef(REF, PEAK, OUTFILE, PS); script_obj.run(); // Update log item - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; + li.setStopTime(new Timestamp(new Date().getTime())); + li.setStatus(0); + firePropertyChange("log", li, null); + // wait before disposing Thread.sleep(2000); dispose(); - firePropertyChange("log", old_li, null); } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java index 104512f37..c8a5d585b 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java @@ -11,7 +11,9 @@ import java.beans.PropertyChangeEvent; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import javax.swing.DefaultListModel; import javax.swing.JButton; @@ -27,6 +29,8 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.cli.Peak_Analysis.BEDPeakAligntoRefCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") @@ -39,7 +43,7 @@ public class BEDPeakAligntoRefWindow extends JFrame implements ActionListener, P final DefaultListModel refList; ArrayList PeakFiles = new ArrayList(); ArrayList RefFiles = new ArrayList(); - private File OUTPUT_PATH = null; + private File OUT_DIR = null; private JButton btnLoadPeakBed; private JButton btnRemoveBedFile; @@ -55,38 +59,43 @@ public class BEDPeakAligntoRefWindow extends JFrame implements ActionListener, P class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if(PeakFiles.size() < 1 || RefFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No BED Files Loaded!!!"); } else { setProgress(0); - BEDPeakAligntoRefOutput align; int counter = 0; - - for(int r = 0; r < RefFiles.size(); r++) - { - for(int p=0; p < PeakFiles.size(); p++) - { - align = new BEDPeakAligntoRefOutput(RefFiles.get(r), PeakFiles.get(p), OUTPUT_PATH); - align.addPropertyChangeListener("log", new PropertyChangeListener() { + for (int r = 0; r < RefFiles.size(); r++) { + for (int p=0; p < PeakFiles.size(); p++) { + // Execute script + BEDPeakAligntoRefOutput output_obj = new BEDPeakAligntoRefOutput(RefFiles.get(r), PeakFiles.get(p), OUT_DIR); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - align.setVisible(true); - align.run(); + output_obj.setVisible(true); + output_obj.run(); + // Update progress counter++; - int percentComplete = (int)(((double)(counter) / (PeakFiles.size()*RefFiles.size())) * 100); - setProgress(percentComplete); - } - } - JOptionPane.showMessageDialog(null, "Alignment Complete"); - } - } catch(NumberFormatException nfe){ + int percentComplete = (int) (((double) (counter) / (PeakFiles.size() * RefFiles.size())) * 100); + setProgress(percentComplete); + } + } + setProgress(100); + JOptionPane.showMessageDialog(null, "Alignment Complete"); + } + } catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (InterruptedException ie) { + JOptionPane.showMessageDialog(null, ie.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } - return null; + setProgress(100); + return null; } public void done() { @@ -200,13 +209,13 @@ public void actionPerformed(ActionEvent arg0) { sl_contentPane.putConstraint(SpringLayout.EAST, btnOutputDirectory, -175, SpringLayout.EAST, contentPane); sl_contentPane.putConstraint(SpringLayout.NORTH, btnOutputDirectory, 10, SpringLayout.SOUTH, scrollPane_Ref); btnOutputDirectory.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - OUTPUT_PATH = FileSelection.getOutputDir(fc); - if(OUTPUT_PATH != null) { - lblDefaultToLocal.setText(OUTPUT_PATH.getAbsolutePath()); - } - } - }); + public void actionPerformed(ActionEvent e) { + OUT_DIR = FileSelection.getOutputDir(fc); + if(OUT_DIR != null) { + lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); + } + } + }); contentPane.add(btnOutputDirectory); lblCurrentOutput = new JLabel("Current Output:"); @@ -238,29 +247,30 @@ public void actionPerformed(ActionEvent e) { btnCalculate.setActionCommand("start"); btnCalculate.addActionListener(this); } - + @Override public void actionPerformed(ActionEvent arg0) { massXable(contentPane, false); - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - task = new Task(); - task.addPropertyChangeListener(this); - task.execute(); + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + task = new Task(); + task.addPropertyChangeListener(this); + task.execute(); } - + /** - * Invoked when task's progress property changes. - */ - public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } else if ("log" == evt.getPropertyName()) { + * Invoked when task's progress property changes. + */ + @Override + public void propertyChange(PropertyChangeEvent evt) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } - } - + } + public void massXable(Container con, boolean status) { for(Component c : con.getComponents()) { c.setEnabled(status); diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java index ec21522ce..fd0112d04 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityOutput.java @@ -15,17 +15,18 @@ import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; import scriptmanager.scripts.Peak_Analysis.FilterBEDbyProximity; +import scriptmanager.util.ExtensionFileFilter; @SuppressWarnings({"serial"}) public class FilterBEDbyProximityOutput extends JFrame{ private int CUTOFF; private File INPUT; - private String OUTBASE = null; + private File OUT_DIR = null; private JTextArea textArea; - public FilterBEDbyProximityOutput(File input, int cutoff, File output) throws IOException { + public FilterBEDbyProximityOutput(File input, File output, int cutoff) { setTitle("BED File Filter Progress"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(150, 150, 600, 800); @@ -39,32 +40,31 @@ public FilterBEDbyProximityOutput(File input, int cutoff, File output) throws IO CUTOFF = cutoff; INPUT = input; - - String INPUTNAME = input.getName(); - if(output!=null){ - OUTBASE = output.getCanonicalPath() + File.separator + INPUTNAME.substring(0, INPUTNAME.lastIndexOf('.')) + "_" + Integer.toString(CUTOFF) + "bp"; - }else{ - OUTBASE = INPUTNAME.substring(0, INPUTNAME.lastIndexOf('.')) + "_" + Integer.toString(CUTOFF) + "bp"; - } + OUT_DIR = output; } - public void run() throws IOException, InterruptedException - { - LogItem old_li = new LogItem(""); + public void run() throws IOException, InterruptedException { + // Construct output basename + String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(INPUT) + "_" + Integer.toString(CUTOFF) + "bp"; + File OUT_BASENAME = new File(NAME); + if (OUT_DIR != null) { + OUT_BASENAME = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); + } // Initialize LogItem - String command = FilterBEDbyProximityCLI.getCLIcommand(INPUT, OUTBASE, CUTOFF); - LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); - // Execute script + String command = FilterBEDbyProximityCLI.getCLIcommand(INPUT, OUT_BASENAME, CUTOFF); + LogItem li = new LogItem(command); + firePropertyChange("log", null, li); + // Set-up display stream PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); - FilterBEDbyProximity script_obj = new FilterBEDbyProximity(INPUT, CUTOFF, OUTBASE, PS); + // Execute script + FilterBEDbyProximity script_obj = new FilterBEDbyProximity(INPUT, OUT_BASENAME, CUTOFF, PS); script_obj.run(); // Update log item - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; + li.setStopTime(new Timestamp(new Date().getTime())); + li.setStatus(0); + firePropertyChange("log", li, null); + // wait before disposing Thread.sleep(1000); dispose(); - firePropertyChange("log", old_li, null); } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java index ece85cf3c..e9f48ab7d 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java @@ -37,7 +37,7 @@ public class FilterBEDbyProximityWindow extends JFrame implements ActionListener final DefaultListModel bedList; ArrayList BEDFiles = new ArrayList(); - private File OUTPUT_PATH = null; + private File OUT_DIR = null; private JPanel contentPane; private JTextField txtCutoff; @@ -48,7 +48,7 @@ public class FilterBEDbyProximityWindow extends JFrame implements ActionListener class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if(BEDFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No BED Files Selected!!!"); @@ -58,25 +58,32 @@ public Void doInBackground() throws IOException, InterruptedException { JOptionPane.showMessageDialog(null, "Invalid Cutoff Value Entered!!!"); } else { setProgress(0); - FilterBEDbyProximityOutput filter; for(int gfile = 0; gfile < BEDFiles.size(); gfile++) { - filter = new FilterBEDbyProximityOutput(BEDFiles.get(gfile), Integer.parseInt(txtCutoff.getText()), OUTPUT_PATH); - filter.addPropertyChangeListener("log", new PropertyChangeListener() { + FilterBEDbyProximityOutput output_obj = new FilterBEDbyProximityOutput(BEDFiles.get(gfile), OUT_DIR, Integer.parseInt(txtCutoff.getText())); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - filter.setVisible(true); - filter.run(); - int percentComplete = (int)(((double)(gfile + 1) / (BEDFiles.size())) * 100); - setProgress(percentComplete); - } + output_obj.setVisible(true); + output_obj.run(); + // Update progress + int percentComplete = (int) (((double) (gfile + 1) / (BEDFiles.size())) * 100); + setProgress(percentComplete); + } + setProgress(100); JOptionPane.showMessageDialog(null, "Proximity Filter Complete"); } - } catch(NumberFormatException nfe){ + } catch(NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (InterruptedException ie) { + JOptionPane.showMessageDialog(null, ie.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } - return null; + setProgress(100); + return null; } public void done() { @@ -160,13 +167,13 @@ public void actionPerformed(ActionEvent arg0) { sl_contentPane.putConstraint(SpringLayout.WEST, btnOutputDirectory, 150, SpringLayout.WEST, contentPane); sl_contentPane.putConstraint(SpringLayout.EAST, btnOutputDirectory, -150, SpringLayout.EAST, contentPane); btnOutputDirectory.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - OUTPUT_PATH = FileSelection.getOutputDir(fc); - if(OUTPUT_PATH != null) { - lblDefaultToLocal.setText(OUTPUT_PATH.getAbsolutePath()); - } - } - }); + public void actionPerformed(ActionEvent e) { + OUT_DIR = FileSelection.getOutputDir(fc); + if(OUT_DIR != null) { + lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); + } + } + }); contentPane.add(btnOutputDirectory); JLabel lblCurrentOutputDirectory = new JLabel("Current Output:"); @@ -194,31 +201,34 @@ public void actionPerformed(ActionEvent e) { contentPane.add(progressBar); } - @Override public void actionPerformed(ActionEvent arg0) { massXable(contentPane, false); - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - task = new Task(); - task.addPropertyChangeListener(this); - task.execute(); + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + task = new Task(); + task.addPropertyChangeListener(this); + task.execute(); } - + + /** + * Invoked when task's progress property changes. + */ + @Override public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } else if ("log" == evt.getPropertyName()) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } - } - + } + public void massXable(Container con, boolean status) { for(Component c : con.getComponents()) { c.setEnabled(status); if(c instanceof Container) { massXable((Container)c, status); } } } - + } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java index 277fd5df6..148aa0a46 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java @@ -31,6 +31,8 @@ import scriptmanager.cli.Peak_Analysis.RandomCoordinateCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; import scriptmanager.scripts.Peak_Analysis.RandomCoordinate; @@ -52,57 +54,61 @@ public class RandomCoordinateWindow extends JFrame implements ActionListener, Pr private String[] genomeBuilds = { "sacCer3", "sacCer3_cegr", "hg38", "hg38_contigs", "hg19", "hg19_contigs", "mm10" }; private JComboBox cmbGenome; - private File OUTPUT_PATH = null; + private File OUT_DIR = null; public Task task; class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { - try { - if(txtSites.getText().isEmpty()) { - JOptionPane.showMessageDialog(null, "No Sites Entered!!!"); - } else if(Integer.parseInt(txtSites.getText()) < 0) { - JOptionPane.showMessageDialog(null, "Invalid Number of Sites Entered!!!"); - } else if(txtSize.getText().isEmpty()) { - JOptionPane.showMessageDialog(null, "No Window Size Entered!!!"); - } else if(Integer.parseInt(txtSize.getText()) < 1) { - JOptionPane.showMessageDialog(null, "Invalid Window Size Entered!!!"); - } else { - boolean bedStatus = rdbtnBed.isSelected(); - String randomName = (String)cmbGenome.getSelectedItem() + "_" + Integer.parseInt(txtSites.getText()) + "SITES_" + Integer.parseInt(txtSize.getText()) + "bp"; - if(bedStatus){ randomName += ".bed"; } - else{ randomName += ".gff"; } - File OUTFILE; - if(OUTPUT_PATH != null){ - OUTFILE = new File(OUTPUT_PATH + File.separator + randomName); - }else{ - OUTFILE = new File(randomName); + public Void doInBackground() { + try { + if(txtSites.getText().isEmpty()) { + JOptionPane.showMessageDialog(null, "No Sites Entered!!!"); + } else if(Integer.parseInt(txtSites.getText()) < 0) { + JOptionPane.showMessageDialog(null, "Invalid Number of Sites Entered!!!"); + } else if(txtSize.getText().isEmpty()) { + JOptionPane.showMessageDialog(null, "No Window Size Entered!!!"); + } else if(Integer.parseInt(txtSize.getText()) < 1) { + JOptionPane.showMessageDialog(null, "Invalid Window Size Entered!!!"); + } else { + // Construct output filename + String NAME = (String)cmbGenome.getSelectedItem() + "_" + Integer.parseInt(txtSites.getText()) + "SITES_" + Integer.parseInt(txtSize.getText()) + "bp"; + NAME += rdbtnBed.isSelected() ? ".bed" : ".gff"; + File OUT_FILEPATH = new File(NAME); + if (OUT_DIR != null) { + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } // Initialize LogItem - String command = RandomCoordinateCLI.getCLIcommand((String)cmbGenome.getSelectedItem(), OUTFILE, bedStatus, Integer.parseInt(txtSites.getText()), Integer.parseInt(txtSize.getText())); - LogItem new_li = new LogItem(command); - firePropertyChange("log", null, new_li); - // Execute Script and update progress - RandomCoordinate.execute((String)cmbGenome.getSelectedItem(), Integer.parseInt(txtSites.getText()), Integer.parseInt(txtSize.getText()), bedStatus, OUTFILE); - JOptionPane.showMessageDialog(null, "Random Coordinate Generation Complete"); + String command = RandomCoordinateCLI.getCLIcommand((String)cmbGenome.getSelectedItem(), OUT_FILEPATH, rdbtnBed.isSelected(), Integer.parseInt(txtSites.getText()), Integer.parseInt(txtSize.getText())); + LogItem li = new LogItem(command); + firePropertyChange("log", null, li); + // Execute script + RandomCoordinate.execute((String)cmbGenome.getSelectedItem(), OUT_FILEPATH, rdbtnBed.isSelected(), Integer.parseInt(txtSites.getText()), Integer.parseInt(txtSize.getText())); // Update log item - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - firePropertyChange("log", new_li, null); - } - } catch(NumberFormatException nfe){ - JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + li.setStopTime(new Timestamp(new Date().getTime())); + li.setStatus(0); + firePropertyChange("log", li, null); + // Pop-up completion + JOptionPane.showMessageDialog(null, "Random Coordinate Generation Complete"); + } + } catch (NumberFormatException nfe) { + JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (IllegalArgumentException iae) { JOptionPane.showMessageDialog(null, iae.getMessage()); + } catch (OptionException oe) { + oe.printStackTrace(); + JOptionPane.showMessageDialog(null, oe.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } - return null; + return null; } public void done() { - massXable(contentPane, true); - setCursor(null); //turn off the wait cursor - } + massXable(contentPane, true); + setCursor(null); //turn off the wait cursor + } } public RandomCoordinateWindow() { @@ -152,9 +158,9 @@ public RandomCoordinateWindow() { sl_contentPane.putConstraint(SpringLayout.EAST, btnOutputDirectory, -80, SpringLayout.EAST, contentPane); btnOutputDirectory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - OUTPUT_PATH = FileSelection.getOutputDir(fc); - if(OUTPUT_PATH != null) { - lblDefaultToLocal.setText(OUTPUT_PATH.getAbsolutePath()); + OUT_DIR = FileSelection.getOutputDir(fc); + if(OUT_DIR != null) { + lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); } } }); @@ -216,18 +222,22 @@ public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent arg0) { massXable(contentPane, false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - task = new Task(); - task.addPropertyChangeListener(this); - task.execute(); + + task = new Task(); + task.addPropertyChangeListener(this); + task.execute(); } + /** + * Invoked when task's progress property changes. + */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("log" == evt.getPropertyName()) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } - + public void massXable(Container con, boolean status) { for(Component c : con.getComponents()) { c.setEnabled(status); From da0bbf9decd1c5f99e86a049a37885b40b692436 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 31 Oct 2023 19:04:05 -0400 Subject: [PATCH 35/58] add logging to TileGenome ScriptManagerGUI - add property change listener TileGenomeCLI -add getCLIcommand() with javadocs - adjust to script constructor signature change (reorder inputs) TileGenome - reorder constructor params for consistency with other tools (input files, output opts, other opts, gui-specific opts) TileGenomeWindow - adjust inputs/script call structures to account for changes in script class signature - add logitem creation and update steps- add GUI handling of various exceptions thrown by script class for consistency with other tools - add logging propertyChange listeners- standardize output filename construction for consistency with other tools - rename OUTPUT_PATH to OUT_DIR for consistency with other tools --- .../cli/Peak_Analysis/TileGenomeCLI.java | 20 +++- .../scriptmanager/main/ScriptManagerGUI.java | 11 ++ .../scripts/Peak_Analysis/TileGenome.java | 20 ++-- .../Peak_Analysis/TileGenomeWindow.java | 100 +++++++++++------- 4 files changed, 99 insertions(+), 52 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java index 556bf401a..6226a5669 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java @@ -44,7 +44,7 @@ public Integer call() throws Exception { System.exit(1); } - TileGenome.execute(genomeName, window, formatIsBed, output); + TileGenome.execute(genomeName, output, formatIsBed, window); System.err.println( "Genomic Tiling Complete." ); return(0); @@ -81,4 +81,22 @@ private String validateInput() throws IOException { return(r); } + + /** + * Reconstruct CLI command + * + * @param genomeName the genome build to tile coordinates from + * @param output the text file of the tiled coordinates + * @param formatIsBed the format of the coordinate output (BED or GFF) + * @param window the size of the tiles sampled + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(String genomeName, File output, boolean formatIsBed, int window) { + String command = "java -jar $SCRIPTMANAGER peak-analysis tile-genome"; + command += " " + genomeName; + command += " -o " + output.getAbsolutePath(); + command += formatIsBed ? "" : " --gff"; + command += " -w " + window; + return command; + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index aa4db7c88..e0d04024f 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -995,6 +995,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { TileGenomeWindow frame = new TileGenomeWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/scripts/Peak_Analysis/TileGenome.java b/src/main/java/scriptmanager/scripts/Peak_Analysis/TileGenome.java index c0cb24438..8e3b50d04 100644 --- a/src/main/java/scriptmanager/scripts/Peak_Analysis/TileGenome.java +++ b/src/main/java/scriptmanager/scripts/Peak_Analysis/TileGenome.java @@ -28,21 +28,18 @@ public class TileGenome { * * @param GENOME the String encoding the genome build to tile (matches * util.GenomeSizeReference) - * @param windowSize the base-pair length of the tiles - * @param BEDout coordinate file format of output where BED-format is used - * if true and GFF-format used if false * @param OUTPUT the file to write the coordinate tile output to (if null, a * default filename is determined using * <GENOME>_<windowSize>bp.<ext>) + * @param BEDout coordinate file format of output where BED-format is used + * if true and GFF-format used if false + * @param windowSize the base-pair length of the tiles * @throws IOException * @throws IllegalArgumentException */ - public static void execute(String GENOME, int windowSize, boolean BEDout, File OUTPUT) throws IOException, IllegalArgumentException { + public static void execute(String GENOME, File OUTPUT, boolean BEDout, int windowSize) throws IOException, IllegalArgumentException { GenomeSizeReference coord = new GenomeSizeReference(GENOME); - String EXTENSION = ".gff"; - if (BEDout) { - EXTENSION = ".bed"; - } + String EXTENSION = BEDout ? ".bed" : ".gff"; String fileName = GENOME + "_" + windowSize + "bp" + EXTENSION; PrintStream OUT = null; if (OUTPUT == null) { @@ -50,15 +47,16 @@ public static void execute(String GENOME, int windowSize, boolean BEDout, File O } else { OUT = new PrintStream(OUTPUT); } - + // Iterate each chromosome for(int x = 0; x < coord.getChrom().size(); x++) { String CHROM = coord.getChrom().get(x); long SIZE = coord.getChromSize().get(x); + // Iterate each window for(long y = 0; y < SIZE; y += windowSize) { long STOP = y + windowSize; //If beyond the edge of chromosome, set end to size - if(STOP > SIZE) { STOP = SIZE; } - if(BEDout) { + if (STOP > SIZE) { STOP = SIZE; } + if (BEDout) { BEDCoord outcoord = new BEDCoord(CHROM, y, STOP, "+"); OUT.println(outcoord.toString()); } else { diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java index 69aafab75..ae19e0684 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java @@ -10,6 +10,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import javax.swing.ButtonGroup; import javax.swing.JButton; @@ -27,6 +29,8 @@ import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; +import scriptmanager.cli.Peak_Analysis.TileGenomeCLI; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Peak_Analysis.TileGenome; /** @@ -46,40 +50,50 @@ public class TileGenomeWindow extends JFrame implements ActionListener, Property private String[] genomeBuilds = { "sacCer3", "sacCer3_cegr", "hg38", "hg38_contigs", "hg19", "hg19_contigs", "mm10" }; private JComboBox cmbGenome; - private File OUTPUT_PATH = null; + private File OUT_DIR = null; public Task task; class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { - try { - if(txtSize.getText().isEmpty()) { - JOptionPane.showMessageDialog(null, "No Window Size Entered!!!"); - } else if(Integer.parseInt(txtSize.getText()) < 1) { - JOptionPane.showMessageDialog(null, "Invalid Window Size Entered!!!"); - } else { - boolean bedStatus = rdbtnBed.isSelected(); - String randomName = (String)cmbGenome.getSelectedItem() + "_" + Integer.parseInt(txtSize.getText()) + "bp"; - if(bedStatus){ randomName += ".bed"; } - else{ randomName += ".gff"; } - File OUTFILE; - if(OUTPUT_PATH != null){ - OUTFILE = new File(OUTPUT_PATH + File.separator + randomName); - }else{ - OUTFILE = new File(randomName); - } - TileGenome.execute((String)cmbGenome.getSelectedItem(), Integer.parseInt(txtSize.getText()), bedStatus, OUTFILE); - JOptionPane.showMessageDialog(null, "Genomic Tiling Complete"); - } - } catch(NumberFormatException nfe){ - JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + public Void doInBackground() { + try { + if(txtSize.getText().isEmpty()) { + JOptionPane.showMessageDialog(null, "No Window Size Entered!!!"); + } else if(Integer.parseInt(txtSize.getText()) < 1) { + JOptionPane.showMessageDialog(null, "Invalid Window Size Entered!!!"); + } else { + // Construct output filename + String NAME = (String)cmbGenome.getSelectedItem() + "_" + Integer.parseInt(txtSize.getText()) + "bp"; + NAME += rdbtnBed.isSelected() ? ".bed" : ".gff"; + File OUT_FILEPATH = new File(NAME); + if (OUT_DIR != null) { + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); + } + // Initialize LogItem + String command = TileGenomeCLI.getCLIcommand((String)cmbGenome.getSelectedItem(), OUT_FILEPATH, rdbtnBed.isSelected(), Integer.parseInt(txtSize.getText())); + LogItem li = new LogItem(command); + firePropertyChange("log", null, li); + // Execute script + TileGenome.execute((String)cmbGenome.getSelectedItem(), OUT_FILEPATH, rdbtnBed.isSelected(), Integer.parseInt(txtSize.getText())); + // Update log item + li.setStopTime(new Timestamp(new Date().getTime())); + li.setStatus(0); + firePropertyChange("log", li, null); + // Pop-up completion + JOptionPane.showMessageDialog(null, "Genomic Tiling Complete"); + } + } catch(NumberFormatException nfe){ + JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (IllegalArgumentException iae) { JOptionPane.showMessageDialog(null, iae.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } - return null; - } - + return null; + } + public void done() { massXable(contentPane, true); setCursor(null); //turn off the wait cursor @@ -118,13 +132,13 @@ public TileGenomeWindow() { sl_contentPane.putConstraint(SpringLayout.WEST, btnOutputDirectory, 100, SpringLayout.WEST, contentPane); sl_contentPane.putConstraint(SpringLayout.EAST, btnOutputDirectory, -100, SpringLayout.EAST, contentPane); btnOutputDirectory.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - OUTPUT_PATH = FileSelection.getOutputDir(fc); - if(OUTPUT_PATH != null) { - lblDefaultToLocal.setText(OUTPUT_PATH.getAbsolutePath()); - } - } - }); + public void actionPerformed(ActionEvent e) { + OUT_DIR = FileSelection.getOutputDir(fc); + if(OUT_DIR != null) { + lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); + } + } + }); contentPane.add(btnOutputDirectory); JLabel lblCurrentOutputDirectory = new JLabel("Current Output:"); @@ -182,16 +196,22 @@ public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent arg0) { massXable(contentPane, false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - task = new Task(); - task.addPropertyChangeListener(this); - task.execute(); + + task = new Task(); + task.addPropertyChangeListener(this); + task.execute(); } - + + /** + * Invoked when task's progress property changes. + */ + @Override public void propertyChange(PropertyChangeEvent evt) { + if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + } - } - public void massXable(Container con, boolean status) { for(Component c : con.getComponents()) { c.setEnabled(status); From 6ebbd76d9d2e21cb9c1e57ea3959747e89d3daae Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 31 Oct 2023 20:08:07 -0400 Subject: [PATCH 36/58] bugfix Figure Generation logging adjust logging for Figure Generation to fix bugs and add javadocs to getCLIcommand() All Window classes: - rename *Output object as output_obj for consistency with other tools - standardize output filename construction for consistency with other tools - rename property firing for progress updates to "progress" - add setProgress(100) and setProgress(0) at the beginning and end of the main Task block - add GUI handling of various exceptions thrown by script class for consistency with other tools LabelHeatMapOutput and Window - remove superfluous getTimestamp() method MergeHeatMapCLI - rename inputs to getCLIcommand() - remove incorrect appending of "merge.png" MergeHeatMapOutput and Window - bugfix - for un-matched sense/anti PNGs, log item might not update appropriately so LogItem intialization and update done completely within same if-else block. - remove addImage(String name, JLabel pic) helper and hardcode back into main code block - (Window) put Output instantiation code in try-catch block TwoColorHeatMapOutput and Window - remove superfluous System print statements - remove superfluous getTimestamp() method --- .../Figure_Generation/LabelHeatMapCLI.java | 23 +++++++-- .../Figure_Generation/MergeHeatMapCLI.java | 16 ++++-- .../Figure_Generation/TwoColorHeatMapCLI.java | 19 +++++++ .../Figure_Generation/LabelHeatMapOutput.java | 29 +++++------ .../Figure_Generation/LabelHeatMapWindow.java | 24 ++++----- .../Figure_Generation/MergeHeatMapOutput.java | 49 +++++++++---------- .../Figure_Generation/MergeHeatMapWindow.java | 45 ++++++++--------- .../TwoColorHeatMapOutput.java | 35 ++++++------- .../TwoColorHeatMapWindow.java | 25 +++++----- 9 files changed, 149 insertions(+), 116 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java index 084cec4b4..37f60ae9f 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java @@ -113,9 +113,26 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File input, File output, Color color, int borderWidth, - int xTickHeight, int fontSize, String llabel, String mlabel, - String rlabel, String xlabel, String ylabel) { + /** + * Reconstruct CLI command + * + * @param input the PNG file to label + * @param output the output PNG file to generate + * @param color the color of SVG annotation and outline elements + * @param borderWidth the thickness of the PNG border + * @param xTickHeight the height of the tickmarks along the bottom of the PNG + * @param fontSize the size of font to use for annotations + * @param llabel the text labeling the left bound of the bottom axis + * @param mlabel the text labeling the middle of the bottom axis + * @param rlabel the text labeling the right bound of the bottom axis + * @param xlabel the bottom/x-axis text label + * @param ylabel the left/y-axis text label + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, File output, Color color, + int borderWidth, int xTickHeight, int fontSize, + String llabel, String mlabel, String rlabel, + String xlabel, String ylabel) { String command = "java -jar $SCRIPTMANAGER figure-generation label-heatmap"; command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java index cab0069b8..ec9821f38 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java @@ -98,11 +98,19 @@ private String validateInput() throws IOException { return (r); } - public static String getCLIcommand(File senseFile, File antiFile, File outdir) { + /** + * Reconstruct CLI command + * + * @param input1 first input PNG to merge (sense) + * @param input2 second input PNG to merge (anti) + * @param output the merged output PNG file + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input1, File input2, File output) { String command = "java -jar $SCRIPTMANAGER figure-generation merge-heatmap"; - command += " " + antiFile.getAbsolutePath(); - command += " " + senseFile.getAbsolutePath(); - command += " -o " + outdir.getAbsolutePath() + "merge.png"; + command += " " + input1.getAbsolutePath(); + command += " " + input2.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); return command; } diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java index 413185ca1..86efaedba 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java @@ -163,6 +163,25 @@ private String validateInput() throws IOException { return (r); } + /** + * Reconstruct CLI command + * + * @param input the input matrix/CDT to generate a heatmap from + * @param color the max-value color to use + * @param startR the index of the starting row + * @param startC the index of the starting column + * @param pHeight the height (in pixels) of the output image + * @param pWidth the width (in pixels) of the output image + * @param scale the image compression strategy (e.g. "treeview") + * @param abs the matrix value corresponding to the maximum color value + * (absolute strategy) + * @param quant the matrix percentile value corresponding to the maximum color + * value (quantile strategy) + * @param output the output PNG file + * @param trans whether or not to use transparent (vs white) min-value color + * @return command line to execute with formatted inputs + * @throws OptionException + */ public static String getCLIcommand(File input, Color color, int startR, int startC, int pHeight, int pWidth, String scale, double abs, double quant, File output, boolean trans) throws OptionException { String command = "java -jar $SCRIPTMANAGER figure-generation heatmap"; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java index d4ec05303..0975c8906 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java @@ -18,6 +18,7 @@ import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.objects.LogItem; import scriptmanager.scripts.Figure_Generation.LabelHeatMap; +import scriptmanager.util.ExtensionFileFilter; @SuppressWarnings("serial") public class LabelHeatMapOutput extends JFrame { @@ -70,24 +71,25 @@ public LabelHeatMapOutput(ArrayList in, File out_dir, Color c, public void run() throws IOException, OptionException { LogItem old_li = null; for (int x = 0; x < SAMPLE.size(); x++) { - File OUTPUT = new File(SAMPLE.get(x).getName().split("\\.")[0] + "_label.svg"); + // Construct output filename + String NAME = ExtensionFileFilter.stripExtension(SAMPLE.get(x)) + "_label.svg"; + File OUT_FILEPATH = new File(NAME); if (OUT_DIR != null) { - OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + OUTPUT.getName()); + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } - old_li = new LogItem(""); + // Set-up output log JTextArea textArea = new JTextArea(); - // Output image/error to GUI - newpane.addTab(OUTPUT.getName(), new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); + newpane.addTab(OUT_FILEPATH.getName(), new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); PrintStream jtxtPrintStream = new PrintStream(new CustomOutputStream(textArea)); // Initialize LogItem - String command = LabelHeatMapCLI.getCLIcommand(SAMPLE.get(x), OUTPUT, color, + String command = LabelHeatMapCLI.getCLIcommand(SAMPLE.get(x), OUT_FILEPATH, color, borderWidth, xTickHeight, fontSize, xLeftLabel, xMidLabel, xRightLabel, xLabel, yLabel); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute script - LabelHeatMap script_obj = new LabelHeatMap(SAMPLE.get(x), OUTPUT, color, + LabelHeatMap script_obj = new LabelHeatMap(SAMPLE.get(x), OUT_FILEPATH, color, borderWidth, xTickHeight, fontSize, xLeftLabel, xMidLabel, xRightLabel, xLabel, yLabel, jtxtPrintStream); @@ -96,17 +98,10 @@ public void run() throws IOException, OptionException { new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); old_li = new_li; - firePropertyChange("heat", x, x + 1); + // Update progress + firePropertyChange("progress", x, x + 1); } + // Update log at completion firePropertyChange("log", old_li, null); - System.out.println("Program Complete"); - System.out.println(getTimeStamp()); } - - private static String getTimeStamp() { - Date date = new Date(); - String time = new Timestamp(date.getTime()).toString(); - return time; - } - } diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java index 0c23d5f31..3df21aaa0 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java @@ -71,10 +71,9 @@ public class LabelHeatMapWindow extends JFrame implements ActionListener, Proper class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - setProgress(0); - + public Void doInBackground() { try { + setProgress(0); // Parse inputs from window fields Color color = btnColor.getForeground(); int borderWidth = Integer.parseInt(txtBorderWidth.getText()); @@ -86,35 +85,38 @@ public Void doInBackground() throws IOException { String ylabel = txtYLabel.getText(); int fontSize = Integer.parseInt(txtFontSize.getText()); // Make script object and run - LabelHeatMapOutput out_win = new LabelHeatMapOutput(txtFiles, OUT_DIR, color, + LabelHeatMapOutput output_obj = new LabelHeatMapOutput(txtFiles, OUT_DIR, color, borderWidth, xTickHeight, fontSize, llabel, mlabel, rlabel, xlabel, ylabel); - out_win.run(); - out_win.addPropertyChangeListener("heat", new PropertyChangeListener() { + output_obj.run(); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int) (((double) (temp) / (txtFiles.size())) * 100); setProgress(percentComplete); } }); - out_win.addPropertyChangeListener("log", new PropertyChangeListener() { + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - out_win.setVisible(true); - out_win.run(); - + output_obj.setVisible(true); + output_obj.run(); + // Update progress setProgress(100); JOptionPane.showMessageDialog(null, "Generation Complete"); - return null; } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (OptionException oe) { JOptionPane.showMessageDialog(null, oe.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } + setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapOutput.java index fcb6cffc4..cec5c051d 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapOutput.java @@ -1,7 +1,5 @@ package scriptmanager.window_interface.Figure_Generation; -// import java.awt.image.BufferedImage; - import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollPane; @@ -39,6 +37,7 @@ public MergeHeatMapOutput(ArrayList in, File out_dir) { } public void run() throws IOException { + // Group files into "sense"-containing and "anti"-containing lists senseFile = new ArrayList(); antiFile = new ArrayList(); for (int x = 0; x < pngFiles.size(); x++) { @@ -50,43 +49,43 @@ public void run() throws IOException { } LogItem old_li = new LogItem(""); for (int x = 0; x < senseFile.size(); x++) { + // Search antiFile list for files containing the same base as the current sense PNG file and save the index String name = senseFile.get(x).getName(); - String out = name.substring(0, name.lastIndexOf("sense")); + String BASE = name.substring(0, name.lastIndexOf("sense")); int matchIndex = -999; for (int y = 0; y < antiFile.size(); y++) { - if (antiFile.get(y).getName().contains(out)) { + if (antiFile.get(y).getName().contains(BASE)) { matchIndex = y; } } - File OUTPUT = new File(out + "merge.png"); + // Construct output filename + File OUT_FILEPATH = new File(BASE + "merge.png"); if (OUT_DIR != null) { - OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + OUTPUT.getName()); + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + OUT_FILEPATH.getName()); } - // Initialize LogItem - String command = MergeHeatMapCLI.getCLIcommand(senseFile.get(x), antiFile.get(x), OUTPUT); - LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); // Store results in JFrame window if (matchIndex != -999) { + // Initialize LogItem + String command = MergeHeatMapCLI.getCLIcommand(senseFile.get(x), antiFile.get(matchIndex), OUT_FILEPATH); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); // Execute script - JLabel pic = MergeHeatMapPlot.mergePNG(senseFile.get(x), antiFile.get(matchIndex), OUTPUT); - addImage(OUTPUT.getName(), pic); + JLabel pic = MergeHeatMapPlot.mergePNG(senseFile.get(x), antiFile.get(matchIndex), OUT_FILEPATH); + newpane.addTab(OUT_FILEPATH.getName(), new JScrollPane(pic, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; } else { - JLabel pic = MergeHeatMapPlot.mergePNG(senseFile.get(x), null, OUTPUT); - addImage(OUTPUT.getName(), pic); + // no logging if no match + // display sense without merge if no match + JLabel pic = MergeHeatMapPlot.mergePNG(senseFile.get(x), null, OUT_FILEPATH); + newpane.addTab(OUT_FILEPATH.getName(), new JScrollPane(pic, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); } - // Update log item - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; - firePropertyChange("merge", x, x + 1); + // Update progress + firePropertyChange("progress", x, x + 1); } + // Update log at completion firePropertyChange("log", old_li, null); } - - private void addImage(String name, JLabel pic) { - newpane.addTab(name, new JScrollPane(pic, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); - } - } \ No newline at end of file diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java index 55f554334..5c28b454d 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java @@ -11,9 +11,7 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; -import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Date; import javax.swing.DefaultListModel; import javax.swing.JButton; @@ -21,6 +19,7 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JScrollPane; @@ -29,9 +28,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.cli.BAM_Manipulation.BAMRemoveDupCLI; -import scriptmanager.cli.Figure_Generation.MergeHeatMapCLI; -import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") @@ -55,23 +51,28 @@ public class MergeHeatMapWindow extends JFrame implements ActionListener, Proper class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - setProgress(0); - MergeHeatMapOutput heat = new MergeHeatMapOutput(pngFiles, OUT_DIR); - heat.addPropertyChangeListener("merge", new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent propertyChangeEvent) { - int temp = (Integer) propertyChangeEvent.getNewValue(); - int percentComplete = (int) (((double) (temp) / (pngFiles.size() / 2)) * 100); - setProgress(percentComplete); - } - }); - heat.addPropertyChangeListener("log", new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); - } - }); - heat.setVisible(true); - heat.run(); + public Void doInBackground() { + try { + setProgress(0); + MergeHeatMapOutput output_obj = new MergeHeatMapOutput(pngFiles, OUT_DIR); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent propertyChangeEvent) { + int temp = (Integer) propertyChangeEvent.getNewValue(); + int percentComplete = (int) (((double) (temp) / (pngFiles.size() / 2)) * 100); + setProgress(percentComplete); + } + }); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); + output_obj.setVisible(true); + output_obj.run(); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java index 2d3bf02e6..a54f128a2 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java @@ -35,7 +35,7 @@ public class TwoColorHeatMapOutput extends JFrame { public static Color MAXCOLOR = new Color(255, 0, 0); public boolean transparentBackground = false; - protected static boolean OUTPUTSTATUS = false; + protected static boolean OUTPUT_STATUS = false; protected static File OUT_DIR = null; public static double COLOR_RATIO = 1; @@ -64,25 +64,26 @@ public TwoColorHeatMapOutput(ArrayList in, Color c, int startR, int startC quantile = quant; OUT_DIR = out_dir; - OUTPUTSTATUS = outstatus; + OUTPUT_STATUS = outstatus; } public void run() throws IOException, OptionException { LogItem old_li = null; for (int x = 0; x < SAMPLE.size(); x++) { - File OUTPUT = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(SAMPLE.get(x)) + "_" + scaleType + ".png"); + // Construct output filename + String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(SAMPLE.get(x)) + "_" + scaleType + ".png"; + File OUT_FILEPATH = new File(NAME); if (OUT_DIR != null) { - OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + OUTPUT.getName()); + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } - old_li = new LogItem(""); // Initialize LogItem String command = TwoColorHeatMapCLI.getCLIcommand(SAMPLE.get(x), MAXCOLOR, startROW, startCOL, - pixelHeight, pixelWidth, scaleType, absolute, quantile, OUTPUT, transparentBackground); + pixelHeight, pixelWidth, scaleType, absolute, quantile, OUT_FILEPATH, transparentBackground); LogItem new_li = new LogItem(command); - if (OUTPUTSTATUS) { firePropertyChange("log", old_li, new_li); } + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, new_li); } // Execute script TwoColorHeatMap script_object = new TwoColorHeatMap(SAMPLE.get(x), MAXCOLOR, startROW, startCOL, - pixelHeight, pixelWidth, scaleType, absolute, quantile, OUTPUT, OUTPUTSTATUS, transparentBackground); + pixelHeight, pixelWidth, scaleType, absolute, quantile, OUT_FILEPATH, OUTPUT_STATUS, transparentBackground); script_object.run(); JLabel picLabel = script_object.getImg(); // Update log item @@ -90,19 +91,11 @@ public void run() throws IOException, OptionException { new_li.setStatus(0); old_li = new_li; // Output image/error to GUI - newpane.addTab(OUTPUT.getName(), new JScrollPane(picLabel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); - firePropertyChange("heat", x, x + 1); + newpane.addTab(OUT_FILEPATH.getName(), new JScrollPane(picLabel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); + // Update progress + firePropertyChange("progress", x, x + 1); } - if (OUTPUTSTATUS) { firePropertyChange("log", old_li, null); } - System.out.println("Program Complete"); - System.out.println(getTimeStamp()); + // Update log at completion + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, null); } } - - private static String getTimeStamp() { - Date date = new Date(); - String time = new Timestamp(date.getTime()).toString(); - return time; - } - } diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java index 851355201..ef563b7c6 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java @@ -78,9 +78,7 @@ public class TwoColorHeatMapWindow extends JFrame implements ActionListener, Pro class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - setProgress(0); - + public Void doInBackground() { try { if (txtFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No files loaded!!!"); @@ -102,6 +100,7 @@ public Void doInBackground() throws IOException { JOptionPane.showMessageDialog(null, "Invalid quantile contrast threshold value entered!!! Must be larger than 0-1"); } + setProgress(0); Color COLOR = btnColor.getForeground(); int startR = Integer.parseInt(txtRow.getText()); @@ -119,38 +118,38 @@ public Void doInBackground() throws IOException { if (OUT_DIR == null) { OUT_DIR = new File(System.getProperty("user.dir")); } - double absolute = Double.parseDouble(txtAbsolute.getText()); if (rdbtnPercentileValue.isSelected()) { absolute = -999; } double quantile = Double.parseDouble(txtPercent.getText()); - TwoColorHeatMapOutput heat = new TwoColorHeatMapOutput(txtFiles, COLOR, startR, startC, pHeight, pWidth, + TwoColorHeatMapOutput output_obj = new TwoColorHeatMapOutput(txtFiles, COLOR, startR, startC, pHeight, pWidth, scaletype, absolute, quantile, OUT_DIR, chckbxOutputHeatmap.isSelected(), chckbxTransparentBackground.isSelected()); - - heat.addPropertyChangeListener("heat", new PropertyChangeListener() { + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int) (((double) (temp) / (txtFiles.size())) * 100); setProgress(percentComplete); } }); - heat.addPropertyChangeListener("log", new PropertyChangeListener() { + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - heat.setVisible(true); - heat.run(); - - setProgress(100); - return null; + output_obj.setVisible(true); + output_obj.run(); } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (OptionException oe) { + oe.printStackTrace(); JOptionPane.showMessageDialog(null, oe.getMessage()); } + setProgress(100); return null; } From 105cdfe11f522802adbeb41e8adef633fc7b1601 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 31 Oct 2023 20:29:37 -0400 Subject: [PATCH 37/58] add logging to FourColorSequence ScriptManagerGUI - add property change listener FourColorSequenceCLI -add getCLIcommand() with javadocs FourColorSequenceWindow - initialize log item and update log item code blocks - add log property change listener - add GUI handling of various exceptions thrown by script class for consistency with other tools - standardize output filename construction for consistency with other tools --- .../FourColorSequenceCLI.java | 31 +++++++++++-- .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++ .../FourColorSequenceWindow.java | 46 +++++++++++++++---- 3 files changed, 74 insertions(+), 14 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/FourColorSequenceCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/FourColorSequenceCLI.java index 4420fb153..dd4674c2a 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/FourColorSequenceCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/FourColorSequenceCLI.java @@ -35,11 +35,9 @@ public class FourColorSequenceCLI implements Callable { @Parameters(index = "0", description = "input FASTA file of sequences to plot") private File fastaFile; - @Option(names = { "-o", - "--output" }, description = "specify output filename, please use PNG extension\n(default=FASTA filename with \"_4color.png\" appended to the name in working directory of ScriptManager") + @Option(names = { "-o", "--output" }, description = "specify output filename, please use PNG extension\n(default=FASTA filename with \"_4color.png\" appended to the name in working directory of ScriptManager") private File output = null; - @Option(names = { "-c", - "--colors" }, arity = "4..5", description = "For custom colors: List colors to use for ATGC[N], in that order. Type hexadecimal string to represent colors, e.g. FF0000 is hexadecimal for red.\n(default=A-red,T-green,G-yellow,C-blue,N-gray, if only 4 colors specified, N will be set to gray)\n See for some color options with their corresponding hex strings.") + @Option(names = { "-c", "--colors" }, arity = "4..5", description = "For custom colors: List colors to use for ATGC[N], in that order. Type hexadecimal string to represent colors, e.g. FF0000 is hexadecimal for red.\n(default=A-red,T-green,G-yellow,C-blue,N-gray, if only 4 colors specified, N will be set to gray)\n See for some color options with their corresponding hex strings.") private ArrayList colors = null; @Option(names = { "-x", "--pixel-width" }, description = "pixel width (default=1)") private int pixelWidth = 1; @@ -70,7 +68,7 @@ public Integer call() throws Exception { } // Set N-color to gray if only 4 colors provided as input if (colors == null || colors.size() == 4) { - ATCG_COLORS.add(4, Color.GRAY); // default C-color + ATCG_COLORS.add(4, Color.GRAY); // default N-color } // Generate Heatmap @@ -129,4 +127,27 @@ private String validateInput() throws IOException { return (r); } + + /** + * Reconstruct CLI command + * + * @param input the FASTA file to generate sequence plot from + * @param output the PNG image of the sequence plot + * @param COLORS the list of colors encoding the various nucleotides (A,T,G,C,N) + * @param h the height of each pixel + * @param w the width of each pixel + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, File output, ArrayList COLORS, int h, int w) throws IndexOutOfBoundsException { + String command = "java -jar $SCRIPTMANAGER figure-generation four-color"; + command += " -o " + output.getAbsolutePath(); + command += " -c"; + for (int x=0; x<5; x++) { + command += " " + Integer.toHexString(COLORS.get(x).getRGB()).substring(2); + } + command += " -y " + h; + command += " -x " + w; + command += " " + input.getAbsolutePath(); + return (command); + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index e0d04024f..badccf929 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1849,6 +1849,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { FourColorSequenceWindow frame = new FourColorSequenceWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/FourColorSequenceWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/FourColorSequenceWindow.java index 89637a7c0..b55a71034 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/FourColorSequenceWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/FourColorSequenceWindow.java @@ -11,7 +11,9 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import java.util.Vector; import javax.swing.DefaultListModel; @@ -34,6 +36,8 @@ import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; +import scriptmanager.cli.Figure_Generation.FourColorSequenceCLI; +import scriptmanager.objects.LogItem; import scriptmanager.scripts.Figure_Generation.FourColorPlot; @SuppressWarnings("serial") @@ -67,38 +71,60 @@ public class FourColorSequenceWindow extends JFrame implements ActionListener, P class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { - setProgress(0); if (Integer.parseInt(txtHeight.getText()) < 1) { JOptionPane.showMessageDialog(null, "Invalid Height Size!!! Must be larger than 0"); } else if (Integer.parseInt(txtWidth.getText()) < 1) { JOptionPane.showMessageDialog(null, "Invalid Width Size!!! Must be larger than 0"); } else { - ArrayList COLORS = new ArrayList(); + // Store nucleotide colors + ArrayList COLORS = new ArrayList(5); COLORS.add(btnAColor.getForeground()); COLORS.add(btnTColor.getForeground()); COLORS.add(btnGColor.getForeground()); COLORS.add(btnCColor.getForeground()); COLORS.add(btnNColor.getForeground()); + setProgress(0); + LogItem old_li = null; for (int x = 0; x < fastaFiles.size(); x++) { - String OUTPUT = ExtensionFileFilter.stripExtensionIgnoreGZ(fastaFiles.get(x)) + ".png"; - if(OUT_DIR != null) { - OUTPUT = OUT_DIR + File.separator + OUTPUT; + // Construct output filename + String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(fastaFiles.get(x)) + ".png"; + File OUT_FILEPATH = new File(NAME); + if (OUT_DIR != null) { + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } - FourColorPlot.generatePLOT(fastaFiles.get(x), new File(OUTPUT), COLORS, - Integer.parseInt(txtHeight.getText()), Integer.parseInt(txtWidth.getText())); + // Initialize LogItem + String command = FourColorSequenceCLI.getCLIcommand(fastaFiles.get(x), OUT_FILEPATH, COLORS, Integer.parseInt(txtHeight.getText()), Integer.parseInt(txtWidth.getText())); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script + FourColorPlot.generatePLOT(fastaFiles.get(x), OUT_FILEPATH, COLORS, Integer.parseInt(txtHeight.getText()), Integer.parseInt(txtWidth.getText())); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Update progress int percentComplete = (int) (((double) (x + 1) / fastaFiles.size()) * 100); setProgress(percentComplete); } + // Update log at completion + firePropertyChange("log", old_li, null); + // Update progress setProgress(100); JOptionPane.showMessageDialog(null, "Plots Generated"); - return null; } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IndexOutOfBoundsException ioobe) { + ioobe.printStackTrace(); + JOptionPane.showMessageDialog(null, "Invalid Number of colors!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } + setProgress(100); return null; } @@ -311,6 +337,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From ed34f6af240acd2f81367c3082c08a1dbdaee637 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Thu, 2 Nov 2023 17:51:13 -0400 Subject: [PATCH 38/58] add logging to PlotComposite ScriptManagerGUI - add property change listener CompositePlotCLI - add getCLIcommand() with javadocs - fix validateInput() to account for undefined output directory PlotCompositeOutput - rename OUTPUT_STATUS for consistency with other tools - initialize log item and update log item code blocks - switch fire property name "composite" --> "progress" for consistency with other tools - remove superfluous getTimeStamp() and STDOUT print statements PlotCompositeWindow - bugfix - handle NoSuchElementException for parsing imroperly formatted inputs - set OUT_DIR if not defined - add log property change listener - add GUI handling of various exceptions thrown by script class for consistency with other tools - standardize output filename construction for consistency with other tools --- .../Figure_Generation/CompositePlotCLI.java | 45 +++++++++++++++++-- .../scriptmanager/main/ScriptManagerGUI.java | 11 +++++ .../PlotCompositeOutput.java | 44 +++++++++--------- .../PlotCompositeWindow.java | 42 +++++++++++------ 4 files changed, 103 insertions(+), 39 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/CompositePlotCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/CompositePlotCLI.java index dbb2246ac..bbbb9d90e 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/CompositePlotCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/CompositePlotCLI.java @@ -44,8 +44,7 @@ public class CompositePlotCLI implements Callable { private int pixelWidth = 500; @Option(names = { "-y", "--height" }, description = "indicate a pixel height for the plot (default=270)") private int pixelHeight = 270; - @Option(names = { "-c", - "--custom-colors" }, description = "indicate colors to use for each series. Must indicate a number of colors that matches number of dataseries\n" + @Option(names = { "-c", "--custom-colors" }, description = "indicate colors to use for each series. Must indicate a number of colors that matches number of dataseries\n" + "default behavior:\n" + "if one series input, use black\n" + "if two series input, use blue(sense) and red(anti)\n" + "if greater than two series, cycle through a set of 10 preset colors based on Rossi et al, 2021 (PMID:33692541).", arity = "1..") @@ -86,7 +85,9 @@ private String validateInput() throws IOException { } // Output file check - if (output != null) { + if (output == null) { + output = new File(System.getProperty("user.dir")); + } else { if (output.getParent() == null) { // System.err.println("default to current directory"); } else if (!new File(output.getParent()).exists()) { @@ -118,4 +119,42 @@ private String validateInput() throws IOException { } return (r); } + + /** + * Reconstruct CLI command + * + * @param input a tab-delimited file containing the composite information + * in the format of scripts.Figure_Generation.TagPileup's + * output + * @param output filepath to save composite image to. if null, defaults to + * <InputWithoutExtension>_plot.png. + * @param outputImage to save image (true) or not (false) + * @param title the string to include at the top of the line chart + * @param COLORS the color palette list of colors to plot. If null, then a + * different color palette is chosen based on the number of + * lines parsed from the composite input file: if n=1, then + * black is used, if n=2, then the first plot is blue and the + * second is red, if n>2, then the YEP color pallete is + * used. + * @param legend to include the legend in the chart (true) or not (false) + * @param pxHeight height of image to save + * @param pxWidth width of image to save + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, File output, String title, ArrayList COLORS, boolean legend, int pxHeight, int pxWidth) { + String command = "java -jar $SCRIPTMANAGER figure-generation composite-plot"; + command += " -o " + output.getAbsolutePath(); + command += title==null ? "" : " -t " + title; + if (COLORS!=null) { + command += " -c"; + for (int x=0; x SAMPLE = null; protected static File OUT_DIR; - protected static boolean outputImg; + protected static boolean OUTPUT_STATUS; protected static boolean includeLegend = true; protected static int pxHeight; @@ -56,7 +57,7 @@ public PlotCompositeOutput(ArrayList in, File o_dir, boolean o, boolean l, SAMPLE = in; OUT_DIR = o_dir; - outputImg = o; + OUTPUT_STATUS = o; includeLegend = l; pxHeight = ph; pxWidth = pw; @@ -75,26 +76,25 @@ public PlotCompositeOutput(ArrayList in, File o_dir, boolean o, boolean l, * @throws IOException */ public void run() throws IOException { + LogItem old_li = null; for (int x = 0; x < SAMPLE.size(); x++) { - try { - // Execute script - ChartPanel chart = new ChartPanel(PlotComposite.plotCompositeFile(SAMPLE.get(x), OUT_DIR, outputImg, SAMPLE.get(x).getName(), null, includeLegend, pxHeight, pxWidth)); - chart.setPreferredSize(new java.awt.Dimension(500, 270)); - // Output image/error to GUI - newpane.addTab(SAMPLE.get(x).getName(), chart); - } catch (Exception e) { - JOptionPane.showMessageDialog(null, e.getMessage()); - } - - firePropertyChange("composite", x, x + 1); + // Initialize LogItem + String command = CompositePlotCLI.getCLIcommand(SAMPLE.get(x), OUT_DIR, SAMPLE.get(x).getName(), null, includeLegend, pxHeight, pxWidth); + LogItem new_li = new LogItem(command); + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, new_li); } + // Execute script + ChartPanel chart = new ChartPanel(PlotComposite.plotCompositeFile(SAMPLE.get(x), OUT_DIR, OUTPUT_STATUS, SAMPLE.get(x).getName(), null, includeLegend, pxHeight, pxWidth)); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Output image to display + chart.setPreferredSize(new java.awt.Dimension(500, 270)); + newpane.addTab(SAMPLE.get(x).getName(), chart); + // Update progress + firePropertyChange("progress", x, x + 1); } - System.out.println("Program Complete"); - System.out.println(getTimeStamp()); - } - - private static String getTimeStamp() { - Date date = new Date(); - String time = new Timestamp(date.getTime()).toString(); - return time; + // Update log at completion + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, null); } } } diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java index 64bd9ad3c..2e306350a 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java @@ -14,6 +14,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.NoSuchElementException; import javax.swing.DefaultListModel; import javax.swing.JButton; @@ -46,7 +47,7 @@ @SuppressWarnings("serial") public class PlotCompositeWindow extends JFrame implements ActionListener, PropertyChangeListener { private JPanel contentPane; - protected JFileChooser fc = new JFileChooser(new File(System.getProperty("user.dir"))); + protected JFileChooser fc = new JFileChooser(new File(System.getProperty("user.dir"))); final DefaultListModel expList; ArrayList txtFiles = new ArrayList(); @@ -89,9 +90,7 @@ public class PlotCompositeWindow extends JFrame implements ActionListener, Prope */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - setProgress(0); - + public Void doInBackground() { try { if (txtFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No files loaded!!!"); @@ -100,24 +99,36 @@ public Void doInBackground() throws IOException { } else if (Integer.parseInt(txtPixelWidth.getText()) < 1) { JOptionPane.showMessageDialog(null, "Invalid pixel width!!! Must be greater than 1"); } else { - PlotCompositeOutput output = new PlotCompositeOutput(txtFiles, OUT_DIR, chckbxOutputDir.isSelected(), chckbxIncludeLegend.isSelected(), Integer.parseInt(txtPixelHeight.getText()), Integer.parseInt(txtPixelWidth.getText())); - output.addPropertyChangeListener("composite", new PropertyChangeListener() { + setProgress(0); + if (OUT_DIR==null) { + OUT_DIR = new File(System.getProperty("user.dir")); + } + PlotCompositeOutput output_obj = new PlotCompositeOutput(txtFiles, OUT_DIR, chckbxOutputDir.isSelected(), chckbxIncludeLegend.isSelected(), Integer.parseInt(txtPixelHeight.getText()), Integer.parseInt(txtPixelWidth.getText())); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int)(((double)(temp) / (txtFiles.size())) * 100); setProgress(percentComplete); } }); - - output.setVisible(true); - output.run(); - - setProgress(100); - return null; + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); + output_obj.setVisible(true); + output_obj.run(); } - } catch(NumberFormatException nfe){ + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (NoSuchElementException nsee){ + nsee.printStackTrace(); + JOptionPane.showMessageDialog(null, "Check that your input files are properly formatted!"); } + setProgress(100); return null; } @@ -145,7 +156,7 @@ public PlotCompositeWindow() { sl_contentPane.putConstraint(SpringLayout.WEST, scrollPane, 10, SpringLayout.WEST, contentPane); sl_contentPane.putConstraint(SpringLayout.EAST, scrollPane, -10, SpringLayout.EAST, contentPane); contentPane.add(scrollPane); - + expList = new DefaultListModel(); final JList listExp = new JList(expList); listExp.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); @@ -300,10 +311,13 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From e4e327c7853f075774fb9086a8ca8a3925149e91 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 7 Nov 2023 14:15:54 -0500 Subject: [PATCH 39/58] add logging to ThreeColorHeatMap ScriptManagerGUI - add property change listener ThreeColorHeatMapCLI - add getCLIcommand() with javadocs ThreeColorHeatMapOutput - rename OUTPUT_PATH to OUT_DIR for consistency with other tools - adjust handling of incompatible threshold values with an Exception (remove postDialog String) - initialize log item and update log item code blocks - standardize output filename construction for consistency with other tools ThreeColorHeatMapWindow - add log property change listeners - rename *Output object as output_obj for consistency with other tools - add GUI handling of various exceptions thrown by script class for consistency with other tools - remove superfluous System print statements - remove superfluous getTimestamp() method --- .../ThreeColorHeatMapCLI.java | 84 ++++++++++++++++++- .../scriptmanager/main/ScriptManagerGUI.java | 11 +++ .../ThreeColorHeatMapOutput.java | 68 ++++++++------- .../ThreeColorHeatMapWindow.java | 55 ++++++------ 4 files changed, 153 insertions(+), 65 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java index 78accd5a2..dea8f6d54 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java @@ -33,8 +33,7 @@ public class ThreeColorHeatMapCLI implements Callable { @Parameters(index = "0", description = "") private File CDT; - @Option(names = { "-o", - "--output" }, description = "specify output filename, please use PNG extension\n(default=CDT filename with \"_.png\" appended to the name in working directory of ScriptManager") + @Option(names = { "-o", "--output" }, description = "specify output filename, please use PNG extension\n(default=CDT filename with \"_.png\" appended to the name in working directory of ScriptManager") private File output = null; @Option(names = { "-r", "--start-row" }, description = "") private int startROW = 1; @@ -44,8 +43,7 @@ public class ThreeColorHeatMapCLI implements Callable { private int pixelWidth = 200; @Option(names = { "-y", "--height" }, description = "indicate a pixel height for the heatmap (default=600)") private int pixelHeight = 600; - @Option(names = { "-z", - "--compression" }, description = "choose an image compression type: 1=Treeview, 2=Bicubic, 3=Bilinear, 4=Nearest Neighbor (default=1Treeview)") + @Option(names = { "-z", "--compression" }, description = "choose an image compression type: 1=Treeview, 2=Bicubic, 3=Bilinear, 4=Nearest Neighbor (default=1Treeview)") private int compression = 1; @ArgGroup(exclusive = true, multiplicity = "0..1", heading = "%nSelect minimum value:%n\t@|fg(red) (select no more than one of these options)|@%n") @@ -269,4 +267,82 @@ private String validateInput() throws IOException { return (r); } + + /** + * Reconstruct CLI command + * + * @param input the input matrix/CDT to generate a heatmap from + * @param c_min the min-value color to use + * @param c_mid the mid-value color to use + * @param c_max the max-value color to use + * @param c_nan the color to use for NaN values + * @param startR the index of the starting row + * @param startC the index of the starting column + * @param pHeight the height (in pixels) of the output image + * @param pWidth the width (in pixels) of the output image + * @param scale the image compression strategy (e.g. "treeview") + * @param minPstatus the matrix value corresponding to the minimum color value + * (absolute strategy) + * @param midPstatus the matrix value corresponding to the middle color value + * (absolute strategy) + * @param maxPstatus the matrix value corresponding to the maximum color value + * (absolute strategy) + * @param min_quant the matrix percentile value corresponding to the minimum + * color value (quantile strategy) + * @param mid_quant the matrix percentile value corresponding to the middle + * color value (quantile strategy) + * @param max_quant the matrix percentile value corresponding to the maximum + * color value (quantile strategy) + * @param exZ whether or not to exclude zero values from percentile + * calculations + * @param output the output PNG file + * @return command line to execute with formatted inputs + * @throws OptionException + */ + public static String getCLIcommand(File input, Color c_min, Color c_mid, Color c_max, Color c_nan, int startR, int startC, + int pHeight, int pWidth, String scale, boolean minPstatus, boolean midPstatus, boolean maxPstatus, + double min_quant, double mid_quant, double max_quant, boolean exZ, File output) throws OptionException { + String command = "java -jar $SCRIPTMANAGER figure-generation three-color"; + command += " " + input.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + + command += " --color-min " + Integer.toHexString(c_min.getRGB()).substring(2); + command += " --color-mid " + Integer.toHexString(c_mid.getRGB()).substring(2); + command += " --color-max " + Integer.toHexString(c_max.getRGB()).substring(2); + command += " --color-nan " + Integer.toHexString(c_nan.getRGB()).substring(2); + + command += " -r " + startR; + command += " -l " + startC; + command += " -y " + pHeight; + command += " -x " + pWidth; + switch (scale) { + case "treeview": + command += " -z 1"; + break; + case "bicubic": + command += " -z 2"; + break; + case "bilinear": + command += " -z 3"; + break; + case "neighbor": + command += " -z 4"; + break; + default: + throw new OptionException("invalid compression string"); + } + + command += minPstatus ? " -pn " + min_quant : " -an " + min_quant; + command += midPstatus ? " -pd " + mid_quant : " -ad " + mid_quant; + command += maxPstatus ? " -px " + max_quant : " -ax " + max_quant; + + command += c_min.getAlpha()==0 ? " --transparent-min" : ""; + command += c_mid.getAlpha()==0 ? " --transparent-mid" : ""; + command += c_max.getAlpha()==0 ? " --transparent-max" : ""; + command += c_nan.getAlpha()==0 ? " --transparent-nan" : ""; + + command += exZ ? "--include-zeros" : ""; + + return (command); + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index fcf342fac..b84d341ec 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1736,6 +1736,17 @@ public void actionPerformed(ActionEvent arg0) { public void run() { try { ThreeColorHeatMapWindow frame = new ThreeColorHeatMapWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapOutput.java index 98692811b..18d8712c0 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapOutput.java @@ -8,12 +8,14 @@ import java.util.Date; import javax.swing.JFrame; -import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTabbedPane; +import scriptmanager.cli.Figure_Generation.ThreeColorHeatMapCLI; +import scriptmanager.objects.LogItem; import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.scripts.Figure_Generation.ThreeColorHeatMap; +import scriptmanager.util.ExtensionFileFilter; @SuppressWarnings("serial") public class ThreeColorHeatMapOutput extends JFrame { @@ -39,7 +41,7 @@ public class ThreeColorHeatMapOutput extends JFrame { protected static double MINVAL = -10; protected static boolean excludeZeros = false; - protected static boolean OUTPUTSTATUS = false; + protected static boolean OUTPUT_STATUS = false; protected static File OUT_DIR = null; public static double COLOR_RATIO = 1; @@ -81,45 +83,41 @@ public ThreeColorHeatMapOutput(ArrayList in, excludeZeros = exZ; OUT_DIR = out_dir; - OUTPUTSTATUS = outstatus; - System.out.println(OUTPUTSTATUS); + OUTPUT_STATUS = outstatus; } - public void run() throws IOException { - String postRunDialog = ""; + public void run() throws IOException, OptionException { + LogItem old_li = null; for (int x = 0; x < SAMPLE.size(); x++) { - File OUTPUT = new File(SAMPLE.get(x).getName().split("\\.")[0] + "_" + scaleType + ".png"); + // Construct output filename + String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(SAMPLE.get(x)) + "_" + scaleType + ".png"; + File OUT_FILEPATH = new File(NAME); if (OUT_DIR != null) { - OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + OUTPUT); + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } + // Initialize LogItem + String command = ThreeColorHeatMapCLI.getCLIcommand(SAMPLE.get(x), MINCOLOR, MIDCOLOR, MAXCOLOR, NANCOLOR, + startROW, startCOL, pixelHeight, pixelWidth, scaleType, + percentileMin, percentileMid, percentileMax, + MAXVAL, MIDVAL, MINVAL, excludeZeros, OUT_FILEPATH); + LogItem new_li = new LogItem(command); + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, new_li); } // Execute script - try { - ThreeColorHeatMap script_object = new ThreeColorHeatMap(SAMPLE.get(x), - MINCOLOR, MIDCOLOR, MAXCOLOR, NANCOLOR, - startROW, startCOL, pixelHeight, pixelWidth, scaleType, - percentileMin, percentileMid, percentileMax, - MAXVAL, MIDVAL, MINVAL, excludeZeros, OUTPUT, OUTPUTSTATUS); - script_object.run(); - // Output image/error to GUI - newpane.addTab(OUTPUT.getName(), new JScrollPane(script_object.getImg(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); - } catch (OptionException e) { - postRunDialog += e.getMessage() + "\n"; - } - firePropertyChange("heat", x, x + 1); - } - System.out.println("Program Complete"); - System.out.println(getTimeStamp()); - if (!postRunDialog.equals("")) { - JOptionPane.showMessageDialog(null, postRunDialog); + ThreeColorHeatMap script_object = new ThreeColorHeatMap(SAMPLE.get(x), MINCOLOR, MIDCOLOR, MAXCOLOR, NANCOLOR, + startROW, startCOL, pixelHeight, pixelWidth, scaleType, + percentileMin, percentileMid, percentileMax, + MAXVAL, MIDVAL, MINVAL, excludeZeros, OUT_FILEPATH, OUTPUT_STATUS); + script_object.run(); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Output image + newpane.addTab(OUT_FILEPATH.getName(), new JScrollPane(script_object.getImg(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); + // Update progress + firePropertyChange("progress", x, x + 1); } + // Update log at completion + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, null); } } - - private static String getTimeStamp() { - Date date = new Date(); - String time = new Timestamp(date.getTime()).toString(); - return time; - } - } - diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java index 9c27b1cf7..c5bcb630a 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java @@ -37,6 +37,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.FileSelection; @SuppressWarnings("serial") @@ -95,43 +96,35 @@ public class ThreeColorHeatMapWindow extends JFrame implements ActionListener, P class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - setProgress(0); - + public Void doInBackground() { try { if (txtFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No files loaded!!!"); } else if (Integer.parseInt(txtRow.getText()) < 0) { - JOptionPane.showMessageDialog(null, - "Invalid Starting Row!!! Must be greater than 0, 0-based indexing"); + JOptionPane.showMessageDialog(null, "Invalid Starting Row!!! Must be greater than 0, 0-based indexing"); } else if (Integer.parseInt(txtCol.getText()) < 0) { - JOptionPane.showMessageDialog(null, - "Invalid Starting Column!!! Must be greater than 0, 0-based indexing"); + JOptionPane.showMessageDialog(null, "Invalid Starting Column!!! Must be greater than 0, 0-based indexing"); } else if (Integer.parseInt(txtHeight.getText()) < 1) { JOptionPane.showMessageDialog(null, "Invalid Image Height!!! Must be greater than 0"); } else if (Integer.parseInt(txtWidth.getText()) < 1) { JOptionPane.showMessageDialog(null, "Invalid Image Width!!! Must be greater than 0"); } else if (rdbtnMaxAbsoluteValue.isSelected() && Double.parseDouble(txtAbsoluteMax.getText()) <= Double .parseDouble(txtAbsoluteMid.getText())) { - JOptionPane.showMessageDialog(null, - "Invalid absolute contrast threshold values entered!!! Max be larger than Mid"); + JOptionPane.showMessageDialog(null, "Invalid absolute contrast threshold values entered!!! Max be larger than Mid"); } else if (rdbtnMinAbsoluteValue.isSelected() && Double.parseDouble(txtAbsoluteMid.getText()) <= Double .parseDouble(txtAbsoluteMin.getText())) { - JOptionPane.showMessageDialog(null, - "Invalid absolute contrast threshold values entered!!! Mid be larger than Min"); + JOptionPane.showMessageDialog(null, "Invalid absolute contrast threshold values entered!!! Mid be larger than Min"); } else if (rdbtnMaxPercentileValue.isSelected() && (Double.parseDouble(txtPercentMax.getText()) <= 0 || Double.parseDouble(txtPercentMax.getText()) > 1)) { - JOptionPane.showMessageDialog(null, - "Invalid max quantile contrast threshold value entered!!! Must be larger than 0-1"); + JOptionPane.showMessageDialog(null, "Invalid max quantile contrast threshold value entered!!! Must be larger than 0-1"); } else if (rdbtnMaxPercentileValue.isSelected() && (Double.parseDouble(txtPercentMin.getText()) <= 0 || Double.parseDouble(txtPercentMin.getText()) > 1)) { - JOptionPane.showMessageDialog(null, - "Invalid min quantile contrast threshold value entered!!! Must be larger than 0-1"); + JOptionPane.showMessageDialog(null, "Invalid min quantile contrast threshold value entered!!! Must be larger than 0-1"); } else if (rdbtnMaxPercentileValue.isSelected() && (Double .parseDouble(txtPercentMax.getText()) <= Double.parseDouble(txtPercentMin.getText()))) { - JOptionPane.showMessageDialog(null, - "Invalid quantile contrast threshold values entered!!! Max must be larger than Min"); + JOptionPane.showMessageDialog(null, "Invalid quantile contrast threshold values entered!!! Max must be larger than Min"); } + setProgress(0); // parameter input checks need to be added to script portion Color c_min = btnMinColor.getForeground(); Color c_mid = btnMidColor.getForeground(); @@ -158,7 +151,6 @@ public Void doInBackground() throws IOException { q_mid = Double.parseDouble(txtPercentMid.getText()); q_max = Double.parseDouble(txtPercentMax.getText()); } - // AAA > 0 // AAP > 1 // APA > 2 @@ -167,26 +159,35 @@ public Void doInBackground() throws IOException { // PAP > 5 // PPA > 6 // PPP > 7 - - ThreeColorHeatMapOutput heat = new ThreeColorHeatMapOutput(txtFiles, c_max, c_mid, c_min, c_nan, startR, + // Execute script + ThreeColorHeatMapOutput output_obj = new ThreeColorHeatMapOutput(txtFiles, c_max, c_mid, c_min, c_nan, startR, startC, pHeight, pWidth, scaletype, rdbtnMinPercentileValue.isSelected(), rdbtnMidPercentileValue.isSelected(), rdbtnMaxPercentileValue.isSelected(), q_min, q_mid, q_max, chckbxExcludeZeros.isSelected(), OUT_DIR, chckbxOutputHeatmap.isSelected()); - - heat.addPropertyChangeListener("heat", new PropertyChangeListener() { + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int) (((double) (temp) / (txtFiles.size())) * 100); setProgress(percentComplete); } }); - heat.setVisible(true); - heat.run(); - setProgress(100); - return null; + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); + output_obj.setVisible(true); + output_obj.run(); } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (OptionException oe) { + oe.printStackTrace(); + JOptionPane.showMessageDialog(null, oe.getMessage()); } + setProgress(100); return null; } @@ -700,6 +701,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From e9149149c93f1146a17ae585de7d23abb1eaa340 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 7 Nov 2023 18:07:13 -0500 Subject: [PATCH 40/58] add logging to ConvertBED/GFFChrNames ScriptManagerGUI - add property change listener ConvertBED/GFFChrNamesCLI - add getCLIcommand() with javadocs ConvertBED/GFFChrNamesWindow - add log property change listeners - standardize output filename construction for consistency with other tools - initialize log item and update log item code blocks - add try-catch block for GUI handling of various exceptions thrown by script class for consistency with other tools --- .../File_Utilities/ConvertBEDChrNamesCLI.java | 20 +++++ .../File_Utilities/ConvertGFFChrNamesCLI.java | 20 +++++ .../scriptmanager/main/ScriptManagerGUI.java | 22 ++++++ .../ConvertBEDChrNamesWindow.java | 74 ++++++++++++------- .../ConvertGFFChrNamesWindow.java | 74 ++++++++++++------- 5 files changed, 156 insertions(+), 54 deletions(-) diff --git a/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java index 918ce5055..9f37c3f19 100644 --- a/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java +++ b/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java @@ -99,4 +99,24 @@ private String validateInput() throws IOException { return(r); } + + /** + * Reconstruct CLI command + * + * @param AtoR whether to do a arabic to roman numeral conversion (vs roman to arabic numeral) + * @param input the BED file to convert chr names of + * @param output the output GFF file of converted coords + * @param useChrmt whether or not to use "chrmt" + * @param gzOutput gzip output + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(boolean AtoR, File input, File output, boolean useChrmt, boolean gzOutput) { + String command = "java -jar $SCRIPTMANAGER file-utilities convert-bed-genome"; + command += AtoR ? "" : " --to-arabic" ; + command += " -o " + output.getAbsolutePath(); + command += useChrmt ? " --chrmt" : ""; + command += gzOutput ? " --gzip" : ""; + command += " " + input.getAbsolutePath(); + return command; + } } diff --git a/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java index 724e1c7ed..b5050022b 100644 --- a/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java +++ b/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java @@ -99,4 +99,24 @@ private String validateInput() throws IOException { return(r); } + + /** + * Reconstruct CLI command + * + * @param AtoR whether to do a arabic to roman numeral conversion (vs roman to arabic numeral) + * @param input the GFF file to convert chr names of + * @param output the output BED file of converted coords + * @param useChrmt whether or not to use "chrmt" + * @param gzOutput gzip output + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(boolean AtoR, File input, File output, boolean useChrmt, boolean gzOutput) { + String command = "java -jar $SCRIPTMANAGER file-utilities convert-gff-genome"; + command += AtoR ? "" : " --to-arabic" ; + command += " -o " + output.getAbsolutePath(); + command += useChrmt ? " --chrmt" : ""; + command += gzOutput ? " --gzip" : ""; + command += " " + input.getAbsolutePath(); + return command; + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index b84d341ec..ac08f5459 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -711,6 +711,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { ConvertBEDChrNamesWindow frame = new ConvertBEDChrNamesWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); @@ -739,6 +750,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { ConvertGFFChrNamesWindow frame = new ConvertGFFChrNamesWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java index 1ec41aafc..55219467b 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java @@ -11,6 +11,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.ButtonGroup; @@ -31,8 +33,11 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.LogItem; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; + +import scriptmanager.cli.File_Utilities.ConvertBEDChrNamesCLI; import scriptmanager.scripts.File_Utilities.ConvertChrNames; @SuppressWarnings("serial") @@ -61,36 +66,48 @@ public class ConvertBEDChrNamesWindow extends JFrame implements ActionListener, class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - setProgress(0); - // apply to each fil in vector - for (int x = 0; x < BEDFiles.size(); x++) { - File XBED = BEDFiles.get(x); - // Set suffix format - String SUFFIX = rdbtnA2R.isSelected() ? "_toRoman.bed" : "_toArabic.bed"; - SUFFIX += chckbxGzipOutput.isSelected() ? ".gz" : ""; - // Set output filepath with name and output directory - String OUTPUT = ExtensionFileFilter.stripExtension(XBED); - // Strip second extension if input has ".gz" first extension - if (XBED.getName().endsWith(".bed.gz")) { - OUTPUT = ExtensionFileFilter.stripExtensionPath(new File(OUTPUT)) ; - } - // Add user-selected directory - if (OUT_DIR != null) { - OUTPUT = OUT_DIR + File.separator + OUTPUT; - } - // Execute conversion and update progress - if (rdbtnA2R.isSelected()) { - ConvertChrNames.convert_ArabictoRoman(XBED, new File(OUTPUT + SUFFIX), chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); - } else { - ConvertChrNames.convert_RomantoArabic(XBED, new File(OUTPUT + SUFFIX), chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + public Void doInBackground() { + try { + setProgress(0); + LogItem old_li = null; + // apply to each fil in vector + for (int x = 0; x < BEDFiles.size(); x++) { + File XBED = BEDFiles.get(x); + // Construct output filename + String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(XBED); + NAME += rdbtnA2R.isSelected() ? "_toRoman.bed" : "_toArabic.bed"; + NAME += chckbxGzipOutput.isSelected() ? ".gz" : ""; + File OUT_FILEPATH = new File(NAME); + if (OUT_DIR != null) { + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); + } + // Initialize LogItem + String command = ConvertBEDChrNamesCLI.getCLIcommand(rdbtnA2R.isSelected(), XBED, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script + if (rdbtnA2R.isSelected()) { + ConvertChrNames.convert_ArabictoRoman(XBED, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + } else { + ConvertChrNames.convert_RomantoArabic(XBED, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + } + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Update progress + int percentComplete = (int) (((double) (x + 1) / BEDFiles.size()) * 100); + setProgress(percentComplete); } - // Update progress bar - int percentComplete = (int) (((double) (x + 1) / BEDFiles.size()) * 100); - setProgress(percentComplete); + // Update log at completion + firePropertyChange("log", old_li, null); + setProgress(100); + JOptionPane.showMessageDialog(null, "Conversion Complete"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } setProgress(100); - JOptionPane.showMessageDialog(null, "Conversion Complete"); return null; } @@ -235,10 +252,13 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java index bb1456e52..ea88145cc 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java @@ -11,6 +11,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.ButtonGroup; @@ -31,8 +33,11 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.LogItem; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; + +import scriptmanager.cli.File_Utilities.ConvertGFFChrNamesCLI; import scriptmanager.scripts.File_Utilities.ConvertChrNames; @SuppressWarnings("serial") @@ -61,36 +66,48 @@ public class ConvertGFFChrNamesWindow extends JFrame implements ActionListener, class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - setProgress(0); - // apply to each fil in vector - for (int x = 0; x < GFFFiles.size(); x++) { - File XGFF = GFFFiles.get(x); - // Set suffix format - String SUFFIX = rdbtnA2R.isSelected() ? "_toRoman.gff" : "_toArabic.gff"; - SUFFIX += chckbxGzipOutput.isSelected() ? ".gz" : ""; - // Set output filepath with name and output directory - String OUTPUT = ExtensionFileFilter.stripExtension(XGFF); - // Strip second extension if input has ".gz" first extension - if (XGFF.getName().endsWith(".gff.gz")) { - OUTPUT = ExtensionFileFilter.stripExtensionPath(new File(OUTPUT)) ; - } - // Add user-selected directory - if (OUT_DIR != null) { - OUTPUT = OUT_DIR + File.separator + OUTPUT; - } - // Execute conversion and update progress - if (rdbtnA2R.isSelected()) { - ConvertChrNames.convert_ArabictoRoman(XGFF, new File(OUTPUT + SUFFIX), chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); - } else { - ConvertChrNames.convert_RomantoArabic(XGFF, new File(OUTPUT + SUFFIX), chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + public Void doInBackground() { + try { + setProgress(0); + LogItem old_li = null; + // apply to each fil in vector + for (int x = 0; x < GFFFiles.size(); x++) { + File XGFF = GFFFiles.get(x); + // Construct output filename + String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(XGFF); + NAME += rdbtnA2R.isSelected() ? "_toRoman.gff" : "_toArabic.gff"; + NAME += chckbxGzipOutput.isSelected() ? ".gz" : ""; + File OUT_FILEPATH = new File(NAME); + if (OUT_DIR != null) { + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); + } + // Initialize LogItem + String command = ConvertGFFChrNamesCLI.getCLIcommand(rdbtnA2R.isSelected(), XGFF, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script + if (rdbtnA2R.isSelected()) { + ConvertChrNames.convert_ArabictoRoman(XGFF, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + } else { + ConvertChrNames.convert_RomantoArabic(XGFF, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + } + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Update progress + int percentComplete = (int) (((double) (x + 1) / GFFFiles.size()) * 100); + setProgress(percentComplete); } - // Update progress bar - int percentComplete = (int) (((double) (x + 1) / GFFFiles.size()) * 100); - setProgress(percentComplete); + // Update log at completion + firePropertyChange("log", old_li, null); + setProgress(100); + JOptionPane.showMessageDialog(null, "Conversion Complete"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } setProgress(100); - JOptionPane.showMessageDialog(null, "Conversion Complete"); return null; } @@ -235,10 +252,13 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From 48c1085c9ac9b09dd248d65821e3e1ae77199a39 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 7 Nov 2023 19:18:40 -0500 Subject: [PATCH 41/58] add logging to Gzip (de)compressFile tools ScriptManagerGUI - add property change listener ScriptManager - add two tools to CLI CompressFileCLI and DecompressGZFileCLI - initialize CLI (non existent before, violating ScriptManager architecture rules) - execution of script should simply print information for finding gzip utility (linux style) - add getCLIcommand() with javadocs CompressFileWindow and DecompressGZFileWindow - move task block into try-catch statement - initialize and update log item - add property change listener - add GUI handling of try-catch exceptions --- .../cli/File_Utilities/CompressFileCLI.java | 43 +++++++++++++++++++ .../File_Utilities/DecompressGZFileCLI.java | 43 +++++++++++++++++++ .../scriptmanager/main/ScriptManager.java | 6 ++- .../scriptmanager/main/ScriptManagerGUI.java | 22 ++++++++++ .../File_Utilities/CompressFileWindow.java | 41 +++++++++++++++--- .../DecompressGZFileWindow.java | 42 ++++++++++++++---- 6 files changed, 181 insertions(+), 16 deletions(-) create mode 100644 src/main/java/scriptmanager/cli/File_Utilities/CompressFileCLI.java create mode 100644 src/main/java/scriptmanager/cli/File_Utilities/DecompressGZFileCLI.java diff --git a/src/main/java/scriptmanager/cli/File_Utilities/CompressFileCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/CompressFileCLI.java new file mode 100644 index 000000000..fb1119fcf --- /dev/null +++ b/src/main/java/scriptmanager/cli/File_Utilities/CompressFileCLI.java @@ -0,0 +1,43 @@ +package scriptmanager.cli.File_Utilities; + +import picocli.CommandLine.Command; + +import java.io.File; +import java.util.concurrent.Callable; + +import scriptmanager.objects.ToolDescriptions; + +/** + * Print a message redirecting user to the original CLI tool. + * + * @author Olivia Lang + * @see scriptmanager.scripts.File_Utilities.GZipFiles + */ +@Command(name = "gzip-compress", mixinStandardHelpOptions = true, + description = ToolDescriptions.compressFileDescription + "\n"+ + "@|bold **Please use the command line gzip this job**|@ \n"+ + "@|bold,yellow 'gzip -k infile.txt'|@", + version = "ScriptManager "+ ToolDescriptions.VERSION, + exitCodeOnInvalidInput = 1, + exitCodeOnExecutionException = 1) +public class CompressFileCLI implements Callable { + @Override + public Integer call() throws Exception { + System.err.println("***Please use the command line for gzip this job***\n"+ + "\t'gzip -k infile.txt'" ); + System.exit(1); + return(1); + } + + /** + * Reconstruct CLI command + * + * @param input the file to gzip compress + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input) { + String command = "gzip -k"; + command += " " + input.getAbsolutePath(); + return(command); + } +} diff --git a/src/main/java/scriptmanager/cli/File_Utilities/DecompressGZFileCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/DecompressGZFileCLI.java new file mode 100644 index 000000000..acd94784f --- /dev/null +++ b/src/main/java/scriptmanager/cli/File_Utilities/DecompressGZFileCLI.java @@ -0,0 +1,43 @@ +package scriptmanager.cli.File_Utilities; + +import picocli.CommandLine.Command; + +import java.io.File; +import java.util.concurrent.Callable; + +import scriptmanager.objects.ToolDescriptions; + +/** + * Print a message redirecting user to the original CLI tool. + * + * @author Olivia Lang + * @see scriptmanager.scripts.File_Utilities.GZipFiles + */ +@Command(name = "gzip-decompress", mixinStandardHelpOptions = true, + description = ToolDescriptions.decompressFileDescription + "\n"+ + "@|bold **Please use the command line gzip this job**|@ \n"+ + "@|bold,yellow 'gzip -dk infile.txt.txt'|@", + version = "ScriptManager "+ ToolDescriptions.VERSION, + exitCodeOnInvalidInput = 1, + exitCodeOnExecutionException = 1) +public class DecompressGZFileCLI implements Callable { + @Override + public Integer call() throws Exception { + System.err.println("***Please use the command line gzip for this job***\n"+ + "\t'gzip -dk infile.txt'" ); + System.exit(1); + return(1); + } + + /** + * Reconstruct CLI command + * + * @param input the file to gzip decompress + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input) { + String command = "gzip -dk"; + command += " " + input.getAbsolutePath(); + return(command); + } +} diff --git a/src/main/java/scriptmanager/main/ScriptManager.java b/src/main/java/scriptmanager/main/ScriptManager.java index e0b6e8d9a..b239065f8 100755 --- a/src/main/java/scriptmanager/main/ScriptManager.java +++ b/src/main/java/scriptmanager/main/ScriptManager.java @@ -41,8 +41,10 @@ import scriptmanager.cli.Figure_Generation.LabelHeatMapCLI; import scriptmanager.cli.File_Utilities.MD5ChecksumCLI; +import scriptmanager.cli.File_Utilities.CompressFileCLI; import scriptmanager.cli.File_Utilities.ConvertBEDChrNamesCLI; import scriptmanager.cli.File_Utilities.ConvertGFFChrNamesCLI; +import scriptmanager.cli.File_Utilities.DecompressGZFileCLI; import scriptmanager.cli.Peak_Analysis.BEDPeakAligntoRefCLI; import scriptmanager.cli.Peak_Analysis.FilterBEDbyProximityCLI; import scriptmanager.cli.Peak_Analysis.RandomCoordinateCLI; @@ -181,7 +183,9 @@ class Figure_GenerationCLI extends SubcommandCLI {} subcommands = { MD5ChecksumCLI.class, ConvertBEDChrNamesCLI.class, - ConvertGFFChrNamesCLI.class + ConvertGFFChrNamesCLI.class, + CompressFileCLI.class, + DecompressGZFileCLI.class }, description = "Includes the tool MD5Checksum.") class File_UtilitiesCLI extends SubcommandCLI {} diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index ac08f5459..3063697d0 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -789,6 +789,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { CompressFileWindow frame = new CompressFileWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); @@ -817,6 +828,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { DecompressGZFileWindow frame = new DecompressGZFileWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/CompressFileWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/CompressFileWindow.java index 2c42472cd..3c6e71dfa 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/CompressFileWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/CompressFileWindow.java @@ -9,6 +9,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.DefaultListModel; @@ -25,7 +27,10 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.cli.File_Utilities.CompressFileCLI; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; + import scriptmanager.scripts.File_Utilities.GZipFiles; /** @@ -51,15 +56,34 @@ public class CompressFileWindow extends JFrame implements ActionListener, Proper class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - setProgress(0); - for(int x = 0; x < GeneralFiles.size(); x++) { - GZipFiles.compressFile(GeneralFiles.get(x), 8192); - int percentComplete = (int)(((double)(x + 1) / GeneralFiles.size()) * 100); - setProgress(percentComplete); + public Void doInBackground() { + try { + setProgress(0); + LogItem old_li = null; + for(int x = 0; x < GeneralFiles.size(); x++) { + // Initialize LogItem + String command = CompressFileCLI.getCLIcommand(GeneralFiles.get(x)); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script + GZipFiles.compressFile(GeneralFiles.get(x), 8192); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Update progress + int percentComplete = (int)(((double)(x + 1) / GeneralFiles.size()) * 100); + setProgress(percentComplete); + } + // Update log at completion + firePropertyChange("log", old_li, null); + setProgress(100); + JOptionPane.showMessageDialog(null, "Compressing Complete"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } setProgress(100); - JOptionPane.showMessageDialog(null, "Compressing Complete"); return null; } @@ -153,10 +177,13 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/DecompressGZFileWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/DecompressGZFileWindow.java index 2a0cebd9c..4235a4b89 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/DecompressGZFileWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/DecompressGZFileWindow.java @@ -9,6 +9,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.DefaultListModel; @@ -25,7 +27,10 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; + +import scriptmanager.cli.File_Utilities.DecompressGZFileCLI; import scriptmanager.scripts.File_Utilities.GZipFiles; /** @@ -51,15 +56,33 @@ public class DecompressGZFileWindow extends JFrame implements ActionListener, Pr class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - setProgress(0); - for(int x = 0; x < GZFiles.size(); x++) { - GZipFiles.decompressFile(GZFiles.get(x), 8192); - int percentComplete = (int)(((double)(x + 1) / GZFiles.size()) * 100); - setProgress(percentComplete); + public Void doInBackground() { + try { + setProgress(0); + LogItem old_li = null; + for(int x = 0; x < GZFiles.size(); x++) { + // Initialize LogItem + String command = DecompressGZFileCLI.getCLIcommand(GZFiles.get(x)); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script + GZipFiles.decompressFile(GZFiles.get(x), 8192); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Update progress + int percentComplete = (int)(((double)(x + 1) / GZFiles.size()) * 100); + setProgress(percentComplete); + } + // Update log at completion + firePropertyChange("log", old_li, null); + setProgress(100); + JOptionPane.showMessageDialog(null, "Decompressing Complete"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } - setProgress(100); - JOptionPane.showMessageDialog(null, "Decompressing Complete"); return null; } @@ -153,10 +176,13 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From fe25a9613caac588e9533d876fbbeb2a555974f4 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 14 Nov 2023 13:50:49 -0500 Subject: [PATCH 42/58] add logging to MD5Checksum ScriptManagerGUI - add property change listener MD5ChecksumCLI - adjust CLI to write to STDOUT instead of `md5checksum.txt` by default -add getCLIcommand() with javadocs - leverage STDOUT default writing to shell-style append MD5 checksum results MD5ChecksumWindow - initialize log item and update log item code blocks - add log property change listener - add GUI handling of various exceptions thrown by script class for consistency with other tools - standardize OUT_DIR filename update for consistency with other tools --- .../cli/File_Utilities/MD5ChecksumCLI.java | 23 +++- .../scriptmanager/main/ScriptManagerGUI.java | 11 ++ .../File_Utilities/MD5ChecksumWindow.java | 111 +++++++++++------- 3 files changed, 100 insertions(+), 45 deletions(-) diff --git a/src/main/java/scriptmanager/cli/File_Utilities/MD5ChecksumCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/MD5ChecksumCLI.java index 601eb58af..0cdd52297 100644 --- a/src/main/java/scriptmanager/cli/File_Utilities/MD5ChecksumCLI.java +++ b/src/main/java/scriptmanager/cli/File_Utilities/MD5ChecksumCLI.java @@ -5,7 +5,6 @@ import picocli.CommandLine.Parameters; import java.util.concurrent.Callable; - import java.io.File; import java.io.PrintStream; @@ -30,15 +29,31 @@ public class MD5ChecksumCLI implements Callable { private File input; @Option(names = {"-o", "--output"}, description = "specify output filepath") - private File output = new File("md5checksum.txt"); + private File output = null; @Override public Integer call() throws Exception { String md5hash = MD5Checksum.calculateMD5(input.getAbsolutePath()); - PrintStream OUT = new PrintStream( output ); + PrintStream OUT = System.out; + if (output != null) { + OUT = new PrintStream( output ); + } OUT.println("MD5 (" + input.getName() + ") = " + md5hash); OUT.close(); return(0); } -} + /** + * Reconstruct CLI command + * + * @param input the file to get checksums from + * @param output the file checksums are written to + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, File output) { + String command = "java -jar $SCRIPTMANAGER file-utilities md5checksum"; + command += " " + input.getAbsolutePath(); + command += " >> " + output; + return command; + } +} \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 3063697d0..3b5e2b86c 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -683,6 +683,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { MD5ChecksumWindow frame = new MD5ChecksumWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/MD5ChecksumWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/MD5ChecksumWindow.java index e841b99fd..1d7dd9e4e 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/MD5ChecksumWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/MD5ChecksumWindow.java @@ -13,6 +13,8 @@ import java.io.IOException; import java.io.PrintStream; import java.security.NoSuchAlgorithmException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.DefaultListModel; @@ -31,6 +33,9 @@ import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; +import scriptmanager.objects.LogItem; + +import scriptmanager.cli.File_Utilities.MD5ChecksumCLI; import scriptmanager.scripts.File_Utilities.MD5Checksum; @SuppressWarnings("serial") @@ -38,10 +43,9 @@ public class MD5ChecksumWindow extends JFrame implements ActionListener, Propert private JPanel contentPane; protected JFileChooser fc = new JFileChooser(new File(System.getProperty("user.dir"))); - private File OUTPUT_PATH = null; - private PrintStream OUT = null; + private File OUT_DIR = null; final DefaultListModel expList; - Vector Files = new Vector(); + Vector inputs = new Vector(); private JButton btnLoad; private JButton btnRemove; @@ -54,29 +58,51 @@ public class MD5ChecksumWindow extends JFrame implements ActionListener, Propert private JButton btnOutput; class Task extends SwingWorker { - @Override - public Void doInBackground() throws IOException, NoSuchAlgorithmException { - setProgress(0); - - if(OUTPUT_PATH == null) OUT = new PrintStream("md5checksum.txt"); - else OUT = new PrintStream(OUTPUT_PATH + File.separator + "md5checksum.txt"); - for(int x = 0; x < Files.size(); x++) { - String md5hash = MD5Checksum.calculateMD5(Files.get(x).getAbsolutePath()); - OUT.println("MD5 (" + Files.get(x).getName() + ") = " + md5hash); - int percentComplete = (int)(((double)(x + 1) / Files.size()) * 100); - setProgress(percentComplete); - } - setProgress(100); - - OUT.close(); - JOptionPane.showMessageDialog(null, "Calculation Complete"); - return null; - } - - public void done() { - massXable(contentPane, true); - setCursor(null); //turn off the wait cursor - } + @Override + public Void doInBackground() { + try { + setProgress(0); + File OUT_FILEPATH = new File("md5checksum.txt"); + if (OUT_DIR != null) { + OUT_FILEPATH = new File(OUT_DIR.getAbsoluteFile() + File.separator + "md5checksum.txt"); + } + PrintStream OUT = new PrintStream(OUT_FILEPATH); + LogItem old_li = null; + for(int x = 0; x < inputs.size(); x++) { + // Initialize LogItem + String command = MD5ChecksumCLI.getCLIcommand(inputs.get(x), OUT_FILEPATH); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script (calculate MD5 for each file) + String md5hash = MD5Checksum.calculateMD5(inputs.get(x).getAbsolutePath()); + OUT.println("MD5 (" + inputs.get(x).getName() + ") = " + md5hash); + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + firePropertyChange("log", old_li, null); + // Update progress + int percentComplete = (int)(((double)(x + 1) / inputs.size()) * 100); + setProgress(percentComplete); + } + OUT.close(); + setProgress(100); + JOptionPane.showMessageDialog(null, "Calculation Complete"); + } catch (NoSuchAlgorithmException nsae) { + nsae.printStackTrace(); + JOptionPane.showMessageDialog(null, "Unexpected NoSuchAlgorithmException from MD5Checksum-MessageDigest call. May need to create Github issue ticket if there isn't already an open ticket for this error. " + nsae.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } + setProgress(100); + return null; + } + + public void done() { + massXable(contentPane, true); + setCursor(null); //turn off the wait cursor + } } public MD5ChecksumWindow() { @@ -108,7 +134,7 @@ public void actionPerformed(ActionEvent e) { File[] newFiles = FileSelection.getGenericFiles(fc); if(newFiles != null) { for(int x = 0; x < newFiles.length; x++) { - Files.add(newFiles[x]); + inputs.add(newFiles[x]); expList.addElement(newFiles[x].getName()); } } @@ -123,7 +149,7 @@ public void actionPerformed(ActionEvent e) { btnRemove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { while(listExp.getSelectedIndex() > -1) { - Files.remove(listExp.getSelectedIndex()); + inputs.remove(listExp.getSelectedIndex()); expList.remove(listExp.getSelectedIndex()); } } @@ -160,9 +186,9 @@ public void actionPerformed(ActionEvent arg0) { btnOutput = new JButton("Output Directory"); btnOutput.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - OUTPUT_PATH = FileSelection.getOutputDir(fc); - if(OUTPUT_PATH != null) { - lblDefaultToLocal.setText(OUTPUT_PATH.getAbsolutePath()); + OUT_DIR = FileSelection.getOutputDir(fc); + if(OUT_DIR != null) { + lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); } } }); @@ -182,17 +208,20 @@ public void actionPerformed(ActionEvent arg0) { task.addPropertyChangeListener(this); task.execute(); } - + /** - * Invoked when task's progress property changes. - */ - public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } - } - + * Invoked when task's progress property changes. + */ + @Override + public void propertyChange(PropertyChangeEvent evt) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + } + public void massXable(Container con, boolean status) { for(Component c : con.getComponents()) { c.setEnabled(status); From c01e628d87c92ab90006be996df271e4acd56ca3 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Wed, 15 Nov 2023 09:12:16 -0500 Subject: [PATCH 43/58] add logging to ScalingFactor ScriptManagerGUI - add property change listener ScalingFactorCLI - add getCLIcommand() with javadocs (use new scaling method encodings) ScalingFactor - move OUTPUT_STATUS to last parameter for consisstency with other tools - add final constants for encoding scaling method ScalingFactorOutput - Move OUTPUT_STATUS to last parameter for consisstency with other tools - rename OUTPUT_PATH to OUT_DIR and OUTPUTSTATUS to OUTPUT_STATUS for consistency with other tools - initialize log item and update log item code blocks - standardize output filename construction for consistency with other tools - change propertyChange "scale" to "progress" for consistency with other tools ScalingFactorWindow - initialize log item and update log item code blocks - use ScalingFactor scaleType constants - add log property change listener - add GUI handling of various exceptions thrown by script class for consistency with other tools - rename *Output object as output_obj for consistency with other tools - standardize OUT_DIR filename update for consistency with other tools --- .../cli/Read_Analysis/ScalingFactorCLI.java | 56 +++++++++-- .../scriptmanager/main/ScriptManagerGUI.java | 11 +++ .../scripts/Read_Analysis/ScalingFactor.java | 41 ++++---- .../Read_Analysis/ScalingFactorOutput.java | 47 +++++++--- .../Read_Analysis/ScalingFactorWindow.java | 93 +++++++++++-------- 5 files changed, 169 insertions(+), 79 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java b/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java index 83e22ba44..c6cebf143 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java @@ -11,6 +11,7 @@ import java.io.IOException; import scriptmanager.objects.ToolDescriptions; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.scripts.Read_Analysis.ScalingFactor; @@ -29,7 +30,7 @@ public class ScalingFactorCLI implements Callable { private File bamFile; @Option(names = {"-o", "--output"}, description = "Specify basename for output files (default = _ScalingFactors.out") - private String outputBasename = null; + private File outputBasename = null; @Option(names = {"-f", "--blacklist"}, description = "specify blacklist file to filter by") private File blacklistFilter = null; @Option(names = {"-c", "--control"}, description = "control BAM file") @@ -65,7 +66,7 @@ public Integer call() throws Exception { } System.err.println( "OUTBASE: " + outputBasename ); - ScalingFactor script_obj = new ScalingFactor(bamFile, blacklistFilter, controlBAM, outputBasename, true, scaleType, window, minFrac); + ScalingFactor script_obj = new ScalingFactor(bamFile, blacklistFilter, controlBAM, outputBasename, scaleType, window, minFrac, true); script_obj.run(); System.err.println("Scaling Factor Calculated."); @@ -110,16 +111,15 @@ private String validateInput() throws IOException { } //set default output filename if(outputBasename==null){ - outputBasename = ExtensionFileFilter.stripExtension(bamFile); + outputBasename = new File(ExtensionFileFilter.stripExtension(bamFile)); //check output filename is valid - }else{ - File tempOut = new File(outputBasename); + } else { //no check ext //check directory - if(tempOut.getParent()==null){ + if(outputBasename.getParent()==null){ // System.err.println("default to current directory"); - } else if(!new File(tempOut.getParent()).exists()){ - r += "(!)Check output directory exists: " + tempOut.getParent() + "\n"; + } else if(!new File(outputBasename.getParent()).exists()){ + r += "(!)Check output directory exists: " + outputBasename.getParent() + "\n"; } } @@ -143,4 +143,44 @@ private String validateInput() throws IOException { return(r); } + + /** + * Reconstruct CLI command + * + * @param bamFile the BAM file to calculate a scaling factor for + * @param bl BED formatted blacklist of regions to exclude from the + * calculation + * @param c control BAM file (used by NCIS-style scaling methods) + * @param obase output basename for storing scaling factor and other reference + * data + * @param scale scaling method + * @param win window size (used by NCIS-style scaling methods) + * @param min minimum fraction (used by NCIS-style scaling methods) + * @return + * @throws OptionException + */ + public static String getCLIcommand(File bamFile, File bl, File c, File obase, int scale, int win, double min) throws OptionException { + String command = "java -jar $SCRIPTMANAGER read-analysis scaling-factor"; + command += " -o " + obase.getAbsolutePath(); + command += bl==null ? "" : " -f " + bl; + switch (scale) { + case ScalingFactor.TOTAL_TAG: + command += " --total-tag"; + break; + case ScalingFactor.NCIS: + command += " --ncis"; + command += " -c " + c; + break; + case ScalingFactor.NCIS_W_TOTAL_TAG: + command += " --both"; + command += " -c " + c; + break; + default: + throw new OptionException("invalid scaling type value"); + } + command += " -w " + win; + command += " -m " + min; + command += " " + bamFile; + return(command); + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index 3b5e2b86c..abd228b2b 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1443,6 +1443,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { ScalingFactorWindow frame = new ScalingFactorWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/scripts/Read_Analysis/ScalingFactor.java b/src/main/java/scriptmanager/scripts/Read_Analysis/ScalingFactor.java index aea894403..1ba59d82e 100644 --- a/src/main/java/scriptmanager/scripts/Read_Analysis/ScalingFactor.java +++ b/src/main/java/scriptmanager/scripts/Read_Analysis/ScalingFactor.java @@ -46,7 +46,7 @@ public class ScalingFactor { private File BAMFile = null; private File BLACKLISTFile = null; private File CONTROL = null; - private String OUTBASENAME = null; + private File OUT_BASENAME = null; private boolean OUTPUTSTATUS = false; private String FILEID = null; @@ -70,6 +70,10 @@ public class ScalingFactor { private String dialogMessage = null; + public static final short TOTAL_TAG = 1; + public static final short NCIS = 2; + public static final short NCIS_W_TOTAL_TAG = 3; + /** * Initialize scaling factor parameters in this constructor * @@ -97,12 +101,11 @@ public class ScalingFactor { * the NCIS parameter for the minimum fraction (only used if * scale!=1) */ - public ScalingFactor(File bamFile, File bl, File c, String out_basename, boolean out, int scale, int win, - double min) { + public ScalingFactor(File bamFile, File bl, File c, File out_basename, int scale, int win, double min, boolean out) { BAMFile = bamFile; BLACKLISTFile = bl; CONTROL = c; - OUTBASENAME = out_basename; + OUT_BASENAME = out_basename; OUTPUTSTATUS = out; scaleType = scale; windowSize = win; @@ -122,7 +125,7 @@ public void run() throws IOException { } // Load up the Control File once per run - if (scaleType != 1) { + if (scaleType != TOTAL_TAG) { System.err.println(getTimeStamp() + "\nLoading control genome array..."); initalizeGenomeMetainformation(CONTROL); Cgenome = initializeList(CONTROL, false); @@ -143,7 +146,7 @@ public void run() throws IOException { } SCALE = 1; - if (scaleType == 1) { + if (scaleType == TOTAL_TAG) { initalizeGenomeMetainformation(BAMFile); Sgenome = initializeList(BAMFile, true); double genomeSize = 0; @@ -165,13 +168,13 @@ public void run() throws IOException { System.err.println("Control tags: " + CTagcount); System.err.println("Bin count: " + Sgenome.size()); - if (scaleType == 2) { + if (scaleType == NCIS) { System.err.println("\nCalculating NCIS scaling ratio..."); - SCALE = 1 / scalingRatioByNCIS(Sgenome, Cgenome, OUTBASENAME, FILEID, minFraction); + SCALE = 1 / scalingRatioByNCIS(Sgenome, Cgenome, OUT_BASENAME, FILEID, minFraction); System.err.println("NCIS sample scaling ratio: " + SCALE); - } else if (scaleType == 3) { + } else if (scaleType == NCIS_W_TOTAL_TAG) { System.err.println("\nCalculating Total tag NCIS scaling ratio..."); - SCALE = 1 / scalingRatioByHitRatioAndNCIS(Sgenome, Cgenome, STagcount, CTagcount, OUTBASENAME, + SCALE = 1 / scalingRatioByHitRatioAndNCIS(Sgenome, Cgenome, STagcount, CTagcount, OUT_BASENAME, FILEID, minFraction); System.err.println("NCIS with Total Tag sample scaling ratio: " + SCALE); } @@ -182,15 +185,15 @@ public void run() throws IOException { // Output scaling factor is user-specified if (OUTPUTSTATUS) { - PrintStream OUT = new PrintStream(new File(OUTBASENAME + "_ScalingFactors.out")); + PrintStream OUT = new PrintStream(OUT_BASENAME + "_ScalingFactors.out"); OUT.println("Sample file:\t" + BAMFile.getCanonicalPath()); - if (scaleType == 1) { + if (scaleType == TOTAL_TAG) { OUT.println("Scaling type:\tTotalTag"); } else { OUT.println("Control file:\t" + CONTROL); - if (scaleType == 2) { + if (scaleType == NCIS) { OUT.println("Scaling type:\tNCIS"); - } else if (scaleType == 3) { + } else if (scaleType == NCIS_W_TOTAL_TAG) { OUT.println("Scaling type:\tTotalTag with NCIS"); } OUT.println("Window size (bp):\t" + windowSize); @@ -380,7 +383,7 @@ public boolean verifyFiles() throws IOException { * @param minFrac * @return */ - public double scalingRatioByNCIS(List setA, List setB, String outpath, String fileid, + public double scalingRatioByNCIS(List setA, List setB, File outpath, String fileid, double minFrac) { double scalingRatio = 1; double totalAtScaling = 0; @@ -443,7 +446,7 @@ public int compare(PairedCounts o1, PairedCounts o2) { * @return */ public double scalingRatioByHitRatioAndNCIS(List setA, List setB, double totalA, double totalB, - String outpath, String fileid, double minFrac) { + File outpath, String fileid, double minFrac) { double scalingRatio = 1; double totalAtScaling = 0; if (setA.size() != setB.size()) { @@ -542,7 +545,7 @@ public int compareByTotal(PairedCounts pc) { } - public void plotGraphs(List counts, double totalAtScaling, double scalingRatio, String outbase, + public void plotGraphs(List counts, double totalAtScaling, double scalingRatio, File outbase, String fileid, String scaletype) { // Scaling plot generation // Cumulative ratio vs bin total @@ -586,12 +589,12 @@ public void plotGraphs(List counts, double totalAtScaling, double if (OUTPUTSTATUS) { // Print data points to files try { - FileWriter Cfout = new FileWriter(outbase + "." + scaletype + "_scaling-ccr.count"); + FileWriter Cfout = new FileWriter(outbase.getAbsolutePath() + "." + scaletype + "_scaling-ccr.count"); for (int d = 0; d < bintotals.size(); d++) { Cfout.write(bintotals.get(d) + "\t" + ratios.get(d) + "\n"); } Cfout.close(); - FileWriter Mfout = new FileWriter(outbase + "." + scaletype + "_scaling-marginal.count"); + FileWriter Mfout = new FileWriter(outbase.getAbsolutePath() + "." + scaletype + "_scaling-marginal.count"); for (int d = 0; d < bintot.size(); d++) { Mfout.write(bintot.get(d) + "\t" + mratios.get(d) + "\n"); } diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorOutput.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorOutput.java index c7e30d3a0..a5605560a 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorOutput.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorOutput.java @@ -4,7 +4,9 @@ import java.awt.Dimension; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import javax.swing.JFrame; import javax.swing.JLayeredPane; @@ -15,6 +17,9 @@ import javax.swing.SpringLayout; import scriptmanager.util.ExtensionFileFilter; +import scriptmanager.cli.Read_Analysis.ScalingFactorCLI; +import scriptmanager.objects.LogItem; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.scripts.Read_Analysis.ScalingFactor; @SuppressWarnings("serial") @@ -24,7 +29,7 @@ public class ScalingFactorOutput extends JFrame { private File BLACKLISTFile = null; private File CONTROL = null; private File OUT_DIR = null; - private boolean OUTPUTSTATUS = false; + private boolean OUTPUT_STATUS = false; private int scaleType = -1; private int windowSize = 500; @@ -37,8 +42,7 @@ public class ScalingFactorOutput extends JFrame { final JTabbedPane tabbedPane_CummulativeScatterplot; final JTabbedPane tabbedPane_MarginalScatterplot; - public ScalingFactorOutput(ArrayList b, File bl, File c, File out_dir, boolean out, int scale, int win, - double min) { + public ScalingFactorOutput(ArrayList b, File bl, File c, File out_dir, int scale, int win, double min, boolean out) { setTitle("Scaling Factor"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(150, 150, 800, 800); @@ -59,7 +63,7 @@ public ScalingFactorOutput(ArrayList b, File bl, File c, File out_dir, boo BLACKLISTFile = bl; CONTROL = c; OUT_DIR = out_dir; - OUTPUTSTATUS = out; + OUTPUT_STATUS = out; scaleType = scale; windowSize = win; minFraction = min; @@ -72,19 +76,30 @@ public ScalingFactorOutput(ArrayList b, File bl, File c, File out_dir, boo } } - public void run() throws IOException { + public void run() throws OptionException, IOException { + LogItem old_li = null; for (int z = 0; z < BAMFiles.size(); z++) { - File SAMPLE = BAMFiles.get(z); // Pull current BAM file - - String OUTBASE = ExtensionFileFilter.stripExtension(SAMPLE); - if(OUT_DIR != null) { - OUTBASE = OUT_DIR.getAbsolutePath() + File.separator + OUTBASE; + // Pull current BAM file + File SAMPLE = BAMFiles.get(z); + // Construct output basename + String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(SAMPLE); + File OUT_BASENAME = new File(NAME); + if (OUT_DIR != null) { + OUT_BASENAME = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } - ScalingFactor script_obj = new ScalingFactor(SAMPLE, BLACKLISTFile, CONTROL, OUTBASE, OUTPUTSTATUS, - scaleType, windowSize, minFraction); + // Initialize LogItem + String command = ScalingFactorCLI.getCLIcommand(SAMPLE, BLACKLISTFile, CONTROL, OUT_BASENAME, scaleType, windowSize, minFraction); + LogItem new_li = new LogItem(command); + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, new_li); } + // Execute script + ScalingFactor script_obj = new ScalingFactor(SAMPLE, BLACKLISTFile, CONTROL, OUT_BASENAME, scaleType, windowSize, minFraction, OUTPUT_STATUS); script_obj.run(); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Update display SCALINGFACTORS.add(script_obj.getScalingFactor()); if (script_obj.getDialogMessage() != null) { @@ -98,9 +113,11 @@ public void run() throws IOException { tabbedPane_CummulativeScatterplot.add(SAMPLE.getName(), script_obj.getCCPlot()); tabbedPane_MarginalScatterplot.add(SAMPLE.getName(), script_obj.getMPlot()); } - firePropertyChange("scale", z, (z + 1)); + // Update progress + firePropertyChange("progress", z, (z + 1)); } - + // Update log after final input + if (OUTPUT_STATUS) { firePropertyChange("log", old_li, null); } // Make frame visible at completion of correlations if not already visible if (!this.isVisible()) { this.setVisible(true); diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java index 07029a3dc..79dbc839c 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java @@ -35,8 +35,11 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.FileSelection; +import scriptmanager.scripts.Read_Analysis.ScalingFactor; + @SuppressWarnings("serial") public class ScalingFactorWindow extends JFrame implements ActionListener, PropertyChangeListener { private JPanel contentPane; @@ -76,45 +79,58 @@ public class ScalingFactorWindow extends JFrame implements ActionListener, Prope */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { - if (BAMFiles.size() < 1) { - JOptionPane.showMessageDialog(null, "No BAM Files Loaded!!!"); - } else if (!rdbtnTotalTag.isSelected() && lblNoControlLoaded.getText().equals("No Control Loaded")) { - JOptionPane.showMessageDialog(null, "No Control File Loaded!!!"); - } else if (!rdbtnTotalTag.isSelected() && Integer.parseInt(txtWindow.getText()) <= 0) { - JOptionPane.showMessageDialog(null, "Invalid Window Size Selected!!!"); - } else if (!rdbtnTotalTag.isSelected() && (Double.parseDouble(txtFraction.getText()) >= 1 - || Double.parseDouble(txtFraction.getText()) <= 0)) { - JOptionPane.showMessageDialog(null, "Invalid Minimum Fraction Selected!!! Must be between 0 & 1"); - } else { - setProgress(0); - - int scaleType = 0; - if (rdbtnTotalTag.isSelected()) { - scaleType = 1; - CONTROL = null; - } else if (rdbtnNCIS.isSelected()) { - scaleType = 2; - } else if (rdbtnNcisWithTotal.isSelected()) { - scaleType = 3; - } - - ScalingFactorOutput scale = new ScalingFactorOutput(BAMFiles, BLACKLIST, CONTROL, - OUT_DIR, chckbxOutputStatistics.isSelected(), scaleType, - Integer.parseInt(txtWindow.getText()), Double.parseDouble(txtFraction.getText())); - scale.addPropertyChangeListener("scale", new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent propertyChangeEvent) { - int temp = (Integer) propertyChangeEvent.getNewValue(); - int percentComplete = (int) (((double) (temp) / BAMFiles.size()) * 100); - setProgress(percentComplete); + public Void doInBackground() { + try { + if (BAMFiles.size() < 1) { + JOptionPane.showMessageDialog(null, "No BAM Files Loaded!!!"); + } else if (!rdbtnTotalTag.isSelected() && lblNoControlLoaded.getText().equals("No Control Loaded")) { + JOptionPane.showMessageDialog(null, "No Control File Loaded!!!"); + } else if (!rdbtnTotalTag.isSelected() && Integer.parseInt(txtWindow.getText()) <= 0) { + JOptionPane.showMessageDialog(null, "Invalid Window Size Selected!!!"); + } else if (!rdbtnTotalTag.isSelected() && (Double.parseDouble(txtFraction.getText()) >= 1 + || Double.parseDouble(txtFraction.getText()) <= 0)) { + JOptionPane.showMessageDialog(null, "Invalid Minimum Fraction Selected!!! Must be between 0 & 1"); + } else { + setProgress(0); + + int scaleType = 0; + if (rdbtnTotalTag.isSelected()) { + scaleType = ScalingFactor.TOTAL_TAG; + CONTROL = null; + } else if (rdbtnNCIS.isSelected()) { + scaleType = ScalingFactor.NCIS; + } else if (rdbtnNcisWithTotal.isSelected()) { + scaleType = ScalingFactor.NCIS_W_TOTAL_TAG; } - }); - // scale.setVisible(true); - scale.run(); - - setProgress(100); - JOptionPane.showMessageDialog(null, "All Scaling Factors Calculated"); + // Execute script + ScalingFactorOutput output_obj = new ScalingFactorOutput(BAMFiles, BLACKLIST, CONTROL, + OUT_DIR, scaleType, Integer.parseInt(txtWindow.getText()), + Double.parseDouble(txtFraction.getText()), chckbxOutputStatistics.isSelected()); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent propertyChangeEvent) { + int temp = (Integer) propertyChangeEvent.getNewValue(); + int percentComplete = (int) (((double) (temp) / BAMFiles.size()) * 100); + setProgress(percentComplete); + } + }); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); + output_obj.run(); + output_obj.setVisible(true); + JOptionPane.showMessageDialog(null, "All Scaling Factors Calculated"); + } + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (OptionException oe) { + oe.printStackTrace(); + JOptionPane.showMessageDialog(null, oe.getMessage()); } + // Update progress + setProgress(100); return null; } @@ -406,10 +422,13 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From 9bc550efc3125ee7e86043441c9d135ec52c7475 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Wed, 15 Nov 2023 10:10:20 -0500 Subject: [PATCH 44/58] add logging to ScaleMatrix ScriptManagerGUI - add property change listener ScaleMatrixCLI - add getCLIcommand() with javadocs FourColorSequenceWindow - initialize log item and update log item code blocks - add log property change listener - add GUI handling of various exceptions thrown by script class for consistency with other tools - standardize output filename construction for consistency with other tools --- .../cli/Read_Analysis/ScaleMatrixCLI.java | 20 +++++++ .../scriptmanager/main/ScriptManagerGUI.java | 11 ++++ .../Read_Analysis/ScaleMatrixWindow.java | 55 +++++++++++++------ 3 files changed, 70 insertions(+), 16 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Read_Analysis/ScaleMatrixCLI.java b/src/main/java/scriptmanager/cli/Read_Analysis/ScaleMatrixCLI.java index 603be37b0..11c4cf7c3 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/ScaleMatrixCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/ScaleMatrixCLI.java @@ -85,4 +85,24 @@ private String validateInput() throws IOException { return(r); } + + /** + * Reconstruct CLI command + * + * @param input the tab-delimited matrix file to scale + * @param output the output file for the scaled matrix + * @param scalingFactor the factor to scale the matrix by + * @param rowStart the matrix row start + * @param colStart the matrix col start + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, File output, double scalingFactor, int rowStart, int colStart) { + String command = "java -jar $SCRIPTMANAGER read-analysis scale-matrix"; + command += " " + input.getAbsolutePath(); + command += " -o " + output.getAbsolutePath(); + command += " -s " + scalingFactor; + command += " -r " + rowStart; + command += " -l " + colStart; + return command; + } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index abd228b2b..c0a923177 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -1486,6 +1486,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { ScaleMatrixWindow frame = new ScaleMatrixWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java index 214d175d2..368fd9450 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java @@ -18,7 +18,9 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import java.util.StringTokenizer; import javax.swing.ButtonGroup; @@ -41,8 +43,11 @@ import javax.swing.border.EmptyBorder; import javax.swing.table.DefaultTableModel; +import scriptmanager.objects.LogItem; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; + +import scriptmanager.cli.Read_Analysis.ScaleMatrixCLI; import scriptmanager.scripts.Read_Analysis.ScaleMatrix; @SuppressWarnings("serial") @@ -78,7 +83,7 @@ public class ScaleMatrixWindow extends JFrame implements ActionListener, Propert */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { if (TABFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No Files Loaded!!!"); @@ -93,45 +98,60 @@ public Void doInBackground() throws IOException { try { Double.parseDouble(expTable.getValueAt(x, 1).toString()); } catch (NumberFormatException e) { - JOptionPane.showMessageDialog(null, - TABFiles.get(x).getName() + " possesses an invalid scaling factor!!!"); + JOptionPane.showMessageDialog(null, TABFiles.get(x).getName() + " possesses an invalid scaling factor!!!"); ALLNUM = false; } } - + // Loop through matrix files with valid scaling factors if (ALLNUM) { setProgress(0); double SCALE = 0; if (rdbtnUniformScaling.isSelected()) { SCALE = Double.parseDouble(txtUniform.getText()); } - + LogItem old_li = null; for (int x = 0; x < TABFiles.size(); x++) { - if (rdbtnFilespecifcScaling.isSelected()) { - SCALE = Double.parseDouble(expTable.getValueAt(x, 1).toString()); - } - + // Pull input file File XTAB = TABFiles.get(x); - String OUTPUT = ExtensionFileFilter.stripExtension(XTAB) + "_SCALE." - + ExtensionFileFilter.getExtension(XTAB); + // Construct output filename + String NAME = ExtensionFileFilter.stripExtension(XTAB) + "_SCALE." + ExtensionFileFilter.getExtension(XTAB); + File OUT_FILEPATH = new File(NAME); if (OUT_DIR != null) { - OUTPUT = OUT_DIR + File.separator + OUTPUT; + OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } - - ScaleMatrix scale = new ScaleMatrix(XTAB, new File(OUTPUT), SCALE, - Integer.parseInt(txtRow.getText()), Integer.parseInt(txtCol.getText())); + // Determine out scaling factor + if (rdbtnFilespecifcScaling.isSelected()) { + SCALE = Double.parseDouble(expTable.getValueAt(x, 1).toString()); + } + // Initialize LogItem + String command = ScaleMatrixCLI.getCLIcommand(XTAB, OUT_FILEPATH, SCALE, Integer.parseInt(txtRow.getText()), Integer.parseInt(txtCol.getText())); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script + ScaleMatrix scale = new ScaleMatrix(XTAB, OUT_FILEPATH, SCALE, Integer.parseInt(txtRow.getText()), Integer.parseInt(txtCol.getText())); scale.run(); - + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Update progress int percentComplete = (int) (((double) (x + 1) / TABFiles.size()) * 100); setProgress(percentComplete); } + // Update log after final input + firePropertyChange("log", old_li, null); + // Update progress setProgress(100); JOptionPane.showMessageDialog(null, "All Matrices Scaled"); } } } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "Invalid Scaling Factor!!! Must be number"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } + setProgress(100); return null; } @@ -359,10 +379,13 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From e2d6408927ca6f1ad4420642472cae0eac1bab1f Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 15:31:54 -0500 Subject: [PATCH 45/58] fix downstream merge bugs --- .../cli/BAM_Statistics/PEStatsCLI.java | 2 +- .../BED_Manipulation/BEDtoGFFCLI.java | 10 +++++----- .../BED_Manipulation/ExpandBEDCLI.java | 8 ++++---- .../BED_Manipulation/SortBEDCLI.java | 19 +++++++++---------- .../GFF_Manipulation/ExpandGFFCLI.java | 7 ++++--- .../GFF_Manipulation/GFFtoBEDCLI.java | 6 ++++-- .../GFF_Manipulation/SortGFFCLI.java | 16 ++++++++-------- .../ShiftCoordCLI.java | 7 ++++--- .../Sequence_Analysis/DNAShapefromBEDCLI.java | 4 +++- .../DNAShapefromFASTACLI.java | 4 +++- .../BAM_Manipulation/BAMMarkDuplicates.java | 1 - .../BED_Manipulation/BEDtoGFF.java | 4 ++-- .../BED_Manipulation/ExpandBED.java | 4 ++-- .../BED_Manipulation/SortBED.java | 8 ++++---- .../GFF_Manipulation/ExpandGFF.java | 4 ++-- .../GFF_Manipulation/GFFtoBED.java | 2 +- .../GFF_Manipulation/SortGFF.java | 12 ++++++------ .../Coordinate_Manipulation/ShiftCoord.java | 4 ++-- .../BAM_Manipulation/BAIIndexerWindow.java | 6 +++--- .../BED_Manipulation/BEDtoGFFWindow.java | 7 +++---- .../BED_Manipulation/ExpandBEDWindow.java | 7 +++---- .../BED_Manipulation/SortBEDWindow.java | 8 ++++---- .../GFF_Manipulation/ExpandGFFWindow.java | 4 ++-- .../DNAShapefromFASTAOutput.java | 2 +- 24 files changed, 80 insertions(+), 76 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java index 171c43586..ff241c6ad 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java @@ -55,7 +55,7 @@ public Integer call() throws Exception { System.exit(1); } - PEStats.getPEStats( outputBasename, bamFile, dup, MIN_INSERT, MAX_INSERT, null, null, sum); + PEStats.getPEStats(bamFile, outputBasename, dup, MIN_INSERT, MAX_INSERT, null, null, sum); System.err.println("Calculations Complete"); return(0); diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java index 19edf73b1..2aa517c64 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFCLI.java @@ -55,7 +55,7 @@ public Integer call() throws Exception { System.exit(1); } - BEDtoGFF.convertBEDtoGFF(output, bedFile, gzOutput); + BEDtoGFF.convertBEDtoGFF(bedFile, output, gzOutput); System.err.println("Conversion Complete"); return(0); @@ -92,16 +92,16 @@ private String validateInput() throws IOException { /** * Returns the CLI command for replicating results with Script Manager - * @param OUTPUT Output GFF file * @param BED Bed file to be converted - * @param gzOutput If output should be zipped + * @param OUTPUT Output GFF file + * @param gzOutput whether or not to gzip output * @return The CLI command for replicating results */ - public static String getCLIcommand(File OUTPUT, File BED, boolean gzOutput) { + public static String getCLIcommand(File BED, File OUTPUT, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation bed-to-gff"; command += " " + BED.getAbsolutePath(); - command += gzOutput ? " -z" : ""; command += " -o " + OUTPUT; + command += gzOutput ? " -z " : ""; return(command); } } diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java index 521839976..42bcbcbea 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/ExpandBEDCLI.java @@ -68,7 +68,7 @@ public Integer call() throws Exception { System.exit(1); } - ExpandBED.expandBEDBorders(output, bedFile, SIZE, byCenter, gzOutput); + ExpandBED.expandBEDBorders(bedFile, output, SIZE, byCenter, gzOutput); System.err.println("Expansion Complete"); return(0); @@ -127,11 +127,11 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File bedFile, File output, int size, boolean gzOutput, boolean byCenter) { + public static String getCLIcommand(File input, File output, int size, boolean byCenter, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation expand-bed"; - command += " " + bedFile.getAbsolutePath(); - command += gzOutput ? " -z " : ""; + command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); + command += gzOutput ? " -z " : ""; command += byCenter ? " -c " + size : " -b " + size; return command; } diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java index 324fde2c7..dc49f88be 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/BED_Manipulation/SortBEDCLI.java @@ -35,7 +35,7 @@ public class SortBEDCLI implements Callable { private File cdtFile; @Option(names = {"-o", "--output"}, description = "specify output file basename with no .cdt/.bed/.jtv extension (default=_SORT") - private String outputBasename = null; + private File outputBasename = null; @Option(names = {"-c", "--center"}, description = "sort by center on the input size of expansion in bins (default=100)") private int center = -999; @Option(names = {"-z", "--gzip"}, description = "gzip output (default=false)") @@ -66,7 +66,7 @@ public Integer call() throws Exception { index[1] = (CDT_SIZE / 2) + (center / 2); } - SortBED.sortBEDbyCDT(outputBasename, bedFile, cdtFile, index[0], index[1], gzOutput); + SortBED.sortBEDbyCDT(bedFile, cdtFile, outputBasename, index[0], index[1], gzOutput); System.err.println("Sort Complete"); return(0); @@ -93,16 +93,15 @@ private String validateInput() throws IOException { //set default output filename if(outputBasename==null){ - outputBasename = ExtensionFileFilter.stripExtensionIgnoreGZ(bedFile) + "_SORT"; + outputBasename = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(bedFile) + "_SORT"); //check output filename is valid }else{ //no extension check //check directory - File BASEFILE = new File(outputBasename); - if(BASEFILE.getParent()==null){ + if(outputBasename.getParent()==null){ // System.err.println("default to current directory"); - } else if(!new File(BASEFILE.getParent()).exists()){ - r += "(!)Check output directory exists: " + BASEFILE.getParent() + "\n"; + } else if(!new File(outputBasename.getParent()).exists()){ + r += "(!)Check output directory exists: " + outputBasename.getParent() + "\n"; } } @@ -124,13 +123,13 @@ else if( center<0 ){ return(r); } - public static String getCLIcommand(File OUTPUT, File BED, File CDT, int startidx, int stopidx, boolean gzOutput) { + public static String getCLIcommand(File input, File CDT, File OUTPUT, int startidx, int stopidx, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation sort-bed"; - command += " " + BED.getAbsolutePath(); + command += " " + input.getAbsolutePath(); command += " " + CDT.getAbsolutePath(); command += " -x " + startidx + " " + stopidx; - command += gzOutput ? " -z" : ""; command += " -o " + OUTPUT.getAbsolutePath(); + command += gzOutput ? " -z" : ""; return command; } } diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java index 44124fd16..97b05af50 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFCLI.java @@ -69,7 +69,7 @@ public Integer call() throws Exception { System.exit(1); } - ExpandGFF.expandGFFBorders(output, gffFile, SIZE, byCenter, gzOutput); + ExpandGFF.expandGFFBorders(gffFile, output, SIZE, byCenter, gzOutput); System.err.println("Expansion Complete"); return(0); @@ -131,10 +131,11 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File bedFile, File output, int size, boolean byCenter) { + public static String getCLIcommand(File input, File output, int size, boolean byCenter, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation expand-gff"; - command += " " + bedFile.getAbsolutePath(); + command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); + command += gzOutput ? " -z " : ""; command += byCenter ? " -c " + size : " -b " + size; return command; } diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java index 5c7f0b5d1..fea4710e5 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java @@ -51,7 +51,7 @@ public Integer call() throws Exception { System.exit(1); } - GFFtoBED.convertGFFtoBED(output, gffFile, gzOutput); + GFFtoBED.convertGFFtoBED(gffFile, output, gzOutput); System.err.println("Conversion Complete"); return(0); @@ -83,10 +83,12 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File GFF, File output) { + + public static String getCLIcommand(File GFF, File output, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation gff-to-bed"; command += " " + GFF.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); + command += gzOutput ? " -z " : ""; return command; } } diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java index fdf5f03e2..3bcf7b55e 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/GFF_Manipulation/SortGFFCLI.java @@ -35,7 +35,7 @@ public class SortGFFCLI implements Callable { private File cdtFile; @Option(names = {"-o", "--output"}, description = "specify output file basename with no .cdt/.gff/.jtv extension (default=_SORT") - private String outputBasename = null; + private File outputBasename = null; @Option(names = {"-z", "--gzip"}, description = "gzip output (default=false)") private boolean gzOutput = false; @Option(names = {"-c", "--center"}, description = "sort by center on the input size of expansion in bins (default=100)") @@ -66,7 +66,7 @@ public Integer call() throws Exception { index[1] = (CDT_SIZE / 2) + (center / 2); } - SortGFF.sortGFFbyCDT(outputBasename, gffFile, cdtFile, index[0], index[1], gzOutput); + SortGFF.sortGFFbyCDT(gffFile, cdtFile, outputBasename, index[0], index[1], gzOutput); System.err.println("Sort Complete"); return(0); @@ -100,16 +100,15 @@ private String validateInput() throws IOException { //set default output filename if(outputBasename==null){ - outputBasename = ExtensionFileFilter.stripExtensionIgnoreGZ(gffFile) + "_SORT"; + outputBasename = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(gffFile) + "_SORT"); //check output filename is valid }else{ //no extension check //check directory - File BASEFILE = new File(outputBasename); - if(BASEFILE.getParent()==null){ + if(outputBasename.getParent()==null){ // System.err.println("default to current directory"); - } else if(!new File(BASEFILE.getParent()).exists()){ - r += "(!)Check output directory exists: " + BASEFILE.getParent() + "\n"; + } else if(!new File(outputBasename.getParent()).exists()){ + r += "(!)Check output directory exists: " + outputBasename.getParent() + "\n"; } } @@ -130,12 +129,13 @@ else if( center<0 ){ return(r); } - public static String getCLIcommand(File OUTPUT, File BED, File CDT, int startidx, int stopidx) { + public static String getCLIcommand(File BED, File CDT, File OUTPUT, int startidx, int stopidx, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER coordinatesort-manipulation sort-gff"; command += " " + BED.getAbsolutePath(); command += " " + CDT.getAbsolutePath(); command += " -x " + startidx + " " + stopidx; command += " -o " + OUTPUT.getAbsolutePath(); + command += gzOutput ? " -z " : ""; return command; } } \ No newline at end of file diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java index 167095138..150cb1677 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java @@ -56,9 +56,9 @@ public Integer call() throws Exception { } if(isGFF) { - ShiftCoord.shiftGFFInterval(new File(outputFilepath), input, shift, stranded, gzOutput); + ShiftCoord.shiftGFFInterval(input, new File(outputFilepath), shift, stranded, gzOutput); } else { - ShiftCoord.shiftBEDInterval(new File(outputFilepath), input, shift, stranded, gzOutput); + ShiftCoord.shiftBEDInterval(input, new File(outputFilepath), shift, stranded, gzOutput); } System.err.println("Shift Complete"); @@ -92,7 +92,8 @@ private String validateInput() throws IOException { } return(r); } - public static String getCLIcommand(File input, File output, int shift, boolean stranded, boolean gzOutput, boolean isGFF) { + + public static String getCLIcommand(File input, File output, int shift, boolean stranded, boolean isGFF, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation shift-coord"; command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java index 675661214..c7e9ec51c 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java @@ -185,11 +185,13 @@ private String validateInput() throws IOException { * @param type a four-element boolean list for specifying shape type to output * (no enforcement on size) * @param str force strandedness (true=forced, false=not forced) + * @param gzOutput whether or not to gzip output * @return command line to execute with formatted inputs */ - public static String getCLIcommand(File gen, File input, String out, boolean[] type, boolean str) { + public static String getCLIcommand(File gen, File input, String out, boolean[] type, boolean str, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER sequence-analysis dna-shape-bed"; command += " -o " + out; + command += gzOutput ? " -z " : ""; command += type[0] ? " --groove" : ""; command += type[1] ? " --propeller" : ""; command += type[2] ? " --helical" : ""; diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java index ef288638b..98c8b90ac 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java @@ -175,11 +175,13 @@ private String validateInput() throws IOException { * to) * @param type a four-element boolean list for specifying shape type to output * (no enforcement on size) + * @param gzOutput whether or not to gzip output * @return command line to execute with formatted inputs */ - public static String getCLIcommand(File fa, String out, boolean[] type) { + public static String getCLIcommand(File fa, String out, boolean[] type, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER sequence-analysis dna-shape-fasta"; command += " -o " + out; + command += gzOutput ? " -z " : ""; command += type[0] ? " --groove" : ""; command += type[1] ? " --propeller" : ""; command += type[2] ? " --helical" : ""; diff --git a/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java b/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java index 5de200ec4..b7c4973e8 100644 --- a/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java +++ b/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java @@ -15,7 +15,6 @@ * @see scriptmanager.window_interface.BAM_Manipulation.BAMMarkDupWindow */ public class BAMMarkDuplicates { - /** * Runs MarkDuplicates picard tool * @param in BAM file to be marked diff --git a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/BEDtoGFF.java b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/BEDtoGFF.java index 9ef63b830..dbf5bf02b 100644 --- a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/BEDtoGFF.java +++ b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/BEDtoGFF.java @@ -20,12 +20,12 @@ public class BEDtoGFF { /** * Read the BED-formatted input file and write it as a GFF-formatted output file. * - * @param outpath the filepath destination of the GFF-formatted output * @param input the BED-formatted file to convert + * @param outpath the filepath destination of the GFF-formatted output * @param gzOutput If this is true, the output file will be gzipped. * @throws IOException Invalid file or parameters */ - public static void convertBEDtoGFF(File outpath, File input, boolean gzOutput) throws IOException { + public static void convertBEDtoGFF(File input, File outpath, boolean gzOutput) throws IOException { // chr22 TeleGene enhancer 10000000 10001000 500 + . touch1 // Initialize output writer PrintStream OUT = System.out; diff --git a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/ExpandBED.java b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/ExpandBED.java index b3df63241..bbd2e9909 100644 --- a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/ExpandBED.java +++ b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/ExpandBED.java @@ -20,14 +20,14 @@ public class ExpandBED { /** * Self-contained method for expanding the BED-formatted intervals in a BED file by user-specified distance and strategy. This method accounts for even-sized BED interval expansion in midpoint calculations by using the strand-aware downstream nucleotide between the two center nucleotides. * - * @param out_filepath Filepath to save expanded BED-formatted files. If null, outputs to STDOUT. * @param input Filepath to starting BED-formatted coordinates we want to shift. Supports automatic detection and handling of GZipped BED-formatted files. Must have at least 3 tab-delimited columns per BED specifications. + * @param out_filepath Filepath to save expanded BED-formatted files. If null, outputs to STDOUT. * @param SIZE Integer value indicating number of nucleotides to expand by (must be a positive integer). * @param ExCenter Specifies expansion strategy: if true, size expansion will be performed from the midpoint of each BED interval, if false, size expansion will be performed from the border/edges of the BED intervals (default=true). * @param gzOutput If this is true, the output file will be gzipped. * @throws IOException Invalid file or parameters */ - public static void expandBEDBorders(File out_filepath, File input, int SIZE, boolean ExCenter, boolean gzOutput ) throws IOException { + public static void expandBEDBorders(File input, File out_filepath, int SIZE, boolean ExCenter, boolean gzOutput ) throws IOException { // Initialize output writer PrintStream OUT = System.out; if (out_filepath != null) { diff --git a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/SortBED.java b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/SortBED.java index 54abee939..3474fa41e 100644 --- a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/SortBED.java +++ b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/BED_Manipulation/SortBED.java @@ -22,15 +22,15 @@ public class SortBED { /** * Sort a BED file by the values from a CDT matrix file. Includes Gzip support. * - * @param outbase Filepath basename (without ext) to save the sorted BED (<basename>.bed) and sorted CDT (<basename>.cdt) files. * @param bed input BED file to sort * @param cdt input CDT file with values to sort by + * @param outbase Filepath basename (without ext) to save the sorted BED (<basename>.bed) and sorted CDT (<basename>.cdt) files. * @param START_INDEX the start column to consider when summing values to sort * @param STOP_INDEX * @param gzOutput if true, the output files will be gzipped. * @throws IOException Invalid file or parameters */ - public static void sortBEDbyCDT(String outbase, File bed, File cdt, int START_INDEX, int STOP_INDEX, boolean gzOutput ) throws IOException { + public static void sortBEDbyCDT(File bed, File cdt, File outbase, int START_INDEX, int STOP_INDEX, boolean gzOutput ) throws IOException { ArrayList SORT = new ArrayList(); HashMap CDTFile = new HashMap(); String CDTHeader = ""; @@ -59,7 +59,7 @@ public static void sortBEDbyCDT(String outbase, File bed, File cdt, int START_IN PrintStream OUT; // Initialize output writer String suffix = ".cdt" + (gzOutput? ".gz": ""); - OUT = GZipUtilities.makePrintStream(new File(outbase + suffix), gzOutput); + OUT = GZipUtilities.makePrintStream(new File(outbase.getCanonicalPath() + suffix), gzOutput); // Output sorted CDT File OUT.println(CDTHeader); for (int x = 0; x < SORT.size(); x++) { @@ -86,7 +86,7 @@ public static void sortBEDbyCDT(String outbase, File bed, File cdt, int START_IN // Initialize output writer suffix = ".bed" + (gzOutput? ".gz": ""); - OUT = GZipUtilities.makePrintStream(new File(outbase + suffix), gzOutput); + OUT = GZipUtilities.makePrintStream(new File(outbase.getCanonicalPath() + suffix), gzOutput); // Output sorted BED File for (int x = 0; x < SORT.size(); x++) { OUT.println(BEDFile.get(SORT.get(x).getName())); diff --git a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/ExpandGFF.java b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/ExpandGFF.java index de33358f2..665815686 100644 --- a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/ExpandGFF.java +++ b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/ExpandGFF.java @@ -24,14 +24,14 @@ public ExpandGFF(){} /** * Self-contained method for expanding the GFF-formatted intervals in a GFF file by user-specified distance and strategy. This method accounts for even-sized GFF interval expansion in midpoint calculations by using the strand-aware downstream nucleotide between the two center nucleotides. * - * @param out_filepath Filepath to save expanded GFF-formatted files. If null, outputs to STDOUT. * @param input Filepath to starting GFF-formatted coordinates we want to shift. Supports automatic detection and handling of GZipped GFF-formatted files. Must have at least 3 tab-delimited columns per GFF specifications. + * @param out_filepath Filepath to save expanded GFF-formatted files. If null, outputs to STDOUT. * @param SIZE Integer value indicating number of nucleotides to expand by (must be a positive integer). * @param ExCenter Specifies expansion strategy: if true, size expansion will be performed from the midpoint of each GFF interval, if false, size expansion will be performed from the border/edges of the GFF intervals (default=true). * @param gzOutput whether or not to gzip output * @throws IOException Invalid file or parameters */ - public static void expandGFFBorders(File out_filepath, File input, int SIZE, boolean ExCenter, boolean gzOutput) throws IOException { + public static void expandGFFBorders(File input, File out_filepath, int SIZE, boolean ExCenter, boolean gzOutput) throws IOException { // GFF: chr22 TeleGene enhancer 10000000 10001000 500 + . touch1 // GFF: chr12 bed2gff chr12_384641_384659_+ 384642 384659 42.6 + . // chr12_384641_384659_+; diff --git a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/GFFtoBED.java b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/GFFtoBED.java index 189f3ae52..34a2d138a 100644 --- a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/GFFtoBED.java +++ b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/GFFtoBED.java @@ -16,7 +16,7 @@ * @see scriptmanager.window_interface.Coordinate_Manipulation.GFF_Manipulation.GFFtoBEDWindow */ public class GFFtoBED { - public static void convertGFFtoBED(File out_filepath, File input, boolean gzOutput) throws IOException { + public static void convertGFFtoBED(File input, File out_filepath, boolean gzOutput) throws IOException { // GFF: chr22 TeleGene enhancer 10000000 10001000 500 + . touch1 // BED: chr12 605113 605120 region_0 0 + diff --git a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/SortGFF.java b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/SortGFF.java index c7356f178..f3bfbf569 100644 --- a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/SortGFF.java +++ b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/GFF_Manipulation/SortGFF.java @@ -23,14 +23,14 @@ public class SortGFF { /** * Sort a GFF file by the values from a CDT matrix file. * - * @param outname Filepath basename (without ext) to save the sorted GFF (<basename>.gff) and sorted CDT (<basename>.cdt) files. * @param gff input GFF file to sort * @param cdt input CDT file with values to sort by + * @param outname Filepath basename (without ext) to save the sorted GFF (<basename>.gff) and sorted CDT (<basename>.cdt) files. * @param START_INDEX the start column to consider when summing values to sort * @param STOP_INDEX The last column to consider when summing values (non-inclusive) * @param gzOutput whether or not to gzip output */ - public static void sortGFFbyCDT(String outname, File gff, File cdt, int START_INDEX, int STOP_INDEX, boolean gzOutput) + public static void sortGFFbyCDT(File gff, File cdt, File outname, int START_INDEX, int STOP_INDEX, boolean gzOutput) throws IOException { ArrayList SORT = new ArrayList(); HashMap CDTFile = new HashMap(); @@ -58,8 +58,8 @@ public static void sortGFFbyCDT(String outname, File gff, File cdt, int START_IN Collections.sort(SORT, GFFCoord.ScoreComparator); // Output sorted CDT File - String SUFFIX = ".cdt" + (gzOutput? ".gz": ""); - PrintStream OUT = GZipUtilities.makePrintStream(new File(outname + SUFFIX), gzOutput); + String SUFFIX = ".cdt" + (gzOutput ? ".gz": ""); + PrintStream OUT = GZipUtilities.makePrintStream(new File(outname.getCanonicalFile() + SUFFIX), gzOutput); OUT.println(CDTHeader); for (int x = 0; x < SORT.size(); x++) { OUT.println(CDTFile.get(SORT.get(x).getName())); @@ -83,8 +83,8 @@ public static void sortGFFbyCDT(String outname, File gff, File cdt, int START_IN br.close(); // Output sorted GFF File - SUFFIX = ".gff" + (gzOutput? ".gz": ""); - OUT = GZipUtilities.makePrintStream(new File(outname + SUFFIX), gzOutput); + SUFFIX = ".gff" + (gzOutput ? ".gz": ""); + OUT = GZipUtilities.makePrintStream(new File(outname.getCanonicalFile() + SUFFIX), gzOutput); for (int x = 0; x < SORT.size(); x++) { OUT.println(GFFFile.get(SORT.get(x).getName())); } diff --git a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/ShiftCoord.java b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/ShiftCoord.java index f2b80db1d..de8d7fff7 100644 --- a/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/ShiftCoord.java +++ b/src/main/java/scriptmanager/scripts/Coordinate_Manipulation/ShiftCoord.java @@ -20,14 +20,14 @@ public class ShiftCoord { /** * Shift BED-formatted intervals by a user-defined direction and distance. Includes Gzip support. * - * @param out_filepath Filepath to save shifted BED-formatted files. If null, outputs to STDOUT. * @param input Filepath to starting BED-formatted coordinates we want to shift. Supports automatic detection and handling of GZipped BED-formatted files. Must have at least 3 tab-delimited columns per BED specifications. + * @param out_filepath Filepath to save shifted BED-formatted files. If null, outputs to STDOUT. * @param SHIFT Integer value indicating number and direction of nucleotides to shift the entire intervals (negative values are upstream shifts while positive values are downstream shifts) * @param stranded If this is true, then the stranded-ness of features is taken into account for the directionality of the shift. Otherwise all upstream shifts move intervals to the left and all downstream shifts move to the right with respect to the reference. * @param gzOutput If this is true, the output file will be gzipped. * @throws IOException Invalid file or parameters */ - public static void shiftBEDInterval(File out_filepath, File input, int SHIFT, boolean stranded, boolean gzOutput) throws IOException { + public static void shiftBEDInterval(File input, File out_filepath, int SHIFT, boolean stranded, boolean gzOutput) throws IOException { // Initialize output writer PrintStream OUT = System.out; if (out_filepath != null) { diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java index fd6bf541e..2284c567a 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAIIndexerWindow.java @@ -176,7 +176,7 @@ public void actionPerformed(ActionEvent arg0) { btnIndex.addActionListener(this); } -/** + /** * Runs when a task is invoked, making window non-interactive and executing the task. */ @Override @@ -200,9 +200,9 @@ public void propertyChange(PropertyChangeEvent evt) { } else if ("log" == evt.getPropertyName()) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } - } + } - /** + /** * Makes the content pane non-interactive If the window should be interactive data * @param con Content pane to make non-interactive * @param status If the window should be interactive diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java index b4e3bf482..fa1a5694f 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java @@ -79,22 +79,21 @@ public class BEDtoGFFWindow extends JFrame implements ActionListener, PropertyCh class Task extends SwingWorker { @Override public Void doInBackground() throws IOException { - boolean GZIP = chckbxGzipOutput.isSelected(); setProgress(0); LogItem old_li = new LogItem(""); for (int x = 0; x < BEDFiles.size(); x++) { File XBED = BEDFiles.get(x); // Set outfilepath - String OUTPUT = ExtensionFileFilter.stripExtensionIgnoreGZ(XBED) + ".gff" + (GZIP? ".gz": ""); + String OUTPUT = ExtensionFileFilter.stripExtensionIgnoreGZ(XBED) + ".gff" + (chckbxGzipOutput.isSelected()? ".gz": ""); if (OUT_DIR != null) { OUTPUT = OUT_DIR + File.separator + OUTPUT; } // Initialize LogItem - String command = BEDtoGFFCLI.getCLIcommand(new File(OUTPUT), XBED, GZIP); + String command = BEDtoGFFCLI.getCLIcommand(XBED, new File(OUTPUT), chckbxGzipOutput.isSelected()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute conversion and update progress - BEDtoGFF.convertBEDtoGFF(new File(OUTPUT), XBED, GZIP); + BEDtoGFF.convertBEDtoGFF(XBED, new File(OUTPUT), chckbxGzipOutput.isSelected()); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java index d156909b2..fcf160b48 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java @@ -94,7 +94,6 @@ public Void doInBackground() throws IOException { if (SIZE < 1) { JOptionPane.showMessageDialog(null, "Invalid Expansion Size!!! Must be larger than 0 bp"); } else { - boolean GZIP = chckbxGzipOutput.isSelected(); setProgress(0); LogItem old_li = new LogItem(""); for (int x = 0; x < BEDFiles.size(); x++) { @@ -107,14 +106,14 @@ public Void doInBackground() throws IOException { OUTPUT = OUT_DIR + File.separator + OUTPUT; } // Add suffix - OUTPUT += "_" + Integer.toString(SIZE) + "bp.bed" + (GZIP? ".gz": ""); + OUTPUT += "_" + Integer.toString(SIZE) + "bp.bed" + (chckbxGzipOutput.isSelected() ? ".gz": ""); // Initialize LogItem - String command = ExpandBEDCLI.getCLIcommand(XBED, new File(OUTPUT), SIZE, chckbxGzipOutput.isSelected(), rdbtnExpandFromCenter.isSelected()); + String command = ExpandBEDCLI.getCLIcommand(XBED, new File(OUTPUT), SIZE, rdbtnExpandFromCenter.isSelected(), chckbxGzipOutput.isSelected()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute expansion and update progress - ExpandBED.expandBEDBorders(new File(OUTPUT), XBED, SIZE, rdbtnExpandFromCenter.isSelected(), GZIP); + ExpandBED.expandBEDBorders(new File(OUTPUT), XBED, SIZE, rdbtnExpandFromCenter.isSelected(), chckbxGzipOutput.isSelected()); int percentComplete = (int) (((double) (x + 1) / BEDFiles.size()) * 100); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java index 3d3ba6bf9..9ec30fc1c 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java @@ -124,13 +124,13 @@ public Void doInBackground() throws IOException { } setProgress(0); - LogItem old_li = new LogItem(""); + LogItem old_li = null; // Initialize LogItem - String command = SortBEDCLI.getCLIcommand(new File(OUTPUT), BED_File, CDT_File, START_INDEX, STOP_INDEX, chckbxGzipOutput.isSelected()); + String command = SortBEDCLI.getCLIcommand(BED_File, CDT_File, new File(OUTPUT), START_INDEX, STOP_INDEX, chckbxGzipOutput.isSelected()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); - // Execute Wrapper - SortBED.sortBEDbyCDT(OUTPUT, BED_File, CDT_File, START_INDEX, STOP_INDEX, chckbxGzipOutput.isSelected()); + // Execute script + SortBED.sortBEDbyCDT(BED_File, CDT_File, new File(OUTPUT), START_INDEX, STOP_INDEX, chckbxGzipOutput.isSelected()); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java index 88df20aa8..dca17105f 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java @@ -103,11 +103,11 @@ public Void doInBackground() throws IOException { OUTPUT = OUT_DIR + File.separator + OUTPUT; } // Initialize LogItem - String command = ExpandGFFCLI.getCLIcommand(XGFF, new File(OUTPUT), SIZE, rdbtnExpandFromCenter.isSelected()); + String command = ExpandGFFCLI.getCLIcommand(XGFF, new File(OUTPUT), SIZE, rdbtnExpandFromCenter.isSelected(), chckbxGzipOutput.isSelected()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute expansion and update progress - ExpandGFF.expandGFFBorders(new File(OUTPUT), XGFF, SIZE, rdbtnExpandFromCenter.isSelected(), chckbxGzipOutput.isSelected()); + ExpandGFF.expandGFFBorders(XGFF, new File(OUTPUT), SIZE, rdbtnExpandFromCenter.isSelected(), chckbxGzipOutput.isSelected()); int percentComplete = (int) (((double) (x + 1) / GFFFiles.size()) * 100); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAOutput.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAOutput.java index 2e6e3a618..cddacea20 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAOutput.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAOutput.java @@ -125,7 +125,7 @@ public void run() throws IOException, InterruptedException { BASENAME = OUT_DIR.getCanonicalPath() + File.separator + BASENAME; } // Initialize LogItem - String command = DNAShapefromFASTACLI.getCLIcommand(FASTA.get(x), BASENAME, OUTPUT_TYPE); + String command = DNAShapefromFASTACLI.getCLIcommand(FASTA.get(x), BASENAME, OUTPUT_TYPE, OUTPUT_GZIP); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); From 7f839e4b6947ad24c2cc8744b94800c54c7920fd Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 18:59:36 -0500 Subject: [PATCH 46/58] add missing Javadocs and tags update code with missing javadocs param tags and method override tag decorations also removal of duplicate comments and fixing of whitespace --- .../Figure_Generation/CompositePlotCLI.java | 1 + .../scripts/BAM_Manipulation/BAMFileSort.java | 2 +- .../scripts/BAM_Statistics/SEStats.java | 24 ++++++++++--------- .../Peak_Analysis/FilterBEDbyProximity.java | 1 - .../Peak_Analysis/RandomCoordinate.java | 3 ++- .../scripts/Peak_Calling/GeneTrack.java | 4 ++-- .../scripts/Read_Analysis/AggregateData.java | 1 + .../scripts/Read_Analysis/ScaleMatrix.java | 1 + .../scripts/Read_Analysis/ScalingFactor.java | 4 ++-- .../BAM_Format_Converter/BAMtoBEDOutput.java | 1 + .../BAM_Format_Converter/BAMtoBEDWindow.java | 1 + .../BAM_Format_Converter/BAMtoGFFOutput.java | 1 + .../BAM_Format_Converter/BAMtoGFFWindow.java | 1 + .../BAMtobedGraphWindow.java | 1 + .../BAMtoscIDXOutput.java | 1 + .../BAMtoscIDXWindow.java | 4 +--- .../BED_Manipulation/BEDtoGFFWindow.java | 6 ++--- .../BED_Manipulation/ExpandBEDWindow.java | 9 ++----- .../BED_Manipulation/SortBEDWindow.java | 3 ++- .../GFF_Manipulation/ExpandGFFWindow.java | 3 ++- .../GFF_Manipulation/GFFtoBEDWindow.java | 1 + .../GFF_Manipulation/SortGFFWindow.java | 3 ++- .../ShiftIntervalWindow.java | 2 +- .../PlotCompositeWindow.java | 5 +--- .../SignalDuplicationWindow.java | 5 ++-- .../Peak_Calling/GeneTrackWindow.java | 21 +++++++++------- .../Peak_Calling/PeakPairWindow.java | 21 +++++++++------- .../Read_Analysis/AggregateDataWindow.java | 1 + .../Read_Analysis/SimilarityMatrixWindow.java | 1 + .../Read_Analysis/TagPileupWindow.java | 3 ++- .../Sequence_Analysis/FASTAExtractWindow.java | 1 + .../Sequence_Analysis/SearchMotifWindow.java | 1 + 32 files changed, 76 insertions(+), 61 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/CompositePlotCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/CompositePlotCLI.java index 1ab538fc3..a5de31245 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/CompositePlotCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/CompositePlotCLI.java @@ -19,6 +19,7 @@ * Command line interface for {@link scriptmanager.scripts.Figure_Generation.PlotComposite} * * @author Olivia Lang + * @see scriptmanager.scripts.Read_Analysis.TagPileup */ @Command(name = "composite-plot", mixinStandardHelpOptions = true, description = ToolDescriptions.composite_description, diff --git a/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMFileSort.java b/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMFileSort.java index 591e8725c..9cd4803b3 100644 --- a/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMFileSort.java +++ b/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMFileSort.java @@ -17,7 +17,7 @@ public class BAMFileSort { /** - * Creates a new BAMFileSort object (unnecessary because class conly contains static methods) + * Creates a new BAMFileSort object (unnecessary because class only contains static methods) */ public BAMFileSort(){} diff --git a/src/main/java/scriptmanager/scripts/BAM_Statistics/SEStats.java b/src/main/java/scriptmanager/scripts/BAM_Statistics/SEStats.java index 6bc80ee5c..7d892058a 100644 --- a/src/main/java/scriptmanager/scripts/BAM_Statistics/SEStats.java +++ b/src/main/java/scriptmanager/scripts/BAM_Statistics/SEStats.java @@ -26,9 +26,11 @@ public class SEStats { * Outputs BAM Header including alignment statistics and parameters given any * indexed (BAI) BAM File * - * @param out_filepath File path to output text file to - * @param bamFile input BAM file (indexed) - * @param ps Output print stream + * @param bamFile the BAM file to get statistics on (from header) + * @param output text file to write output to (if OUTPUT_STATUS=true) + * @param OUTPUT_STATUS whether or not to write output info + * @param ps stream for GUI output display + * @throws IOException */ public static void getSEStats(File bamFile, File output, boolean OUTPUT_STATUS, PrintStream ps ) throws IOException { @@ -93,13 +95,13 @@ public static void getSEStats(File bamFile, File output, boolean OUTPUT_STATUS, } /** - *Helper method to de-clutter method above: - *Prints output to both pop-up window (for GUI) and output file (GUI and CLI) - * - *@param p PrintStream to GUI output - *@param out PrintStream to file - *@param line Line to print - */ + * Helper method to print output to both pop-up window (for GUI) and output file + * (GUI and CLI) + * + * @param p stream wrapper to GUI output window + * @param out stream to output file (used by both GUI and CLI) + * @param line string to print to both streams + */ private static void printBoth( PrintStream p, PrintStream out, String line ){ if (p != null) { p.println( line ); } if (out != null) { out.println( line ); } @@ -110,7 +112,7 @@ private static void printBoth( PrintStream p, PrintStream out, String line ){ * @return Timestamp The time at which the BAM file was analyzed */ private static String getTimeStamp() { - Date date= new Date(); + Date date = new Date(); String time = new Timestamp(date.getTime()).toString(); return time; } diff --git a/src/main/java/scriptmanager/scripts/Peak_Analysis/FilterBEDbyProximity.java b/src/main/java/scriptmanager/scripts/Peak_Analysis/FilterBEDbyProximity.java index 6e4430c43..d7b68a598 100644 --- a/src/main/java/scriptmanager/scripts/Peak_Analysis/FilterBEDbyProximity.java +++ b/src/main/java/scriptmanager/scripts/Peak_Analysis/FilterBEDbyProximity.java @@ -46,7 +46,6 @@ public class FilterBEDbyProximity{ */ public FilterBEDbyProximity(File input, File outputBase, int cutoff, PrintStream ps, boolean gzOutput) throws IOException { INPUT = input; - //OUT_BASENAME = outputBase; CUTOFF = cutoff; PS = ps; diff --git a/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java b/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java index 1f5e764ce..7b71bcada 100644 --- a/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java +++ b/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java @@ -30,7 +30,7 @@ public class RandomCoordinate { * * @param GENOME the String encoding the genome build to tile (matches * util.GenomeSizeReference) - * @param OUTPUT the file to write the coordinate tile output to (if null, a + * @param output the file to write the coordinate tile output to (if null, a * default filename is determined using * <GENOME>_<numSites>SITES_<windowSize>bp.<ext>) * @param BEDout coordinate file format of output where BED-format is used @@ -38,6 +38,7 @@ public class RandomCoordinate { * @param numSites the number of random coordinate sites to sample * @param windowSize the base-pair length of each coordinate interval * @param gzOutput whether or not to gzip output + * @throws OptionException thrown when window size is larger than a chromosome/contig in GENOME * @throws IOException Invalid file or parameters * @throws IllegalArgumentException */ diff --git a/src/main/java/scriptmanager/scripts/Peak_Calling/GeneTrack.java b/src/main/java/scriptmanager/scripts/Peak_Calling/GeneTrack.java index 50a86490f..20a5b0657 100755 --- a/src/main/java/scriptmanager/scripts/Peak_Calling/GeneTrack.java +++ b/src/main/java/scriptmanager/scripts/Peak_Calling/GeneTrack.java @@ -310,8 +310,8 @@ private void fileWriter(float[][] peaks, String s) { private int firstvalue; /** - * Holds the end overlapping region of the anti strand - */ + * Holds the end overlapping region of the anti strand + */ private double[] antidata; /** * Holds the end overlapping region of the sense strand diff --git a/src/main/java/scriptmanager/scripts/Read_Analysis/AggregateData.java b/src/main/java/scriptmanager/scripts/Read_Analysis/AggregateData.java index 266f7867b..3b968c683 100644 --- a/src/main/java/scriptmanager/scripts/Read_Analysis/AggregateData.java +++ b/src/main/java/scriptmanager/scripts/Read_Analysis/AggregateData.java @@ -40,6 +40,7 @@ public class AggregateData { * @param c Starting column (1-indexed) * @param index Operation to be performed (0 = sum, 1 = average, 2 = median, 3 = * mode, 4 = min, 5 = max, 6 = positional variance) + * @param gzOutput whether or not to gzip output */ public AggregateData(ArrayList in, File out, boolean m, int r, int c, int index, boolean gzOutput) { INPUT = in; diff --git a/src/main/java/scriptmanager/scripts/Read_Analysis/ScaleMatrix.java b/src/main/java/scriptmanager/scripts/Read_Analysis/ScaleMatrix.java index c4478b6f5..451a1782d 100644 --- a/src/main/java/scriptmanager/scripts/Read_Analysis/ScaleMatrix.java +++ b/src/main/java/scriptmanager/scripts/Read_Analysis/ScaleMatrix.java @@ -34,6 +34,7 @@ public class ScaleMatrix { * @param s Scaling factor * @param r Starting row (1-indexed) * @param c Starting column (1-indexed) + * @param gzOutput whether or not to gzip output */ public ScaleMatrix(File m, File o, double s, int r, int c, boolean gzOutput) { MATRIX = m; diff --git a/src/main/java/scriptmanager/scripts/Read_Analysis/ScalingFactor.java b/src/main/java/scriptmanager/scripts/Read_Analysis/ScalingFactor.java index 1f09fff8f..28d261937 100644 --- a/src/main/java/scriptmanager/scripts/Read_Analysis/ScalingFactor.java +++ b/src/main/java/scriptmanager/scripts/Read_Analysis/ScalingFactor.java @@ -83,14 +83,14 @@ public class ScalingFactor { * determine background signal * @param out_basename the filepath base name (the script will append suffixes) * for the output files - * @param out whether or not to write the output (write =true, don't - * write = false) * @param scale an integer value encoding the scaling type strategy to * use (1=Total Tag, 2=NCIS, 3=NCISwithTotal) * @param win the NCIS parameter for the window/bin size (only used if * scale!=1) * @param min the NCIS parameter for the minimum fraction (only used if * scale!=1) + * @param out whether or not to write the output (write =true, don't + * write = false) */ public ScalingFactor(File bamFile, File bl, File c, File out_basename, int scale, int win, double min, boolean out) { BAMFile = bamFile; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java index 5a0cba12d..1df7315f0 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java @@ -47,6 +47,7 @@ public class BAMtoBEDOutput extends JFrame { * @param pair_status Specifies if proper pairs are required (0 = not required, !0 = required) * @param min_size Minimum acceptable insert size * @param max_size Maximum acceptable insert size + * @param gzOutput whether or not to gzip output */ public BAMtoBEDOutput(File b, File out_dir, int s, int pair_status, int min_size, int max_size, boolean gzOutput) { setTitle("BAM to BED Progress"); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java index 3fd4ba410..138a5aa2f 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java @@ -405,6 +405,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when the task's progress changes */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java index 018dd69e3..55a6dc832 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java @@ -47,6 +47,7 @@ public class BAMtoGFFOutput extends JFrame { * @param pair_status Specifies if proper pairs are required (0 = not required, !0 = required) * @param min_size Minimum acceptable insert size * @param max_size Maximum acceptable insert size + * @param gzOutput whether or not to gzip output */ public BAMtoGFFOutput(File b, File out_dir, int s, int pair_status, int min_size, int max_size, boolean gzOutput) { setTitle("BAM to GFF Progress"); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java index 4090feffb..0bc5453a9 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java @@ -406,6 +406,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress changes, updating the progress bar. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java index 9597db42e..2ca03ebf5 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java @@ -384,6 +384,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when the task's progress changes */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java index b69c2dbb0..dc9eb554f 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java @@ -47,6 +47,7 @@ public class BAMtoscIDXOutput extends JFrame { * @param pair_status Specifies if proper pairs are required (0 = not required, !0 = required) * @param min_size Minimum acceptable insert size * @param max_size Maximum acceptable insert size + * @param gzOutput whether or not to gzip output */ public BAMtoscIDXOutput(File b, File out_dir, int s, int pair_status, int min_size, int max_size, boolean gzOutput) { setTitle("BAM to scIDX Progress"); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java index 9357d017d..547202ca1 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java @@ -370,9 +370,6 @@ public void actionPerformed(ActionEvent e) { }); } - /** - * Runs when a task is invoked, making window non-interactive and executing the task.. - */ /** * Runs when a task is invoked, making window non-interactive and executing the task. */ @@ -389,6 +386,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java index fa1a5694f..4f2f9ba31 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java @@ -70,9 +70,6 @@ public class BEDtoGFFWindow extends JFrame implements ActionListener, PropertyCh private JButton btnOutput; private static JCheckBox chckbxGzipOutput; - /** - * Organize user inputs for calling script - */ /** * Organizes user inputs for calling script */ @@ -216,7 +213,7 @@ public void actionPerformed(ActionEvent e) { contentPane.add(chckbxGzipOutput); } -/** + /** * Runs when a task is invoked, making window non-interactive and executing the task. */ @Override @@ -232,6 +229,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java index fcf160b48..ca274676a 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java @@ -80,9 +80,6 @@ public class ExpandBEDWindow extends JFrame implements ActionListener, PropertyC private static JRadioButton rdbtnAddToBorder; private static JCheckBox chckbxGzipOutput; - /** - * Organize user inputs for calling script - */ /** * Organizes user inputs for calling script */ @@ -268,7 +265,7 @@ public void actionPerformed(ActionEvent e) { btnExecute.addActionListener(this); } -/** + /** * Runs when a task is invoked, making window non-interactive and executing the task. */ @Override @@ -284,6 +281,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes and updates the progress bar */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); @@ -293,9 +291,6 @@ public void propertyChange(PropertyChangeEvent evt) { } } - /** - * Invoked when task's progress property changes and updates the progress bar - */ /** * Makes the content pane non-interactive If the window should be interactive data * @param con Content pane to make non-interactive diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java index 9ec30fc1c..87c49b144 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java @@ -401,7 +401,7 @@ public void actionPerformed(ActionEvent e) { contentPane.add(btnLoadCdtFile); } -/** + /** * Runs when a task is invoked, making window non-interactive and executing the task. */ @Override @@ -417,6 +417,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes and updates the progress bar */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java index dca17105f..d21d96dc1 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java @@ -261,7 +261,7 @@ public void actionPerformed(ActionEvent e) { btnConvert.addActionListener(this); } -/** + /** * Runs when a task is invoked, making window non-interactive and executing the task. */ @Override @@ -277,6 +277,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes and updates the progress bar */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java index 3ece1890a..a638ab7c6 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java @@ -226,6 +226,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes and updates the progress bar */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java index bf6a0b318..511c8293b 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java @@ -392,7 +392,7 @@ public void actionPerformed(ActionEvent e) { contentPane.add(btnLoadCdtFile); } -/** + /** * Runs when a task is invoked, making window non-interactive and executing the task. */ @Override @@ -408,6 +408,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes and updates the progress bar */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java index 15efeb25c..d3172971b 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java @@ -401,7 +401,7 @@ public void itemStateChanged(ItemEvent e) { btnExecute.addActionListener(this); } -/** + /** * Runs when a task is invoked, making window non-interactive and executing the task. */ @Override diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java index 967d82b43..a72df9e0b 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java @@ -91,9 +91,6 @@ public class PlotCompositeWindow extends JFrame implements ActionListener, Prope */ public Task task; - /** - * Organize user inputs for calling script - */ /** * Organizes user inputs for calling script */ @@ -307,7 +304,7 @@ public void activateOutput(boolean activate) { txtPixelWidth.setEnabled(activate); } -/** + /** * Runs when a task is invoked, making window non-interactive and executing the task. */ @Override diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java index 031c745de..e63cfdfb0 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java @@ -220,8 +220,9 @@ public void actionPerformed(ActionEvent arg0) { } /** - * Invoked when task's progress property changes and updates the progress bar. - */ + * Invoked when task's progress property changes. + */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java index 824376d69..0373750be 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java @@ -346,15 +346,18 @@ public void actionPerformed(ActionEvent arg0) { } /** - * Invoked when task's progress property changes. - */ - public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } - } - + * Invoked when task's progress property changes. + */ + @Override + public void propertyChange(PropertyChangeEvent evt) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + } + /** * Makes the content pane non-interactive If the window should be interactive data * @param con Content pane to make non-interactive diff --git a/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java index b134bccfc..64bd649ae 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java @@ -398,15 +398,18 @@ public void actionPerformed(ActionEvent arg0) { } /** - * Invoked when task's progress property changes. - */ - public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } - } - + * Invoked when task's progress property changes. + */ + @Override + public void propertyChange(PropertyChangeEvent evt) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + } + /** * Makes the content pane non-interactive If the window should be interactive data * @param con Content pane to make non-interactive diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java index 7a86d8200..0d627be85 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java @@ -282,6 +282,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/SimilarityMatrixWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/SimilarityMatrixWindow.java index 34347e465..11eec432e 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/SimilarityMatrixWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/SimilarityMatrixWindow.java @@ -244,6 +244,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java index e2fcd9506..88d24e5ed 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java @@ -1039,7 +1039,7 @@ public void activateBlacklist(boolean activate) { } /** - * Extract read aspect and read output to update the cartoon accordingly. + * Extract read aspect and read output to upddate the cartoon accordingly. */ public void updateCartoon() { int aspect = cbox_ReadAspect.getSelectedIndex(); @@ -1151,6 +1151,7 @@ public void massXable(Container con, boolean status) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java index b8c3a49d2..5ff4ee15d 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java @@ -285,6 +285,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java index 81e34871e..07f231658 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java @@ -262,6 +262,7 @@ public void actionPerformed(ActionEvent arg0) { /** * Invoked when task's progress property changes. */ + @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); From 88c4acf02f7dfaaeed21d764336a43ca82128784 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 20:08:05 -0500 Subject: [PATCH 47/58] standardize Exception handling in GUI Window class add generic Exception handling for GUI windows such that... - a standard ToolDescriptions comment pops up - comment directs users to open an issue ticket (if one is not already made) - comment includes message from Exception object for more detail about error - also prints stacktrace of exception add ScriptManager also removed some unused imports --- .../Exceptions/ScriptManagerException.java | 11 +++++++++++ .../scriptmanager/objects/ToolDescriptions.java | 7 ++++++- .../BAM_Format_Converter/BAMtoBEDWindow.java | 12 +++++++++++- .../BAM_Format_Converter/BAMtoGFFWindow.java | 12 +++++++++++- .../BAMtobedGraphWindow.java | 16 +++++++++++----- .../BAM_Format_Converter/BAMtoscIDXWindow.java | 17 +++++++++++------ .../BAM_Manipulation/BAMMarkDupWindow.java | 4 ++++ .../BAM_Manipulation/FilterforPIPseqWindow.java | 10 +++++++--- .../BAM_Manipulation/MergeBAMWindow.java | 8 ++++++-- .../BAM_Manipulation/SortBAMWindow.java | 8 ++++++-- .../BAMGenomeCorrelationWindow.java | 10 +++++++--- .../BAM_Statistics/CrossCorrelationWindow.java | 3 +++ .../BAM_Statistics/PEStatWindow.java | 4 ++++ .../BAM_Statistics/SEStatWindow.java | 5 ++++- .../BED_Manipulation/BEDtoGFFWindow.java | 13 ++++++++++++- .../BED_Manipulation/ExpandBEDWindow.java | 7 +++++++ .../BED_Manipulation/SortBEDWindow.java | 9 ++++++++- .../GFF_Manipulation/ExpandGFFWindow.java | 9 ++++++++- .../GFF_Manipulation/GFFtoBEDWindow.java | 12 +++++++++++- .../GFF_Manipulation/SortGFFWindow.java | 9 ++++++++- .../ShiftIntervalWindow.java | 10 +++++++++- .../FourColorSequenceWindow.java | 4 ++++ .../Figure_Generation/LabelHeatMapWindow.java | 4 ++++ .../Figure_Generation/MergeHeatMapWindow.java | 4 ++++ .../Figure_Generation/PlotCompositeWindow.java | 10 +++++++--- .../ThreeColorHeatMapWindow.java | 10 +++++++--- .../TwoColorHeatMapWindow.java | 10 +++++++--- .../File_Utilities/CompressFileWindow.java | 4 ++++ .../ConvertBEDChrNamesWindow.java | 6 +++++- .../ConvertGFFChrNamesWindow.java | 6 +++++- .../File_Utilities/DecompressGZFileWindow.java | 4 ++++ .../File_Utilities/MD5ChecksumWindow.java | 5 ++++- .../Peak_Analysis/BEDPeakAligntoRefWindow.java | 8 ++++---- .../FilterBEDbyProximityWindow.java | 4 ++++ .../Peak_Analysis/RandomCoordinateWindow.java | 6 +++++- .../Peak_Analysis/SignalDuplicationWindow.java | 13 +++++++++---- .../Peak_Analysis/TileGenomeWindow.java | 6 +++++- .../Peak_Calling/GeneTrackWindow.java | 9 ++++++++- .../Peak_Calling/PeakPairWindow.java | 9 ++++++++- .../Read_Analysis/AggregateDataWindow.java | 9 ++++++++- .../Read_Analysis/ScaleMatrixWindow.java | 4 ++++ .../Read_Analysis/ScalingFactorWindow.java | 10 +++++++--- .../Read_Analysis/TagPileupWindow.java | 9 ++++++++- .../Read_Analysis/TransposeMatrixWindow.java | 9 ++++++++- .../DNAShapefromBEDWindow.java | 9 ++++++++- .../DNAShapefromFASTAWindow.java | 9 ++++++++- .../Sequence_Analysis/FASTAExtractWindow.java | 9 ++++++++- .../Sequence_Analysis/RandomizeFASTAWindow.java | 9 ++++++++- .../Sequence_Analysis/SearchMotifWindow.java | 12 +++++++++++- 49 files changed, 341 insertions(+), 66 deletions(-) create mode 100644 src/main/java/scriptmanager/objects/Exceptions/ScriptManagerException.java diff --git a/src/main/java/scriptmanager/objects/Exceptions/ScriptManagerException.java b/src/main/java/scriptmanager/objects/Exceptions/ScriptManagerException.java new file mode 100644 index 000000000..282e5e2a5 --- /dev/null +++ b/src/main/java/scriptmanager/objects/Exceptions/ScriptManagerException.java @@ -0,0 +1,11 @@ +package scriptmanager.objects.Exceptions; + +/** + * Exception to track internally thrown exceptions + * + * @author Olivia Lang + */ +@SuppressWarnings("serial") +public class ScriptManagerException extends Exception { + +} diff --git a/src/main/java/scriptmanager/objects/ToolDescriptions.java b/src/main/java/scriptmanager/objects/ToolDescriptions.java index 09af46ebe..76a79b7f5 100644 --- a/src/main/java/scriptmanager/objects/ToolDescriptions.java +++ b/src/main/java/scriptmanager/objects/ToolDescriptions.java @@ -2,7 +2,7 @@ /** * This class acts as a central and shared storage location for each tool's - * description for consistency between CLI help message and the GUI-displayed + * description for consistentcy betweeen CLI help message and the GUI-displayed * text. * * @author Olivia Lang @@ -23,6 +23,11 @@ public class ToolDescriptions { * The version string for the whole tool */ public static final String VERSION = "0.14-dev"; + + /** + * Message to user to direct user to open an issue ticket in case of unexpected exception. Print alongside exception's stack trace/message information + */ + public static final String UNEXPECTED_EXCEPTION_MESSAGE = "Unexpected exception encountered. Please copy the stack trace and open a Github issue ticket if a ticket does not already exist for your error."; // BAM Statistics public static final String se_stat_description = "Output BAM Header including alignment statistics and parameters given any indexed (BAI) BAM File."; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java index 138a5aa2f..3785818a9 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java @@ -39,6 +39,7 @@ import scriptmanager.cli.BAM_Format_Converter.BAMtoBEDCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -90,7 +91,7 @@ public class BAMtoBEDWindow extends JFrame implements ActionListener, PropertyCh */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if (chckbxFilterByMinimum.isSelected() && Integer.parseInt(txtMin.getText()) < 0) { JOptionPane.showMessageDialog(null, @@ -148,6 +149,15 @@ public void propertyChange(PropertyChangeEvent evt) { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (InterruptedException ie) { + ie.printStackTrace(); + JOptionPane.showMessageDialog(null, "Unexpected InterruptedException: " + ie.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java index 0bc5453a9..fac59084c 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java @@ -39,6 +39,7 @@ import scriptmanager.cli.BAM_Format_Converter.BAMtoGFFCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -90,7 +91,7 @@ public class BAMtoGFFWindow extends JFrame implements ActionListener, PropertyCh */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if (chckbxFilterByMinimum.isSelected() && Integer.parseInt(txtMin.getText()) < 0) { JOptionPane.showMessageDialog(null, @@ -149,6 +150,15 @@ public void propertyChange(PropertyChangeEvent evt) { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (InterruptedException ie) { + ie.printStackTrace(); + JOptionPane.showMessageDialog(null, "Unexpected InterruptedException: " + ie.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java index 2ca03ebf5..8c9ec9e2f 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java @@ -13,8 +13,6 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; -import java.sql.Timestamp; -import java.util.Date; import java.util.Vector; import javax.swing.ButtonGroup; @@ -37,8 +35,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.cli.BAM_Format_Converter.BAMtobedGraphCLI; -import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -89,7 +86,7 @@ public class BAMtobedGraphWindow extends JFrame implements ActionListener, Prope */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if (chckbxFilterByMinimum.isSelected() && Integer.parseInt(txtMin.getText()) < 0) { JOptionPane.showMessageDialog(null, @@ -145,6 +142,15 @@ public void propertyChange(PropertyChangeEvent evt) { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (InterruptedException ie) { + ie.printStackTrace(); + JOptionPane.showMessageDialog(null, "Unexpected InterruptedException: " + ie.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java index 547202ca1..468d43478 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java @@ -13,8 +13,6 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; -import java.sql.Timestamp; -import java.util.Date; import java.util.Vector; @@ -38,8 +36,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.objects.LogItem; -import scriptmanager.cli.BAM_Format_Converter.BAMtoscIDXCLI; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -90,7 +87,7 @@ public class BAMtoscIDXWindow extends JFrame implements ActionListener, Property */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if (chckbxFilterByMinimum.isSelected() && Integer.parseInt(txtMin.getText()) < 0) { JOptionPane.showMessageDialog(null, @@ -137,7 +134,6 @@ public void propertyChange(PropertyChangeEvent evt) { }); convert.setVisible(true); - convert.run(); int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); @@ -147,6 +143,15 @@ public void propertyChange(PropertyChangeEvent evt) { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (InterruptedException ie) { + ie.printStackTrace(); + JOptionPane.showMessageDialog(null, "Unexpected InterruptedException: " + ie.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java index 3bfdd461d..45f494117 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java @@ -35,6 +35,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; @@ -128,6 +129,9 @@ public Void doInBackground() { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java index 98c2ff21e..2843d6f8a 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java @@ -36,6 +36,7 @@ import scriptmanager.cli.BAM_Manipulation.FilterforPIPseqCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; @@ -118,12 +119,15 @@ public Void doInBackground() { firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Permanganate-Seq Filtering Complete"); - } catch (IOException ioe) { - ioe.printStackTrace(); - JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (InterruptedException ie) { ie.printStackTrace(); JOptionPane.showMessageDialog(null, "InterruptedException - " + ie.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java index 85f5ca7ec..9c24b1b84 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java @@ -35,6 +35,7 @@ import java.util.Date; import scriptmanager.cli.BAM_Manipulation.MergeBAMCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; import scriptmanager.scripts.BAM_Manipulation.MergeBAM; @@ -106,11 +107,14 @@ public Void doInBackground() { // Update progress setProgress(100); JOptionPane.showMessageDialog(null, "Merging Complete"); + } catch (SAMException se) { + JOptionPane.showMessageDialog(null, se.getMessage()); } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); - } catch (SAMException se) { - JOptionPane.showMessageDialog(null, se.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java index 0e08614a3..6cb22bf2e 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java @@ -35,6 +35,7 @@ import scriptmanager.cli.BAM_Manipulation.SortBAMCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.BAM_Manipulation.BAMFileSort; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -105,11 +106,14 @@ public Void doInBackground() { firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Sorting Complete"); + } catch (SAMException se) { + JOptionPane.showMessageDialog(null, se.getMessage()); } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); - } catch (SAMException se) { - JOptionPane.showMessageDialog(null, se.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java index 9b0e98802..79a893357 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java @@ -41,6 +41,7 @@ import javax.swing.border.TitledBorder; import scriptmanager.charts.HeatMap; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.FileSelection; @@ -137,12 +138,15 @@ public void propertyChange(PropertyChangeEvent evt) { } } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Input Fields Must Contain Integers"); - } catch (IOException ioe) { - ioe.printStackTrace(); - JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (OptionException oe) { oe.printStackTrace(); JOptionPane.showMessageDialog(null, oe.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java index 854c877ab..4b655d62e 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/CrossCorrelationWindow.java @@ -38,6 +38,7 @@ import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.objects.ArchTEx.CorrParameter; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -140,8 +141,10 @@ public void propertyChange(PropertyChangeEvent evt) { JOptionPane.showMessageDialog(null, "Input Fields Must Contain Integers"); } catch (IOException ioe) { ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (Exception e) { e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java index 6f37f0ee9..4d38ba0dd 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/PEStatWindow.java @@ -34,6 +34,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -113,6 +114,9 @@ public void propertyChange(PropertyChangeEvent evt) { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java index e42e42c8a..cb52215a2 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatWindow.java @@ -26,12 +26,12 @@ import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JScrollPane; -import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.SpringLayout; import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -95,6 +95,9 @@ public void propertyChange(PropertyChangeEvent evt) { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java index 4f2f9ba31..2adc4cf07 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java @@ -32,6 +32,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.BEDtoGFFCLI; @@ -75,7 +76,8 @@ public class BEDtoGFFWindow extends JFrame implements ActionListener, PropertyCh */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { + try { setProgress(0); LogItem old_li = new LogItem(""); for (int x = 0; x < BEDFiles.size(); x++) { @@ -102,6 +104,15 @@ public Void doInBackground() throws IOException { firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Conversion Complete"); + + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); + } + setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java index ca274676a..263c7e6d4 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/ExpandBEDWindow.java @@ -38,6 +38,7 @@ import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.ExpandBEDCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.Coordinate_Manipulation.BED_Manipulation.ExpandBED; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -124,6 +125,12 @@ public Void doInBackground() throws IOException { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java index 87c49b144..6373dff81 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java @@ -35,6 +35,7 @@ import scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.SortBEDCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.CDTUtilities; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -101,7 +102,7 @@ public class SortBEDWindow extends JFrame implements ActionListener, PropertyCha */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { if (rdbtnSortbyCenter.isSelected() && Integer.parseInt(txtMid.getText()) > CDT_SIZE) { JOptionPane.showMessageDialog(null, "Sort Size is larger than CDT File!!!"); @@ -141,6 +142,12 @@ public Void doInBackground() throws IOException { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java index d21d96dc1..c572f8688 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java @@ -38,6 +38,7 @@ import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.ExpandGFFCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.Coordinate_Manipulation.GFF_Manipulation.ExpandGFF; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -85,7 +86,7 @@ public class ExpandGFFWindow extends JFrame implements ActionListener, PropertyC */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { SIZE = Integer.parseInt(txtSize.getText()); if (SIZE < 1) { @@ -121,6 +122,12 @@ public Void doInBackground() throws IOException { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java index a638ab7c6..0060934dc 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDWindow.java @@ -32,6 +32,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.GFFtoBEDCLI; @@ -75,7 +76,8 @@ public class GFFtoBEDWindow extends JFrame implements ActionListener, PropertyCh */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { + try { setProgress(0); LogItem old_li = null; for (int x = 0; x < BEDFiles.size(); x++) { @@ -102,6 +104,14 @@ public Void doInBackground() throws IOException { firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Conversion Complete"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); + } + setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java index 511c8293b..ddd5330d7 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java @@ -35,6 +35,7 @@ import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.SortGFFCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.CDTUtilities; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -98,7 +99,7 @@ public class SortGFFWindow extends JFrame implements ActionListener, PropertyCha */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { if (rdbtnSortbyCenter.isSelected() && Integer.parseInt(txtMid.getText()) > CDT_SIZE) { JOptionPane.showMessageDialog(null, "Sort Size is larger than CDT File!!!"); @@ -138,6 +139,12 @@ public Void doInBackground() throws IOException { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java index d3172971b..0b947ab02 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java @@ -42,6 +42,7 @@ import scriptmanager.cli.Coordinate_Manipulation.GFF_Manipulation.SortGFFCLI; import scriptmanager.cli.Coordinate_Manipulation.ShiftCoordCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.Coordinate_Manipulation.ShiftCoord; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -95,7 +96,7 @@ public class ShiftIntervalWindow extends JFrame implements ActionListener, Prope */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { int SHIFT = Integer.parseInt(txtShift.getText()); if (SHIFT == 0) { @@ -173,7 +174,14 @@ public Void doInBackground() throws IOException { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } + setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/FourColorSequenceWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/FourColorSequenceWindow.java index a5a6ed3b4..273a062aa 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/FourColorSequenceWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/FourColorSequenceWindow.java @@ -38,6 +38,7 @@ import scriptmanager.util.FileSelection; import scriptmanager.cli.Figure_Generation.FourColorSequenceCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.Figure_Generation.FourColorPlot; /** @@ -139,6 +140,9 @@ public Void doInBackground() { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java index c6374990a..358480f93 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java @@ -36,6 +36,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.FileSelection; @@ -132,6 +133,9 @@ public void propertyChange(PropertyChangeEvent evt) { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java index 3e97f418b..78143847e 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/MergeHeatMapWindow.java @@ -28,6 +28,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -89,6 +90,9 @@ public void propertyChange(PropertyChangeEvent evt) { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java index a72df9e0b..571f42d80 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/PlotCompositeWindow.java @@ -34,6 +34,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -125,14 +126,17 @@ public void propertyChange(PropertyChangeEvent evt) { output_obj.setVisible(true); output_obj.run(); } - } catch (IOException ioe) { - ioe.printStackTrace(); - JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (NoSuchElementException nsee){ nsee.printStackTrace(); JOptionPane.showMessageDialog(null, "Check that your input files are properly formatted!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java index 7e74891c6..a2160c88d 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java @@ -37,6 +37,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.FileSelection; @@ -197,12 +198,15 @@ public void propertyChange(PropertyChangeEvent evt) { output_obj.run(); } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); - } catch (IOException ioe) { - ioe.printStackTrace(); - JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (OptionException oe) { oe.printStackTrace(); JOptionPane.showMessageDialog(null, oe.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java index f102273f4..c2bdc5ca1 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java @@ -37,6 +37,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.FileSelection; @@ -159,12 +160,15 @@ public void propertyChange(PropertyChangeEvent evt) { output_obj.run(); } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); - } catch (IOException ioe) { - ioe.printStackTrace(); - JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (OptionException oe) { oe.printStackTrace(); JOptionPane.showMessageDialog(null, oe.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/CompressFileWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/CompressFileWindow.java index c55856876..e2e68e618 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/CompressFileWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/CompressFileWindow.java @@ -29,6 +29,7 @@ import scriptmanager.cli.File_Utilities.CompressFileCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; import scriptmanager.scripts.File_Utilities.GZipFiles; @@ -92,6 +93,9 @@ public Void doInBackground() { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java index 574822353..ebd2f0bf2 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java @@ -34,6 +34,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -82,7 +83,7 @@ public class ConvertBEDChrNamesWindow extends JFrame implements ActionListener, */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { setProgress(0); LogItem old_li = null; @@ -122,6 +123,9 @@ public Void doInBackground() throws IOException { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java index 3fec788e0..0ce1d14f3 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java @@ -34,6 +34,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -82,7 +83,7 @@ public class ConvertGFFChrNamesWindow extends JFrame implements ActionListener, */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { setProgress(0); LogItem old_li = null; @@ -122,6 +123,9 @@ public Void doInBackground() throws IOException { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/DecompressGZFileWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/DecompressGZFileWindow.java index be05fcd51..a86e53027 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/DecompressGZFileWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/DecompressGZFileWindow.java @@ -28,6 +28,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; import scriptmanager.cli.File_Utilities.DecompressGZFileCLI; @@ -92,6 +93,9 @@ public Void doInBackground() { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/MD5ChecksumWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/MD5ChecksumWindow.java index 6ad3ff9ab..6f0cc0118 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/MD5ChecksumWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/MD5ChecksumWindow.java @@ -34,7 +34,7 @@ import scriptmanager.util.FileSelection; import scriptmanager.objects.LogItem; - +import scriptmanager.objects.ToolDescriptions; import scriptmanager.cli.File_Utilities.MD5ChecksumCLI; import scriptmanager.scripts.File_Utilities.MD5Checksum; @@ -110,6 +110,9 @@ public Void doInBackground() { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java index 0200ea023..88de1bbce 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/BEDPeakAligntoRefWindow.java @@ -11,9 +11,7 @@ import java.beans.PropertyChangeEvent; import java.io.File; import java.io.IOException; -import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Date; import javax.swing.DefaultListModel; import javax.swing.JButton; @@ -30,8 +28,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.cli.Peak_Analysis.BEDPeakAligntoRefCLI; -import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -111,6 +108,9 @@ public void propertyChange(PropertyChangeEvent evt) { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java index 89ee08765..d72ce4e13 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/FilterBEDbyProximityWindow.java @@ -29,6 +29,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -97,6 +98,9 @@ public void propertyChange(PropertyChangeEvent evt) { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java index ccb442f0e..ad003e875 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java @@ -32,6 +32,7 @@ import scriptmanager.cli.Peak_Analysis.RandomCoordinateCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -73,7 +74,7 @@ public class RandomCoordinateWindow extends JFrame implements ActionListener, Pr class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if(txtSites.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "No Sites Entered!!!"); @@ -115,6 +116,9 @@ public Void doInBackground() throws IOException, InterruptedException { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java index e63cfdfb0..552b67149 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java @@ -29,6 +29,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.Peak_Analysis.SignalDuplication; /** @@ -67,7 +68,7 @@ public class SignalDuplicationWindow extends JFrame implements ActionListener, P */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { if(Double.parseDouble(txtWindow.getText()) < 1) { JOptionPane.showMessageDialog(null, "Invalid Bin Size!!! Must be larger than 0 bp"); @@ -86,13 +87,17 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { setProgress(percentComplete); } }); - signal.setVisible(true); signal.run(); - } - } catch(NumberFormatException nfe){ + } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java index d52820a7f..3a619676f 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java @@ -32,6 +32,7 @@ import scriptmanager.util.FileSelection; import scriptmanager.cli.Peak_Analysis.TileGenomeCLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.Peak_Analysis.TileGenome; /** @@ -68,7 +69,7 @@ public class TileGenomeWindow extends JFrame implements ActionListener, Property */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if(txtSize.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "No Window Size Entered!!!"); @@ -103,6 +104,9 @@ public Void doInBackground() throws IOException, InterruptedException { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java index 0373750be..0b92e1775 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java @@ -33,6 +33,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.Peak_Calling.GeneTrack; /** @@ -81,7 +82,7 @@ public class GeneTrackWindow extends JFrame implements ActionListener, PropertyC */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if(Integer.parseInt(txtSigma.getText()) < 1) { JOptionPane.showMessageDialog(null, "Invalid Sigma!!!"); @@ -125,6 +126,12 @@ public Void doInBackground() throws IOException, InterruptedException { } } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java index 64bd649ae..f3874d710 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java @@ -35,6 +35,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.Peak_Calling.PeakPair; /** @@ -90,7 +91,7 @@ public class PeakPairWindow extends JFrame implements ActionListener, PropertyCh */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { if(Integer.parseInt(txtUp.getText()) < 0) { JOptionPane.showMessageDialog(null, "Invalid Upstream Distance!!!"); @@ -131,6 +132,12 @@ public Void doInBackground() throws IOException { } } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java index 0d627be85..606bfd486 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java @@ -34,6 +34,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.Read_Analysis.AggregateData; /** @@ -81,7 +82,7 @@ public class AggregateDataWindow extends JFrame implements ActionListener, Prope */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { setProgress(0); try { if (Integer.parseInt(txtRow.getText()) < 1) { @@ -106,6 +107,12 @@ public Void doInBackground() throws IOException { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java index 0b4e0045c..2073216e8 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java @@ -45,6 +45,7 @@ import javax.swing.table.DefaultTableModel; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -167,6 +168,9 @@ public Void doInBackground() { } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java index 7a504ec5a..14c821faf 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java @@ -35,6 +35,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.objects.CustomExceptions.OptionException; import scriptmanager.util.FileSelection; @@ -137,12 +138,15 @@ public void propertyChange(PropertyChangeEvent evt) { output_obj.setVisible(true); JOptionPane.showMessageDialog(null, "All Scaling Factors Calculated"); } - } catch (IOException ioe) { - ioe.printStackTrace(); - JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); } catch (OptionException oe) { oe.printStackTrace(); JOptionPane.showMessageDialog(null, oe.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } // Update progress setProgress(100); diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java index 88d24e5ed..e49c2eb5f 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java @@ -50,6 +50,7 @@ import scriptmanager.objects.CompositeCartoon; import scriptmanager.objects.PileupParameters; import scriptmanager.objects.ReadFragmentCartoon; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; @@ -139,7 +140,7 @@ public class TagPileupWindow extends JFrame implements ActionListener, PropertyC */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if (Integer.parseInt(txtBin.getText()) < 1) { JOptionPane.showMessageDialog(null, "Invalid Bin Size!!! Must be larger than 0 bp"); @@ -255,6 +256,12 @@ public void propertyChange(PropertyChangeEvent evt) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!", "Validate Input", JOptionPane.ERROR_MESSAGE); } catch (SAMException se) { JOptionPane.showMessageDialog(null, se.getMessage(), "Validate Input", JOptionPane.ERROR_MESSAGE); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/TransposeMatrixWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/TransposeMatrixWindow.java index 7b818fcca..33439cc02 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/TransposeMatrixWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/TransposeMatrixWindow.java @@ -37,6 +37,7 @@ import scriptmanager.util.FileSelection; import scriptmanager.util.GZipUtilities; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.objects.CustomExceptions.ScriptManagerException; import scriptmanager.scripts.Read_Analysis.TransposeMatrix; @@ -73,7 +74,7 @@ public class TransposeMatrixWindow extends JFrame implements ActionListener, Pro */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { if (TABFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No Files Loaded!!!"); @@ -119,6 +120,12 @@ public Void doInBackground() throws IOException { } catch (ScriptManagerException sme) { sme.printStackTrace(); JOptionPane.showMessageDialog(null, sme.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDWindow.java index fea06663a..fed794c1d 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromBEDWindow.java @@ -31,6 +31,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -81,7 +82,7 @@ public class DNAShapefromBEDWindow extends JFrame implements ActionListener, Pro */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { if (INPUT == null) { JOptionPane.showMessageDialog(null, "Genomic File Not Loaded!!!"); @@ -118,6 +119,12 @@ public void propertyChange(PropertyChangeEvent evt) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (InterruptedException e) { e.printStackTrace(); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAWindow.java index 110d8559d..5dbb88d1d 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/DNAShapefromFASTAWindow.java @@ -31,6 +31,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -77,7 +78,7 @@ public class DNAShapefromFASTAWindow extends JFrame implements ActionListener, P */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { if (FASTAFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No FASTA Files Loaded!!!"); @@ -112,6 +113,12 @@ public void propertyChange(PropertyChangeEvent evt) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (InterruptedException e) { e.printStackTrace(); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java index 5ff4ee15d..a3b82affe 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java @@ -31,6 +31,7 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FileSelection; /** @@ -77,7 +78,7 @@ public class FASTAExtractWindow extends JFrame implements ActionListener, Proper */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException { + public Void doInBackground() { try { if (INPUT == null) { JOptionPane.showMessageDialog(null, "Genomic File Not Loaded!!!"); @@ -107,6 +108,12 @@ public void propertyChange(PropertyChangeEvent evt) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); } catch (InterruptedException e) { e.printStackTrace(); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/RandomizeFASTAWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/RandomizeFASTAWindow.java index 17df3498b..59bfa24fd 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/RandomizeFASTAWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/RandomizeFASTAWindow.java @@ -39,6 +39,7 @@ import scriptmanager.util.ExtensionFileFilter; import scriptmanager.cli.Sequence_Analysis.RandomizeFASTACLI; import scriptmanager.objects.LogItem; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.scripts.Sequence_Analysis.RandomizeFASTA; /** @@ -82,7 +83,7 @@ public class RandomizeFASTAWindow extends JFrame implements ActionListener, Prop */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if (FASTAFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No FASTA Files Loaded!!!"); @@ -123,6 +124,12 @@ public Void doInBackground() throws IOException, InterruptedException { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Seed!!!"); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java index 07f231658..e8a62232e 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java @@ -30,6 +30,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; +import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.FASTAUtilities; /** @@ -68,7 +69,7 @@ public class SearchMotifWindow extends JFrame implements ActionListener, Propert */ class Task extends SwingWorker { @Override - public Void doInBackground() throws IOException, InterruptedException { + public Void doInBackground() { try { if (GenomeFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No FASTA Files Selected!!!"); @@ -100,6 +101,15 @@ public void propertyChange(PropertyChangeEvent evt) { } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (InterruptedException ie) { + ie.printStackTrace(); + JOptionPane.showMessageDialog(null, "Unexpected InterruptedException: " + ie.getMessage()); + } catch (IOException ioe) { + ioe.printStackTrace(); + JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } setProgress(100); return null; From 446a8b1440f335bfd35013cdfcc8c32acc9c1e4b Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 20:27:18 -0500 Subject: [PATCH 48/58] fix "seperate" typo to "separate" #150 --- .../Read_Analysis/TagPileupWindow.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java index e49c2eb5f..c6b8f18ad 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java @@ -87,7 +87,7 @@ public class TagPileupWindow extends JFrame implements ActionListener, PropertyC private JButton btnRemoveBlacklistfilter; private JComboBox cbox_ReadAspect; private JComboBox cbox_ReadOutput; - private JToggleButton tglSeperate; + private JToggleButton tglSeparate; private JToggleButton tglCombined; private JComboBox cbox_Transform; @@ -171,7 +171,7 @@ public Void doInBackground() { // Load up parameters for the pileup into single object PileupParameters param = new PileupParameters(); ArrayList colors = new ArrayList(); - if (tglSeperate.isSelected()) { + if (tglSeparate.isSelected()) { param.setStrand(0); colors.add(btnSenseColor.getForeground()); colors.add(btnAntiColor.getForeground()); @@ -582,14 +582,14 @@ public void itemStateChanged(ItemEvent e) { // Stand Options int SCALE = 170; - tglSeperate = new JToggleButton("Seperate"); - sl_contentPane.putConstraint(SpringLayout.NORTH, tglSeperate, 10, SpringLayout.SOUTH, pnlFilterReads); - sl_contentPane.putConstraint(SpringLayout.WEST, tglSeperate, 10, SpringLayout.EAST, scrollPane_BED); - sl_contentPane.putConstraint(SpringLayout.EAST, tglSeperate, 10 + SCALE*2, SpringLayout.EAST, scrollPane_BED); - tglSeperate.setSelected(true); - tglSeperate.addItemListener(new ItemListener() { + tglSeparate = new JToggleButton("Separate"); + sl_contentPane.putConstraint(SpringLayout.NORTH, tglSeparate, 10, SpringLayout.SOUTH, pnlFilterReads); + sl_contentPane.putConstraint(SpringLayout.WEST, tglSeparate, 10, SpringLayout.EAST, scrollPane_BED); + sl_contentPane.putConstraint(SpringLayout.EAST, tglSeparate, 10 + SCALE*2, SpringLayout.EAST, scrollPane_BED); + tglSeparate.setSelected(true); + tglSeparate.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { - if (tglSeperate.isSelected()) { + if (tglSeparate.isSelected()) { btnSenseColor.setEnabled(true); btnAntiColor.setEnabled(true); btnCombinedColor.setEnabled(false); @@ -601,12 +601,12 @@ public void itemStateChanged(ItemEvent e) { } } }); - contentPane.add(tglSeperate); + contentPane.add(tglSeparate); tglCombined = new JToggleButton("Combined"); - sl_contentPane.putConstraint(SpringLayout.NORTH, tglCombined, 0, SpringLayout.NORTH, tglSeperate); - sl_contentPane.putConstraint(SpringLayout.WEST, tglCombined, 0, SpringLayout.EAST, tglSeperate); - sl_contentPane.putConstraint(SpringLayout.EAST, tglCombined, SCALE, SpringLayout.EAST, tglSeperate); + sl_contentPane.putConstraint(SpringLayout.NORTH, tglCombined, 0, SpringLayout.NORTH, tglSeparate); + sl_contentPane.putConstraint(SpringLayout.WEST, tglCombined, 0, SpringLayout.EAST, tglSeparate); + sl_contentPane.putConstraint(SpringLayout.EAST, tglCombined, SCALE, SpringLayout.EAST, tglSeparate); tglCombined.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (tglCombined.isSelected()) { @@ -623,13 +623,13 @@ public void itemStateChanged(ItemEvent e) { contentPane.add(tglCombined); ButtonGroup toggleStrand = new ButtonGroup(); - toggleStrand.add(tglSeperate); + toggleStrand.add(tglSeparate); toggleStrand.add(tglCombined); btnSenseColor = new JButton("Sense Color"); - sl_contentPane.putConstraint(SpringLayout.NORTH, btnSenseColor, 0, SpringLayout.SOUTH, tglSeperate); - sl_contentPane.putConstraint(SpringLayout.WEST, btnSenseColor, 0, SpringLayout.WEST, tglSeperate); - sl_contentPane.putConstraint(SpringLayout.EAST, btnSenseColor, SCALE, SpringLayout.WEST, tglSeperate); + sl_contentPane.putConstraint(SpringLayout.NORTH, btnSenseColor, 0, SpringLayout.SOUTH, tglSeparate); + sl_contentPane.putConstraint(SpringLayout.WEST, btnSenseColor, 0, SpringLayout.WEST, tglSeparate); + sl_contentPane.putConstraint(SpringLayout.EAST, btnSenseColor, SCALE, SpringLayout.WEST, tglSeparate); btnSenseColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Color newColor = JColorChooser.showDialog(btnSenseColor, "Select an Output Color", btnSenseColor.getForeground()); @@ -646,7 +646,7 @@ public void actionPerformed(ActionEvent arg0) { btnAntiColor = new JButton("Anti Color"); sl_contentPane.putConstraint(SpringLayout.NORTH, btnAntiColor, 0, SpringLayout.NORTH, btnSenseColor); sl_contentPane.putConstraint(SpringLayout.WEST, btnAntiColor, 0, SpringLayout.EAST, btnSenseColor); - sl_contentPane.putConstraint(SpringLayout.EAST, btnAntiColor, 0, SpringLayout.EAST, tglSeperate); + sl_contentPane.putConstraint(SpringLayout.EAST, btnAntiColor, 0, SpringLayout.EAST, tglSeparate); btnAntiColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(btnAntiColor, "Select an Output Color", btnAntiColor.getForeground()); @@ -1016,7 +1016,7 @@ public void actionPerformed(ActionEvent e) { */ public void allowReadChoice(boolean activate) { cbox_ReadOutput.setEnabled(activate); - tglSeperate.setEnabled(activate); + tglSeparate.setEnabled(activate); } /** @@ -1105,7 +1105,7 @@ public void massXable(Container con, boolean status) { if (!chckbxFilterByMax.isSelected()) { txtMax.setEnabled(false); } - if (tglSeperate.isSelected()) { + if (tglSeparate.isSelected()) { btnSenseColor.setEnabled(true); btnAntiColor.setEnabled(true); btnCombinedColor.setEnabled(false); From e7b7c563243b4a5304b7aa9c8eed34419cd8564c Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 20:35:58 -0500 Subject: [PATCH 49/58] rename objects to output_obj for consistency Instantiation of *Output.java objects was named differently from tool-to-tool. For consistency across tools, I am renaming them all `object_obj` --- .../BAM_Format_Converter/BAMtoBEDWindow.java | 13 ++++++------- .../BAM_Format_Converter/BAMtoGFFWindow.java | 14 ++++++-------- .../BAM_Format_Converter/BAMtobedGraphWindow.java | 13 ++++++------- .../BAM_Format_Converter/BAMtoscIDXWindow.java | 13 ++++++------- .../Read_Analysis/TagPileupWindow.java | 14 ++++++-------- .../Sequence_Analysis/FASTAExtractWindow.java | 10 +++++----- .../Sequence_Analysis/SearchMotifWindow.java | 8 ++++---- 7 files changed, 39 insertions(+), 46 deletions(-) diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java index 3785818a9..cb621b1eb 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDWindow.java @@ -129,18 +129,17 @@ public Void doInBackground() { if (chckbxFilterByMaximum.isSelected()) { MAX = Integer.parseInt(txtMax.getText()); } - + // process each bam for (int x = 0; x < BAMFiles.size(); x++) { - BAMtoBEDOutput convert = new BAMtoBEDOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX, chckbxGzipOutput.isSelected()); - convert.addPropertyChangeListener("log", new PropertyChangeListener() { + BAMtoBEDOutput output_obj = new BAMtoBEDOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX, chckbxGzipOutput.isSelected()); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - - convert.setVisible(true); - convert.run(); - + output_obj.setVisible(true); + output_obj.run(); + // Update progress int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java index fac59084c..5d22433c8 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFWindow.java @@ -129,19 +129,17 @@ public Void doInBackground() { if (chckbxFilterByMaximum.isSelected()) { MAX = Integer.parseInt(txtMax.getText()); } - + // process each bam for (int x = 0; x < BAMFiles.size(); x++) { - - BAMtoGFFOutput convert = new BAMtoGFFOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX, chckbxGzipOutput.isSelected()); - convert.addPropertyChangeListener("log", new PropertyChangeListener() { + BAMtoGFFOutput output_obj = new BAMtoGFFOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX, chckbxGzipOutput.isSelected()); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - - convert.setVisible(true); - convert.run(); - + output_obj.setVisible(true); + output_obj.run(); + // Update progress int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java index 8c9ec9e2f..831735e70 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtobedGraphWindow.java @@ -122,18 +122,17 @@ public Void doInBackground() { if (chckbxFilterByMaximum.isSelected()) { MAX = Integer.parseInt(txtMax.getText()); } - + // process each bam for (int x = 0; x < BAMFiles.size(); x++) { - BAMtobedGraphOutput convert = new BAMtobedGraphOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, - MIN, MAX, chckbxGzipOutput.isSelected()); - convert.addPropertyChangeListener("log", new PropertyChangeListener() { + BAMtobedGraphOutput output_obj = new BAMtobedGraphOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX, chckbxGzipOutput.isSelected()); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - convert.setVisible(true); - convert.run(); - + output_obj.setVisible(true); + output_obj.run(); + // Update progress int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java index 468d43478..5b503af99 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXWindow.java @@ -123,18 +123,17 @@ public Void doInBackground() { if (chckbxFilterByMaximum.isSelected()) { MAX = Integer.parseInt(txtMax.getText()); } - + // process each bam for (int x = 0; x < BAMFiles.size(); x++) { - - BAMtoscIDXOutput convert = new BAMtoscIDXOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX, chckbxGzipOutput.isSelected()); - convert.addPropertyChangeListener("log", new PropertyChangeListener() { + BAMtoscIDXOutput output_obj = new BAMtoscIDXOutput(BAMFiles.get(x), OUT_DIR, STRAND, PAIR, MIN, MAX, chckbxGzipOutput.isSelected()); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - - convert.setVisible(true); - + output_obj.setVisible(true); + output_obj.run(); + // Update progress int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java index c6b8f18ad..5d6fc3a3e 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java @@ -233,24 +233,21 @@ public Void doInBackground() { // param.printAll(); // Initialize, addPropertyChangeListeners, and execute - TagPileupOutput pile = new TagPileupOutput(BEDFiles, BAMFiles, param, colors); - pile.addPropertyChangeListener("tag", new PropertyChangeListener() { + TagPileupOutput output_obj = new TagPileupOutput(BEDFiles, BAMFiles, param, colors); + output_obj.addPropertyChangeListener("tag", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int) (((double) (temp) / (BAMFiles.size() * BEDFiles.size())) * 100); setProgress(percentComplete); } }); - pile.addPropertyChangeListener("log", new PropertyChangeListener() { + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - pile.setVisible(true); - pile.run(); - - setProgress(100); - return null; + output_obj.setVisible(true); + output_obj.run(); } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!", "Validate Input", JOptionPane.ERROR_MESSAGE); @@ -263,6 +260,7 @@ public void propertyChange(PropertyChangeEvent evt) { e.printStackTrace(); JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } + setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java index a3b82affe..a6a0f481f 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/FASTAExtractWindow.java @@ -86,23 +86,23 @@ public Void doInBackground() { JOptionPane.showMessageDialog(null, "No BED Files Loaded!!!"); } else { setProgress(0); - FASTAExtractOutput signal = new FASTAExtractOutput(INPUT, BEDFiles, OUT_DIR, + FASTAExtractOutput output_obj = new FASTAExtractOutput(INPUT, BEDFiles, OUT_DIR, chckbxStrand.isSelected(), rdbtnBedName.isSelected(), chckbxGzipOutput.isSelected()); - signal.addPropertyChangeListener("progress", new PropertyChangeListener() { + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { int temp = (Integer) propertyChangeEvent.getNewValue(); int percentComplete = (int) (((double) (temp) / BEDFiles.size()) * 100); setProgress(percentComplete); } }); - signal.addPropertyChangeListener("log", new PropertyChangeListener() { + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - signal.setVisible(true); - signal.run(); + output_obj.setVisible(true); + output_obj.run(); } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); diff --git a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java index e8a62232e..8d515b6e1 100644 --- a/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java +++ b/src/main/java/scriptmanager/window_interface/Sequence_Analysis/SearchMotifWindow.java @@ -83,15 +83,15 @@ public Void doInBackground() { } else { setProgress(0); for (int gfile = 0; gfile < GenomeFiles.size(); gfile++) { - SearchMotifOutput search = new SearchMotifOutput(GenomeFiles.get(gfile), txtMotif.getText(), + SearchMotifOutput output_obj = new SearchMotifOutput(GenomeFiles.get(gfile), txtMotif.getText(), Integer.parseInt(txtMismatch.getText()), OUT_DIR, chckbxGzipOutput.isSelected()); - search.addPropertyChangeListener("log", new PropertyChangeListener() { + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } }); - search.setVisible(true); - search.run(); + output_obj.setVisible(true); + output_obj.run(); // Update progress int percentComplete = (int) (((double) (gfile + 1) / (GenomeFiles.size())) * 100); setProgress(percentComplete); From 5a6c99199aef2e37004eebee11fe84196723bc9f Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 20:44:28 -0500 Subject: [PATCH 50/58] add GUI output BAM indexing commands to log in addition to the logging primary tool's executio, the indexing of output commands should also be logged --- .../BAM_Manipulation/BAMMarkDupWindow.java | 11 ++++- .../FilterforPIPseqWindow.java | 12 +++++- .../BAM_Manipulation/MergeBAMWindow.java | 42 +++++++++++-------- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java index 45f494117..a0e651d8e 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java @@ -38,6 +38,7 @@ import scriptmanager.objects.ToolDescriptions; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; +import scriptmanager.cli.BAM_Manipulation.BAIIndexerCLI; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; import scriptmanager.cli.BAM_Manipulation.BAMRemoveDupCLI; import scriptmanager.scripts.BAM_Manipulation.BAMMarkDuplicates; @@ -100,14 +101,22 @@ public Void doInBackground() { firePropertyChange("log", old_li, new_li); // Execute script BAMMarkDuplicates.mark(BAMFiles.get(x), chckbxRemoveDuplicates.isSelected(), OUTPUT, METRICS); - // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); old_li = new_li; // Generate index on output if (chckbxGenerateBaiIndex.isSelected()) { + // Initialize LogItem (index BAM) + command = BAIIndexerCLI.getCLIcommand(BAMFiles.get(x)); + old_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script (index) BAIIndexer.generateIndex(OUTPUT); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; } // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java index 2843d6f8a..58097508b 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/FilterforPIPseqWindow.java @@ -34,6 +34,7 @@ import javax.swing.JTextField; import javax.swing.SwingConstants; +import scriptmanager.cli.BAM_Manipulation.BAIIndexerCLI; import scriptmanager.cli.BAM_Manipulation.FilterforPIPseqCLI; import scriptmanager.objects.LogItem; import scriptmanager.objects.ToolDescriptions; @@ -100,7 +101,7 @@ public Void doInBackground() { String command = FilterforPIPseqCLI.getCLIcommand(BAMFiles.get(x), GENOME, OUTPUT, txtSeq.getText()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); - // Execute Wrapper + // Execute script FilterforPIPseqOutput output_obj = new FilterforPIPseqOutput(BAMFiles.get(x), GENOME, OUTPUT, txtSeq.getText()); output_obj.setVisible(true); output_obj.run(); @@ -110,7 +111,16 @@ public Void doInBackground() { old_li = new_li; // Generate BAI on output if selected if (chckbxGenerateBaiIndex.isSelected()) { + // Initialize LogItem (index BAM) + command = BAIIndexerCLI.getCLIcommand(BAMFiles.get(x)); + old_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script (index) BAIIndexer.generateIndex(OUTPUT); + // Update log item + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; } // Update progress int percentComplete = (int) (((double) (x + 1) / BAMFiles.size()) * 100); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java index 9c24b1b84..b3a907776 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/MergeBAMWindow.java @@ -33,6 +33,8 @@ import java.sql.Timestamp; import java.util.Date; + +import scriptmanager.cli.BAM_Manipulation.BAIIndexerCLI; import scriptmanager.cli.BAM_Manipulation.MergeBAMCLI; import scriptmanager.objects.LogItem; import scriptmanager.objects.ToolDescriptions; @@ -65,7 +67,7 @@ public class MergeBAMWindow extends JFrame implements ActionListener, PropertyCh private JButton btnOutput; private JTextField txtOutput; private JCheckBox chckbxUseMultipleCpus; - private JCheckBox chckbxGenerateBaiindex; + private JCheckBox chckbxGenerateBaiIndex; private JProgressBar progressBar; private JLabel lblDefaultToLocal; @@ -81,7 +83,6 @@ class Task extends SwingWorker { @Override public Void doInBackground() { setProgress(0); - LogItem old_li = null; try { // Construct output filename File OUTPUT = new File(txtOutput.getText()); @@ -89,21 +90,28 @@ public Void doInBackground() { OUTPUT = new File(OUT_DIR.getCanonicalPath() + File.separator + txtOutput.getText()); } // Initialize LogItem - String command = MergeBAMCLI.getCLIcommand(BAMFiles, OUTPUT, chckbxUseMultipleCpus.isSelected()); - LogItem new_li = new LogItem(command); - firePropertyChange("log", old_li, new_li); + String command = MergeBAMCLI.getCLIcommand(BAMFiles, OUTPUT, chckbxUseMultipleCpus.isSelected()); + LogItem li = new LogItem(command); + firePropertyChange("log", null, li); // Execute Picard wrapper MergeBAM.run(BAMFiles, OUTPUT, chckbxUseMultipleCpus.isSelected()); // Update LogItem - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; - // Index if checkbox selected - if(chckbxGenerateBaiindex.isSelected()) { + li.setStopTime(new Timestamp(new Date().getTime())); + li.setStatus(0); + // Generate index on output + if (chckbxGenerateBaiIndex.isSelected()) { + // Initialize LogItem (index BAM) + command = BAIIndexerCLI.getCLIcommand(OUTPUT); + li = new LogItem(command); + firePropertyChange("log", null, li); + // Execute script (index) BAIIndexer.generateIndex(OUTPUT); + // Update log item + li.setStopTime(new Timestamp(new Date().getTime())); + li.setStatus(0); } // Update log after final input - firePropertyChange("log", old_li, null); + firePropertyChange("log", li, null); // Update progress setProgress(100); JOptionPane.showMessageDialog(null, "Merging Complete"); @@ -216,12 +224,12 @@ public void actionPerformed(ActionEvent arg0) { chckbxUseMultipleCpus.setToolTipText("Increases Merging Speed on Computers with Multiple CPUs"); contentPane.add(chckbxUseMultipleCpus); - chckbxGenerateBaiindex = new JCheckBox("Generate BAI-Index"); - sl_contentPane.putConstraint(SpringLayout.WEST, chckbxGenerateBaiindex, 5, SpringLayout.WEST, contentPane); - sl_contentPane.putConstraint(SpringLayout.SOUTH, lblOutputFileName, -6, SpringLayout.NORTH, chckbxGenerateBaiindex); - sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxGenerateBaiindex, 0, SpringLayout.NORTH, chckbxUseMultipleCpus); - chckbxGenerateBaiindex.setSelected(true); - contentPane.add(chckbxGenerateBaiindex); + chckbxGenerateBaiIndex = new JCheckBox("Generate BAI-Index"); + sl_contentPane.putConstraint(SpringLayout.WEST, chckbxGenerateBaiIndex, 5, SpringLayout.WEST, contentPane); + sl_contentPane.putConstraint(SpringLayout.SOUTH, lblOutputFileName, -6, SpringLayout.NORTH, chckbxGenerateBaiIndex); + sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxGenerateBaiIndex, 0, SpringLayout.NORTH, chckbxUseMultipleCpus); + chckbxGenerateBaiIndex.setSelected(true); + contentPane.add(chckbxGenerateBaiIndex); JLabel lblCurrent = new JLabel("Current Output:"); sl_contentPane.putConstraint(SpringLayout.WEST, lblCurrent, 0, SpringLayout.WEST, scrollPane); From 3a8e6a92ca746ef089e445e9099c149e819707dc Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 20:50:34 -0500 Subject: [PATCH 51/58] bugfix roman to arabic directionality in log the RtoA/AtoR logic was inverted for the getCLIcommand function --- .../cli/File_Utilities/ConvertBEDChrNamesCLI.java | 6 +++--- .../cli/File_Utilities/ConvertGFFChrNamesCLI.java | 6 +++--- .../File_Utilities/ConvertBEDChrNamesWindow.java | 8 ++++---- .../File_Utilities/ConvertGFFChrNamesWindow.java | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java index cad73b66d..b92f7d565 100644 --- a/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java +++ b/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java @@ -107,16 +107,16 @@ private String validateInput() throws IOException { /** * Reconstruct CLI command * - * @param AtoR whether to do a arabic to roman numeral conversion (vs roman to arabic numeral) + * @param RtoA whether to do a roman to arabic numeral conversion (vs arabic to roman numeral) * @param input the BED file to convert chr names of * @param output the output GFF file of converted coords * @param useChrmt whether or not to use "chrmt" * @param gzOutput gzip output * @return command line to execute with formatted inputs */ - public static String getCLIcommand(boolean AtoR, File input, File output, boolean useChrmt, boolean gzOutput) { + public static String getCLIcommand(boolean RtoA, File input, File output, boolean useChrmt, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER file-utilities convert-bed-genome"; - command += AtoR ? "" : " --to-arabic" ; + command += RtoA ? " --to-arabic" : ""; command += " -o " + output.getAbsolutePath(); command += useChrmt ? " --chrmt" : ""; command += gzOutput ? " --gzip" : ""; diff --git a/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java index 925bda7a1..ce963cba5 100644 --- a/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java +++ b/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java @@ -108,16 +108,16 @@ private String validateInput() throws IOException { /** * Reconstruct CLI command * - * @param AtoR whether to do a arabic to roman numeral conversion (vs roman to arabic numeral) + * @param RtoA whether to do a roman to arabic numeral conversion (vs arabic to roman numeral) * @param input the GFF file to convert chr names of * @param output the output BED file of converted coords * @param useChrmt whether or not to use "chrmt" * @param gzOutput gzip output * @return command line to execute with formatted inputs */ - public static String getCLIcommand(boolean AtoR, File input, File output, boolean useChrmt, boolean gzOutput) { + public static String getCLIcommand(boolean RtoA, File input, File output, boolean useChrmt, boolean gzOutput) { String command = "java -jar $SCRIPTMANAGER file-utilities convert-gff-genome"; - command += AtoR ? "" : " --to-arabic" ; + command += RtoA ? " --to-arabic" : ""; command += " -o " + output.getAbsolutePath(); command += useChrmt ? " --chrmt" : ""; command += gzOutput ? " --gzip" : ""; diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java index ebd2f0bf2..414b188f2 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertBEDChrNamesWindow.java @@ -99,14 +99,14 @@ public Void doInBackground() { OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } // Initialize LogItem - String command = ConvertBEDChrNamesCLI.getCLIcommand(rdbtnA2R.isSelected(), XBED, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + String command = ConvertBEDChrNamesCLI.getCLIcommand(rdbtnR2A.isSelected(), XBED, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute script - if (rdbtnA2R.isSelected()) { - ConvertChrNames.convert_ArabictoRoman(XBED, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); - } else { + if (rdbtnR2A.isSelected()) { ConvertChrNames.convert_RomantoArabic(XBED, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + } else { + ConvertChrNames.convert_ArabictoRoman(XBED, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); } // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); diff --git a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java index 0ce1d14f3..e130b9d6b 100644 --- a/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java +++ b/src/main/java/scriptmanager/window_interface/File_Utilities/ConvertGFFChrNamesWindow.java @@ -99,14 +99,14 @@ public Void doInBackground() { OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); } // Initialize LogItem - String command = ConvertGFFChrNamesCLI.getCLIcommand(rdbtnA2R.isSelected(), XGFF, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + String command = ConvertGFFChrNamesCLI.getCLIcommand(rdbtnR2A.isSelected(), XGFF, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute script - if (rdbtnA2R.isSelected()) { - ConvertChrNames.convert_ArabictoRoman(XGFF, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); - } else { + if (rdbtnR2A.isSelected()) { ConvertChrNames.convert_RomantoArabic(XGFF, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); + } else { + ConvertChrNames.convert_ArabictoRoman(XGFF, OUT_FILEPATH, chckbxChrmt.isSelected(), chckbxGzipOutput.isSelected()); } // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); From e3bc09634ae7f3b72be48aa3fd1f60f74e9cb7e9 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 21:23:35 -0500 Subject: [PATCH 52/58] bugfix shift-coord boolean mixup the adjacent booleans in the method signature for gzOutput and isGFF were meixed up in the logging function getCLIcommand and in the method call in the GUI. This commit fixes this bug --- .../cli/Coordinate_Manipulation/ShiftCoordCLI.java | 2 +- .../Coordinate_Manipulation/ShiftIntervalWindow.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java index 150cb1677..504712543 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java @@ -93,7 +93,7 @@ private String validateInput() throws IOException { return(r); } - public static String getCLIcommand(File input, File output, int shift, boolean stranded, boolean isGFF, boolean gzOutput) { + public static String getCLIcommand(File input, File output, int shift, boolean stranded, boolean gzOutput, boolean isGFF) { String command = "java -jar $SCRIPTMANAGER coordinate-manipulation shift-coord"; command += " " + input.getAbsolutePath(); command += " -o " + output.getAbsolutePath(); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java index 0b947ab02..3401a9861 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java @@ -118,7 +118,7 @@ public Void doInBackground() { OUTPUT = OUT_DIR + File.separator + OUTPUT; } // Initialize LogItem - String command = ShiftCoordCLI.getCLIcommand(XBED, new File(OUTPUT + SUFFIX), SHIFT, chckbxStranded.isSelected(), false, chckbxGzipOutput.isSelected()); + String command = ShiftCoordCLI.getCLIcommand(XBED, new File(OUTPUT + SUFFIX), SHIFT, chckbxStranded.isSelected(), chckbxGzipOutput.isSelected(), false); LogItem new_li = new LogItem(command); firePropertyChange("log", old_li, new_li); // Execute script From 5d86c5c22e109b0aecc8193704106478f38e0ad1 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 21:43:19 -0500 Subject: [PATCH 53/58] fix output filename construction to account for gzOutput Many default output file construction statements in *CLI and *Window/*Output classes were missing the ".gz" extension. This commit fixes these statements --- .../cli/BAM_Format_Converter/BAMtoBEDCLI.java | 10 +++++----- .../cli/BAM_Format_Converter/BAMtoGFFCLI.java | 10 +++++----- .../cli/BAM_Format_Converter/BAMtoscIDXCLI.java | 10 +++++----- .../cli/Coordinate_Manipulation/ShiftCoordCLI.java | 7 ++++--- .../cli/File_Utilities/ConvertBEDChrNamesCLI.java | 9 ++++----- .../cli/File_Utilities/ConvertGFFChrNamesCLI.java | 9 ++++----- .../cli/Peak_Analysis/BEDPeakAligntoRefCLI.java | 3 ++- .../cli/Peak_Analysis/RandomCoordinateCLI.java | 5 +++-- .../scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java | 9 +++++---- .../cli/Read_Analysis/ScaleMatrixCLI.java | 4 +++- .../cli/Read_Analysis/TransposeMatrixCLI.java | 4 +++- .../cli/Sequence_Analysis/FASTAExtractCLI.java | 4 ++-- .../cli/Sequence_Analysis/RandomizeFASTACLI.java | 4 ++-- .../cli/Sequence_Analysis/SearchMotifCLI.java | 3 ++- .../scripts/Read_Analysis/AggregateData.java | 2 +- .../BAM_Format_Converter/BAMtoBEDOutput.java | 4 ++-- .../BAM_Format_Converter/BAMtoGFFOutput.java | 4 ++-- .../BAM_Format_Converter/BAMtoscIDXOutput.java | 4 ++-- .../window_interface/BAM_Statistics/SEStatOutput.java | 3 +-- .../BED_Manipulation/SortBEDWindow.java | 5 +++-- .../GFF_Manipulation/SortGFFWindow.java | 3 ++- .../Peak_Analysis/RandomCoordinateWindow.java | 7 +++---- .../Peak_Analysis/TileGenomeWindow.java | 6 +++--- .../Read_Analysis/ScaleMatrixWindow.java | 5 +++-- 24 files changed, 71 insertions(+), 63 deletions(-) diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java index e28be5c2f..01684fd7e 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java @@ -116,11 +116,11 @@ private String validateInput() throws IOException { } //set default output filename if(output==null && !stdout){ - if(STRAND==0){ output = new File( bamFile.getName().split("\\.")[0] + "_READ1.bed" ); } - else if(STRAND==1){ output = new File( bamFile.getName().split("\\.")[0] + "_READ2.bed" ); } - else if(STRAND==2){ output = new File( bamFile.getName().split("\\.")[0] + "_COMBINED.bed" ); } - else if(STRAND==3){ output = new File( bamFile.getName().split("\\.")[0] + "_MIDPOINT.bed" ); } - else if(STRAND==4){ output = new File( bamFile.getName().split("\\.")[0] + "_FRAGMENT.bed" ); } + if (STRAND==0) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ1.bed" + (gzOutput ? ".gz" : "")); } + else if (STRAND==1) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ2.bed" + (gzOutput ? ".gz" : "")); } + else if (STRAND==2) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_COMBINED.bed" + (gzOutput ? ".gz" : "")); } + else if (STRAND==3) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_MIDPOINT.bed" + (gzOutput ? ".gz" : "")); } + else if (STRAND==4) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_FRAGMENT.bed" + (gzOutput ? ".gz" : "")); } else { r += "(!)Somehow invalid STRAND!This error should never print. Check code if it does.\n"; } //check stdout and output not both selected }else if(stdout){ diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java index 7b47ba08b..7cc638e71 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java @@ -116,11 +116,11 @@ private String validateInput() throws IOException { } //set default output filename if(output==null && !stdout){ - if(STRAND==0){ output = new File( bamFile.getName().split("\\.")[0] + "_READ1.gff" ); } - else if(STRAND==1){ output = new File( bamFile.getName().split("\\.")[0] + "_READ2.gff" ); } - else if(STRAND==2){ output = new File( bamFile.getName().split("\\.")[0] + "_COMBINED.gff" ); } - else if(STRAND==3){ output = new File( bamFile.getName().split("\\.")[0] + "_MIDPOINT.gff" ); } - else if(STRAND==4){ output = new File( bamFile.getName().split("\\.")[0] + "_FRAGMENT.gff" ); } + if (STRAND==0) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ1.gff" + (gzOutput ? ".gz" : "")); } + else if (STRAND==1) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ2.gff" + (gzOutput ? ".gz" : "")); } + else if (STRAND==2) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_COMBINED.gff" + (gzOutput ? ".gz" : "")); } + else if (STRAND==3) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_MIDPOINT.gff" + (gzOutput ? ".gz" : "")); } + else if (STRAND==4) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_FRAGMENT.gff" + (gzOutput ? ".gz" : "")); } else { r += "(!)Somehow invalid STRAND!This error should never print. Check code if it does.\n"; } //check stdout and output not both selected }else if(stdout){ diff --git a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java index 6a9dc41ee..a9b6d7a60 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java @@ -112,11 +112,11 @@ private String validateInput() throws IOException { } //set default output filename if(output==null && !stdout){ - if(STRAND==0){ output = new File( bamFile.getName().split("\\.")[0] + "_READ1.tab" ); } - else if(STRAND==1){ output = new File( bamFile.getName().split("\\.")[0] + "_READ2.tab" ); } - else if(STRAND==2){ output = new File( bamFile.getName().split("\\.")[0] + "_COMBINED.tab" ); } - else if(STRAND==3){ output = new File( bamFile.getName().split("\\.")[0] + "_MIDPOINT.tab" ); } - else if(STRAND==4){ output = new File( bamFile.getName().split("\\.")[0] + "_FRAGMENT.tab" ); } + if (STRAND==0) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ1.tab" + (gzOutput ? ".gz" : "")); } + else if (STRAND==1) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ2.tab" + (gzOutput ? ".gz" : "")); } + else if (STRAND==2) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_COMBINED.tab" + (gzOutput ? ".gz" : "")); } + else if (STRAND==3) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_MIDPOINT.tab" + (gzOutput ? ".gz" : "")); } + else if (STRAND==4) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_FRAGMENT.tab" + (gzOutput ? ".gz" : "")); } else { r += "(!)Somehow invalid STRAND!This error should never print. Check code if it does.\n"; } //check stdout and output not both selected }else if(stdout){ diff --git a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java index 504712543..8f6615422 100644 --- a/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java +++ b/src/main/java/scriptmanager/cli/Coordinate_Manipulation/ShiftCoordCLI.java @@ -76,9 +76,10 @@ private String validateInput() throws IOException { //set default output filename if(outputFilepath==null){ - String SUFFIX = shift < 0 ? "_shift" + shift + "bp." : "_shift+" + shift + "bp."; - SUFFIX += isGFF ? "gff" : "bed"; - outputFilepath = ExtensionFileFilter.stripExtensionIgnoreGZ(input) + SUFFIX; + outputFilepath = ExtensionFileFilter.stripExtensionIgnoreGZ(input) + + (shift < 0 ? "_shift" + shift + "bp." : "_shift+" + shift + "bp") + + (isGFF ? ".gff" : ".bed") + + (gzOutput ? ".gz" : ""); //check output filename is valid }else{ //no extension check diff --git a/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java index b92f7d565..69a346ec2 100644 --- a/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java +++ b/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java @@ -87,12 +87,11 @@ private String validateInput() throws IOException { } //set default output filename if (output == null) { - // Set suffix format - String SUFFIX = toArabic ? "_toRoman.gff" : "_toArabic.gff"; // Set output filepath with name and output directory - String OUTPUT = ExtensionFileFilter.stripExtensionIgnoreGZ(coordFile); - output = new File(OUTPUT + SUFFIX); - }else{ + output = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(coordFile) + + (toArabic ? "_toRoman.gff" : "_toArabic.gff") + + (gzOutput ? ".gz" : "")); + } else { //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java index ce963cba5..97f405983 100644 --- a/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java +++ b/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java @@ -88,12 +88,11 @@ private String validateInput() throws IOException { } //set default output filename if (output == null) { - // Set suffix format - String SUFFIX = toArabic ? "_toRoman.bed" : "_toArabic.bed"; // Set output filepath with name and output directory - String OUTPUT = ExtensionFileFilter.stripExtensionIgnoreGZ(coordFile); - output = new File(OUTPUT + SUFFIX); - }else{ + output = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(coordFile) + + (toArabic ? "_toRoman.bed" : "_toArabic.bed") + + (gzOutput ? ".gz" : "")); + } else { //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java index 34c5ee17b..8f045607c 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java @@ -75,7 +75,8 @@ private String validateInput() throws IOException { if(!r.equals("")){ return(r); } //set default output filename if(output==null){ - output = new File(ExtensionFileFilter.stripExtension(peakBED) + "_" + ExtensionFileFilter.stripExtension(refBED) + "_Output.cdt"); + output = new File(ExtensionFileFilter.stripExtension(peakBED) + "_" + ExtensionFileFilter.stripExtension(refBED) + "_Output.cdt" + + (gzOutput ? ".gz" : "")); //check output filename is valid }else{ //check directory diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java index 9452bd63b..610b9d123 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java @@ -63,10 +63,11 @@ public Integer call() throws Exception { private String validateInput() throws IOException { String r = ""; - String ext = formatIsBed ? "bed" : "gff"; //set default output filename if(output==null){ - output = new File("random_coordinates_" + genomeName + "_" + numSites + "sites_" + window + "bp." + ext); + output = new File("random_coordinates_" + genomeName + "_" + numSites + "sites_" + window + "bp" + + (formatIsBed ? ".bed" : ".gff") + + (gzOutput ? ".gz" : "")); //check output filename is valid }else{ //check directory diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java index b6d8329b0..fc039b909 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java @@ -61,12 +61,13 @@ public Integer call() throws Exception { private String validateInput() throws IOException { String r = ""; - String ext = formatIsBed ? "bed" : "gff"; //set default output filename - if(output==null){ - output = new File(genomeName + "_" + window + "bp." + ext); + if (output==null) { + output = new File(genomeName + "_" + window + "bp" + + (formatIsBed ? ".bed" : ".gff") + + (gzOutput ? ".gz" : "")); //check output filename is valid - }else{ + } else { //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Read_Analysis/ScaleMatrixCLI.java b/src/main/java/scriptmanager/cli/Read_Analysis/ScaleMatrixCLI.java index 2f3147393..da9882e37 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/ScaleMatrixCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/ScaleMatrixCLI.java @@ -74,7 +74,9 @@ private String validateInput() throws IOException { //no check ext //set default output filename if(output==null){ - output = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(matrixFile) + "_SCALE." + ExtensionFileFilter.getExtensionIgnoreGZ(matrixFile)); + output = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(matrixFile) + "_SCALE." + + ExtensionFileFilter.getExtensionIgnoreGZ(matrixFile) + + (gzOutput ? ".gz" : "")); //check output filename is valid }else if( output.isDirectory() ){ r += "(!)Must indicate file (not a directory) for your output."; diff --git a/src/main/java/scriptmanager/cli/Read_Analysis/TransposeMatrixCLI.java b/src/main/java/scriptmanager/cli/Read_Analysis/TransposeMatrixCLI.java index be91a2b9f..54afc77ae 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/TransposeMatrixCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/TransposeMatrixCLI.java @@ -65,7 +65,9 @@ private String validateInput() throws IOException { //no check ext //set default output filename if(output==null){ - output = new File(ExtensionFileFilter.stripExtension(matrixFile) + "_TRANPOSE." + ExtensionFileFilter.getExtension(matrixFile)); + output = new File(ExtensionFileFilter.stripExtension(matrixFile) + "_TRANPOSE." + + ExtensionFileFilter.getExtension(matrixFile) + + (gzOutput ? ".gz" : "")); //check output filename is valid }else if( output.isDirectory() ){ r += "(!)Must indicate file (not a directory) for your output."; diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java index 0f3141774..55c45a090 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/FASTAExtractCLI.java @@ -82,8 +82,8 @@ private String validateInput() throws IOException { } // set default output filename if (output == null) { - String NAME = ExtensionFileFilter.stripExtension(bedFile) + ".fa"; - output = new File(NAME); + output = new File(ExtensionFileFilter.stripExtension(bedFile) + ".fa" + + (gzOutput ? ".gz" : "")); // check output filename is valid } else { // check directory diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java index fdb415e82..6ea397ebc 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java @@ -74,8 +74,8 @@ private String validateInput() throws IOException { } // set default output filename if (output == null) { - String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(fastaFile) + "_RAND.fa"; - output = new File(NAME); + output = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(fastaFile) + "_RAND.fa" + + (gzOutput ? ".gz" : "")); // check output filename is valid } else { // check directory diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java index 7c2ed90c5..38a4e8007 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java @@ -78,7 +78,8 @@ private String validateInput() throws IOException { // set default output filename if (output == null) { String NAME = motif + "_" + Integer.toString(ALLOWED_MISMATCH) + "Mismatch_" - + ExtensionFileFilter.stripExtension(fastaFile) + ".bed"; + + ExtensionFileFilter.stripExtension(fastaFile) + ".bed" + + (gzOutput ? ".gz" : ""); output = new File(NAME); // check output filename is valid } else { diff --git a/src/main/java/scriptmanager/scripts/Read_Analysis/AggregateData.java b/src/main/java/scriptmanager/scripts/Read_Analysis/AggregateData.java index 3b968c683..63c88e10a 100644 --- a/src/main/java/scriptmanager/scripts/Read_Analysis/AggregateData.java +++ b/src/main/java/scriptmanager/scripts/Read_Analysis/AggregateData.java @@ -177,7 +177,7 @@ public String getMessage() { * @throws IOException Invalid file or parameters */ public void outputFileScore(File IN) throws FileNotFoundException, IOException { - String NEWNAME = ExtensionFileFilter.stripExtension(IN) + "_SCORES.out"; + String NEWNAME = ExtensionFileFilter.stripExtensionIgnoreGZ(IN) + "_SCORES.out"; if (OUT_PATH != null) { OUT = GZipUtilities.makePrintStream(new File(OUT_PATH.getAbsolutePath() + File.separator + NEWNAME + (OUTPUT_GZIP? ".gz": "")), OUTPUT_GZIP); } else { diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java index 1df7315f0..464bce52e 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoBEDOutput.java @@ -15,6 +15,7 @@ import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Format_Converter.BAMtoBED; +import scriptmanager.util.ExtensionFileFilter; /** * Output wrapper for running @@ -88,8 +89,7 @@ public BAMtoBEDOutput(File b, File out_dir, int s, int pair_status, int min_size */ public void run() throws IOException, InterruptedException { // Open Output File - String OUTPUT = BAM.getName().split("\\.")[0] + "_" + READ + ".bed"; - OUTPUT += (OUTPUT_GZIP? ".gz": ""); + String OUTPUT = ExtensionFileFilter.stripExtensionIgnoreGZ(BAM) + "_" + READ + ".bed" + (OUTPUT_GZIP ? ".gz": ""); if (OUT_DIR != null) { OUTPUT = OUT_DIR.getCanonicalPath() + File.separator + OUTPUT; } diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java index 55a6dc832..ad61ca121 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoGFFOutput.java @@ -15,6 +15,7 @@ import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Format_Converter.BAMtoGFF; +import scriptmanager.util.ExtensionFileFilter; /** * Output wrapper for running @@ -88,11 +89,10 @@ public BAMtoGFFOutput(File b, File out_dir, int s, int pair_status, int min_size */ public void run() throws IOException, InterruptedException { // Open Output File - String OUTPUT = BAM.getName().split("\\.")[0] + "_" + READ + ".gff"; + String OUTPUT = ExtensionFileFilter.stripExtensionIgnoreGZ(BAM) + "_" + READ + ".gff" + (OUTPUT_GZIP ? ".gz": ""); if (OUT_DIR != null) { OUTPUT = OUT_DIR.getCanonicalPath() + File.separator + OUTPUT; } - OUTPUT = OUTPUT + (OUTPUT_GZIP? ".gz": ""); // Call script here, pass in ps and OUT PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java index dc9eb554f..617e54e96 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Format_Converter/BAMtoscIDXOutput.java @@ -15,6 +15,7 @@ import scriptmanager.objects.CustomOutputStream; import scriptmanager.objects.LogItem; import scriptmanager.scripts.BAM_Format_Converter.BAMtoscIDX; +import scriptmanager.util.ExtensionFileFilter; /** * Output wrapper for running @@ -86,11 +87,10 @@ public BAMtoscIDXOutput(File b, File out_dir, int s, int pair_status, int min_si */ public void run() throws IOException, InterruptedException { // Open Output File - String OUTPUT = BAM.getName().split("\\.")[0] + "_" + READ + ".tab"; + String OUTPUT = ExtensionFileFilter.stripExtensionIgnoreGZ(BAM) + "_" + READ + ".tab" + (OUTPUT_GZIP ? ".gz": ""); if (OUT_DIR != null) { OUTPUT = OUT_DIR.getCanonicalPath() + File.separator + OUTPUT; } - OUTPUT += (OUTPUT_GZIP? ".gz": ""); // Call script here, pass in ps and OUT PrintStream PS = new PrintStream(new CustomOutputStream(textArea)); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java index 01049a36c..31cb30b86 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/SEStatOutput.java @@ -2,7 +2,6 @@ import java.awt.BorderLayout; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; import java.net.URISyntaxException; @@ -87,7 +86,7 @@ public void run() throws IOException { LogItem new_li = new LogItem(command); if (OUTPUT_STATUS) { firePropertyChange("log", old_li, new_li); } // Execute script - SEStats.getSEStats(bamFiles.get(x), new File(OUT_DIR + File.separator + NAME), OUTPUT_STATUS, ps_stats); + SEStats.getSEStats(bamFiles.get(x), OUT_FILEPATH, OUTPUT_STATUS, ps_stats); // Update log item new_li.setStopTime(new Timestamp(new Date().getTime())); new_li.setStatus(0); diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java index 6373dff81..3c17507f7 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/SortBEDWindow.java @@ -360,9 +360,10 @@ public void actionPerformed(ActionEvent e) { String sortName = ""; try { sortName = ExtensionFileFilter.stripExtensionIgnoreGZ(BED_File) + "_SORT.bed"; - } catch (IOException e1) { + sortName += chckbxGzipOutput.isSelected() ? ".gz" : ""; + } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Invalid BED"); - }; + } txtOutput.setText(sortName); } } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java index ddd5330d7..e34c4e34f 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/SortGFFWindow.java @@ -351,7 +351,8 @@ public void actionPerformed(ActionEvent e) { String sortName = ""; try { sortName = ExtensionFileFilter.stripExtensionIgnoreGZ(GFF_File) + "_SORT.gff"; - } catch (IOException e1) { + sortName += chckbxGzipOutput.isSelected() ? ".gz" : ""; + } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Invalid GFF"); } txtOutput.setText(sortName); diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java index ad003e875..e4bd87830 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java @@ -34,7 +34,6 @@ import scriptmanager.objects.LogItem; import scriptmanager.objects.ToolDescriptions; import scriptmanager.objects.CustomExceptions.OptionException; -import scriptmanager.util.ExtensionFileFilter; import scriptmanager.util.FileSelection; import scriptmanager.scripts.Peak_Analysis.RandomCoordinate; @@ -86,9 +85,9 @@ public Void doInBackground() { JOptionPane.showMessageDialog(null, "Invalid Window Size Entered!!!"); } else { // Construct output filename - String NAME = (String)cmbGenome.getSelectedItem() + "_" + Integer.parseInt(txtSites.getText()) + "SITES_" + Integer.parseInt(txtSize.getText()) + "bp"; - NAME += rdbtnBed.isSelected() ? ".bed" : ".gff"; - NAME += chckbxGzipOutput.isSelected() ? ".gz" : ""; + String NAME = (String)cmbGenome.getSelectedItem() + "_" + Integer.parseInt(txtSites.getText()) + "SITES_" + Integer.parseInt(txtSize.getText()) + "bp" + + (rdbtnBed.isSelected() ? ".bed" : ".gff") + + (chckbxGzipOutput.isSelected() ? ".gz" : ""); File OUT_FILEPATH = new File(NAME); if (OUT_DIR != null) { OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java index 3a619676f..89008af37 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/TileGenomeWindow.java @@ -77,9 +77,9 @@ public Void doInBackground() { JOptionPane.showMessageDialog(null, "Invalid Window Size Entered!!!"); } else { // Construct output filename - String NAME = (String)cmbGenome.getSelectedItem() + "_" + Integer.parseInt(txtSize.getText()) + "bp"; - NAME += rdbtnBed.isSelected() ? ".bed" : ".gff"; - NAME += chckbxGzipOutput.isSelected() ? ".gz" : ""; + String NAME = (String)cmbGenome.getSelectedItem() + "_" + Integer.parseInt(txtSize.getText()) + "bp" + + (rdbtnBed.isSelected() ? ".bed" : ".gff") + + (chckbxGzipOutput.isSelected() ? ".gz" : ""); File OUT_FILEPATH = new File(NAME); if (OUT_DIR != null) { OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java index 2073216e8..db07ff2ba 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScaleMatrixWindow.java @@ -131,8 +131,9 @@ public Void doInBackground() { // Pull input file File XTAB = TABFiles.get(x); // Construct output filename - String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(XTAB) + "_SCALE." + ExtensionFileFilter.getExtensionIgnoreGZ(XTAB); - NAME += chckbxGzipOutput.isSelected() ? ".gz" : ""; + String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(XTAB) + "_SCALE." + + ExtensionFileFilter.getExtensionIgnoreGZ(XTAB) + + (chckbxGzipOutput.isSelected() ? ".gz" : ""); File OUT_FILEPATH = new File(NAME); if (OUT_DIR != null) { OUT_FILEPATH = new File(OUT_DIR.getCanonicalPath() + File.separator + NAME); From 4499e7e31ef4b70bd7d606d012eaa1dd998c7ce2 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 22:20:00 -0500 Subject: [PATCH 54/58] consolidate redundant exception packages There is more than one exception package in this codebase so I am consolidating them under `scriptmanager.objects.Exceptions` --- .../cli/BAM_Statistics/BAMGenomeCorrelationCLI.java | 2 +- .../cli/Figure_Generation/LabelHeatMapCLI.java | 2 +- .../cli/Figure_Generation/ThreeColorHeatMapCLI.java | 2 +- .../cli/Figure_Generation/TwoColorHeatMapCLI.java | 2 +- .../cli/Read_Analysis/ScalingFactorCLI.java | 2 +- .../cli/Read_Analysis/TransposeMatrixCLI.java | 2 +- .../objects/CustomExceptions/ScriptManagerException.java | 9 --------- .../OptionException.java | 2 +- .../objects/Exceptions/ScriptManagerException.java | 3 +++ .../{CustomExceptions => Exceptions}/package-info.java | 2 +- .../scripts/BAM_Statistics/BAMGenomeCorrelation.java | 2 +- .../scripts/Figure_Generation/LabelHeatMap.java | 2 +- .../scripts/Figure_Generation/ThreeColorHeatMap.java | 5 +---- .../scripts/Peak_Analysis/RandomCoordinate.java | 2 +- .../scripts/Read_Analysis/TransposeMatrix.java | 2 +- .../BAM_Statistics/BAMGenomeCorrelationOutput.java | 2 +- .../BAM_Statistics/BAMGenomeCorrelationWindow.java | 2 +- .../Figure_Generation/LabelHeatMapOutput.java | 2 +- .../Figure_Generation/LabelHeatMapWindow.java | 2 +- .../Figure_Generation/ThreeColorHeatMapOutput.java | 2 +- .../Figure_Generation/ThreeColorHeatMapWindow.java | 2 +- .../Figure_Generation/TwoColorHeatMapOutput.java | 2 +- .../Figure_Generation/TwoColorHeatMapWindow.java | 2 +- .../Peak_Analysis/RandomCoordinateWindow.java | 2 +- .../Read_Analysis/ScalingFactorOutput.java | 2 +- .../Read_Analysis/ScalingFactorWindow.java | 2 +- .../Read_Analysis/TransposeMatrixWindow.java | 2 +- 27 files changed, 28 insertions(+), 37 deletions(-) delete mode 100644 src/main/java/scriptmanager/objects/CustomExceptions/ScriptManagerException.java rename src/main/java/scriptmanager/objects/{CustomExceptions => Exceptions}/OptionException.java (94%) rename src/main/java/scriptmanager/objects/{CustomExceptions => Exceptions}/package-info.java (56%) diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java index 6f9f5f35b..23a0786c7 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java @@ -15,7 +15,7 @@ import scriptmanager.charts.HeatMap; import scriptmanager.objects.ToolDescriptions; import scriptmanager.objects.ArchTEx.CorrParameter; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.scripts.BAM_Statistics.BAMGenomeCorrelation; diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java index ccaa9a87b..e0ccb8643 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/LabelHeatMapCLI.java @@ -12,7 +12,7 @@ import java.util.regex.Pattern; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.scripts.Figure_Generation.LabelHeatMap; diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java index 0d5279493..7dd4129dd 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java @@ -15,7 +15,7 @@ import java.util.regex.Pattern; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.scripts.Figure_Generation.ThreeColorHeatMap; diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java index 4a3ba5569..eb90a0a22 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/TwoColorHeatMapCLI.java @@ -14,7 +14,7 @@ import java.util.regex.Pattern; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.scripts.Figure_Generation.TwoColorHeatMap; diff --git a/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java b/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java index 098b50e4c..403ed15cf 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java @@ -11,7 +11,7 @@ import java.io.IOException; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.scripts.Read_Analysis.ScalingFactor; diff --git a/src/main/java/scriptmanager/cli/Read_Analysis/TransposeMatrixCLI.java b/src/main/java/scriptmanager/cli/Read_Analysis/TransposeMatrixCLI.java index 54afc77ae..3d5979815 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/TransposeMatrixCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/TransposeMatrixCLI.java @@ -10,7 +10,7 @@ import java.io.IOException; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.ScriptManagerException; +import scriptmanager.objects.Exceptions.ScriptManagerException; import scriptmanager.util.ExtensionFileFilter; import scriptmanager.scripts.Read_Analysis.TransposeMatrix; diff --git a/src/main/java/scriptmanager/objects/CustomExceptions/ScriptManagerException.java b/src/main/java/scriptmanager/objects/CustomExceptions/ScriptManagerException.java deleted file mode 100644 index bd8f38960..000000000 --- a/src/main/java/scriptmanager/objects/CustomExceptions/ScriptManagerException.java +++ /dev/null @@ -1,9 +0,0 @@ -package scriptmanager.objects.CustomExceptions; - -@SuppressWarnings("serial") -public class ScriptManagerException extends Exception { - - public ScriptManagerException(String message) { - super(message); - } -} diff --git a/src/main/java/scriptmanager/objects/CustomExceptions/OptionException.java b/src/main/java/scriptmanager/objects/Exceptions/OptionException.java similarity index 94% rename from src/main/java/scriptmanager/objects/CustomExceptions/OptionException.java rename to src/main/java/scriptmanager/objects/Exceptions/OptionException.java index 8dd8dfdab..cc7a68528 100644 --- a/src/main/java/scriptmanager/objects/CustomExceptions/OptionException.java +++ b/src/main/java/scriptmanager/objects/Exceptions/OptionException.java @@ -1,4 +1,4 @@ -package scriptmanager.objects.CustomExceptions; +package scriptmanager.objects.Exceptions; /** * Custom exception used with LabelHeatmap and ThreeColorHeatMap tools diff --git a/src/main/java/scriptmanager/objects/Exceptions/ScriptManagerException.java b/src/main/java/scriptmanager/objects/Exceptions/ScriptManagerException.java index 282e5e2a5..5372652dc 100644 --- a/src/main/java/scriptmanager/objects/Exceptions/ScriptManagerException.java +++ b/src/main/java/scriptmanager/objects/Exceptions/ScriptManagerException.java @@ -8,4 +8,7 @@ @SuppressWarnings("serial") public class ScriptManagerException extends Exception { + public ScriptManagerException(String message) { + super(message); + } } diff --git a/src/main/java/scriptmanager/objects/CustomExceptions/package-info.java b/src/main/java/scriptmanager/objects/Exceptions/package-info.java similarity index 56% rename from src/main/java/scriptmanager/objects/CustomExceptions/package-info.java rename to src/main/java/scriptmanager/objects/Exceptions/package-info.java index f3421eb50..1c1112bf1 100644 --- a/src/main/java/scriptmanager/objects/CustomExceptions/package-info.java +++ b/src/main/java/scriptmanager/objects/Exceptions/package-info.java @@ -1,4 +1,4 @@ /** * Custom exceptions created for ScriptManager tools */ -package scriptmanager.objects.CustomExceptions; \ No newline at end of file +package scriptmanager.objects.Exceptions; \ No newline at end of file diff --git a/src/main/java/scriptmanager/scripts/BAM_Statistics/BAMGenomeCorrelation.java b/src/main/java/scriptmanager/scripts/BAM_Statistics/BAMGenomeCorrelation.java index 06ee44a1c..8025fdb0e 100644 --- a/src/main/java/scriptmanager/scripts/BAM_Statistics/BAMGenomeCorrelation.java +++ b/src/main/java/scriptmanager/scripts/BAM_Statistics/BAMGenomeCorrelation.java @@ -21,7 +21,7 @@ import org.jfree.chart.ChartPanel; import scriptmanager.charts.HeatMap; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.scripts.BAM_Statistics.CorrelationScripts.CorrelationCoord; import scriptmanager.scripts.BAM_Statistics.CorrelationScripts.CorrelationExtract; diff --git a/src/main/java/scriptmanager/scripts/Figure_Generation/LabelHeatMap.java b/src/main/java/scriptmanager/scripts/Figure_Generation/LabelHeatMap.java index d49778e73..2b6399cd2 100644 --- a/src/main/java/scriptmanager/scripts/Figure_Generation/LabelHeatMap.java +++ b/src/main/java/scriptmanager/scripts/Figure_Generation/LabelHeatMap.java @@ -15,7 +15,7 @@ import org.jfree.graphics2d.svg.SVGGraphics2D; import org.jfree.graphics2d.svg.SVGUtils; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; /** * Decorate an input PNG file with plot labels and save as an SVG.
diff --git a/src/main/java/scriptmanager/scripts/Figure_Generation/ThreeColorHeatMap.java b/src/main/java/scriptmanager/scripts/Figure_Generation/ThreeColorHeatMap.java index 62b7d5fb9..bfbfb5d91 100644 --- a/src/main/java/scriptmanager/scripts/Figure_Generation/ThreeColorHeatMap.java +++ b/src/main/java/scriptmanager/scripts/Figure_Generation/ThreeColorHeatMap.java @@ -7,21 +7,18 @@ import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; -import java.util.zip.GZIPInputStream; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JLabel; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.GZipUtilities; /** diff --git a/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java b/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java index 7b71bcada..59fa690fb 100644 --- a/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java +++ b/src/main/java/scriptmanager/scripts/Peak_Analysis/RandomCoordinate.java @@ -7,7 +7,7 @@ import scriptmanager.objects.CoordinateObjects.BEDCoord; import scriptmanager.objects.CoordinateObjects.GFFCoord; import scriptmanager.objects.CoordinateObjects.GenericCoord; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.GZipUtilities; import scriptmanager.util.GenomeSizeReference; diff --git a/src/main/java/scriptmanager/scripts/Read_Analysis/TransposeMatrix.java b/src/main/java/scriptmanager/scripts/Read_Analysis/TransposeMatrix.java index baf18a17e..776c792bc 100644 --- a/src/main/java/scriptmanager/scripts/Read_Analysis/TransposeMatrix.java +++ b/src/main/java/scriptmanager/scripts/Read_Analysis/TransposeMatrix.java @@ -13,7 +13,7 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -import scriptmanager.objects.CustomExceptions.ScriptManagerException; +import scriptmanager.objects.Exceptions.ScriptManagerException; import scriptmanager.util.GZipUtilities; public class TransposeMatrix { diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationOutput.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationOutput.java index 72fca83ed..ce1dcb389 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationOutput.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationOutput.java @@ -20,7 +20,7 @@ import scriptmanager.cli.BAM_Statistics.BAMGenomeCorrelationCLI; import scriptmanager.objects.LogItem; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.scripts.BAM_Statistics.BAMGenomeCorrelation; /** diff --git a/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java index 79a893357..ace60f826 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Statistics/BAMGenomeCorrelationWindow.java @@ -42,7 +42,7 @@ import scriptmanager.charts.HeatMap; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.FileSelection; /** diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java index 508d21b14..82e579482 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapOutput.java @@ -15,7 +15,7 @@ import scriptmanager.cli.Figure_Generation.LabelHeatMapCLI; import scriptmanager.objects.CustomOutputStream; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.objects.LogItem; import scriptmanager.scripts.Figure_Generation.LabelHeatMap; import scriptmanager.util.ExtensionFileFilter; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java index 358480f93..de583c99e 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/LabelHeatMapWindow.java @@ -37,7 +37,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.FileSelection; /** diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapOutput.java index 9d87c22b3..c23e901d7 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapOutput.java @@ -13,7 +13,7 @@ import scriptmanager.cli.Figure_Generation.ThreeColorHeatMapCLI; import scriptmanager.objects.LogItem; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.scripts.Figure_Generation.ThreeColorHeatMap; import scriptmanager.util.ExtensionFileFilter; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java index a2160c88d..8bae0e847 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/ThreeColorHeatMapWindow.java @@ -38,7 +38,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.FileSelection; /** diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java index 48218eda3..ac611640b 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapOutput.java @@ -14,7 +14,7 @@ import scriptmanager.cli.Figure_Generation.TwoColorHeatMapCLI; import scriptmanager.objects.LogItem; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.scripts.Figure_Generation.TwoColorHeatMap; import scriptmanager.util.ExtensionFileFilter; diff --git a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java index c2bdc5ca1..69dea0a2c 100644 --- a/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java +++ b/src/main/java/scriptmanager/window_interface/Figure_Generation/TwoColorHeatMapWindow.java @@ -38,7 +38,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.FileSelection; /** diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java index e4bd87830..78dfa37af 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/RandomCoordinateWindow.java @@ -33,7 +33,7 @@ import scriptmanager.cli.Peak_Analysis.RandomCoordinateCLI; import scriptmanager.objects.LogItem; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.FileSelection; import scriptmanager.scripts.Peak_Analysis.RandomCoordinate; diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorOutput.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorOutput.java index 0a32b1af0..835405a92 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorOutput.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorOutput.java @@ -19,7 +19,7 @@ import scriptmanager.util.ExtensionFileFilter; import scriptmanager.cli.Read_Analysis.ScalingFactorCLI; import scriptmanager.objects.LogItem; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.scripts.Read_Analysis.ScalingFactor; /** diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java index 14c821faf..b7214de39 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/ScalingFactorWindow.java @@ -36,7 +36,7 @@ import javax.swing.border.EmptyBorder; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.OptionException; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.util.FileSelection; import scriptmanager.scripts.Read_Analysis.ScalingFactor; diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/TransposeMatrixWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/TransposeMatrixWindow.java index 33439cc02..c2fb5ffc3 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/TransposeMatrixWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/TransposeMatrixWindow.java @@ -38,7 +38,7 @@ import scriptmanager.util.GZipUtilities; import scriptmanager.objects.LogItem; import scriptmanager.objects.ToolDescriptions; -import scriptmanager.objects.CustomExceptions.ScriptManagerException; +import scriptmanager.objects.Exceptions.ScriptManagerException; import scriptmanager.scripts.Read_Analysis.TransposeMatrix; /** From b0180d119e31274f828337e668103b4f155b684b Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Tue, 28 Nov 2023 22:21:31 -0500 Subject: [PATCH 55/58] fix verbosity reporting of logging writeShell allow window components to track output filename and verbosity level (remove getters and setters too) --- .../scriptmanager/main/LogManagerWindow.java | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/src/main/java/scriptmanager/main/LogManagerWindow.java b/src/main/java/scriptmanager/main/LogManagerWindow.java index b0d9bd746..a1c00b375 100644 --- a/src/main/java/scriptmanager/main/LogManagerWindow.java +++ b/src/main/java/scriptmanager/main/LogManagerWindow.java @@ -36,6 +36,7 @@ import scriptmanager.util.FileSelection; import scriptmanager.objects.LogItem; import scriptmanager.objects.ToolDescriptions; +import scriptmanager.objects.Exceptions.ScriptManagerException; /** * Store, update, and manage the set of LogItems that make up a ScriptManager @@ -77,10 +78,8 @@ public class LogManagerWindow extends JFrame { private ArrayList logItems; private Timestamp logStart; - private int verbosity = 0; private File odir = null; - private String ofilename; private boolean on = true; @@ -93,7 +92,6 @@ public LogManagerWindow() { // Initilize log timestamp logStart = new Timestamp(new Date().getTime()); logItems = new ArrayList(); - ofilename = logStart.toString().replace(' ', '_').replace(':', '-') + "_logfile.sh"; initialize(); } @@ -200,7 +198,7 @@ public void actionPerformed(ActionEvent e) { sl_pnlSettings.putConstraint(SpringLayout.NORTH, txtOutputFilename, 0, SpringLayout.NORTH, lblFileSeparator); sl_pnlSettings.putConstraint(SpringLayout.WEST, txtOutputFilename, 10, SpringLayout.EAST, lblFileSeparator); sl_pnlSettings.putConstraint(SpringLayout.EAST, txtOutputFilename, -10, SpringLayout.EAST, pnl_Settings); - txtOutputFilename.setText(getFilename()); + txtOutputFilename.setText(logStart.toString().replace(' ', '_').replace(':', '-') + "_logfile.sh"); pnl_Settings.add(txtOutputFilename); txtOutputFilename.setColumns(100); @@ -211,6 +209,8 @@ public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) { try { writeLogShell(); + } catch (ScriptManagerException sme) { + JOptionPane.showMessageDialog(null, sme.getMessage()); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, ioe.getMessage()); } @@ -289,15 +289,11 @@ public void drawTable() { public ArrayList getLogItems() { return logItems; } public LogItem getLogItem(int i) { return logItems.get(i); } public Timestamp getLogStart() { return logStart; } - public int getVerbosity() { return verbosity; } - public String getFilename() { return ofilename; } public File getOutputDirectory() { return odir; } // Setters public void setToggleOn(boolean toggle) { on = toggle; } public void setLogStart(Timestamp time) { logStart = time; } - public void setVerbosity(int v) { verbosity = v; } - public void setFilename(String o) { ofilename = o; } public void setOutputDirectory(File o) { odir = o; } // Status - getters, setters, and Comparators @@ -333,17 +329,36 @@ public void removeLogItems(int[] r_idxs) { } } + /** + * Get the verbosity value from the radio buttons + * + * @return verbosity level (1, 2, or 3) + */ + public short getLogVerbosity() throws ScriptManagerException { + if (verbosity1.isSelected()) { + return 1; + } else if (verbosity2.isSelected()) { + return 2; + } else if (verbosity3.isSelected()) { + return 3; + } + throw new ScriptManagerException("Unrecognized verbosity level. This should never throw"); + } + /** * Write the contents of the log as a shell script * * @throws IOException Invalid file or parameters */ - public void writeLogShell() throws IOException { + public void writeLogShell() throws IOException, ScriptManagerException { // Create File & initialize stream - PrintStream OUT = new PrintStream(new File(OUT_DIR + File.separator + ofilename)); + PrintStream OUT = new PrintStream(new File(OUT_DIR + File.separator + txtOutputFilename.getText())); + + // Determine verbosity of output + short verbosity = getLogVerbosity(); // Write Header (V=1+) - OUT.println("# VERSION\t" + ToolDescriptions.VERSION); + OUT.println("# VERSION\t" + ToolDescriptions.VERSION + "\tVerbosity Level:" + verbosity); OUT.println("SCRIPTMANAGER=/path/to/ScriptManager.jar"); OUT.println("PICARD=/path/to/picard.jar"); OUT.println(); @@ -351,7 +366,7 @@ public void writeLogShell() throws IOException { // Write LogInfo start time (V=1+) OUT.println("# Log start time: " + logStart.toString()); - // Sort LogItems for writing--not needed unless fireproperty adding out of order + // Add later: Sort LogItems for writing--not needed unless fireproperty adding out of order // Record each LogItem for (int i = 0; i=2) { // Write LogItem status (V=2+) - OUT.println("# " + item.getStatus()); + OUT.println("# Exit status: " + item.getStatus()); // Write LogItem end time (V=2+) - OUT.println("# " + item.getStopTime().toString()); + OUT.println(item.getStopTime()==null ? "#Incomplete" : "# " + item.getStopTime().toString()); // Write LogItem runtime (V=3+) if(verbosity>=3) { - OUT.println("# Runtime: " + (item.getStopTime().getTime() - item.getStartTime().getTime())); + OUT.println(item.getStopTime()==null ? "# Runtime: -" : "# Runtime: " + (item.getStopTime().getTime() - item.getStartTime().getTime())); } } // TODO: Write Toggle Log info From 508c9304f6688309d24cfc90a542af57bdc44a61 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Wed, 29 Nov 2023 14:31:30 -0500 Subject: [PATCH 56/58] add logging to AggregateData ScriptManagerGUI - add property change listener for AggregateData AggregateData - create final static constants for encoding aggregation types - throw Exceptions instead of setting "endMessage" variable - restructure PrintStream construction AggregateDataCLI - add getCLIcommand() with javadocs - add support for static constants encoding aggregation types AggregateDataOutput and Window - add logitem creation and update steps - add logging propertyChange listener - add final progress bar update to 100% - set OUT_DIR button will no longer set OUT_DIR to null if user clicks "Cancel" in FileSelector --- .../cli/Read_Analysis/AggregateDataCLI.java | 69 ++++++++-- .../scriptmanager/main/ScriptManagerGUI.java | 11 ++ .../scripts/Read_Analysis/AggregateData.java | 123 ++++++++++-------- .../Read_Analysis/AggregateDataWindow.java | 58 +++++++-- 4 files changed, 183 insertions(+), 78 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Read_Analysis/AggregateDataCLI.java b/src/main/java/scriptmanager/cli/Read_Analysis/AggregateDataCLI.java index 8fb756085..beb5b1d0c 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/AggregateDataCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/AggregateDataCLI.java @@ -12,6 +12,7 @@ import java.util.concurrent.Callable; import scriptmanager.objects.ToolDescriptions; +import scriptmanager.objects.Exceptions.OptionException; import scriptmanager.scripts.Read_Analysis.AggregateData; /** @@ -89,7 +90,6 @@ public Integer call() throws Exception { AggregateData script_obj = new AggregateData(matFiles, output, merge, startROW, startCOL, aggType, gzOutput); script_obj.run(); - System.err.println(script_obj.getMessage()); return(0); } @@ -150,22 +150,73 @@ private String validateInput() throws IOException { r += "(!)Must indicate directory (not a file) if you're not using the merge option."; } } - }else{ + } else { output = new File(System.getProperty("user.dir")); } //Set numeric indicator for aggregation method - if(aggr.avg) { aggType = 1; } - else if(aggr.med) { aggType = 2; } - else if(aggr.mod) { aggType = 3; } - else if(aggr.min) { aggType = 4; } - else if(aggr.max) { aggType = 5; } - else if(aggr.var) { aggType = 6; } - + if(aggr.avg) { aggType = AggregateData.AVERAGE; } + else if(aggr.med) { aggType = AggregateData.MEDIAN; } + else if(aggr.mod) { aggType = AggregateData.MODE; } + else if(aggr.min) { aggType = AggregateData.MINIMUM; } + else if(aggr.max) { aggType = AggregateData.MAXIMUM; } + else if(aggr.var) { aggType = AggregateData.POSITIONAL_VARIANCE; } + //validate row&column start indexes if(startROW<0){ r += "(!)Row start must not be less than zero\n"; } if(startCOL<0){ r += "(!)Column start must not be less than zero\n"; } return(r); } + + /** + * Reconstruct CLI command + * + * @param in ArrayList of TAB files to be processed + * @param output Output directory + * @param m Whether results should be merged into one file + * @param r Starting row (1-indexed) + * @param l Starting column (1-indexed) + * @param index the metric to aggregate by + * @param gzOutput gzip output + * @return command line to execute with formatted inputs + * @throws OptionException + */ + public static String getCLIcommand(ArrayList in, File output, boolean m, int r, int l, int index, boolean gzOutput) throws OptionException { + String command = "java -jar $SCRIPTMANAGER read-analysis aggregate-data"; + command += " -o " + output.getAbsolutePath(); + command += gzOutput ? " --gzip" : ""; + command += m ? " -m" : ""; + switch (index) { + case AggregateData.SUM: + command += " --sum"; + break; + case AggregateData.AVERAGE: + command += " --avg"; + break; + case AggregateData.MEDIAN: + command += " --med"; + break; + case AggregateData.MODE: + command += " --mod"; + break; + case AggregateData.MINIMUM: + command += " --min"; + break; + case AggregateData.MAXIMUM: + command += " --max"; + break; + case AggregateData.POSITIONAL_VARIANCE: + command += " --var"; + break; + default: + throw new OptionException("invalid scaling type value"); + } + command += " -r " + r; + command += " -l " + l; + for (int i = 0; i INPUT = null; private File OUT_PATH = null; @@ -26,8 +42,6 @@ public class AggregateData { private int ROWSTART = 1; private int COLSTART = 1; private int METRIC = 0; - private PrintStream OUT; - private String endMessage = ""; private boolean OUTPUT_GZIP; /** @@ -57,19 +71,22 @@ public AggregateData(ArrayList in, File out, boolean m, int r, int c, int * * @throws IOException Invalid file or parameters */ - public void run() throws IOException { + public void run() throws IOException, OptionException, ScriptManagerException { + // One-to-one style aggregate data if (!MERGE) { + // If output is null or directory if (OUT_PATH == null || OUT_PATH.isDirectory()) { - System.err.println(INPUT.get(0)); for (int x = 0; x < INPUT.size(); x++) { outputFileScore(INPUT.get(x)); -// firePropertyChange("file", x, x + 1); + firePropertyChange("progress", x, x + 1); } } else if (INPUT.size() == 1) { - outputFileScore(INPUT.get(0)); + PrintStream OUT = GZipUtilities.makePrintStream(OUT_PATH, OUTPUT_GZIP); + outputFileScore(INPUT.get(0), OUT); } else { - System.err.println("Cannot accept non-directory filename with multi-file input when merge is not flagged."); + throw new OptionException("Cannot accept non-directory filename with multi-file input when merge is not flagged."); } + // Merge-style aggregate data } else { ArrayList> MATRIX = new ArrayList>(); ArrayList> MATRIXID = new ArrayList>(); @@ -99,19 +116,19 @@ public void run() throws IOException { numarray[y] = Double.NaN; } } - if (METRIC == 0) { + if (METRIC == SUM) { scorearray.add(ArrayUtilities.getSum(numarray)); - } else if (METRIC == 1) { + } else if (METRIC == AVERAGE) { scorearray.add(ArrayUtilities.getAverage(numarray)); - } else if (METRIC == 2) { + } else if (METRIC == MEDIAN) { scorearray.add(ArrayUtilities.getMedian(numarray)); - } else if (METRIC == 3) { + } else if (METRIC == MODE) { scorearray.add(ArrayUtilities.getMode(numarray)); - } else if (METRIC == 4) { + } else if (METRIC == MINIMUM) { scorearray.add(ArrayUtilities.getMin(numarray)); - } else if (METRIC == 5) { + } else if (METRIC == MAXIMUM) { scorearray.add(ArrayUtilities.getMax(numarray)); - } else if (METRIC == 6) { + } else if (METRIC == POSITIONAL_VARIANCE) { scorearray.add(ArrayUtilities.getPositionalVariance(numarray)); } count++; @@ -121,29 +138,26 @@ public void run() throws IOException { MATRIXID.add(idarray); } - String name = "ALL_SCORES.out"; - if (OUT_PATH == null) { - OUT = GZipUtilities.makePrintStream(new File(name + (OUTPUT_GZIP? ".gz": "")), OUTPUT_GZIP); - } else if (!OUT_PATH.isDirectory()) { - OUT = GZipUtilities.makePrintStream(OUT_PATH, OUTPUT_GZIP); - } else { - OUT = GZipUtilities.makePrintStream(new File(OUT_PATH.getCanonicalPath() + File.separator + name + (OUTPUT_GZIP? ".gz": "")), OUTPUT_GZIP); - } - // Check all arrays are the same size int ARRAYLENGTH = MATRIX.get(0).size(); boolean ALLSAME = true; for (int x = 0; x < MATRIX.size(); x++) { if (MATRIX.get(x).size() != ARRAYLENGTH || MATRIXID.get(x).size() != ARRAYLENGTH) { - ALLSAME = false; - endMessage = "Different number of rows between:\n" + INPUT.get(0).getName() + "\n" - + INPUT.get(x).getName(); - return; + throw new ScriptManagerException("Different number of rows between:\n" + INPUT.get(0).getName() + "\n" + INPUT.get(x).getName()); } } - - System.err.println(getMessage()); - + // (will not proceed if exception thrown above) + // Construct output stream + PrintStream OUT; + String name = "ALL_SCORES.out" + (OUTPUT_GZIP? ".gz": ""); + if (OUT_PATH == null) { + OUT = GZipUtilities.makePrintStream(new File(name), OUTPUT_GZIP); + } else if (!OUT_PATH.isDirectory()) { + OUT = GZipUtilities.makePrintStream(OUT_PATH, OUTPUT_GZIP); + } else { + OUT = GZipUtilities.makePrintStream(new File(OUT_PATH.getCanonicalPath() + File.separator + name), OUTPUT_GZIP); + } + // Print matrix for elements that are the same size if (ALLSAME) { for (int x = 0; x < INPUT.size(); x++) { OUT.print("\t" + INPUT.get(x).getName()); @@ -159,29 +173,24 @@ public void run() throws IOException { } OUT.close(); } - endMessage = "Data Parsed"; - } - - /** - * Returns "Data Parsed," or an error message if script failed - * @return "Data Parsed," or an error message if script failed - */ - public String getMessage() { - return (endMessage); } /** * Calls {@link AggregateData#outputFileScore(File, PrintStream)} but outputs results to a new file if a PrintStream is not provided + *
+ * Assumes OUTPUT_PATH is null or directory! + * * @param IN Input file (used to generate output file's name) * @throws FileNotFoundException Script could not find valid input file * @throws IOException Invalid file or parameters */ public void outputFileScore(File IN) throws FileNotFoundException, IOException { - String NEWNAME = ExtensionFileFilter.stripExtensionIgnoreGZ(IN) + "_SCORES.out"; + PrintStream OUT; + String NAME = ExtensionFileFilter.stripExtensionIgnoreGZ(IN) + "_SCORES.out" + (OUTPUT_GZIP? ".gz": ""); if (OUT_PATH != null) { - OUT = GZipUtilities.makePrintStream(new File(OUT_PATH.getAbsolutePath() + File.separator + NEWNAME + (OUTPUT_GZIP? ".gz": "")), OUTPUT_GZIP); + OUT = GZipUtilities.makePrintStream(new File(OUT_PATH.getAbsolutePath() + File.separator + NAME), OUTPUT_GZIP); } else { - OUT = GZipUtilities.makePrintStream(new File(NEWNAME + (OUTPUT_GZIP? ".gz": "")), OUTPUT_GZIP); + OUT = GZipUtilities.makePrintStream(new File(NAME), OUTPUT_GZIP); } outputFileScore(IN, OUT); } @@ -194,19 +203,19 @@ public void outputFileScore(File IN) throws FileNotFoundException, IOException { * @throws IOException Invalid file or parameters */ public void outputFileScore(File IN, PrintStream OUT) throws FileNotFoundException, IOException { - if (METRIC == 0) { + if (METRIC == SUM) { OUT.println("\tSum"); - } else if (METRIC == 1) { + } else if (METRIC == AVERAGE) { OUT.println("\tAverage"); - } else if (METRIC == 2) { + } else if (METRIC == MEDIAN) { OUT.println("\tMedian"); - } else if (METRIC == 3) { + } else if (METRIC == MODE) { OUT.println("\tMode"); - } else if (METRIC == 4) { + } else if (METRIC == MINIMUM) { OUT.println("\tMin"); - } else if (METRIC == 5) { + } else if (METRIC == MAXIMUM) { OUT.println("\tMax"); - } else if (METRIC == 6) { + } else if (METRIC == POSITIONAL_VARIANCE) { OUT.println("\tPositionalVariance"); } @@ -230,19 +239,19 @@ public void outputFileScore(File IN, PrintStream OUT) throws FileNotFoundExcepti numarray[x] = Double.NaN; } } - if (METRIC == 0) { + if (METRIC == SUM) { OUT.println(ID[0] + "\t" + ArrayUtilities.getSum(numarray)); - } else if (METRIC == 1) { + } else if (METRIC == AVERAGE) { OUT.println(ID[0] + "\t" + ArrayUtilities.getAverage(numarray)); - } else if (METRIC == 2) { + } else if (METRIC == MEDIAN) { OUT.println(ID[0] + "\t" + ArrayUtilities.getMedian(numarray)); - } else if (METRIC == 3) { + } else if (METRIC == MODE) { OUT.println(ID[0] + "\t" + ArrayUtilities.getMode(numarray)); - } else if (METRIC == 4) { + } else if (METRIC == MINIMUM) { OUT.println(ID[0] + "\t" + ArrayUtilities.getMin(numarray)); - } else if (METRIC == 5) { + } else if (METRIC == MAXIMUM) { OUT.println(ID[0] + "\t" + ArrayUtilities.getMax(numarray)); - } else if (METRIC == 6) { + } else if (METRIC == POSITIONAL_VARIANCE) { OUT.println(ID[0] + "\t" + ArrayUtilities.getPositionalVariance(numarray)); } count++; diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java index 606bfd486..39ea02dd4 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/AggregateDataWindow.java @@ -11,7 +11,9 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListModel; @@ -35,6 +37,11 @@ import scriptmanager.util.FileSelection; import scriptmanager.objects.ToolDescriptions; +import scriptmanager.objects.LogItem; +import scriptmanager.objects.Exceptions.OptionException; +import scriptmanager.objects.Exceptions.ScriptManagerException; + +import scriptmanager.cli.Read_Analysis.AggregateDataCLI; import scriptmanager.scripts.Read_Analysis.AggregateData; /** @@ -53,7 +60,7 @@ public class AggregateDataWindow extends JFrame implements ActionListener, Prope */ protected JFileChooser fc = new JFileChooser(new File(System.getProperty("user.dir"))); - private File OUT_DIR = null; + private File OUT_DIR = new File(System.getProperty("user.dir")); final DefaultListModel expList; ArrayList SUMFiles = new ArrayList(); @@ -90,23 +97,46 @@ public Void doInBackground() { } else if (Integer.parseInt(txtCol.getText()) < 1) { JOptionPane.showMessageDialog(null, "Invalid Start Column!!! Must be larger than 0 (1-based)"); } else { + // Initialize LogItem + String command = AggregateDataCLI.getCLIcommand(SUMFiles, OUT_DIR, chckbxMergeToOne.isSelected(), + Integer.parseInt(txtRow.getText()), Integer.parseInt(txtCol.getText()), + cmbMethod.getSelectedIndex(), chckbxGzipOutput.isSelected()); + LogItem li = new LogItem(command); + firePropertyChange("log", null, li); + // Execute script AggregateData script_obj = new AggregateData(SUMFiles, OUT_DIR, chckbxMergeToOne.isSelected(), Integer.parseInt(txtRow.getText()), Integer.parseInt(txtCol.getText()), cmbMethod.getSelectedIndex(), chckbxGzipOutput.isSelected()); + script_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent propertyChangeEvent) { + int temp = (Integer) propertyChangeEvent.getNewValue(); + int percentComplete = (int) (((double) (temp) / SUMFiles.size()) * 100); + setProgress(percentComplete); + } + }); + script_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); script_obj.run(); - -// parse.addPropertyChangeListener("file", new PropertyChangeListener() { -// public void propertyChange(PropertyChangeEvent propertyChangeEvent) { -// int temp = (Integer) propertyChangeEvent.getNewValue(); -// int percentComplete = (int)(((double)(temp) / (SUMFiles.size())) * 100); -// setProgress(percentComplete); -// } -// }); + // Update log item + li.setStopTime(new Timestamp(new Date().getTime())); + li.setStatus(0); + // Update log at completion + firePropertyChange("log", li, null); + // Update progress setProgress(100); - JOptionPane.showMessageDialog(null, script_obj.getMessage()); + JOptionPane.showMessageDialog(null, "Data Parsed"); } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + } catch (OptionException oe) { +// oe.printStackTrace(); + JOptionPane.showMessageDialog(null, oe.getMessage()); + } catch (ScriptManagerException sme) { +// sme.printStackTrace(); + JOptionPane.showMessageDialog(null, sme.getMessage()); } catch (IOException ioe) { ioe.printStackTrace(); JOptionPane.showMessageDialog(null, "I/O issues: " + ioe.getMessage()); @@ -114,6 +144,7 @@ public Void doInBackground() { e.printStackTrace(); JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } + setProgress(100); return null; } @@ -234,8 +265,9 @@ public void actionPerformed(ActionEvent arg0) { sl_contentPane.putConstraint(SpringLayout.NORTH, btnOutput, 15, SpringLayout.SOUTH, lblColumnStart); btnOutput.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - OUT_DIR = FileSelection.getOutputDir(fc); - if (OUT_DIR != null) { + File temp = FileSelection.getOutputDir(fc); + if(temp != null) { + OUT_DIR = temp; lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); } } @@ -294,6 +326,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From a0a7f93cb4776ba9e25b38266099404e0883ff67 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Wed, 29 Nov 2023 15:18:44 -0500 Subject: [PATCH 57/58] add template log support for not-implemented tools Add skeleton code for GeneTrack, PeakPair, SignalDuplication, and Similarity matrix tools --- .../Peak_Analysis/SignalDuplicationCLI.java | 16 +++- .../cli/Peak_Calling/GeneTrackCLI.java | 20 ++++- .../cli/Peak_Calling/PeakPairCLI.java | 20 ++++- .../Read_Analysis/SimilarityMatrixCLI.java | 16 ++++ .../scriptmanager/main/ScriptManagerGUI.java | 33 ++++++++ .../SignalDuplicationWindow.java | 83 +++++++++++++------ .../Peak_Calling/GeneTrackWindow.java | 29 +++++-- .../Peak_Calling/PeakPairWindow.java | 27 ++++-- .../Read_Analysis/SimilarityMatrixWindow.java | 24 +++++- 9 files changed, 225 insertions(+), 43 deletions(-) diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/SignalDuplicationCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/SignalDuplicationCLI.java index 54a2fe746..442946faa 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/SignalDuplicationCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/SignalDuplicationCLI.java @@ -3,7 +3,7 @@ import picocli.CommandLine.Command; import java.util.concurrent.Callable; - +import java.io.File; import java.io.IOException; import scriptmanager.objects.ToolDescriptions; @@ -49,4 +49,18 @@ private String validateInput() throws IOException { //append messages to the user to `r` return(r); } + + /** + * Reconstruct CLI command + * + * @param input + * @param bam + * @param window + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, File bam, double window) { + String command = "# (Not yet implemented) java -jar $SCRIPTMANAGER peak-analysis signal-dup"; + /* TODO: implement CLI */ + return(command); + } } diff --git a/src/main/java/scriptmanager/cli/Peak_Calling/GeneTrackCLI.java b/src/main/java/scriptmanager/cli/Peak_Calling/GeneTrackCLI.java index 1912c3824..a43f8b4c7 100644 --- a/src/main/java/scriptmanager/cli/Peak_Calling/GeneTrackCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Calling/GeneTrackCLI.java @@ -2,7 +2,7 @@ import picocli.CommandLine.Command; import java.util.concurrent.Callable; - +import java.io.File; import java.io.IOException; import scriptmanager.objects.ToolDescriptions; @@ -48,4 +48,22 @@ private String validateInput() throws IOException { //append messages to the user to `r` return(r); } + + /** + * Reconstruct CLI command + * + * @param id + * @param s + * @param e + * @param f + * @param u + * @param d + * @param path + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File id, int s, int e, int f, int u, int d, String path) { + String command = "# (Not yet implemented) java -jar $SCRIPTMANAGER peak-calling gene-track"; + /* TODO: implement CLI */ + return(command); + } } diff --git a/src/main/java/scriptmanager/cli/Peak_Calling/PeakPairCLI.java b/src/main/java/scriptmanager/cli/Peak_Calling/PeakPairCLI.java index c9c9068e6..9751a14b1 100644 --- a/src/main/java/scriptmanager/cli/Peak_Calling/PeakPairCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Calling/PeakPairCLI.java @@ -3,7 +3,7 @@ import picocli.CommandLine.Command; import java.util.concurrent.Callable; - +import java.io.File; import java.io.IOException; import scriptmanager.objects.ToolDescriptions; @@ -49,4 +49,22 @@ private String validateInput() throws IOException { //append messages to the user to `r` return(r); } + + /** + * Reconstruct CLI command + * + * @param in + * @param mode + * @param up + * @param down + * @param bin + * @param abs + * @param rel + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File in, int mode, int up, int down, int bin, int abs, int rel) { + String command = "# (Not yet implemented) java -jar $SCRIPTMANAGER peak-calling peak-pair"; + /* TODO: implement CLI */ + return(command); + } } diff --git a/src/main/java/scriptmanager/cli/Read_Analysis/SimilarityMatrixCLI.java b/src/main/java/scriptmanager/cli/Read_Analysis/SimilarityMatrixCLI.java index 2f0f06986..b4bc385db 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/SimilarityMatrixCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/SimilarityMatrixCLI.java @@ -6,6 +6,7 @@ import scriptmanager.objects.ToolDescriptions; +import java.io.File; import java.io.IOException; /** @@ -50,4 +51,19 @@ private String validateInput() throws IOException { return(r); } + + /** + * Reconstruct CLI command + * + * @param input + * @param output + * @param index + * @param correlateColumns + * @return command line to execute with formatted inputs + */ + public static String getCLIcommand(File input, File output, int index, boolean correlateColumns) { + String command = "# (Not yet implemented) java -jar $SCRIPTMANAGER read-analysis similarity-matrix"; + /* TODO: implement CLI */ + return(command); + } } diff --git a/src/main/java/scriptmanager/main/ScriptManagerGUI.java b/src/main/java/scriptmanager/main/ScriptManagerGUI.java index d4a91e7b0..761be93f1 100755 --- a/src/main/java/scriptmanager/main/ScriptManagerGUI.java +++ b/src/main/java/scriptmanager/main/ScriptManagerGUI.java @@ -885,6 +885,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { GeneTrackWindow frame = new GeneTrackWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); @@ -914,6 +925,17 @@ public void actionPerformed(ActionEvent e) { public void run() { try { PeakPairWindow frame = new PeakPairWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); @@ -1141,6 +1163,17 @@ public void actionPerformed(ActionEvent arg0) { public void run() { try { SignalDuplicationWindow frame = new SignalDuplicationWindow(); + frame.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // Add log item if logging is turned on + if ("log" == evt.getPropertyName() && logs.getToggleOn()) { + if (evt.getNewValue() != null) { + logs.addLogItem((LogItem) evt.getNewValue()); + } + logs.updateTable(); + } + } + }); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java index 552b67149..e94823b3c 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Analysis/SignalDuplicationWindow.java @@ -9,6 +9,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.DefaultListModel; @@ -28,8 +30,11 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import scriptmanager.util.FileSelection; +import scriptmanager.objects.LogItem; import scriptmanager.objects.ToolDescriptions; +import scriptmanager.util.FileSelection; + +import scriptmanager.cli.Peak_Analysis.SignalDuplicationCLI; import scriptmanager.scripts.Peak_Analysis.SignalDuplication; /** @@ -77,18 +82,39 @@ public Void doInBackground() { } else if(BAMFiles.size() < 1) { JOptionPane.showMessageDialog(null, "No BAM Files Loaded!!!"); } else { - setProgress(0); - SignalDuplication signal = new SignalDuplication(INPUT, BAMFiles, Double.parseDouble(txtWindow.getText())); - - signal.addPropertyChangeListener("tag", new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent propertyChangeEvent) { - int temp = (Integer) propertyChangeEvent.getNewValue(); - int percentComplete = (int)(((double)(temp) / BAMFiles.size()) * 100); - setProgress(percentComplete); - } - }); - signal.setVisible(true); - signal.run(); + setProgress(0); + /* Output class object needs to be created + LogItem creation and updates should be moved to Output class along with + non-script code in the current script class + */ + // Initialize LogItem + String command = SignalDuplicationCLI.getCLIcommand(INPUT, BAMFiles.get(0), Double.parseDouble(txtWindow.getText())); + LogItem li = new LogItem(command); + // Execute script + SignalDuplication output_obj = new SignalDuplication(INPUT, BAMFiles, Double.parseDouble(txtWindow.getText())); + output_obj.addPropertyChangeListener("progress", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent propertyChangeEvent) { + int temp = (Integer) propertyChangeEvent.getNewValue(); + int percentComplete = (int)(((double)(temp) / BAMFiles.size()) * 100); + setProgress(percentComplete); + } + }); + output_obj.addPropertyChangeListener("log", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + }); + output_obj.setVisible(true); + output_obj.run(); + // Update log item + li.setStopTime(new Timestamp(new Date().getTime())); + li.setStatus(0); + firePropertyChange("log", li, null); + // Pop-up completion + setProgress(100); + JOptionPane.showMessageDialog(null, "Random Coordinate Generation Complete"); + // Update progress + /* TODO */ } } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); @@ -99,7 +125,8 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { e.printStackTrace(); JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } - return null; + setProgress(100); + return null; } public void done() { @@ -217,24 +244,26 @@ public void actionPerformed(ActionEvent e) { @Override public void actionPerformed(ActionEvent arg0) { massXable(contentPane, false); - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - task = new Task(); - task.addPropertyChangeListener(this); - task.execute(); + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + task = new Task(); + task.addPropertyChangeListener(this); + task.execute(); } - + /** * Invoked when task's progress property changes. */ @Override - public void propertyChange(PropertyChangeEvent evt) { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } - } - + public void propertyChange(PropertyChangeEvent evt) { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); + } + } + /** * Makes the content pane non-interactive If the window should be interactive data * @param con Content pane to make non-interactive diff --git a/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java index 0b92e1775..1ded31132 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Calling/GeneTrackWindow.java @@ -12,6 +12,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.DefaultListModel; @@ -33,7 +35,10 @@ import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; +import scriptmanager.objects.LogItem; import scriptmanager.objects.ToolDescriptions; + +import scriptmanager.cli.Peak_Calling.GeneTrackCLI; import scriptmanager.scripts.Peak_Calling.GeneTrack; /** @@ -112,17 +117,29 @@ public Void doInBackground() { if(OUTPUT_PATH != null) { DIRECTORY = OUTPUT_PATH.getCanonicalPath() + File.separator + DIRECTORY; } new File(DIRECTORY).mkdirs(); - - setProgress(0); - for(int x = 0; x < IDXFiles.size(); x++) { + + setProgress(0); + LogItem old_li = null; + for(int x = 0; x < IDXFiles.size(); x++) { + // Initialize LogItem + String command = GeneTrackCLI.getCLIcommand(IDXFiles.get(x), SIGMA, EXCLUSION, FILTER, UP, DOWN, DIRECTORY); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script GeneTrack track = new GeneTrack(IDXFiles.get(x), SIGMA, EXCLUSION, FILTER, UP, DOWN, DIRECTORY); track.setVisible(true); track.run(); - + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Update progress int percentComplete = (int)(((double)(x + 1) / IDXFiles.size()) * 100); setProgress(percentComplete); } - setProgress(100); + // final update + firePropertyChange("log", old_li, null); + setProgress(100); } } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); @@ -132,7 +149,7 @@ public Void doInBackground() { } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); - } + } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java b/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java index f3874d710..2ab83c6ea 100644 --- a/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java +++ b/src/main/java/scriptmanager/window_interface/Peak_Calling/PeakPairWindow.java @@ -12,6 +12,8 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; import java.util.Vector; import javax.swing.ButtonGroup; @@ -35,7 +37,10 @@ import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; +import scriptmanager.objects.LogItem; import scriptmanager.objects.ToolDescriptions; + +import scriptmanager.cli.Peak_Calling.PeakPairCLI; import scriptmanager.scripts.Peak_Calling.PeakPair; /** @@ -119,16 +124,28 @@ public Void doInBackground() { if(rdbtnAbsoluteThreshold.isSelected()) ABS = Integer.parseInt(txtAbs.getText()); if(rdbtnRelativeThreshold.isSelected()) REL = Integer.parseInt(txtRel.getText()); - setProgress(0); - for(int x = 0; x < BAMFiles.size(); x++) { + setProgress(0); + LogItem old_li = null; + for(int x = 0; x < BAMFiles.size(); x++) { + // Initialize LogItem + String command = PeakPairCLI.getCLIcommand(BAMFiles.get(x), MODE, UP, DOWN, BIN, ABS, REL); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script PeakPair peak = new PeakPair(BAMFiles.get(x), MODE, UP, DOWN, BIN, ABS, REL); peak.setVisible(true); peak.run(); - + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Update progress int percentComplete = (int)(((double)(x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); } - setProgress(100); + // final update + firePropertyChange("log", old_li, null); + setProgress(100); } } catch(NumberFormatException nfe){ JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); @@ -138,7 +155,7 @@ public Void doInBackground() { } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); - } + } return null; } diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/SimilarityMatrixWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/SimilarityMatrixWindow.java index 11eec432e..fbff76a49 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/SimilarityMatrixWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/SimilarityMatrixWindow.java @@ -11,7 +11,9 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; @@ -32,7 +34,9 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; +import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; +import scriptmanager.cli.Read_Analysis.SimilarityMatrixCLI; import scriptmanager.scripts.Read_Analysis.SimilarityMatrix; /** @@ -81,18 +85,32 @@ public Void doInBackground() throws IOException { JOptionPane.showMessageDialog(null, "No TAB Files Loaded!!!"); } else { setProgress(0); - + LogItem old_li = null; for (int x = 0; x < TABFiles.size(); x++) { + // Initialize LogItem + String command = SimilarityMatrixCLI.getCLIcommand(TABFiles.get(x), OUT_DIR, + comboBox.getSelectedIndex(), rdbtnCorrelateColumns.isSelected()); + LogItem new_li = new LogItem(command); + firePropertyChange("log", old_li, new_li); + // Execute script SimilarityMatrix matrix = new SimilarityMatrix(TABFiles.get(x), OUT_DIR, comboBox.getSelectedIndex(), rdbtnCorrelateColumns.isSelected()); matrix.run(); - + // Update LogItem + new_li.setStopTime(new Timestamp(new Date().getTime())); + new_li.setStatus(0); + old_li = new_li; + // Update progress int percentComplete = (int) (((double) (x + 1) / TABFiles.size()) * 100); setProgress(percentComplete); } + // final update + firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "All Matrices Generated"); } + /* TODO: Add try-catch block */ + setProgress(100); return null; } @@ -249,6 +267,8 @@ public void propertyChange(PropertyChangeEvent evt) { if ("progress" == evt.getPropertyName()) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); + } else if ("log" == evt.getPropertyName()) { + firePropertyChange("log", evt.getOldValue(), evt.getNewValue()); } } From ae45363c0002a1197470449de56a711bb306c345 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Wed, 29 Nov 2023 15:22:41 -0500 Subject: [PATCH 58/58] add minor fixes discovered during testing - default filename construction for ConvertBED/GFFChrNames tools fixed to match flags - remove extra update log item code block in BAMMarkDupWindow - include final setProgress(100) for ExpandBED and SortBAM - make sure to initialize LogItem old_li to null for BEDtoGFFWindow (for consistency with other tools) - Change handling of null values from OUT_DIR file selector in TagPileup --- .../cli/File_Utilities/ConvertBEDChrNamesCLI.java | 2 +- .../cli/File_Utilities/ConvertGFFChrNamesCLI.java | 2 +- .../BAM_Manipulation/BAMMarkDupWindow.java | 6 ------ .../BAM_Manipulation/SortBAMWindow.java | 2 ++ .../BED_Manipulation/BEDtoGFFWindow.java | 2 +- .../GFF_Manipulation/ExpandGFFWindow.java | 1 + .../Read_Analysis/TagPileupWindow.java | 15 ++++++--------- 7 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java index 69a346ec2..a01a64e9a 100644 --- a/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java +++ b/src/main/java/scriptmanager/cli/File_Utilities/ConvertBEDChrNamesCLI.java @@ -89,7 +89,7 @@ private String validateInput() throws IOException { if (output == null) { // Set output filepath with name and output directory output = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(coordFile) - + (toArabic ? "_toRoman.gff" : "_toArabic.gff") + + (toArabic ? "_toArabic.bed" : "_toRoman.bed") + (gzOutput ? ".gz" : "")); } else { //check directory diff --git a/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java b/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java index 97f405983..e9b114f65 100644 --- a/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java +++ b/src/main/java/scriptmanager/cli/File_Utilities/ConvertGFFChrNamesCLI.java @@ -90,7 +90,7 @@ private String validateInput() throws IOException { if (output == null) { // Set output filepath with name and output directory output = new File(ExtensionFileFilter.stripExtensionIgnoreGZ(coordFile) - + (toArabic ? "_toRoman.bed" : "_toArabic.bed") + + (toArabic ? "_toArabic.gff" : "_toRoman.gff") + (gzOutput ? ".gz" : "")); } else { //check directory diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java index a0e651d8e..d9a9b4507 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java @@ -118,15 +118,9 @@ public Void doInBackground() { new_li.setStatus(0); old_li = new_li; } - // Update log item - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; - // Update progress int percentComplete = (int) (((double)(x + 1) / BAMFiles.size()) * 100); setProgress(percentComplete); - } firePropertyChange("log", old_li, null); diff --git a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java index 6cb22bf2e..666ae1488 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/SortBAMWindow.java @@ -103,6 +103,7 @@ public Void doInBackground() { setProgress(percentComplete); } + // final update firePropertyChange("log", old_li, null); setProgress(100); JOptionPane.showMessageDialog(null, "Sorting Complete"); @@ -115,6 +116,7 @@ public Void doInBackground() { e.printStackTrace(); JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } + setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java index 2adc4cf07..1109d6e9d 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/BED_Manipulation/BEDtoGFFWindow.java @@ -79,7 +79,7 @@ class Task extends SwingWorker { public Void doInBackground() { try { setProgress(0); - LogItem old_li = new LogItem(""); + LogItem old_li = null; for (int x = 0; x < BEDFiles.size(); x++) { File XBED = BEDFiles.get(x); // Set outfilepath diff --git a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java index c572f8688..7848a497c 100644 --- a/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java +++ b/src/main/java/scriptmanager/window_interface/Coordinate_Manipulation/GFF_Manipulation/ExpandGFFWindow.java @@ -129,6 +129,7 @@ public Void doInBackground() { e.printStackTrace(); JOptionPane.showMessageDialog(null, ToolDescriptions.UNEXPECTED_EXCEPTION_MESSAGE + e.getMessage()); } + setProgress(100); return null; } diff --git a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java index 5d6fc3a3e..d7ec007df 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java @@ -922,20 +922,17 @@ public void itemStateChanged(ItemEvent e) { btnOutputDirectory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - OUT_DIR = FileSelection.getOutputDir(fc); - if (OUT_DIR != null) { - lblDefaultToLocal.setText(OUT_DIR.getAbsolutePath()); + File temp = FileSelection.getOutputDir(fc); + if(temp != null) { + OUT_DIR = temp; + lblDefaultToLocal.setToolTipText(OUT_DIR.getAbsolutePath()); try { lblDefaultToLocal.setText("..." + ExtensionFileFilter.getSubstringEnd(OUT_DIR, 35)); - } catch (IOException e1) { + } catch (IOException ioe) { System.err.println("Output directory may not be loaded!"); - e1.printStackTrace(); + ioe.printStackTrace(); } - } else { - OUT_DIR = new File(System.getProperty("user.dir")); - lblDefaultToLocal.setText("Default to Local Directory"); } - lblDefaultToLocal.setToolTipText(OUT_DIR.getAbsolutePath()); } });