Skip to content

Commit 36e676c

Browse files
committed
Update scripts to check GZip using MAGIC bytes
Use the new GZipUtilities class to check for GZip file format in both ShiftInterval/Shift coord tool and the Two-color heatmap tool (#88). Remove unnecessary imports along the way.
1 parent 18efc24 commit 36e676c

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/scripts/Coordinate_Manipulation/ShiftCoord.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
import java.util.Arrays;
1212
import java.util.zip.GZIPInputStream;
1313
import java.util.zip.GZIPOutputStream;
14-
import java.util.zip.ZipException;
14+
15+
import util.GZipUtilities;
1516

1617
/**
1718
* This class contains scripts for shifting coordinate intervals (BED/GFF) by a user-defined direction and distance.
@@ -43,9 +44,9 @@ public static void shiftBEDInterval(File out_filepath, File input, int SHIFT, bo
4344
}
4445
// Assume file is gzipped and create normal BufferedReader if not
4546
BufferedReader br;
46-
try {
47+
if(GZipUtilities.isGZipped(input)) {
4748
br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(input)), "UTF-8"));
48-
} catch (ZipException e) {
49+
} else {
4950
br = new BufferedReader(new InputStreamReader(new FileInputStream(input), "UTF-8"));
5051
}
5152
// Initialize line variable to loop through
@@ -112,9 +113,9 @@ public static void shiftGFFInterval(File out_filepath, File input, int SHIFT, bo
112113
}
113114
// Assume file is gzipped and create normal BufferedReader if not
114115
BufferedReader br;
115-
try {
116+
if(GZipUtilities.isGZipped(input)) {
116117
br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(input)), "UTF-8"));
117-
} catch (ZipException e) {
118+
} else {
118119
br = new BufferedReader(new InputStreamReader(new FileInputStream(input), "UTF-8"));
119120
}
120121
// Initialize line variable to loop through

src/scripts/Figure_Generation/TwoColorHeatMap.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
import java.io.InputStreamReader;
1414
import java.io.UnsupportedEncodingException;
1515
import java.util.ArrayList;
16-
import java.util.Arrays;
1716
import java.util.Collections;
18-
import java.util.Scanner;
1917
import java.util.zip.GZIPInputStream;
20-
import java.util.zip.ZipException;
2118

2219
import javax.imageio.ImageIO;
2320
import javax.swing.ImageIcon;
2421
import javax.swing.JLabel;
2522

23+
import util.GZipUtilities;
24+
2625
public class TwoColorHeatMap {
2726

2827
protected static File SAMPLE = null;
@@ -370,9 +369,9 @@ public static ArrayList<double[]> loadMatrix(File input) throws UnsupportedEncod
370369
int currentRow = 0;
371370
// Assume file is gzipped and create normal BufferedReader if not
372371
BufferedReader br;
373-
try {
372+
if(GZipUtilities.isGZipped(input)) {
374373
br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(input)), "UTF-8"));
375-
} catch (ZipException e) {
374+
} else {
376375
br = new BufferedReader(new InputStreamReader(new FileInputStream(input), "UTF-8"));
377376
}
378377
// Initialize line variable to loop through

0 commit comments

Comments
 (0)