Skip to content
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
4 changes: 3 additions & 1 deletion src/cli/BAM_Format_Converter/BAMtoBEDCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ private String validateInput() throws IOException {
else if(readType.midpoint) { STRAND=3; }
else if(readType.fragment) { STRAND=4; }
else { STRAND=0; }
// set PE defaults
if(STRAND==3 || STRAND==4) { matePair=true; }

//check inputs exist
if(!bamFile.exists()){
Expand Down Expand Up @@ -131,7 +133,7 @@ private String validateInput() throws IOException {
// validate insert sizes
if( MIN_INSERT<0 && MIN_INSERT!=-9999 ){ r += "MIN_INSERT must be a positive integer value: " + MIN_INSERT + "\n"; }
if( MAX_INSERT<0 && MAX_INSERT!=-9999 ){ r += "MAX_INSERT must be a positive integer value: " + MAX_INSERT + "\n"; }
if( MAX_INSERT<MIN_INSERT ){ r += "MAX_INSERT must be larger/equal to MIN_INSERT: " + MIN_INSERT + "," + MAX_INSERT + "\n"; }
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;

Expand Down
4 changes: 3 additions & 1 deletion src/cli/BAM_Format_Converter/BAMtoGFFCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ private String validateInput() throws IOException {
else if(readType.midpoint) { STRAND=3; }
else if(readType.fragment) { STRAND=4; }
else { STRAND=0; }
// set PE defaults
if(STRAND==3 || STRAND==4) { matePair=true; }

//check inputs exist
if(!bamFile.exists()){
Expand Down Expand Up @@ -131,7 +133,7 @@ private String validateInput() throws IOException {
// validate insert sizes
if( MIN_INSERT<0 && MIN_INSERT!=-9999 ){ r += "MIN_INSERT must be a positive integer value: " + MIN_INSERT + "\n"; }
if( MAX_INSERT<0 && MAX_INSERT!=-9999 ){ r += "MAX_INSERT must be a positive integer value: " + MAX_INSERT + "\n"; }
if( MAX_INSERT<MIN_INSERT ){ r += "MAX_INSERT must be larger/equal to MIN_INSERT: " + MIN_INSERT + "," + MAX_INSERT + "\n"; }
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;

Expand Down
4 changes: 3 additions & 1 deletion src/cli/BAM_Format_Converter/BAMtobedGraphCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ private String validateInput() throws IOException {
else if(readType.combined) { STRAND=2; }
else if(readType.midpoint) { STRAND=3; }
else { STRAND=0; }
// set PE defaults
if(STRAND==3) { matePair=true; }

//check inputs exist
if(!bamFile.exists()){
Expand Down Expand Up @@ -119,7 +121,7 @@ private String validateInput() throws IOException {
// validate insert sizes
if( MIN_INSERT<0 && MIN_INSERT!=-9999 ){ r += "MIN_INSERT must be a positive integer value: " + MIN_INSERT + "\n"; }
if( MAX_INSERT<0 && MAX_INSERT!=-9999 ){ r += "MAX_INSERT must be a positive integer value: " + MAX_INSERT + "\n"; }
if( MAX_INSERT<MIN_INSERT ){ r += "MAX_INSERT must be larger/equal to MIN_INSERT: " + MIN_INSERT + "," + MAX_INSERT + "\n"; }
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;

Expand Down
4 changes: 3 additions & 1 deletion src/cli/BAM_Format_Converter/BAMtoscIDXCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ private String validateInput() throws IOException {
else if(readType.combined) { STRAND=2; }
else if(readType.midpoint) { STRAND=3; }
else { STRAND=0; }
// set PE defaults
if(STRAND==3) { matePair=true; }

//check inputs exist
if(!bamFile.exists()){
Expand Down Expand Up @@ -128,7 +130,7 @@ private String validateInput() throws IOException {
// validate insert sizes
if( MIN_INSERT<0 && MIN_INSERT!=-9999 ){ r += "MIN_INSERT must be a positive integer value: " + MIN_INSERT + "\n"; }
if( MAX_INSERT<0 && MAX_INSERT!=-9999 ){ r += "MAX_INSERT must be a positive integer value: " + MAX_INSERT + "\n"; }
if( MAX_INSERT<MIN_INSERT ){ r += "MAX_INSERT must be larger/equal to MIN_INSERT: " + MIN_INSERT + "," + MAX_INSERT + "\n"; }
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;

Expand Down
2 changes: 1 addition & 1 deletion src/cli/BAM_Manipulation/FilterforPIPseqCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private String validateInput() throws IOException {
}

//check filter string is valid ATCG
Pattern seqPat = Pattern.compile("[ATCG]");
Pattern seqPat = Pattern.compile("[ATCG]+");
Matcher m = seqPat.matcher( filterString );
if( !m.matches() ){
r += "(!)Filter string must be formatted as a nucleotide sequence.\n" + filterString +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ private String validateInput() throws IOException {
}else{
//check ext
try{
if(!"gff".equals(ExtensionFileFilter.getExtension(output))){
r += "(!)Use GFF extension for output filename. Try: " + ExtensionFileFilter.stripExtension(output) + ".gff\n";
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 GFF extension for output filename. Try: " + output + ".gff\n"; }
//check directory
Expand Down
4 changes: 1 addition & 3 deletions src/cli/Figure_Generation/CompositePlotCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public Integer call() throws Exception {
// Save Composite Plot
OutputStream OUT = new FileOutputStream(output);
ChartUtilities.writeChartAsPNG(OUT, chart, pixelWidth, pixelHeight);

System.err.println( "Image Generated." );
return(0);
}
Expand Down Expand Up @@ -140,8 +140,6 @@ private String validateInput() throws IOException {
}
}

//set default title name
if(title!=null){ title = compositeData.getName(); }
//check pixel ranges are valid
if(pixelHeight<=0){ r += "(!)Cell height must be a positive integer value! check \"-y\" flag.\""; }
if(pixelWidth<=0) { r += "(!)Cell width must be a positive integer value! check \"-x\" flag.\""; }
Expand Down
4 changes: 4 additions & 0 deletions src/cli/Read_Analysis/AggregateDataCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ private String validateInput() throws IOException {
else if(aggr.max) { aggType = 5; }
else if(aggr.var) { aggType = 6; }

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

return(r);
}
}
10 changes: 10 additions & 0 deletions src/cli/Sequence_Analysis/SearchMotifCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import picocli.CommandLine.Parameters;

import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -83,6 +85,14 @@ private String validateInput() throws IOException {
}
}

//check filter string is valid ATCG
Pattern seqPat = Pattern.compile("[ATCG]+");
Matcher m = seqPat.matcher( motif );
if( !m.matches() ){
r += "(!)Motif string must be formatted as a nucleotide sequence.\n" + motif +
" is not a valid nucleotide sequence.\nExpected input string format: \"[ATCG]\"";
}

//check mismatch value
if(ALLOWED_MISMATCH<0){ r += "(!)Please use a non-negative integer for allowed mismatches."; }

Expand Down
25 changes: 13 additions & 12 deletions src/scripts/BAM_Manipulation/FilterforPIPseq.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,38 @@ public class FilterforPIPseq {
File genome = null;
File output = null;
String SEQ = "";
private PrintStream PS;

private PrintStream PS = null;

public FilterforPIPseq(File in, File gen, File out, String s, PrintStream ps) {
bamFile = in;
genome = gen;
output = out;
SEQ = s.toUpperCase();
PS = ps;
}

public void run() throws IOException, InterruptedException {
IndexedFastaSequenceFile QUERY = new IndexedFastaSequenceFile(genome);

IOUtil.assertFileIsReadable(bamFile);
IOUtil.assertFileIsWritable(output);
final SamReader reader = SamReaderFactory.makeDefault().open(bamFile);
reader.getFileHeader().setSortOrder(SAMFileHeader.SortOrder.coordinate);
final SAMFileWriter writer = new SAMFileWriterFactory().makeSAMOrBAMWriter(reader.getFileHeader(), false, output);

printBoth(bamFile.getName()); //output file name to textarea

//Code to get individual chromosome stats
AbstractBAMFileIndex bai = (AbstractBAMFileIndex) reader.indexing().getIndex();
for (int z = 0; z < bai.getNumberOfReferences(); z++) {
SAMSequenceRecord seq = reader.getFileHeader().getSequence(z);

printBoth(seq.getSequenceName());

CloseableIterator<SAMRecord> iter = reader.query(seq.getSequenceName(), 0, seq.getSequenceLength(), false);
while (iter.hasNext()) {
//Create the record object
//Create the record object
SAMRecord sr = iter.next();
if(sr.getReadPairedFlag()) {
if(sr.getProperPairFlag() && sr.getFirstOfPairFlag()) {
Expand All @@ -70,7 +71,7 @@ public void run() throws IOException, InterruptedException {
}
}
//System.out.println(sr.getReadString() + "\t" + seq.getSequenceName() + "\t" + sr.getUnclippedStart() + "\t" + sr.getUnclippedEnd() + "\t" + sr.getReadNegativeStrandFlag() + "\t" + filter);
if(filter.toUpperCase().equals(SEQ)) { writer.addAlignment(sr); }
if(filter.toUpperCase().equals(SEQ)) { writer.addAlignment(sr); }
}
} else {
String filter = "";
Expand All @@ -83,7 +84,7 @@ public void run() throws IOException, InterruptedException {
filter = FASTAUtilities.RevComplement(filter);
}
//System.out.println(sr.getReadString() + "\t" + seq.getSequenceName() + "\t" + sr.getUnclippedStart() + "\t" + sr.getUnclippedEnd() + "\t" + sr.getReadNegativeStrandFlag() + "\t" + filter);
if(filter.toUpperCase().equals(SEQ)) { writer.addAlignment(sr); }
if(filter.toUpperCase().equals(SEQ)) { writer.addAlignment(sr); }
}
}
iter.close();
Expand All @@ -93,7 +94,7 @@ public void run() throws IOException, InterruptedException {
reader.close();
bai.close();
}

private void printBoth(String message){
if(PS!=null){ PS.println(message); }
System.err.println(message);
Expand Down