Skip to content

Commit f4543e8

Browse files
committed
add error checking for unaccounted genome builds
Throw a customized IllegalArgumentException when a genome name not included in the reference `util.GenomeSizeReference` class is given. Add Exception handling to GUI repective tool scripts and GUI window_interface classes
1 parent a84bf55 commit f4543e8

5 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/scripts/Peak_Analysis/RandomCoordinate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public RandomCoordinate(String gen, int sites, int size, boolean bed, File out)
3030
else { EXTENSION = ".gff"; }
3131
}
3232

33-
public void execute() throws IOException {
33+
public void execute() throws IOException, IllegalArgumentException {
3434
GenomeSizeReference coord = new GenomeSizeReference(GENOME);
3535
if(!coord.isSmaller(windowSize)) {
3636
System.err.println("Window size is too large for selected genome!!!\n");

src/scripts/Peak_Analysis/TileGenome.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public TileGenome(String gen, int size, boolean bed, File out) {
2424
else { EXTENSION = ".gff"; }
2525
}
2626

27-
public void execute() throws IOException {
27+
public void execute() throws IOException, IllegalArgumentException {
2828
GenomeSizeReference coord = new GenomeSizeReference(GENOME);
2929

3030
String fileName = GENOME + "_" + windowSize + "bp" + EXTENSION;

src/util/GenomeSizeReference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public GenomeSizeReference(String build) {
2323
setGenome(build);
2424
}
2525

26-
public void setGenome(String build) {
26+
public void setGenome(String build) throws IllegalArgumentException {
2727
if (build.equals("sacCer3")) {
2828
initialize_sacCer3();
2929
} else if(build.equals("sacCer3_cegr")) {
@@ -35,7 +35,7 @@ public void setGenome(String build) {
3535
} else if(build.equals("mm10")) {
3636
initialize_mm10();
3737
} else {
38-
System.err.println("Non-existent genome build!\n");
38+
throw new IllegalArgumentException(" (!)Invalid genomeName selected(" + build + "), please select from one of the provided genomes: sacCer3_cegr, hg19, hg19_contigs, and mm10\n");
3939
}
4040
}
4141

src/window_interface/Peak_Analysis/RandomCoordinateWindow.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public Void doInBackground() throws IOException, InterruptedException {
7474
}
7575
} catch(NumberFormatException nfe){
7676
JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!");
77+
} catch (IllegalArgumentException iae) {
78+
JOptionPane.showMessageDialog(null, iae.getMessage());
7779
}
7880
return null;
7981
}

src/window_interface/Peak_Analysis/TileGenomeWindow.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public Void doInBackground() throws IOException, InterruptedException {
6969
}
7070
} catch(NumberFormatException nfe){
7171
JOptionPane.showMessageDialog(null, "Invalid Input in Fields!!!");
72+
} catch (IllegalArgumentException iae) {
73+
JOptionPane.showMessageDialog(null, iae.getMessage());
7274
}
7375
return null;
7476
}

0 commit comments

Comments
 (0)