From 464faaa5f0c0b7e8d9352d8f26cf3874ecca424d Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Thu, 1 Jun 2023 10:33:24 -0400 Subject: [PATCH 1/4] restructure MarkDup to call picard form window Picard tools will be run using system calls that can be wrapped in a static method of a script class. For MarkDuplicates, the unnecessary constructor and class attributes were removed so that a static call could be made and the window_interface was modified accordingly. --- .../BAM_Manipulation/BAMMarkDuplicates.java | 23 ++------- .../BAM_Manipulation/BAMMarkDupWindow.java | 48 ++++++++++--------- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java b/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java index 451111ef7..db79ba4a7 100644 --- a/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java +++ b/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java @@ -6,24 +6,11 @@ import java.io.IOException; import java.util.ArrayList; -import javax.swing.JFrame; -import javax.swing.JOptionPane; +import htsjdk.samtools.SAMException; -@SuppressWarnings("serial") -public class BAMMarkDuplicates extends JFrame { - File bamFile = null; - boolean removeDuplicates = true; - File output = null; - File metrics = null; - - public BAMMarkDuplicates(File in, boolean remove, File out, File met) { - bamFile = in; - removeDuplicates = remove; - output = out; - metrics = met; - } - - public void run() throws IOException { +public class BAMMarkDuplicates { + + public static void mark(File bamFile, boolean removeDuplicates, File output, File metrics) throws IOException { //Check if BAI index file exists File f = new File(bamFile + ".bai"); if(f.exists() && !f.isDirectory()) { @@ -36,7 +23,7 @@ public void run() throws IOException { else { args.add("REMOVE_DUPLICATES=false"); } markDuplicates.instanceMain(args.toArray(new String[args.size()])); } else { - JOptionPane.showMessageDialog(null, "BAI Index File does not exist for: " + bamFile.getName() + "\n"); + throw new SAMException("BAI Index File does not exist for: " + bamFile.getName() + "\n"); } } } \ No newline at end of file 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 1b4df7f4e..3b6019a46 100644 --- a/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java +++ b/src/main/java/scriptmanager/window_interface/BAM_Manipulation/BAMMarkDupWindow.java @@ -1,5 +1,7 @@ package scriptmanager.window_interface.BAM_Manipulation; +import htsjdk.samtools.SAMException; + import java.awt.Component; import java.awt.Container; import java.awt.Color; @@ -30,8 +32,8 @@ import javax.swing.border.EmptyBorder; import scriptmanager.util.FileSelection; -import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; import scriptmanager.scripts.BAM_Manipulation.BAMMarkDuplicates; +import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; @SuppressWarnings("serial") public class BAMMarkDupWindow extends JFrame implements ActionListener, PropertyChangeListener { @@ -58,27 +60,29 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws Exception { setProgress(0); - 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"); - } - - BAMMarkDuplicates dedup = new BAMMarkDuplicates(BAMFiles.get(x), chckbxRemoveDuplicates.isSelected(), OUTPUT, METRICS); - dedup.run(); - - if(chckbxGenerateBaiIndex.isSelected()) { BAIIndexer.generateIndex(OUTPUT); } - - int percentComplete = (int)(((double)(x + 1) / BAMFiles.size()) * 100); - setProgress(percentComplete); - } - setProgress(100); + try { + 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"); + } + BAMMarkDuplicates.mark(BAMFiles.get(x), chckbxRemoveDuplicates.isSelected(), OUTPUT, METRICS); + + if(chckbxGenerateBaiIndex.isSelected()) { BAIIndexer.generateIndex(OUTPUT); } + + int percentComplete = (int)(((double)(x + 1) / BAMFiles.size()) * 100); + setProgress(percentComplete); + } + } catch (SAMException se){ + JOptionPane.showMessageDialog(null, se.getMessage()); + } + setProgress(100); JOptionPane.showMessageDialog(null, "Mark Duplicates Complete"); return null; } From 4c921771f2d48a0fe311c64684b1b3df798fb7c1 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Wed, 28 Jun 2023 14:23:18 -0400 Subject: [PATCH 2/4] fix TagPileupWindow display spacing This commit changes the pulldown selection strings to use less space and allow the full Read Output pulldown options to be displayed. The "Require PE" for Midpoint and Full Fragment selection strings of Read Aspect were too long and took space away from Read Output. --- .../window_interface/Read_Analysis/TagPileupWindow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 928bfad78..9ce3cae4d 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java @@ -119,7 +119,7 @@ public class TagPileupWindow extends JFrame implements ActionListener, PropertyC private CompositeCartoon compositeCartoon; // Names of fields indexed by PileupParameters constants - private String[] readAspectOptions = {"5' End", "3' End", "Midpoint (Require PE)", "Full Fragment (Require PE)"}; + private String[] readAspectOptions = {"5' End", "3' End", "Midpoint", "Full Fragment"}; private String[] readOutputOptions = {"Read 1", "Read 2", "All Reads"}; private String[] transformationOptions = {"None", "Sliding Window", "Gaussian Smooth"}; From 5aacbe5384c585a842ebffa0eaa8027e1b077346 Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Thu, 29 Jun 2023 10:48:12 -0400 Subject: [PATCH 3/4] change tag extend GUI default to 0 - change default Tag Extend value to 0 in TagPileupWindow - add validate option to pop-up dialog if Tag Extend value is negative - add error-style formatting to JOptionPane dialogs that notify user of input errors #133 --- .../Read_Analysis/TagPileupWindow.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 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 9ce3cae4d..e43d03387 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java @@ -135,26 +135,28 @@ public Void doInBackground() throws IOException, InterruptedException { try { if (Integer.parseInt(txtBin.getText()) < 1) { JOptionPane.showMessageDialog(null, "Invalid Bin Size!!! Must be larger than 0 bp"); + } else if (Integer.parseInt(txtTagExtend.getText()) < 0) { + JOptionPane.showMessageDialog(null, "Invalid Tag Extend length!!! Must be non-negative bp length" + "\n\n" + "Consider adjusting the shift bp value if you are interested in negative extensions.", "Validate Input", JOptionPane.ERROR_MESSAGE); } else if (cbox_Transform.getSelectedIndex()==PileupParameters.WINDOW && Integer.parseInt(txtSmooth.getText()) < 1) { - JOptionPane.showMessageDialog(null, "Invalid Smoothing Window Size!!! Must be larger than 0 bp"); + JOptionPane.showMessageDialog(null, "Invalid Smoothing Window Size!!! Must be larger than 0 bp", "Validate Input", JOptionPane.ERROR_MESSAGE); } else if (cbox_Transform.getSelectedIndex()==PileupParameters.WINDOW && Integer.parseInt(txtSmooth.getText()) % 2 == 0) { - JOptionPane.showMessageDialog(null, "Invalid Smoothing Window Size!!! Must be odd for symmetrical smoothing (so that the window is centered properly)."); + JOptionPane.showMessageDialog(null, "Invalid Smoothing Window Size!!! Must be odd for symmetrical smoothing (so that the window is centered properly).", "Validate Options", JOptionPane.ERROR_MESSAGE); } else if (cbox_Transform.getSelectedIndex()==PileupParameters.GAUSSIAN && Integer.parseInt(txtStdSize.getText()) < 1) { - JOptionPane.showMessageDialog(null, "Invalid Standard Deviation Size!!! Must be larger than 0 bp"); + JOptionPane.showMessageDialog(null, "Invalid Standard Deviation Size!!! Must be larger than 0 bp", "Validate Input", JOptionPane.ERROR_MESSAGE); } else if (cbox_Transform.getSelectedIndex()==PileupParameters.GAUSSIAN && Integer.parseInt(txtNumStd.getText()) < 1) { - JOptionPane.showMessageDialog(null, "Invalid Number of Standard Deviations!!! Must be larger than 0"); + JOptionPane.showMessageDialog(null, "Invalid Number of Standard Deviations!!! Must be larger than 0", "Validate Input", JOptionPane.ERROR_MESSAGE); } else if (Integer.parseInt(txtCPU.getText()) < 1) { - JOptionPane.showMessageDialog(null, "Invalid Number of CPU's!!! Must use at least 1"); + JOptionPane.showMessageDialog(null, "Invalid Number of CPU's!!! Must use at least 1", "Validate Input", JOptionPane.ERROR_MESSAGE); } else if (chckbxFilterByMin.isSelected() && Integer.parseInt(txtMin.getText()) < 0) { - JOptionPane.showMessageDialog(null, "Invalid Minimum Insert Size!!! Must be greater than or equal to 0 bp"); + JOptionPane.showMessageDialog(null, "Invalid Minimum Insert Size!!! Must be greater than or equal to 0 bp", "Validate Input", JOptionPane.ERROR_MESSAGE); } else if (chckbxFilterByMax.isSelected() && Integer.parseInt(txtMax.getText()) < 0) { - JOptionPane.showMessageDialog(null, "Invalid Maximum Insert Size!!! Must be greater than or equal to 0 bp"); + JOptionPane.showMessageDialog(null, "Invalid Maximum Insert Size!!! Must be greater than or equal to 0 bp", "Validate Input", JOptionPane.ERROR_MESSAGE); } else if (chckbxFilterByMin.isSelected() && chckbxFilterByMax.isSelected() && Integer.parseInt(txtMax.getText()) < Integer.parseInt(txtMin.getText())) { - JOptionPane.showMessageDialog(null, "Invalid Maximum & Minimum Insert Sizes!!! Maximum must be larger/equal to Minimum!"); + JOptionPane.showMessageDialog(null, "Invalid Maximum & Minimum Insert Sizes!!! Maximum must be larger/equal to Minimum!", "Validate Input", JOptionPane.ERROR_MESSAGE); } else if (BEDFiles.size() < 1) { - JOptionPane.showMessageDialog(null, "No BED Files Loaded!!!"); + JOptionPane.showMessageDialog(null, "No BED Files Loaded!!!", "Validate Input", JOptionPane.ERROR_MESSAGE); } else if (BAMFiles.size() < 1) { - JOptionPane.showMessageDialog(null, "No BAM Files Loaded!!!"); + JOptionPane.showMessageDialog(null, "No BAM Files Loaded!!!", "Validate Input", JOptionPane.ERROR_MESSAGE); } else { setProgress(0); // Load up parameters for the pileup into single object @@ -239,7 +241,7 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { return null; } } catch (NumberFormatException nfe) { - JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!", "Validate Input", JOptionPane.ERROR_MESSAGE); } return null; } @@ -552,7 +554,7 @@ public void itemStateChanged(ItemEvent e) { sl_ReadManipulation.putConstraint(SpringLayout.NORTH, txtTagExtend, -1, SpringLayout.NORTH, lblTagExtend); sl_ReadManipulation.putConstraint(SpringLayout.WEST, txtTagExtend, 120, SpringLayout.WEST, lblTagExtend); sl_ReadManipulation.putConstraint(SpringLayout.EAST, txtTagExtend, -6, SpringLayout.EAST, pnlReadManipulation); - txtTagExtend.setText("1"); + txtTagExtend.setText("0"); txtTagExtend.setHorizontalAlignment(SwingConstants.CENTER); txtTagExtend.setColumns(10); pnlReadManipulation.add(txtTagExtend); From f411d026ac9901d956bfd6286cadd19bcce7e00a Mon Sep 17 00:00:00 2001 From: Olivia Wen-Mei Lang Date: Thu, 29 Jun 2023 11:13:22 -0400 Subject: [PATCH 4/4] remove in/out extension restrictions on CLI tools This commit removes unnecessary extension filename validation from the CLI tools. This validation is too restrictive and interferes with development of Galaxy wrappers by forcing workarounds (Galaxy uses `.dat` extensions). --- .../cli/BAM_Format_Converter/BAMtoBEDCLI.java | 10 ---------- .../cli/BAM_Format_Converter/BAMtoGFFCLI.java | 10 ---------- .../BAMtobedGraphCLI.java | 4 ---- .../BAM_Format_Converter/BAMtoscIDXCLI.java | 10 ---------- .../BAM_Manipulation/FilterforPIPseqCLI.java | 18 ----------------- .../BAMGenomeCorrelationCLI.java | 4 ---- .../cli/BAM_Statistics/PEStatsCLI.java | 5 ----- .../cli/BAM_Statistics/SEStatsCLI.java | 5 ----- .../Figure_Generation/MergeHeatMapCLI.java | 20 +------------------ .../ThreeColorHeatMapCLI.java | 14 ------------- .../Peak_Analysis/BEDPeakAligntoRefCLI.java | 13 ------------ .../FilterBEDbyProximityCLI.java | 5 ----- .../Peak_Analysis/RandomCoordinateCLI.java | 6 ------ .../cli/Peak_Analysis/TileGenomeCLI.java | 6 ------ .../cli/Read_Analysis/ScalingFactorCLI.java | 11 +--------- .../cli/Read_Analysis/TagPileupCLI.java | 1 - .../Sequence_Analysis/DNAShapefromBEDCLI.java | 8 -------- .../DNAShapefromFASTACLI.java | 6 ------ .../Sequence_Analysis/RandomizeFASTACLI.java | 15 -------------- .../cli/Sequence_Analysis/SearchMotifCLI.java | 17 +--------------- 20 files changed, 3 insertions(+), 185 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..0082cee4a 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java @@ -94,10 +94,6 @@ private String validateInput() throws IOException { r += "(!)BAM file does not exist: " + bamFile.getName() + "\n"; return(r); } - //check input extensions - if(!"bam".equals(ExtensionFileFilter.getExtension(bamFile))){ - r += "(!)Is this a BAM file? Check extension: " + bamFile.getName() + "\n"; - } //check BAI exists File f = new File(bamFile+".bai"); if(!f.exists() || f.isDirectory()){ @@ -116,12 +112,6 @@ private String validateInput() throws IOException { if(output!=null){ r += "(!)Cannot use -s flag with -o.\n"; } //check output filename is valid }else{ - //check ext - try{ - if(!"bed".equals(ExtensionFileFilter.getExtension(output))){ - r += "(!)Use BED extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + ".bed\n"; - } - } catch( NullPointerException e){ r += "(!)Output filename must have extension: use BED extension for output filename. Try: " + output + ".bed\n"; } //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); 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..220f3e10a 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java @@ -94,10 +94,6 @@ private String validateInput() throws IOException { r += "(!)BAM file does not exist: " + bamFile.getName() + "\n"; return(r); } - //check input extensions - if(!"bam".equals(ExtensionFileFilter.getExtension(bamFile))){ - r += "(!)Is this a BAM file? Check extension: " + bamFile.getName() + "\n"; - } //check BAI exists File f = new File(bamFile+".bai"); if(!f.exists() || f.isDirectory()){ @@ -116,12 +112,6 @@ private String validateInput() throws IOException { if(output!=null){ r += "(!)Cannot use -s flag with -o.\n"; } //check output filename is valid }else{ - //check ext - try{ - if(!"gff".equals(ExtensionFileFilter.getExtension(output))){ - r += "(!)Use GFF extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + ".gff\n"; - } - } catch( NullPointerException e){ r += "(!)Output filename must have extension: use GFF extension for output filename. Try: " + output + ".gff\n"; } //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); 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..46dc898c2 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java @@ -89,10 +89,6 @@ private String validateInput() throws IOException { r += "(!)BAM file does not exist: " + bamFile.getName() + "\n"; return(r); } - //check input extensions - if(!"bam".equals(ExtensionFileFilter.getExtension(bamFile))){ - r += "(!)Is this a BAM file? Check extension: " + bamFile.getName() + "\n"; - } //check BAI exists File f = new File(bamFile+".bai"); if(!f.exists() || f.isDirectory()){ 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..513b24400 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java @@ -91,10 +91,6 @@ private String validateInput() throws IOException { r += "(!)BAM file does not exist: " + bamFile.getName() + "\n"; return(r); } - //check input extensions - if(!"bam".equals(ExtensionFileFilter.getExtension(bamFile))){ - r += "(!)Is this a BAM file? Check extension: " + bamFile.getName() + "\n"; - } //check BAI exists File f = new File(bamFile+".bai"); if(!f.exists() || f.isDirectory()){ @@ -113,12 +109,6 @@ private String validateInput() throws IOException { if(output!=null){ r += "(!)Cannot use -s flag with -o.\n"; } //check output filename is valid }else{ - //check ext - try{ - if(!"tab".equals(ExtensionFileFilter.getExtension(output))){ - r += "(!)Use \".tab\" extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + ".tab\n"; - } - } catch( NullPointerException e){ r += "(!)Output filename must have extension: use \".tab\" extension for output filename. Try: " + output + ".tab\n"; } //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java b/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java index be926e6ef..c1df66bf8 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java @@ -73,14 +73,6 @@ private String validateInput() throws IOException { if (!r.equals("")) { return (r); } - // check input extensions - ExtensionFileFilter faFilter = new ExtensionFileFilter("fa"); - if (!faFilter.accept(genomeFASTA)) { - r += "(!)Is this a FASTA file? Check extension: " + genomeFASTA.getName() + "\n"; - } - if (!"bam".equals(ExtensionFileFilter.getExtension(bamFile))) { - r += "(!)Is this a BAM file? Check extension: " + bamFile.getName() + "\n"; - } // check BAI exists File f = new File(bamFile + ".bai"); if (!f.exists() || f.isDirectory()) { @@ -98,16 +90,6 @@ private String validateInput() throws IOException { output = new File(ExtensionFileFilter.stripExtension(bamFile) + "_PSfilter.bam"); // check output filename is valid } else { - // check ext - try { - if (!"bam".equals(ExtensionFileFilter.getExtension(output))) { - r += "(!)Use BAM extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) - + ".bam\n"; - } - } catch (NullPointerException e) { - r += "(!)Output filename must have extension: use BAM extension for output filename. Try: " - + ExtensionFileFilter.stripExtension(output) + ".bam\n"; - } // check directory if (output.getParent() == null) { // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java index af564d7ef..45f2cea0f 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java @@ -123,9 +123,6 @@ private String validateInput() throws IOException { //check input exists if(!BAM.exists()|| BAM.isDirectory()){ r += "(!)BAM[" + x + "] file does not exist: " + BAM.getName() + "\n"; - //check input extensions - }else if(!"bam".equals(ExtensionFileFilter.getExtension(BAM))){ - r += "(!)Is this a BAM file? Check extension: " + BAM.getName() + "\n"; //check BAI exists }else if(!BAI.exists() || BAI.isDirectory()){ r += "(!)BAI Index File does not exist for: " + BAM.getName() + "\n"; @@ -137,7 +134,6 @@ private String validateInput() throws IOException { outputBasename = new File("correlation_matrix"); //check output filename is valid }else{ - //no check ext //check directory if(outputBasename.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java index 73a87f4de..3d4cb3420 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java @@ -62,10 +62,6 @@ private String validateInput() throws IOException { r += "(!)BAM file does not exist: " + bamFile.getName() + "\n"; return(r); } - //check input extensions - if(!"bam".equals(ExtensionFileFilter.getExtension(bamFile))){ - r += "(!)Is this a BAM file? Check extension: " + bamFile.getName() + "\n"; - } //check BAI exists File f = new File(bamFile+".bai"); if(!f.exists() || f.isDirectory()){ @@ -77,7 +73,6 @@ private String validateInput() throws IOException { outputBasename = new File(ExtensionFileFilter.stripExtension(bamFile)); //check output filename is valid }else{ - //no check ext //check directory if(outputBasename.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java b/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java index e714b74a2..4b29d56da 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java @@ -53,10 +53,6 @@ private String validateInput() throws IOException { r += "(!)BAM file does not exist: " + bamFile.getName() + "\n"; return(r); } - //check input extensions - if(!"bam".equals(ExtensionFileFilter.getExtension(bamFile))){ - r += "(!)Is this a BAM file? Check extension: " + bamFile.getName() + "\n"; - } //check BAI exists File f = new File(bamFile+".bai"); if(!f.exists() || f.isDirectory()){ @@ -68,7 +64,6 @@ private String validateInput() throws IOException { output = new File(ExtensionFileFilter.stripExtension(bamFile) + "_stats.txt"); //check output filename is valid }else{ - //no check ext //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java index 10e527045..098819ed7 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java @@ -30,8 +30,7 @@ public class MergeHeatMapCLI implements Callable { @Parameters(index = "1", description = "Second(anti) PNG heatmap to merge, input2") private File antiFile; - @Option(names = { "-o", - "--output" }, description = "specify output filename, please use PNG extension\n(default=\"_merged.png\" appended to the name in working directory of ScriptManager") + @Option(names = { "-o", "--output" }, description = "specify output filename, please use PNG extension\n(default=\"_merged.png\" appended to the name in working directory of ScriptManager") private File output = null; @Override @@ -64,29 +63,12 @@ private String validateInput() throws IOException { if (!r.equals("")) { return (r); } - // check input extensions - if (!"png".equals(ExtensionFileFilter.getExtension(senseFile))) { - r += "(!)Is this a PNG file? Check extension: " + senseFile.getName() + "\n"; - } - if (!"png".equals(ExtensionFileFilter.getExtension(antiFile))) { - r += "(!)Is this a PNG file? Check extension: " + antiFile.getName() + "\n"; - } // set default output filename if (output == null) { String NAME = ExtensionFileFilter.stripExtension(senseFile); output = new File(NAME + "_merged.png"); // check output filename is valid } else { - // check ext - try { - if (!"png".equals(ExtensionFileFilter.getExtension(output))) { - r += "(!)Use PNG extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) - + ".png\n"; - } - } catch (NullPointerException e) { - r += "(!)Output filename must have extension: use PNG extension for output filename. Try: " + output - + ".png\n"; - } // check directory if (output.getParent() == null) { // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java b/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java index 78accd5a2..519557972 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java @@ -164,26 +164,12 @@ private String validateInput() throws IOException { r += "(!)CDT file does not exist: " + CDT.getName() + "\n"; return (r); } - // check input extensions - if (!"cdt".equals(ExtensionFileFilter.getExtension(CDT))) { - r += "(!)Is this a CDT file? Check extension: " + CDT.getName() + "\n"; - } // set default output filename if (output == null) { String NAME = ExtensionFileFilter.stripExtension(CDT); output = new File(NAME + "_" + scaleType + ".png"); // check output filename is valid } else { - // check ext - try { - if (!"png".equals(ExtensionFileFilter.getExtension(output))) { - r += "(!)Use PNG extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) - + ".png\n"; - } - } catch (NullPointerException e) { - r += "(!)Output filename must have extension: use PNG extension for output filename. Try: " + output - + ".png\n"; - } // 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 11251074b..e6ec1dbfc 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java @@ -60,24 +60,11 @@ private String validateInput() throws IOException { r += "(!)BED-ref file does not exist: " + refBED.getName() + "\n"; } if(!r.equals("")){ return(r); } - //check input extensions - if(!"bed".equals(ExtensionFileFilter.getExtension(peakBED))){ - r += "(!)Is this a BED file? Check extension: " + peakBED.getName() + "\n"; - } - if(!"bed".equals(ExtensionFileFilter.getExtension(refBED))){ - r += "(!)Is this a BED file? Check extension: " + refBED.getName() + "\n"; - } //set default output filename if(output==null){ output = new File(ExtensionFileFilter.stripExtension(peakBED) + "_" + ExtensionFileFilter.stripExtension(refBED) + "_Output.cdt"); //check output filename is valid }else{ - //check ext - try{ - if(!"cdt".equals(ExtensionFileFilter.getExtension(output))){ - r += "(!)Use CDT extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + ".cdt\n"; - } - } catch( NullPointerException e){ r += "(!)Output filename must have extension: use CDT extension for output filename. Try: " + output + ".cdt\n"; } //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java index 2f364470f..b14a4b735 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java @@ -57,16 +57,11 @@ private String validateInput() throws IOException { r += "(!)BED file does not exist: " + bedFile.getName() + "\n"; return(r); } - //check input extensions - if(!"bed".equals(ExtensionFileFilter.getExtension(bedFile))){ - 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"; //check output filename is valid }else{ - //no check ext //check directory File tmpOut = new File(outputBasename); if(tmpOut.getParent()==null){ diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java index 3ad83064f..e79d1524e 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java @@ -62,12 +62,6 @@ private String validateInput() throws IOException { output = new File("random_coordinates_" + genomeName + "_" + numSites + "sites_" + window + "bp." + ext); //check output filename is valid }else{ - //check ext - try{ - if(!ext.equals(ExtensionFileFilter.getExtension(output))){ - r += "(!)Use \"." + ext.toUpperCase() + "\" extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + "." + ext + "\n"; - } - } catch( NullPointerException e){ r += "(!)Output filename must have extension: use \"." + ext.toUpperCase() + "\" extension for output filename. Try: " + output + "." + ext + "\n"; } //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java b/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java index 556bf401a..26c03d81d 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java @@ -60,12 +60,6 @@ private String validateInput() throws IOException { output = new File(genomeName + "_" + window + "bp." + ext); //check output filename is valid }else{ - //check ext - try{ - if(!ext.equals(ExtensionFileFilter.getExtension(output))){ - r += "(!)Use \"." + ext.toUpperCase() + "\" extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + "." + ext + "\n"; - } - } catch( NullPointerException e){ r += "(!)Output filename must have extension: use \"." + ext.toUpperCase() + "\" extension for output filename. Try: " + output + "." + ext + "\n"; } //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java b/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java index 83e22ba44..df443cdda 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java @@ -86,19 +86,11 @@ private String validateInput() throws IOException { if(!controlBAM.exists()){ r += "(!)BAM(control) file does not exist: " + controlBAM.getName() + "\n"; } } if(!r.equals("")){ return(r); } - //check input extensions & BAI exists - if(!"bam".equals(ExtensionFileFilter.getExtension(bamFile))){ - r += "(!)Is this a BAM(input) file? Check extension: " + bamFile.getName() + "\n"; - } + //check BAI exists File f = new File(bamFile+".bai"); if(!f.exists() || f.isDirectory()){ r += "(!)BAI Index File does not exist for: " + bamFile.getName() + "\n"; } - if(blacklistFilter!=null){ - if(!"bed".equals(ExtensionFileFilter.getExtension(blacklistFilter))){ - r += "(!)Is this a BED file? Check extension: " + blacklistFilter.getName() + "\n"; - } - } if(controlBAM!=null){ if(!"bam".equals(ExtensionFileFilter.getExtension(controlBAM))){ r += "(!)Is this a BAM(control) file? Check extension: " + controlBAM.getName() + "\n"; @@ -114,7 +106,6 @@ private String validateInput() throws IOException { //check output filename is valid }else{ File tempOut = new File(outputBasename); - //no check ext //check directory if(tempOut.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Read_Analysis/TagPileupCLI.java b/src/main/java/scriptmanager/cli/Read_Analysis/TagPileupCLI.java index c5fc28bde..a94d3636f 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/TagPileupCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/TagPileupCLI.java @@ -187,7 +187,6 @@ private String validateInput() throws IOException { //check output COMPOSITE filename is valid if(outputOptions.outputComposite!="composite_average.out"){ File output = new File(outputOptions.outputComposite); - //no check ext //check directory if(output.getParent()==null){ // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java index d919aec39..6b930bfae 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java @@ -124,14 +124,6 @@ private String validateInput() throws IOException { if (!r.equals("")) { return (r); } - // check input extensions - ExtensionFileFilter faFilter = new ExtensionFileFilter("fa"); - if (!faFilter.accept(genomeFASTA)) { - r += "(!)Is this a FASTA file? Check extension: " + genomeFASTA.getName() + "\n"; - } - if (!"bed".equals(ExtensionFileFilter.getExtension(bedFile))) { - r += "(!)Is this a BED file? Check extension: " + bedFile.getName() + "\n"; - } // set default output filename if (outputBasename == null) { outputBasename = ExtensionFileFilter.stripExtension(bedFile); diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java index ee3850a9a..6fcc30b96 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java @@ -114,18 +114,12 @@ private String validateInput() throws IOException { r += "(!)FASTA file does not exist: " + fastaFile.getName() + "\n"; return (r); } - // check input extensions - ExtensionFileFilter faFilter = new ExtensionFileFilter("fa"); - if (!faFilter.accept(fastaFile)) { - r += "(!)Is this a FASTA file? Check extension: " + fastaFile.getName() + "\n"; - } // set default output filename if (outputBasename == null) { outputBasename = ExtensionFileFilter.stripExtension(fastaFile); // check output filename is valid } else { String outParent = new File(outputBasename).getParent(); - // no extension check // check directory if (outParent == null) { // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java index 86296e6e0..d9520c756 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java @@ -64,27 +64,12 @@ private String validateInput() throws IOException { r += "(!)FASTA file does not exist: " + fastaFile.getName() + "\n"; return (r); } - // check input extension - ExtensionFileFilter faFilter = new ExtensionFileFilter("fa"); - if (!faFilter.accept(fastaFile)) { - r += "(!)Is this a FASTA file? Check extension: " + fastaFile.getName() + "\n"; - } // set default output filename if (output == null) { String NAME = ExtensionFileFilter.stripExtension(fastaFile) + "_RAND.fa"; output = new File(NAME); // check output filename is valid } else { - // check ext - try { - if (!faFilter.accept(output)) { - r += "(!)Use FASTA extension for output filename. Try: " - + ExtensionFileFilter.stripExtension(output) + ".fa\n"; - } - } catch (NullPointerException e) { - r += "(!)Output filename must have extension: use \".fa\" extension for output filename. Try: " + output - + ".fa\n"; - } // check directory if (output.getParent() == null) { // System.err.println("default to current directory"); diff --git a/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java b/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java index 9ca47ce78..34a24be2f 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java @@ -68,29 +68,14 @@ private String validateInput() throws IOException { r += "(!)FASTA file does not exist: " + fastaFile.getName() + "\n"; return (r); } - // check input extensions - ExtensionFileFilter faFilter = new ExtensionFileFilter("fa"); - if (!faFilter.accept(fastaFile)) { - r += "(!)Is this a FASTA file? Check extension: " + fastaFile.getName() + "\n"; - } // set default output filename if (output == null) { String NAME = motif + "_" + Integer.toString(ALLOWED_MISMATCH) + "Mismatch_" + ExtensionFileFilter.stripExtension(fastaFile) + ".bed"; NAME += gzOutput ? ".gz" : ""; output = new File(NAME); - // check output filename is valid + // check output filename is valid } else { - // check ext - try { - if (!"bed".equals(ExtensionFileFilter.getExtension(output))) { - r += "(!)Use BED extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) - + ".bed\n"; - } - } catch (NullPointerException e) { - r += "(!)Output filename must have extension: use BED extension for output filename. Try: " + output - + ".bed\n"; - } // check directory if (output.getParent() == null) { // System.err.println("default to current directory");