Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restructure MarkDup - adjust TagPileupWindow - remove CLI ext validation #134

Merged
merged 6 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=\"<senseFile>_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=\"<senseFile>_merged.png\" appended to the name in working directory of ScriptManager")
private File output = null;

/**
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading
Loading