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 65aaab0d..3752192d 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoBEDCLI.java @@ -106,10 +106,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()){ @@ -128,12 +124,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 1fc5e1e3..e98cfab0 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoGFFCLI.java @@ -106,10 +106,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()){ @@ -128,12 +124,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 36ac1620..a85ed774 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtobedGraphCLI.java @@ -101,10 +101,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 143093bc..269ac5d2 100644 --- a/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Format_Converter/BAMtoscIDXCLI.java @@ -103,10 +103,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()){ @@ -125,12 +121,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 29ee457e..cfe64640 100644 --- a/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Manipulation/FilterforPIPseqCLI.java @@ -80,14 +80,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()) { @@ -105,16 +97,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 4c7aa85f..6ae1d91b 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/BAMGenomeCorrelationCLI.java @@ -135,9 +135,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"; @@ -149,7 +146,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 65cdd917..c2c17fb6 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/PEStatsCLI.java @@ -69,10 +69,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()){ @@ -84,7 +80,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 98140802..6ea727af 100644 --- a/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java +++ b/src/main/java/scriptmanager/cli/BAM_Statistics/SEStatsCLI.java @@ -61,10 +61,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()){ @@ -76,7 +72,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 16330b8a..e65acc7d 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/MergeHeatMapCLI.java @@ -38,8 +38,7 @@ public MergeHeatMapCLI(){} @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; /** @@ -76,29 +75,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 d29a706b..988d1d31 100644 --- a/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java +++ b/src/main/java/scriptmanager/cli/Figure_Generation/ThreeColorHeatMapCLI.java @@ -171,26 +171,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 9f9bb10c..188a272b 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/BEDPeakAligntoRefCLI.java @@ -71,24 +71,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 c777a10a..652582ee 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/FilterBEDbyProximityCLI.java @@ -64,16 +64,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 92471edc..97f0e27e 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/RandomCoordinateCLI.java @@ -69,12 +69,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 c774c8fe..bdfdfd30 100644 --- a/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java +++ b/src/main/java/scriptmanager/cli/Peak_Analysis/TileGenomeCLI.java @@ -67,12 +67,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 b9be7001..db30c9d3 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/ScalingFactorCLI.java @@ -93,19 +93,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"; @@ -121,7 +113,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 3e897199..0458e9b5 100644 --- a/src/main/java/scriptmanager/cli/Read_Analysis/TagPileupCLI.java +++ b/src/main/java/scriptmanager/cli/Read_Analysis/TagPileupCLI.java @@ -198,7 +198,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 b5f1b83a..1d52d6d0 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromBEDCLI.java @@ -131,14 +131,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 88a546bb..cbe9ce35 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/DNAShapefromFASTACLI.java @@ -125,18 +125,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 fa16b8d4..a2c81e63 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/RandomizeFASTACLI.java @@ -70,27 +70,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 bb707b77..213c7426 100644 --- a/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java +++ b/src/main/java/scriptmanager/cli/Sequence_Analysis/SearchMotifCLI.java @@ -75,29 +75,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"); diff --git a/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java b/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java index 9d0b25e7..5de200ec 100644 --- a/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java +++ b/src/main/java/scriptmanager/scripts/BAM_Manipulation/BAMMarkDuplicates.java @@ -6,8 +6,7 @@ import java.io.IOException; import java.util.ArrayList; -import javax.swing.JFrame; -import javax.swing.JOptionPane; +import htsjdk.samtools.SAMException; /** * Picard wrapper for MarkDuplicates @@ -15,32 +14,17 @@ * @author Erik Pavloski * @see scriptmanager.window_interface.BAM_Manipulation.BAMMarkDupWindow */ -@SuppressWarnings("serial") -public class BAMMarkDuplicates extends JFrame { - File bamFile = null; - boolean removeDuplicates = true; - File output = null; - File metrics = null; +public class BAMMarkDuplicates { /** - * Creates a new instance of BAMarkDuplicates with a single file + * Runs MarkDuplicates picard tool * @param in BAM file to be marked * @param remove Removes duplicates instead of marking them if true * @param out Output BAM file * @param met .metrics file for outputting stats - */ - public BAMMarkDuplicates(File in, boolean remove, File out, File met) { - bamFile = in; - removeDuplicates = remove; - output = out; - metrics = met; - } - - /** - * Runs MarkDuplicates picard tool * @throws IOException Invalid file or parameters If BAM file doesn't have corresponding .BAI Index file */ - public void run() throws IOException { + 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()) { @@ -53,7 +37,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 43386b17..73bfc127 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; @@ -33,8 +35,8 @@ import scriptmanager.objects.LogItem; import scriptmanager.util.FileSelection; -import scriptmanager.cli.BAM_Manipulation.BAMRemoveDupCLI; import scriptmanager.scripts.BAM_Manipulation.BAIIndexer; +import scriptmanager.cli.BAM_Manipulation.BAMRemoveDupCLI; import scriptmanager.scripts.BAM_Manipulation.BAMMarkDuplicates; /** @@ -78,38 +80,48 @@ class Task extends SwingWorker { @Override public Void doInBackground() throws Exception { 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"); - } - - // 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(); + LogItem old_li = new LogItem(""); + try { + for(int x = 0; x < BAMFiles.size(); x++) { + String[] NAME = BAMFiles.get(x).getName().split("\\."); + File OUTPUT = null; + File METRICS = null; - // Update log item - new_li.setStopTime(new Timestamp(new Date().getTime())); - new_li.setStatus(0); - old_li = new_li; + 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"); + } + - if(chckbxGenerateBaiIndex.isSelected()) { BAIIndexer.generateIndex(OUTPUT); } + // 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); + + // Run 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; + + // Index output if selected + if(chckbxGenerateBaiIndex.isSelected()) { BAIIndexer.generateIndex(OUTPUT); } - int percentComplete = (int)(((double)(x + 1) / BAMFiles.size()) * 100); - setProgress(percentComplete); - } + // Update progress + int percentComplete = (int)(((double)(x + 1) / BAMFiles.size()) * 100); + setProgress(percentComplete); + } + } catch (SAMException se){ + JOptionPane.showMessageDialog(null, se.getMessage()); + } firePropertyChange("log", old_li, null); - setProgress(100); + setProgress(100); + JOptionPane.showMessageDialog(null, "Mark Duplicates Complete"); 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 ebef260b..c36b7b75 100644 --- a/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java +++ b/src/main/java/scriptmanager/window_interface/Read_Analysis/TagPileupWindow.java @@ -124,7 +124,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"}; @@ -143,26 +143,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 @@ -250,9 +252,9 @@ public void propertyChange(PropertyChangeEvent evt) { return null; } } catch (NumberFormatException nfe) { - JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!"); + JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!", "Validate Input", JOptionPane.ERROR_MESSAGE); } catch (SAMException se) { - JOptionPane.showMessageDialog(null, se.getMessage()); + JOptionPane.showMessageDialog(null, se.getMessage(), "Validate Input", JOptionPane.ERROR_MESSAGE); } return null; } @@ -565,7 +567,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);