Skip to content

Commit 8631a46

Browse files
authored
Merge pull request #50 from CEGRcode/dev
Last bug fixes and additions for v0.13 CLI release
2 parents 0fedaa3 + d2b6910 commit 8631a46

10 files changed

Lines changed: 43 additions & 22 deletions

File tree

src/cli/BAM_Format_Converter/BAMtoBEDCLI.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ private String validateInput() throws IOException {
8686
else if(readType.midpoint) { STRAND=3; }
8787
else if(readType.fragment) { STRAND=4; }
8888
else { STRAND=0; }
89+
// set PE defaults
90+
if(STRAND==3 || STRAND==4) { matePair=true; }
8991

9092
//check inputs exist
9193
if(!bamFile.exists()){
@@ -131,7 +133,7 @@ private String validateInput() throws IOException {
131133
// validate insert sizes
132134
if( MIN_INSERT<0 && MIN_INSERT!=-9999 ){ r += "MIN_INSERT must be a positive integer value: " + MIN_INSERT + "\n"; }
133135
if( MAX_INSERT<0 && MAX_INSERT!=-9999 ){ r += "MAX_INSERT must be a positive integer value: " + MAX_INSERT + "\n"; }
134-
if( MAX_INSERT<MIN_INSERT ){ r += "MAX_INSERT must be larger/equal to MIN_INSERT: " + MIN_INSERT + "," + MAX_INSERT + "\n"; }
136+
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"; }
135137
// turn pair status boolean into int
136138
PAIR = matePair ? 1 : 0;
137139

src/cli/BAM_Format_Converter/BAMtoGFFCLI.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ private String validateInput() throws IOException {
8686
else if(readType.midpoint) { STRAND=3; }
8787
else if(readType.fragment) { STRAND=4; }
8888
else { STRAND=0; }
89+
// set PE defaults
90+
if(STRAND==3 || STRAND==4) { matePair=true; }
8991

9092
//check inputs exist
9193
if(!bamFile.exists()){
@@ -131,7 +133,7 @@ private String validateInput() throws IOException {
131133
// validate insert sizes
132134
if( MIN_INSERT<0 && MIN_INSERT!=-9999 ){ r += "MIN_INSERT must be a positive integer value: " + MIN_INSERT + "\n"; }
133135
if( MAX_INSERT<0 && MAX_INSERT!=-9999 ){ r += "MAX_INSERT must be a positive integer value: " + MAX_INSERT + "\n"; }
134-
if( MAX_INSERT<MIN_INSERT ){ r += "MAX_INSERT must be larger/equal to MIN_INSERT: " + MIN_INSERT + "," + MAX_INSERT + "\n"; }
136+
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"; }
135137
// turn pair status boolean into int
136138
PAIR = matePair ? 1 : 0;
137139

src/cli/BAM_Format_Converter/BAMtobedGraphCLI.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ private String validateInput() throws IOException {
8181
else if(readType.combined) { STRAND=2; }
8282
else if(readType.midpoint) { STRAND=3; }
8383
else { STRAND=0; }
84+
// set PE defaults
85+
if(STRAND==3) { matePair=true; }
8486

8587
//check inputs exist
8688
if(!bamFile.exists()){
@@ -119,7 +121,7 @@ private String validateInput() throws IOException {
119121
// validate insert sizes
120122
if( MIN_INSERT<0 && MIN_INSERT!=-9999 ){ r += "MIN_INSERT must be a positive integer value: " + MIN_INSERT + "\n"; }
121123
if( MAX_INSERT<0 && MAX_INSERT!=-9999 ){ r += "MAX_INSERT must be a positive integer value: " + MAX_INSERT + "\n"; }
122-
if( MAX_INSERT<MIN_INSERT ){ r += "MAX_INSERT must be larger/equal to MIN_INSERT: " + MIN_INSERT + "," + MAX_INSERT + "\n"; }
124+
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"; }
123125
// turn pair status boolean into int
124126
PAIR = matePair ? 1 : 0;
125127

src/cli/BAM_Format_Converter/BAMtoscIDXCLI.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ private String validateInput() throws IOException {
8383
else if(readType.combined) { STRAND=2; }
8484
else if(readType.midpoint) { STRAND=3; }
8585
else { STRAND=0; }
86+
// set PE defaults
87+
if(STRAND==3) { matePair=true; }
8688

8789
//check inputs exist
8890
if(!bamFile.exists()){
@@ -128,7 +130,7 @@ private String validateInput() throws IOException {
128130
// validate insert sizes
129131
if( MIN_INSERT<0 && MIN_INSERT!=-9999 ){ r += "MIN_INSERT must be a positive integer value: " + MIN_INSERT + "\n"; }
130132
if( MAX_INSERT<0 && MAX_INSERT!=-9999 ){ r += "MAX_INSERT must be a positive integer value: " + MAX_INSERT + "\n"; }
131-
if( MAX_INSERT<MIN_INSERT ){ r += "MAX_INSERT must be larger/equal to MIN_INSERT: " + MIN_INSERT + "," + MAX_INSERT + "\n"; }
133+
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"; }
132134
// turn pair status boolean into int
133135
PAIR = matePair ? 1 : 0;
134136

src/cli/BAM_Manipulation/FilterforPIPseqCLI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private String validateInput() throws IOException {
107107
}
108108

109109
//check filter string is valid ATCG
110-
Pattern seqPat = Pattern.compile("[ATCG]");
110+
Pattern seqPat = Pattern.compile("[ATCG]+");
111111
Matcher m = seqPat.matcher( filterString );
112112
if( !m.matches() ){
113113
r += "(!)Filter string must be formatted as a nucleotide sequence.\n" + filterString +

src/cli/Coordinate_Manipulation/GFF_Manipulation/GFFtoBEDCLI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ private String validateInput() throws IOException {
7070
}else{
7171
//check ext
7272
try{
73-
if(!"gff".equals(ExtensionFileFilter.getExtension(output))){
74-
r += "(!)Use GFF extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + ".gff\n";
73+
if(!"bed".equals(ExtensionFileFilter.getExtension(output))){
74+
r += "(!)Use BED extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + ".bed\n";
7575
}
7676
} catch( NullPointerException e){ r += "(!)Output filename must have extension: use GFF extension for output filename. Try: " + output + ".gff\n"; }
7777
//check directory

src/cli/Figure_Generation/CompositePlotCLI.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public Integer call() throws Exception {
104104
// Save Composite Plot
105105
OutputStream OUT = new FileOutputStream(output);
106106
ChartUtilities.writeChartAsPNG(OUT, chart, pixelWidth, pixelHeight);
107-
107+
108108
System.err.println( "Image Generated." );
109109
return(0);
110110
}
@@ -140,8 +140,6 @@ private String validateInput() throws IOException {
140140
}
141141
}
142142

143-
//set default title name
144-
if(title!=null){ title = compositeData.getName(); }
145143
//check pixel ranges are valid
146144
if(pixelHeight<=0){ r += "(!)Cell height must be a positive integer value! check \"-y\" flag.\""; }
147145
if(pixelWidth<=0) { r += "(!)Cell width must be a positive integer value! check \"-x\" flag.\""; }

src/cli/Read_Analysis/AggregateDataCLI.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ private String validateInput() throws IOException {
149149
else if(aggr.max) { aggType = 5; }
150150
else if(aggr.var) { aggType = 6; }
151151

152+
//validate row&column start indexes
153+
if(startROW<0){ r += "(!)Row start must not be less than zero\n"; }
154+
if(startCOL<0){ r += "(!)Column start must not be less than zero\n"; }
155+
152156
return(r);
153157
}
154158
}

src/cli/Sequence_Analysis/SearchMotifCLI.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import picocli.CommandLine.Parameters;
77

88
import java.util.concurrent.Callable;
9+
import java.util.regex.Matcher;
10+
import java.util.regex.Pattern;
911

1012
import java.io.File;
1113
import java.io.IOException;
@@ -83,6 +85,14 @@ private String validateInput() throws IOException {
8385
}
8486
}
8587

88+
//check filter string is valid ATCG
89+
Pattern seqPat = Pattern.compile("[ATCG]+");
90+
Matcher m = seqPat.matcher( motif );
91+
if( !m.matches() ){
92+
r += "(!)Motif string must be formatted as a nucleotide sequence.\n" + motif +
93+
" is not a valid nucleotide sequence.\nExpected input string format: \"[ATCG]\"";
94+
}
95+
8696
//check mismatch value
8797
if(ALLOWED_MISMATCH<0){ r += "(!)Please use a non-negative integer for allowed mismatches."; }
8898

src/scripts/BAM_Manipulation/FilterforPIPseq.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,38 @@ public class FilterforPIPseq {
2424
File genome = null;
2525
File output = null;
2626
String SEQ = "";
27-
28-
private PrintStream PS;
29-
27+
28+
private PrintStream PS = null;
29+
3030
public FilterforPIPseq(File in, File gen, File out, String s, PrintStream ps) {
3131
bamFile = in;
3232
genome = gen;
3333
output = out;
3434
SEQ = s.toUpperCase();
3535
PS = ps;
3636
}
37-
37+
3838
public void run() throws IOException, InterruptedException {
3939
IndexedFastaSequenceFile QUERY = new IndexedFastaSequenceFile(genome);
40-
40+
4141
IOUtil.assertFileIsReadable(bamFile);
4242
IOUtil.assertFileIsWritable(output);
4343
final SamReader reader = SamReaderFactory.makeDefault().open(bamFile);
4444
reader.getFileHeader().setSortOrder(SAMFileHeader.SortOrder.coordinate);
4545
final SAMFileWriter writer = new SAMFileWriterFactory().makeSAMOrBAMWriter(reader.getFileHeader(), false, output);
46-
46+
4747
printBoth(bamFile.getName()); //output file name to textarea
48-
48+
4949
//Code to get individual chromosome stats
5050
AbstractBAMFileIndex bai = (AbstractBAMFileIndex) reader.indexing().getIndex();
5151
for (int z = 0; z < bai.getNumberOfReferences(); z++) {
5252
SAMSequenceRecord seq = reader.getFileHeader().getSequence(z);
53+
5354
printBoth(seq.getSequenceName());
54-
55+
5556
CloseableIterator<SAMRecord> iter = reader.query(seq.getSequenceName(), 0, seq.getSequenceLength(), false);
5657
while (iter.hasNext()) {
57-
//Create the record object
58+
//Create the record object
5859
SAMRecord sr = iter.next();
5960
if(sr.getReadPairedFlag()) {
6061
if(sr.getProperPairFlag() && sr.getFirstOfPairFlag()) {
@@ -70,7 +71,7 @@ public void run() throws IOException, InterruptedException {
7071
}
7172
}
7273
//System.out.println(sr.getReadString() + "\t" + seq.getSequenceName() + "\t" + sr.getUnclippedStart() + "\t" + sr.getUnclippedEnd() + "\t" + sr.getReadNegativeStrandFlag() + "\t" + filter);
73-
if(filter.toUpperCase().equals(SEQ)) { writer.addAlignment(sr); }
74+
if(filter.toUpperCase().equals(SEQ)) { writer.addAlignment(sr); }
7475
}
7576
} else {
7677
String filter = "";
@@ -83,7 +84,7 @@ public void run() throws IOException, InterruptedException {
8384
filter = FASTAUtilities.RevComplement(filter);
8485
}
8586
//System.out.println(sr.getReadString() + "\t" + seq.getSequenceName() + "\t" + sr.getUnclippedStart() + "\t" + sr.getUnclippedEnd() + "\t" + sr.getReadNegativeStrandFlag() + "\t" + filter);
86-
if(filter.toUpperCase().equals(SEQ)) { writer.addAlignment(sr); }
87+
if(filter.toUpperCase().equals(SEQ)) { writer.addAlignment(sr); }
8788
}
8889
}
8990
iter.close();
@@ -93,7 +94,7 @@ public void run() throws IOException, InterruptedException {
9394
reader.close();
9495
bai.close();
9596
}
96-
97+
9798
private void printBoth(String message){
9899
if(PS!=null){ PS.println(message); }
99100
System.err.println(message);

0 commit comments

Comments
 (0)