Skip to content

Commit

Permalink
Fixed typos, and got rid of automatic extension correction
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminbeer256 committed Nov 2, 2023
1 parent 1b81fca commit 8de1fa3
Show file tree
Hide file tree
Showing 40 changed files with 87 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public class SortBEDCLI implements Callable<Integer> {

@Option(names = {"-o", "--output"}, description = "specify output file basename with no .cdt/.bed/.jtv extension (default=<bedFile>_SORT")
private String outputBasename = null;
@Option(names = {"-z", "--gzip"}, description = "gzip output (default=false)")
private boolean gzOutput = false;
@Option(names = {"-c", "--center"}, description = "sort by center on the input size of expansion in bins (default=100)")
private int center = -999;
@Option(names = {"-z", "--gzip"}, description = "gzip output (default=false)")
private boolean gzOutput = false;
@Option(names = {"-x", "--index"}, description = "sort by index from the specified start to the specified stop (0-indexed and half-open interval)",
arity = "2")
private int[] index = {-999, -999};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RandomCoordinateCLI implements Callable<Integer> {
@Option(names = {"-o", "--output"}, description = "Specify output directory (default = current working directory), file name will be random_coordinates_<genomeName>_<window>bp.<ext>")
private File output = null;
@Option(names = {"-z", "--gzip"}, description = "output compressed output (default=false)")
private boolean zip = false;
private boolean gzOutput = false;
@Option(names = {"-f", "--gff"}, description = "file format output as GFF (default format as BED)")
private boolean formatIsBed = true;
@Option(names = {"-n", "--num-sites"}, description = "number of sites (default=1000)")
Expand All @@ -48,7 +48,7 @@ public Integer call() throws Exception {
System.exit(1);
}

RandomCoordinate.execute(genomeName, numSites, window, formatIsBed, output, zip);
RandomCoordinate.execute(genomeName, numSites, window, formatIsBed, output, gzOutput);

System.err.println( "Random Coordinate Generation Complete." );
return(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class TileGenomeCLI implements Callable<Integer> {
@Option(names = {"-o", "--output"}, description = "Specify output directory (default = current working directory), file name will be genome_tiles_<genomeName>_<window>bp.<ext>")
private File output = null;
@Option(names = {"-z", "--gzip"}, description = "output compressed output (default=false)")
private boolean zip = false;
private boolean gzOutput = false;
@Option(names = {"-f", "--gff"}, description = "file format output as GFF (default format as BED)")
private boolean formatIsBed = true;
@Option(names = {"-w", "--window"}, description = "window size in bp (default=200)")
Expand All @@ -46,7 +46,7 @@ public Integer call() throws Exception {
System.exit(1);
}

TileGenome.execute(genomeName, window, formatIsBed, output, zip);
TileGenome.execute(genomeName, window, formatIsBed, output, gzOutput);

System.err.println( "Genomic Tiling Complete." );
return(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import scriptmanager.objects.ToolDescriptions;
import scriptmanager.scripts.Read_Analysis.AggregateData;
import scriptmanager.util.ExtensionFileFilter;

/**
Read_AnalysisCLI/AggregateDataCLI
Expand All @@ -34,7 +33,7 @@ public class AggregateDataCLI implements Callable<Integer> {
@Option(names = {"-o", "--output"}, description = "Specify output file (default = <input1>_SCORES.out, <input2_SCORES.out, ... or ALL_SCORES.out if -m flag is used)")
private File output;
@Option(names = {"-z", "--gzip"}, description = "output compressed output (default=false)")
private boolean zip = false;
private boolean gzOutput = false;

@ArgGroup(exclusive = true, heading = "Aggregation Method%n")
AggType aggr = new AggType();
Expand Down Expand Up @@ -75,7 +74,7 @@ public Integer call() throws Exception {
System.exit(1);
}

AggregateData script_obj = new AggregateData(matFiles, output, merge, startROW, startCOL, aggType, zip);
AggregateData script_obj = new AggregateData(matFiles, output, merge, startROW, startCOL, aggType, gzOutput);
script_obj.run();

System.err.println(script_obj.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ScaleMatrixCLI implements Callable<Integer> {
@Option(names = {"-o", "--output"}, description = "Specify output file (default = <matrixFilename>_SCALE.tab)")
private File output = null;
@Option(names = {"-z", "--gzip"}, description = "output compressed output (default=false)")
private boolean zip = false;
private boolean gzOutput = false;
@Option(names = {"-s", "--scaling-factor"}, description = "scaling factor (default=1)")
private double scale = 1;
@Option(names = {"-r", "--start-row"}, description = "")
Expand All @@ -49,7 +49,7 @@ public Integer call() throws Exception {
System.exit(1);
}

ScaleMatrix script_obj = new ScaleMatrix(matrixFile, output, scale, startROW, startCOL, zip);
ScaleMatrix script_obj = new ScaleMatrix(matrixFile, output, scale, startROW, startCOL, gzOutput);
script_obj.run();

System.err.println("All Matrices Scaled.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static class OutputOptions{
arity="0..1")
private ArrayList<String> outputMatrix = new ArrayList<String>(Arrays.asList("no","matrix","output"));
@Option(names = {"-z", "--gzip"}, description = "output compressed output (default=false)")
private boolean zip = false;
private boolean gzOutput = false;
@Option(names = {"--cdt"}, description = "output matrix in cdt format (default)")
private boolean cdt = false;
@Option(names = {"--tab"}, description = "output matrix in tab format")
Expand Down Expand Up @@ -286,7 +286,7 @@ private String validateInput() throws IOException {
p.setStandard(calcOptions.tagsEqual);

//Set output statuses
p.setGZIPstatus(outputOptions.zip);
p.setGZIPstatus(outputOptions.gzOutput);

//Set Ratio (code to standardize tags sequenced to genome size (1 tag / 1 bp))
if( p.getStandard() && filterOptions.blacklistFilter!=null ){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DNAShapefromBEDCLI implements Callable<Integer> {
"--output" }, description = "Specify basename for output files, files for each shape indicated will share this name with a different suffix")
private String outputBasename = null;
@Option(names = {"-z", "--gzip"}, description = "output compressed output (default=false)")
private boolean zip = false;
private boolean gzOutput = false;
@Option(names = { "--avg-composite" }, description = "Save average composite")
private boolean avgComposite = false;
@Option(names = { "-n", "--no-force" }, description = "don't force-strandedness (default is to force strandedness)")
Expand Down Expand Up @@ -76,7 +76,7 @@ public Integer call() throws Exception {
try {
// Generate Composite Plot
DNAShapefromBED script_obj = new DNAShapefromBED(genomeFASTA, bedFile, outputBasename, OUTPUT_TYPE,
forceStrand, new PrintStream[] { null, null, null, null }, zip);
forceStrand, new PrintStream[] { null, null, null, null }, gzOutput);
script_obj.run();

if (avgComposite) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DNAShapefromFASTACLI implements Callable<Integer> {
@Option(names = { "--avg-composite" }, description = "Save average composite")
private boolean avgComposite = false;
@Option(names = {"-z", "--gzip"}, description = "output compressed output (default=false)")
private boolean zip = false;
private boolean gzOutput = false;

@ArgGroup(validate = false, heading = "Shape Options%n")
ShapeType shape = new ShapeType();
Expand Down Expand Up @@ -70,7 +70,7 @@ public Integer call() throws Exception {

// Generate Composite Plot
DNAShapefromFASTA script_obj = new DNAShapefromFASTA(fastaFile, outputBasename, OUTPUT_TYPE,
new PrintStream[] { null, null, null, null }, zip);
new PrintStream[] { null, null, null, null }, gzOutput);
script_obj.run();

// Print Composite Scores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class RandomizeFASTACLI implements Callable<Integer> {
@Option(names = {"-s", "--seed"}, description = "specify an integer seed for reproducible outputs")
private Integer seed = null;
@Option(names = {"-z", "--gzip"}, description = "output compressed output (default=false)")
private boolean zip = false;
private boolean gzOutput = false;

@Override
public Integer call() throws Exception {
Expand All @@ -46,7 +46,7 @@ public Integer call() throws Exception {
System.exit(1);
}

RandomizeFASTA.randomizeFASTA(fastaFile, output, seed, zip);
RandomizeFASTA.randomizeFASTA(fastaFile, output, seed, gzOutput);

System.err.println("Randomization Complete.");
return (0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public void run() throws IOException, InterruptedException {
}

if (OUTPUT_GZIP){
printPS("Output Gzip: yes");
} else{
printPS("Output Gzip: no");
printPS("Output GZip: yes");
} else {
printPS("Output GZip: no");
}

// Build&Print Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public void run() throws IOException, InterruptedException {
}

if (OUTPUT_GZIP){
printPS("Output Gzip: yes");
} else{
printPS("Output Gzip: no");
printPS("Output GZip: yes");
} else {
printPS("Output GZip: no");
}

// Build&Print Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ public void run() throws IOException, InterruptedException {
// Open Output File
if (OUTBASENAME != null) {
try {
String SUFFIX = ".bedGraph" + (OUTPUT_GZIP? ".gz": "");
if (STRAND <= 2) {
OUTF = GZipUtilities.makePrintStream(new File(OUTBASENAME + "_forward.bedGraph"), OUTPUT_GZIP);
OUTR = GZipUtilities.makePrintStream(new File(OUTBASENAME + "_reverse.bedGraph") , OUTPUT_GZIP);
OUTF = GZipUtilities.makePrintStream(new File(OUTBASENAME + "_forward" + SUFFIX), OUTPUT_GZIP);
OUTR = GZipUtilities.makePrintStream(new File(OUTBASENAME + "_reverse" + SUFFIX) , OUTPUT_GZIP);
} else {
OUTF = GZipUtilities.makePrintStream(new File(OUTBASENAME + "_midpoint.bedGraph"), OUTPUT_GZIP);
OUTF = GZipUtilities.makePrintStream(new File(OUTBASENAME + "_midpoint" + SUFFIX), OUTPUT_GZIP);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
Expand Down Expand Up @@ -109,9 +110,9 @@ public void run() throws IOException, InterruptedException {
}

if (OUTPUT_GZIP){
printPS("Output Gzip: yes");
} else{
printPS("Output Gzip: no");
printPS("Output GZip: yes");
} else {
printPS("Output GZip: no");
}

// Print Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ public void run() throws IOException, InterruptedException {
}

if (OUTPUT_GZIP){
printPS("Output Gzip: yes");
} else{
printPS("Output Gzip: no");
printPS("Output GZip: yes");
} else {
printPS("Output GZip: no");
}

// Print Header
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package scriptmanager.scripts.Coordinate_Manipulation.BED_Manipulation;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.zip.GZIPOutputStream;

import scriptmanager.objects.CoordinateObjects.BEDCoord;
import scriptmanager.util.GZipUtilities;

/**
* This class contains scripts for sorting coordinate intervals (BED/GFF) by the tag counts of a CDT matrix file.
* Sort coordinate intervals (BED) by the tag counts of a CDT matrix file.
*
* @author William KM Lai
* @see scriptmanager.cli.Coordinate_Manipulation.BED_Manipulation.SortBEDCLI
Expand All @@ -28,7 +31,7 @@ public class SortBED {
* @param START_INDEX the start column to consider when summing values to sort
* @param STOP_INDEX
* @param gzOutput if true, the output files will be gzipped.
* @throws IOException
* @throws IOException Invalid file or parameters
*/
public static void sortBEDbyCDT(String outbase, File bed, File cdt, int START_INDEX, int STOP_INDEX, boolean gzOutput ) throws IOException {
ArrayList<BEDCoord> SORT = new ArrayList<BEDCoord>();
Expand All @@ -38,7 +41,7 @@ public static void sortBEDbyCDT(String outbase, File bed, File cdt, int START_IN
BufferedReader br = GZipUtilities.makeReader(cdt);
// Initialize line variable to loop through
String line = br.readLine();
while ((line = br.readLine()) != null) {
while (line != null) {
String[] ID = line.split("\t");
if (!ID[0].contains("YORF") && !ID[0].contains("NAME")) {
double count = 0;
Expand All @@ -50,14 +53,19 @@ public static void sortBEDbyCDT(String outbase, File bed, File cdt, int START_IN
} else {
CDTHeader = line;
}
line = br.readLine();
}
br.close();
// Sort by score
Collections.sort(SORT, BEDCoord.ScoreComparator);

PrintStream OUT;
// Initialize output writer
OUT = GZipUtilities.makePrintStream(new File(outbase + ".cdt"), gzOutput);
if (gzOutput) {
OUT = new PrintStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(outbase + ".cdt.gz"))));
} else {
OUT = new PrintStream(new BufferedOutputStream(new FileOutputStream(outbase + ".cdt")));
}
// Output sorted CDT File
OUT.println(CDTHeader);
for (int x = 0; x < SORT.size(); x++) {
Expand All @@ -73,7 +81,7 @@ public static void sortBEDbyCDT(String outbase, File bed, File cdt, int START_IN
br = GZipUtilities.makeReader(bed);
// Initialize line variable to loop through
line = br.readLine();
while ((line = br.readLine()) != null) {
while (line != null) {
String ID = line.split("\t")[3];
if (!ID.contains("YORF") && !ID.contains("NAME")) {
BEDFile.put(ID, line);
Expand All @@ -83,11 +91,15 @@ public static void sortBEDbyCDT(String outbase, File bed, File cdt, int START_IN
br.close();

// Initialize output writer
OUT = GZipUtilities.makePrintStream(new File(outbase + ".bed"), gzOutput);
if (gzOutput) {
OUT = new PrintStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(outbase + ".bed.gz"))));
} else {
OUT = new PrintStream(new BufferedOutputStream(new FileOutputStream(outbase + ".bed")));
}
// Output sorted BED File
for (int x = 0; x < SORT.size(); x++) {
OUT.println(BEDFile.get(SORT.get(x).getName()));
}
OUT.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public static void sortGFFbyCDT(String outname, File gff, File cdt, int START_IN
Collections.sort(SORT, GFFCoord.ScoreComparator);

// Output sorted CDT File
PrintStream OUT = GZipUtilities.makePrintStream(new File(outname + ".cdt"), gzOutput);
String SUFFIX = ".cdt" + (gzOutput? ".gz": "");
PrintStream OUT = GZipUtilities.makePrintStream(new File(outname + SUFFIX), gzOutput);
OUT.println(CDTHeader);
for (int x = 0; x < SORT.size(); x++) {
OUT.println(CDTFile.get(SORT.get(x).getName()));
Expand All @@ -64,7 +65,8 @@ public static void sortGFFbyCDT(String outname, File gff, File cdt, int START_IN
br.close();

// Output sorted GFF File
OUT = GZipUtilities.makePrintStream(new File(outname + ".gff"), gzOutput);
SUFFIX = ".gff" + (gzOutput? ".gz": "");
OUT = GZipUtilities.makePrintStream(new File(outname + SUFFIX), gzOutput);
for (int x = 0; x < SORT.size(); x++) {
OUT.println(GFFFile.get(SORT.get(x).getName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void itemStateChanged(ItemEvent e) {
sl_contentPane.putConstraint(SpringLayout.EAST, btnOutputDirectory, -250, SpringLayout.EAST, contentPane);
contentPane.add(btnOutputDirectory);

chckbxGzipOutput = new JCheckBox("Output Gzip");
chckbxGzipOutput = new JCheckBox("Output GZip");
sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxGzipOutput, 0, SpringLayout.NORTH, btnIndex);
sl_contentPane.putConstraint(SpringLayout.EAST, chckbxGzipOutput, -83, SpringLayout.WEST, btnOutputDirectory);
contentPane.add(chckbxGzipOutput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void itemStateChanged(ItemEvent e) {
sl_contentPane.putConstraint(SpringLayout.EAST, btnOutputDirectory, -250, SpringLayout.EAST, contentPane);
contentPane.add(btnOutputDirectory);

chckbxGzipOutput = new JCheckBox("Output Gzip");
chckbxGzipOutput = new JCheckBox("Output GZip");
sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxGzipOutput, 0, SpringLayout.NORTH, btnIndex);
sl_contentPane.putConstraint(SpringLayout.EAST, chckbxGzipOutput, -83, SpringLayout.WEST, btnOutputDirectory);
contentPane.add(chckbxGzipOutput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void itemStateChanged(ItemEvent e) {
sl_contentPane.putConstraint(SpringLayout.EAST, btnOutputDirectory, -250, SpringLayout.EAST, contentPane);
contentPane.add(btnOutputDirectory);

chckbxGzipOutput = new JCheckBox("Output Gzip");
chckbxGzipOutput = new JCheckBox("Output GZip");
sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxGzipOutput, 0, SpringLayout.NORTH, btnIndex);
sl_contentPane.putConstraint(SpringLayout.EAST, chckbxGzipOutput, -83, SpringLayout.WEST, btnOutputDirectory);
contentPane.add(chckbxGzipOutput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void itemStateChanged(ItemEvent e) {
sl_contentPane.putConstraint(SpringLayout.EAST, btnOutputDirectory, -250, SpringLayout.EAST, contentPane);
contentPane.add(btnOutputDirectory);

chckbxGzipOutput = new JCheckBox("Output Gzip");
chckbxGzipOutput = new JCheckBox("Output GZip");
sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxGzipOutput, 0, SpringLayout.NORTH, btnIndex);
sl_contentPane.putConstraint(SpringLayout.EAST, chckbxGzipOutput, -83, SpringLayout.WEST, btnOutputDirectory);
contentPane.add(chckbxGzipOutput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void actionPerformed(ActionEvent e) {
contentPane.add(btnOutput);
btnConvert.addActionListener(this);

chckbxGzipOutput = new JCheckBox("Output GZIP");
chckbxGzipOutput = new JCheckBox("Output GZip");
sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxGzipOutput, 0, SpringLayout.NORTH, btnConvert);
sl_contentPane.putConstraint(SpringLayout.WEST, chckbxGzipOutput, 36, SpringLayout.WEST, contentPane);
contentPane.add(chckbxGzipOutput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void actionPerformed(ActionEvent e) {
});
contentPane.add(btnOutput);

chckbxGzipOutput = new JCheckBox("Output GZIP");
chckbxGzipOutput = new JCheckBox("Output GZip");
sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxGzipOutput, 0, SpringLayout.NORTH, btnOutput);
sl_contentPane.putConstraint(SpringLayout.EAST, chckbxGzipOutput, -10, SpringLayout.EAST, contentPane);
contentPane.add(chckbxGzipOutput);
Expand Down
Loading

0 comments on commit 8de1fa3

Please sign in to comment.