Skip to content

Commit 738b7a2

Browse files
authored
Merge pull request #61 from CEGRcode/dev
Merge development Three Color Heatmap and Yeast Genome Converter tools
2 parents 0af1602 + 8508589 commit 738b7a2

135 files changed

Lines changed: 12529 additions & 8578 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ apply plugin: 'eclipse'
99

1010
sourceSets.main.java.srcDirs = ['src']
1111
mainClassName = "main.ScriptManager"
12-
version = 'v0.13'
12+
version = 'v0.13-dev'
1313
sourceCompatibility = 1.8
1414
targetCompatibility = 1.8
1515

src/cli/BAM_Format_Converter/BAMtoBEDCLI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
@Command(name = "bam-to-bed", mixinStandardHelpOptions = true,
2121
description = ToolDescriptions.bam_to_bed_description,
22+
version = "ScriptManager "+ ToolDescriptions.VERSION,
2223
sortOptions = false,
2324
exitCodeOnInvalidInput = 1,
2425
exitCodeOnExecutionException = 1)

src/cli/BAM_Format_Converter/BAMtoGFFCLI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
@Command(name = "bam-to-gff", mixinStandardHelpOptions = true,
2121
description = ToolDescriptions.bam_to_gff_description,
22+
version = "ScriptManager "+ ToolDescriptions.VERSION,
2223
sortOptions = false,
2324
exitCodeOnInvalidInput = 1,
2425
exitCodeOnExecutionException = 1)

src/cli/BAM_Format_Converter/BAMtobedGraphCLI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
@Command(name = "bam-to-bedgraph", mixinStandardHelpOptions = true,
2121
description = ToolDescriptions.bam_to_bedgraph_description,
22+
version = "ScriptManager "+ ToolDescriptions.VERSION,
2223
sortOptions = false,
2324
exitCodeOnInvalidInput = 1,
2425
exitCodeOnExecutionException = 1)

src/cli/BAM_Format_Converter/BAMtoscIDXCLI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
@Command(name = "bam-to-scidx", mixinStandardHelpOptions = true,
2121
description = ToolDescriptions.bam_to_scidx_description,
22+
version = "ScriptManager "+ ToolDescriptions.VERSION,
2223
sortOptions = false,
2324
exitCodeOnInvalidInput = 1,
2425
exitCodeOnExecutionException = 1)

src/cli/BAM_Manipulation/BAIIndexerCLI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
description = ToolDescriptions.bam_indexer_description + "\n"+
1414
"@|bold **Please run the samtools tool directly:**|@ \n"+
1515
"@|bold,yellow 'samtools index <bam-file>'|@",
16+
version = "ScriptManager "+ ToolDescriptions.VERSION,
1617
exitCodeOnInvalidInput = 1,
1718
exitCodeOnExecutionException = 1)
1819
public class BAIIndexerCLI implements Callable<Integer> {

src/cli/BAM_Manipulation/BAMRemoveDupCLI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@|bold **Please run the picard/samtools tools directly:**|@ \n"+
1515
"@|bold,yellow 'java -jar picard.jar MarkDuplicates I=<in.bam> O=<marked.bam>\n"+
1616
"samtools view -F 1024 <marked.bam> > <out.bam>'|@",
17+
version = "ScriptManager "+ ToolDescriptions.VERSION,
1718
exitCodeOnInvalidInput = 1,
1819
exitCodeOnExecutionException = 1)
1920
public class BAMRemoveDupCLI implements Callable<Integer> {

src/cli/BAM_Manipulation/FilterforPIPseqCLI.java

Lines changed: 77 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -11,108 +11,122 @@
1111
import java.util.regex.Matcher;
1212
import java.util.regex.Pattern;
1313

14+
import objects.CustomExceptions.FASTAException;
1415
import objects.ToolDescriptions;
1516
import util.FASTAUtilities;
1617
import util.ExtensionFileFilter;
1718
import scripts.BAM_Manipulation.FilterforPIPseq;
1819

1920
/**
20-
BAM_ManipulatioCLIn/FilterforPIPseqCLI
21-
*/
22-
@Command(name = "filter-pip-seq", mixinStandardHelpOptions = true,
23-
description = ToolDescriptions.filter_pip_seq_description + "\n" +
24-
"Note this program does not index the resulting BAM file and user must use appropriate samtools command to generate BAI.",
25-
sortOptions = false,
26-
exitCodeOnInvalidInput = 1,
27-
exitCodeOnExecutionException = 1)
21+
* BAM_ManipulatioCLIn/FilterforPIPseqCLI
22+
*/
23+
@Command(name = "filter-pip-seq", mixinStandardHelpOptions = true, description = ToolDescriptions.filter_pip_seq_description
24+
+ "\n"
25+
+ "Note this program does not index the resulting BAM file and user must use appropriate samtools command to generate BAI.", version = "ScriptManager "
26+
+ ToolDescriptions.VERSION, sortOptions = false, exitCodeOnInvalidInput = 1, exitCodeOnExecutionException = 1)
2827
public class FilterforPIPseqCLI implements Callable<Integer> {
29-
30-
@Parameters( index = "0", description = "The reference genome FASTA file.")
28+
29+
@Parameters(index = "0", description = "The reference genome FASTA file.")
3130
private File genomeFASTA;
32-
@Parameters( index = "1", description = "The BAM file from which we filter.")
31+
@Parameters(index = "1", description = "The BAM file from which we filter.")
3332
private File bamFile;
34-
35-
@Option(names = {"-o", "--output"}, description = "specify output file (default=<bamFileNoExt>_PSfilter.bam)")
33+
34+
@Option(names = { "-o", "--output" }, description = "specify output file (default=<bamFileNoExt>_PSfilter.bam)")
3635
private File output = null;
37-
@Option(names = {"-f", "--filter"}, description = "filter by upstream sequence, works only for single-nucleotide A,T,C, or G. (default seq ='T')")
36+
@Option(names = { "-f",
37+
"--filter" }, description = "filter by upstream sequence, works only for single-nucleotide A,T,C, or G. (default seq ='T')")
3838
private String filterString = "T";
39-
39+
4040
@Override
4141
public Integer call() throws Exception {
42-
System.err.println( ">FilterforPIPseqCLI.call()" );
42+
System.err.println(">FilterforPIPseqCLI.call()");
4343
String validate = validateInput();
44-
if(!validate.equals("")){
45-
System.err.println( validate );
44+
if (!validate.equals("")) {
45+
System.err.println(validate);
4646
System.err.println("Invalid input. Check usage using '-h' or '--help'");
4747
System.exit(1);
4848
}
49-
50-
FilterforPIPseq script_obj = new FilterforPIPseq(bamFile, genomeFASTA, output, filterString, null);
51-
script_obj.run();
52-
53-
System.err.println( "BAM Generated." );
54-
return(0);
49+
50+
try {
51+
FilterforPIPseq script_obj = new FilterforPIPseq(bamFile, genomeFASTA, output, filterString, null);
52+
script_obj.run();
53+
} catch (FASTAException e) {
54+
System.err.println(e.getMessage() + "\n");
55+
}
56+
57+
System.err.println("BAM Generated.");
58+
return (0);
5559
}
56-
57-
//validateInput outline
60+
61+
// validateInput outline
5862
private String validateInput() throws IOException {
5963
String r = "";
60-
61-
//check inputs exist
62-
if(!bamFile.exists()){
64+
65+
// check inputs exist
66+
if (!bamFile.exists()) {
6367
r += "(!)BAM file does not exist: " + bamFile.getName() + "\n";
6468
}
65-
if(!genomeFASTA.exists()){
69+
if (!genomeFASTA.exists()) {
6670
r += "(!)FASTA file does not exist: " + genomeFASTA.getName() + "\n";
6771
}
68-
if(!r.equals("")){ return(r); }
69-
//check input extensions
72+
if (!r.equals("")) {
73+
return (r);
74+
}
75+
// check input extensions
7076
ExtensionFileFilter faFilter = new ExtensionFileFilter("fa");
71-
if(!faFilter.accept(genomeFASTA)){
77+
if (!faFilter.accept(genomeFASTA)) {
7278
r += "(!)Is this a FASTA file? Check extension: " + genomeFASTA.getName() + "\n";
7379
}
74-
if(!"bam".equals(ExtensionFileFilter.getExtension(bamFile))){
80+
if (!"bam".equals(ExtensionFileFilter.getExtension(bamFile))) {
7581
r += "(!)Is this a BAM file? Check extension: " + bamFile.getName() + "\n";
7682
}
77-
//check BAI exists
78-
File f = new File(bamFile+".bai");
79-
if(!f.exists() || f.isDirectory()){
83+
// check BAI exists
84+
File f = new File(bamFile + ".bai");
85+
if (!f.exists() || f.isDirectory()) {
8086
r += "(!)BAI Index File does not exist for: " + bamFile.getName() + "\n";
8187
}
82-
//check FAI exists (generate if not)
88+
// check FAI exists (generate if not)
8389
File FAI = new File(genomeFASTA + ".fai");
84-
if(!FAI.exists() || FAI.isDirectory()) {
90+
if (!FAI.exists() || FAI.isDirectory()) {
8591
System.err.println("FASTA Index file not found.\nGenerating new one...\n");
86-
boolean FASTA_INDEX = FASTAUtilities.buildFASTAIndex(genomeFASTA);
87-
if(!FASTA_INDEX){ r += "FASTA Index failed to build."; }
92+
try {
93+
FASTAUtilities.buildFASTAIndex(genomeFASTA);
94+
} catch (FASTAException e) {
95+
r += e.getMessage();
96+
}
97+
8898
}
89-
//set default output filename
90-
if(output==null){
99+
// set default output filename
100+
if (output == null) {
91101
output = new File(ExtensionFileFilter.stripExtension(bamFile) + "_PSfilter.bam");
92-
//check output filename is valid
93-
}else{
94-
//check ext
95-
try{
96-
if(!"bam".equals(ExtensionFileFilter.getExtension(output))){
97-
r += "(!)Use BAM extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + ".bam\n";
102+
// check output filename is valid
103+
} else {
104+
// check ext
105+
try {
106+
if (!"bam".equals(ExtensionFileFilter.getExtension(output))) {
107+
r += "(!)Use BAM extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output)
108+
+ ".bam\n";
98109
}
99-
} catch( NullPointerException e){ r += "(!)Output filename must have extension: use BAM extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + ".bam\n"; }
100-
//check directory
101-
if(output.getParent()==null){
110+
} catch (NullPointerException e) {
111+
r += "(!)Output filename must have extension: use BAM extension for output filename. Try: "
112+
+ ExtensionFileFilter.stripExtension(output) + ".bam\n";
113+
}
114+
// check directory
115+
if (output.getParent() == null) {
102116
// System.err.println("default to current directory");
103-
} else if(!new File(output.getParent()).exists()){
104-
r += "(!)Check output directory exists: " + output.getParent() + "\n";
105-
}
117+
} else if (!new File(output.getParent()).exists()) {
118+
r += "(!)Check output directory exists: " + output.getParent() + "\n";
119+
}
106120
}
107-
108-
//check filter string is valid ATCG
121+
122+
// check filter string is valid ATCG
109123
Pattern seqPat = Pattern.compile("[ATCG]+");
110-
Matcher m = seqPat.matcher( filterString );
111-
if( !m.matches() ){
112-
r += "(!)Filter string must be formatted as a nucleotide sequence.\n" + filterString +
113-
" is not a valid nucleotide sequence.\nExpected input string format: \"[ATCG]\"";
124+
Matcher m = seqPat.matcher(filterString);
125+
if (!m.matches()) {
126+
r += "(!)Filter string must be formatted as a nucleotide sequence.\n" + filterString
127+
+ " is not a valid nucleotide sequence.\nExpected input string format: \"[ATCG]\"";
114128
}
115-
116-
return(r);
129+
130+
return (r);
117131
}
118132
}

src/cli/BAM_Manipulation/MergeBAMCLI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
description = ToolDescriptions.merge_bam_description + "\n"+
1414
"@|bold **Please run the picard tool directly:**|@ \n"+
1515
"@|bold,yellow 'java -jar picard.jar MergeSamFiles'|@",
16+
version = "ScriptManager "+ ToolDescriptions.VERSION,
1617
exitCodeOnInvalidInput = 1,
1718
exitCodeOnExecutionException = 1)
1819
public class MergeBAMCLI implements Callable<Integer> {

src/cli/BAM_Manipulation/SortBAMCLI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
description = ToolDescriptions.sort_bam_description + "\n"+
1414
"@|bold **Please run the samtools tool directly:**|@ \n"+
1515
"@|bold,yellow 'samtools sort -o <output.bam> <input.bam>'|@",
16+
version = "ScriptManager "+ ToolDescriptions.VERSION,
1617
exitCodeOnInvalidInput = 1,
1718
exitCodeOnExecutionException = 1)
1819
public class SortBAMCLI implements Callable<Integer> {

0 commit comments

Comments
 (0)