Skip to content

Commit 65d630c

Browse files
committed
add hg38 to TileGenome and RandCoord
Address issue ticket #80 by adding `hg38` and `hg38_contigs` genome options to TileGenome and RandomCoordinate tools util.GenomeSizeReference - update initialize options to include both versions of hg38 - add JavaDocs comments scripts.RandomCoordinate - turn script into a public static void method - add JavaDocs comments scripts.TileGenome - turn script into a public static void method - add JavaDocs comments window_interface.RandomCoordinateWindow - add hg38 as selection options - adjust script call to use public static method - add JavaDocs comments window_interface.TileGenomeWindow - add hg38 as selection options - adjust script call to use public static method - add JavaDocs comments cli.RandomCoordinateCLI - add hg38 as selection options in help message of Parameter - adjust script call to use public static method - add JavaDocs comments cli.TileGenomeCLI - add hg38 as selection options in help message of Parameter - adjust script call to use public static method - add JavaDocs comments
1 parent 5c53220 commit 65d630c

7 files changed

Lines changed: 433 additions & 99 deletions

File tree

src/cli/Peak_Analysis/RandomCoordinateCLI.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
exitCodeOnExecutionException = 1)
2525
public class RandomCoordinateCLI implements Callable<Integer> {
2626

27-
@Parameters( index = "0", description = "reference genome [sacCer3|sacCer3_cegr|hg19|hg19_contigs|mm10]")
27+
@Parameters( index = "0", description = "reference genome [sacCer3|sacCer3_cegr|hg38|hg38_contigs|hg19|hg19_contigs|mm10]")
2828
private String genomeName;
2929

3030
@Option(names = {"-o", "--output"}, description = "Specify output directory (default = current working directory), file name will be random_coordinates_<genomeName>_<window>bp.<ext>")
@@ -46,8 +46,7 @@ public Integer call() throws Exception {
4646
System.exit(1);
4747
}
4848

49-
RandomCoordinate script_obj = new RandomCoordinate(genomeName, numSites, window, formatIsBed, output);
50-
script_obj.execute();
49+
RandomCoordinate.execute(genomeName, numSites, window, formatIsBed, output);
5150

5251
System.err.println( "Random Coordinate Generation Complete." );
5352
return(0);

src/cli/Peak_Analysis/TileGenomeCLI.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
exitCodeOnExecutionException = 1)
2525
public class TileGenomeCLI implements Callable<Integer> {
2626

27-
@Parameters( index = "0", description = "reference genome [sacCer3|sacCer3_cegr|hg19|hg19_contigs|mm10]")
27+
@Parameters( index = "0", description = "reference genome [sacCer3|sacCer3_cegr|hg38|hg38_contigs|hg19|hg19_contigs|mm10]")
2828
private String genomeName;
2929

3030
@Option(names = {"-o", "--output"}, description = "Specify output directory (default = current working directory), file name will be genome_tiles_<genomeName>_<window>bp.<ext>")
@@ -44,8 +44,7 @@ public Integer call() throws Exception {
4444
System.exit(1);
4545
}
4646

47-
TileGenome script_obj = new TileGenome(genomeName, window, formatIsBed, output);
48-
script_obj.execute();
47+
TileGenome.execute(genomeName, window, formatIsBed, output);
4948

5049
System.err.println( "Genomic Tiling Complete." );
5150
return(0);

src/scripts/Peak_Analysis/RandomCoordinate.java

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,45 @@
1111
import objects.CoordinateObjects.GenericCoord;
1212
import util.GenomeSizeReference;
1313

14+
/**
15+
* Class with static method for creating a coordinate file of random sites across a genome.
16+
*
17+
* @author William KM Lai
18+
* @see util.GenomeSizeReference
19+
*/
1420
public class RandomCoordinate {
15-
private File OUTPUT = null;
16-
private String GENOME = "";
17-
private int numSites = 0;
18-
private int windowSize = 0;
19-
20-
private boolean BEDout = true;
21-
private String EXTENSION = ".bed";
22-
23-
public RandomCoordinate(String gen, int sites, int size, boolean bed, File out) {
24-
GENOME = gen;
25-
numSites = sites;
26-
windowSize = size;
27-
OUTPUT = out;
28-
BEDout = bed;
29-
if(BEDout) { EXTENSION = ".bed"; }
30-
else { EXTENSION = ".gff"; }
31-
}
32-
33-
public void execute() throws IOException, IllegalArgumentException {
34-
GenomeSizeReference coord = new GenomeSizeReference(GENOME);
21+
/**
22+
* Create and write output BED/GFF file of random genomic intervals for a genome
23+
* build. All entries will be "+" stranded, score="0.0", and the identifier
24+
* column is a genomic coordinate string (\<chr\>_\<start\>_\<stop\>_\<dir\>).
25+
* For the BED format, the identifier column will be the 4th column while the
26+
* GFF format will use the 9th column for the identifier.
27+
*
28+
* @param GENOME the String encoding the genome build to tile (matches util.GenomeSizeReference)
29+
* @param numSites the number of random coordinate sites to sample
30+
* @param windowSize the base-pair length of each coordinate interval
31+
* @param BEDout coordinate file format of output where BED-format is used if true and GFF-format used if false
32+
* @param OUTPUT the file to write the coordinate tile output to (if null, a default filename is determined using \<GENOME\>_\<numSites\>SITES_\<windowSize\>bp.\<ext\>)
33+
* @throws IOException
34+
* @throws IllegalArgumentException
35+
*/
36+
public static void execute(String GENOME, int numSites, int windowSize, boolean BEDout, File OUTPUT) throws IOException, IllegalArgumentException {
37+
GenomeSizeReference coord = new GenomeSizeReference(GENOME);
3538
if(!coord.isSmaller(windowSize)) {
3639
System.err.println("Window size is too large for selected genome!!!\n");
3740
JOptionPane.showMessageDialog(null, "Invalid Window Size Entered!!!");
3841
} else {
42+
String EXTENSION = ".gff";
43+
if (BEDout) {
44+
EXTENSION = ".bed";
45+
}
3946
String randomName = GENOME + "_" + numSites + "SITES_" + windowSize + "bp" + EXTENSION;
4047
PrintStream OUT = null;
41-
if(OUTPUT == null) OUT = new PrintStream(randomName);
42-
else OUT = new PrintStream(OUTPUT);
48+
if (OUTPUT == null) {
49+
OUT = new PrintStream(randomName);
50+
} else {
51+
OUT = new PrintStream(OUTPUT);
52+
}
4353
for(int x = 0; x < numSites; x++) {
4454
GenericCoord temp = coord.generateRandomCoord(windowSize);
4555
if(BEDout) {

src/scripts/Peak_Analysis/TileGenome.java

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,42 @@
77
import objects.CoordinateObjects.GFFCoord;
88
import util.GenomeSizeReference;
99

10-
public class TileGenome {
11-
private File OUTPUT = null;
12-
private String GENOME = "";
13-
private long windowSize = 0;
14-
15-
private boolean BEDout = true;
16-
private String EXTENSION = ".bed";
17-
18-
public TileGenome(String gen, int size, boolean bed, File out) {
19-
GENOME = gen;
20-
windowSize = size;
21-
OUTPUT = out;
22-
BEDout = bed;
23-
if(BEDout) { EXTENSION = ".bed"; }
24-
else { EXTENSION = ".gff"; }
25-
}
26-
27-
public void execute() throws IOException, IllegalArgumentException {
28-
GenomeSizeReference coord = new GenomeSizeReference(GENOME);
29-
30-
String fileName = GENOME + "_" + windowSize + "bp" + EXTENSION;
10+
/**
11+
* Class with static method for creating a coordinate file of tiles across a genome.
12+
*
13+
* @author William KM Lai
14+
* @see util.GenomeSizeReference
15+
*/
16+
public class TileGenome {
17+
18+
/**
19+
* Create and write output BED/GFF file of genomic intervals tiling the genome.
20+
* All entries will be "+" stranded, score="0.0", and the identifier column is a
21+
* genomic coordinate string (\<chr\>_\<start\>_\<stop\>_\<dir\>). For the BED format,
22+
* the identifier column will be the 4th column while the GFF format will use
23+
* the 9th column for the identifier.
24+
*
25+
* @param GENOME the String encoding the genome build to tile (matches util.GenomeSizeReference)
26+
* @param windowSize the base-pair length of the tiles
27+
* @param BEDout coordinate file format of output where BED-format is used if true and GFF-format used if false
28+
* @param OUTPUT the file to write the coordinate tile output to (if null, a default filename is determined using \<GENOME\>_\<windowSize\>bp.\<ext\>)
29+
* @throws IOException
30+
* @throws IllegalArgumentException
31+
*/
32+
public static void execute(String GENOME, int windowSize, boolean BEDout, File OUTPUT) throws IOException, IllegalArgumentException {
33+
GenomeSizeReference coord = new GenomeSizeReference(GENOME);
34+
String EXTENSION = ".gff";
35+
if (BEDout) {
36+
EXTENSION = ".bed";
37+
}
38+
String fileName = GENOME + "_" + windowSize + "bp" + EXTENSION;
3139
PrintStream OUT = null;
32-
if(OUTPUT == null) OUT = new PrintStream(new File(fileName));
33-
else OUT = new PrintStream(OUTPUT);
34-
40+
if (OUTPUT == null) {
41+
OUT = new PrintStream(new File(fileName));
42+
} else {
43+
OUT = new PrintStream(OUTPUT);
44+
}
45+
3546
for(int x = 0; x < coord.getChrom().size(); x++) {
3647
String CHROM = coord.getChrom().get(x);
3748
long SIZE = coord.getChromSize().get(x);

0 commit comments

Comments
 (0)