Skip to content

Commit

Permalink
Merge pull request #147 from CEGRcode/olivia-logging
Browse files Browse the repository at this point in the history
Incorportate batch of logging support changes
  • Loading branch information
owlang authored Nov 29, 2023
2 parents abcc167 + ae45363 commit 6520743
Show file tree
Hide file tree
Showing 154 changed files with 5,607 additions and 1,695 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/.gradle/
/build/
.metadata
.idea
.idea
2 changes: 1 addition & 1 deletion .project
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
</projectDescription>
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,4 @@ eval "set -- $(
tr '\n' ' '
)" '"$@"'

exec "$JAVACMD" "$@"
exec "$JAVACMD" "$@"
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
:omega
1,000 changes: 1,000 additions & 0 deletions sacCer3_1000SITES_200bp.bed

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;

import scriptmanager.objects.ToolDescriptions;
import scriptmanager.util.ExtensionFileFilter;
Expand Down Expand Up @@ -115,11 +116,11 @@ private String validateInput() throws IOException {
}
//set default output filename
if(output==null && !stdout){
if(STRAND==0){ output = new File( bamFile.getName().split("\\.")[0] + "_READ1.bed" ); }
else if(STRAND==1){ output = new File( bamFile.getName().split("\\.")[0] + "_READ2.bed" ); }
else if(STRAND==2){ output = new File( bamFile.getName().split("\\.")[0] + "_COMBINED.bed" ); }
else if(STRAND==3){ output = new File( bamFile.getName().split("\\.")[0] + "_MIDPOINT.bed" ); }
else if(STRAND==4){ output = new File( bamFile.getName().split("\\.")[0] + "_FRAGMENT.bed" ); }
if (STRAND==0) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ1.bed" + (gzOutput ? ".gz" : "")); }
else if (STRAND==1) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ2.bed" + (gzOutput ? ".gz" : "")); }
else if (STRAND==2) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_COMBINED.bed" + (gzOutput ? ".gz" : "")); }
else if (STRAND==3) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_MIDPOINT.bed" + (gzOutput ? ".gz" : "")); }
else if (STRAND==4) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_FRAGMENT.bed" + (gzOutput ? ".gz" : "")); }
else { r += "(!)Somehow invalid STRAND!This error should never print. Check code if it does.\n"; }
//check stdout and output not both selected
}else if(stdout){
Expand All @@ -143,4 +144,27 @@ private String validateInput() throws IOException {

return(r);
}
public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max) {
String command = "java -jar $SCRIPTMANAGER bam-format-converter bam-to-bed";
command += " " + BAM.getAbsolutePath();
command += " -o " + output.getAbsolutePath();
if (strand == 0) {
command += " -1 ";
} else if (strand == 1) {
command += " -2 ";
} else if (strand == 2) {
command += " -a ";
} else if (strand == 3 ) {
command += " -m ";
} else if (strand == 4) {
command += " -f ";
}
command += pair != 0 ? " -p" : "";
if (min != -9999) {
command += " -n " + min;
} else if (max != -9999) {
command += " -x " + max;
}
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;

import scriptmanager.objects.ToolDescriptions;
import scriptmanager.util.ExtensionFileFilter;
Expand Down Expand Up @@ -115,11 +116,11 @@ private String validateInput() throws IOException {
}
//set default output filename
if(output==null && !stdout){
if(STRAND==0){ output = new File( bamFile.getName().split("\\.")[0] + "_READ1.gff" ); }
else if(STRAND==1){ output = new File( bamFile.getName().split("\\.")[0] + "_READ2.gff" ); }
else if(STRAND==2){ output = new File( bamFile.getName().split("\\.")[0] + "_COMBINED.gff" ); }
else if(STRAND==3){ output = new File( bamFile.getName().split("\\.")[0] + "_MIDPOINT.gff" ); }
else if(STRAND==4){ output = new File( bamFile.getName().split("\\.")[0] + "_FRAGMENT.gff" ); }
if (STRAND==0) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ1.gff" + (gzOutput ? ".gz" : "")); }
else if (STRAND==1) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ2.gff" + (gzOutput ? ".gz" : "")); }
else if (STRAND==2) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_COMBINED.gff" + (gzOutput ? ".gz" : "")); }
else if (STRAND==3) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_MIDPOINT.gff" + (gzOutput ? ".gz" : "")); }
else if (STRAND==4) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_FRAGMENT.gff" + (gzOutput ? ".gz" : "")); }
else { r += "(!)Somehow invalid STRAND!This error should never print. Check code if it does.\n"; }
//check stdout and output not both selected
}else if(stdout){
Expand All @@ -143,4 +144,27 @@ private String validateInput() throws IOException {

return(r);
}
public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max) {
String command = "java -jar $SCRIPTMANAGER bam-format-converter bam-to-gff";
command += " " + BAM.getAbsolutePath();
command += " -o " + output.getAbsolutePath();
if (strand == 0) {
command += " -1 ";
} else if (strand == 1) {
command += " -2 ";
} else if (strand == 2) {
command += " -a ";
} else if (strand == 3 ) {
command += " -m ";
} else if (strand == 4) {
command += " -f ";
}
command += pair != 0 ? " -p" : "";
if (min != -9999) {
command += " -n " + min;
} else if (max != -9999) {
command += " -x " + max;
}
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;

import scriptmanager.objects.ToolDescriptions;
import scriptmanager.util.ExtensionFileFilter;
Expand Down Expand Up @@ -138,4 +139,25 @@ private String validateInput() throws IOException {

return(r);
}
public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max){
String command = "java -jar $SCRIPTMANAGER bam-format-converter bam-to-bedgraph";
command += " " + BAM.getAbsolutePath();
command += " -o " + output.getAbsolutePath();
if (strand == 0) {
command += " -1 ";
} else if (strand == 1) {
command += " -2 ";
} else if (strand == 2) {
command += " -a ";
} else if (strand == 3 ) {
command += " -m ";
}
command += pair != 0 ? " -p" : "";
if (min != -9999) {
command += " -n " + min;
} else if (max != -9999) {
command += " -x " + max;
}
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;

import scriptmanager.objects.ToolDescriptions;
import scriptmanager.util.ExtensionFileFilter;
Expand Down Expand Up @@ -111,11 +112,11 @@ private String validateInput() throws IOException {
}
//set default output filename
if(output==null && !stdout){
if(STRAND==0){ output = new File( bamFile.getName().split("\\.")[0] + "_READ1.tab" ); }
else if(STRAND==1){ output = new File( bamFile.getName().split("\\.")[0] + "_READ2.tab" ); }
else if(STRAND==2){ output = new File( bamFile.getName().split("\\.")[0] + "_COMBINED.tab" ); }
else if(STRAND==3){ output = new File( bamFile.getName().split("\\.")[0] + "_MIDPOINT.tab" ); }
else if(STRAND==4){ output = new File( bamFile.getName().split("\\.")[0] + "_FRAGMENT.tab" ); }
if (STRAND==0) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ1.tab" + (gzOutput ? ".gz" : "")); }
else if (STRAND==1) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_READ2.tab" + (gzOutput ? ".gz" : "")); }
else if (STRAND==2) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_COMBINED.tab" + (gzOutput ? ".gz" : "")); }
else if (STRAND==3) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_MIDPOINT.tab" + (gzOutput ? ".gz" : "")); }
else if (STRAND==4) { output = new File( ExtensionFileFilter.stripExtensionIgnoreGZ(bamFile) + "_FRAGMENT.tab" + (gzOutput ? ".gz" : "")); }
else { r += "(!)Somehow invalid STRAND!This error should never print. Check code if it does.\n"; }
//check stdout and output not both selected
}else if(stdout){
Expand All @@ -136,7 +137,29 @@ private String validateInput() throws IOException {
if( MAX_INSERT<MIN_INSERT && MIN_INSERT!=-9999 && MAX_INSERT!=-9999){ r += "MAX_INSERT must be larger/equal to MIN_INSERT: " + MIN_INSERT + "," + MAX_INSERT + "\n"; }
// turn pair status boolean into int
PAIR = matePair ? 1 : 0;

return(r);
}
public static String getCLIcommand(File BAM, File output, int strand, int pair, int min, int max) {
String command = "java -jar $SCRIPTMANAGER bam-format-converter bam-to-scidx";
System.out.println(output);
System.out.println(BAM);
command += " " + BAM.getAbsolutePath();
command += " -o " + output.getAbsolutePath();
if (strand == 0) {
command += " -1 ";
} else if (strand == 1) {
command += " -2 ";
} else if (strand == 2) {
command += " -a ";
} else if (strand == 3 ) {
command += " -m ";
}
command += pair != 0 ? " -p" : "";
if (min != -9999) {
command += " -n " + min;
} else if (max != -9999) {
command += " -x " + max;
}
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import picocli.CommandLine.Command;

import java.util.concurrent.Callable;
import java.io.File;

import scriptmanager.objects.ToolDescriptions;

Expand Down Expand Up @@ -37,4 +38,18 @@ public Integer call() throws Exception {
System.exit(1);
return(1);
}

/**
* Reconstruct CLI command
*
* @param input the BAM file to index
* @return command line to execute with formatted inputs
*/
public static String getCLIcommand(File input) {
String command = "java -jar $PICARD BuildBamIndex";
command += " INPUT=" + input.getAbsolutePath();
command += " OUTPUT=" + input.getAbsolutePath() + ".bai";
return command;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
exitCodeOnExecutionException = 1)
public class BAMRemoveDupCLI implements Callable<Integer> {

/**
* Creates a new BAMRemoveDupCLI object
*/
public BAMRemoveDupCLI(){}

/**
* Runs when this subcommand is called, running script in respective script package with user defined arguments
* @throws IOException Invalid file or parameters
Expand All @@ -44,19 +39,21 @@ public Integer call() throws Exception {
}

/**
* Returns picard command for generating running MarkDuplicates
* @param BAM BAM file ot be marked
* @param removeDuplicates If duplicate reads should be removed
* @param OUTPUT Ouput BAM file
* @param METRICS .metricts file for outputting stats
* @return Picard command for running MarkDuplicates
* Reconstruct CLI command (Picard)
*
* @param input the BAM file to mark/remove duplicates for
* @param removeDuplicates whether to remove or just mark duplicates
* @param output the marked/filtered BAM output file
* @param metrics the output metrics file with information about the
* deduplicates
* @return command line to execute with formatted inputs
*/
public static String getCLIcommand(File BAM, boolean removeDuplicates, File OUTPUT, File METRICS) {
public static String getCLIcommand(File input, boolean removeDuplicates, File output, File metrics) {
String command = "java -jar $PICARD MarkDuplicates";
command += " INPUT=" + BAM.getAbsolutePath();
command += " OUTPUT=" + OUTPUT.getAbsolutePath();
command += " METRICS_FILE=" + METRICS.getAbsolutePath();
command += removeDuplicates ? "REMOVE_DUPLICATES=true" : "REMOVE_DUPLICATES=false";
command += " INPUT=" + input.getAbsolutePath();
command += " OUTPUT=" + output.getAbsolutePath();
command += " METRICS_FILE=" + metrics.getAbsolutePath();
command += removeDuplicates ? " REMOVE_DUPLICATES=true" : " REMOVE_DUPLICATES=false";
return(command);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,22 @@ private String validateInput() throws IOException {

return (r);
}

/**
* Reconstruct CLI command
*
* @param BAM the BAM file to filter
* @param GENOME the genomic FASTA reference file (should match BAM header)
* @param OUTPUT the output BAM file
* @param txtSeq the IUPAC string to filter by
* @return command line to execute with formatted inputs
*/
public static String getCLIcommand(File BAM, File GENOME, File OUTPUT, String txtSeq) {
String command = "java -jar $SCRIPTMANAGER bam-manipulation filter-pip-seq";
command += " " + GENOME.getAbsolutePath();
command += " " + BAM.getAbsolutePath();
command += " -o " + OUTPUT.getAbsolutePath();
command += " -f " + txtSeq;
return command;
}
}
23 changes: 23 additions & 0 deletions src/main/java/scriptmanager/cli/BAM_Manipulation/MergeBAMCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import picocli.CommandLine.Command;

import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.io.File;

import scriptmanager.objects.ToolDescriptions;

Expand Down Expand Up @@ -38,4 +40,25 @@ public Integer call() throws Exception {
System.exit(1);
return(1);
}

/**
* Reconstruct CLI command
*
* @param inputs the list of input BAM files to merge (corresponds to
* several INPUT values)
* @param output the output file for the merged BAM file (corresponds
* to OUTPUT)
* @param useMultipleCpus whether or not to parallelize (corresponds to
* USE_THREADING)
* @return command line to execute with formatted inputs
*/
public static String getCLIcommand(ArrayList<File> inputs, File output, boolean useMultipleCpus) {
String command = "java -jar $PICARD MergeSamFiles";
for (File in : inputs) {
command += " INPUT=" + in.getAbsolutePath();
}
command += " OUTPUT=" + output.getAbsolutePath();
command += useMultipleCpus ? " USE_THREADING=true" : " USE_THREADING=false";
return command;
}
}
19 changes: 19 additions & 0 deletions src/main/java/scriptmanager/cli/BAM_Manipulation/SortBAMCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import java.io.IOException;
import java.util.concurrent.Callable;

import htsjdk.samtools.SAMFileHeader;

import java.io.File;

import scriptmanager.objects.ToolDescriptions;

/**
Expand Down Expand Up @@ -33,4 +37,19 @@ public Integer call() throws Exception {
System.exit(1);
return(1);
}

/**
* Reconstruct CLI command
*
* @param input the BAM file to be sorted (corresponds to INPUT)
* @param output the file to write the sorted BAM to (corresponds to OUTPUT)
* @return command line to execute with formatted inputs
*/
public static String getCLIcommand(File input, File output) {
String command = "java -jar $PICARD SortSam";
command += " INPUT=" + input.getAbsolutePath();
command += " OUTPUT=" + output.getAbsolutePath();
command += " SORT_ORDER=" + SAMFileHeader.SortOrder.coordinate;
return(command);
}
}
Loading

0 comments on commit 6520743

Please sign in to comment.