File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
src/main/java/au/csiro/variantspark/utils Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ package au .csiro .variantspark .utils ;
2
+
3
+ import java .io .BufferedReader ;
4
+ import java .io .File ;
5
+ import java .io .InputStreamReader ;
6
+ import java .io .IOException ;
7
+ import htsjdk .samtools .util .BlockCompressedInputStream ;
8
+
9
+ public class FileUtils {
10
+
11
+ /**
12
+ *
13
+ * @param file: an input file
14
+ * @return true if input file is BGZIP by check the first two byte of input file
15
+ */
16
+ public static boolean isInputBGZ (final File file ) {
17
+
18
+ try (final BlockCompressedInputStream bgzInputStream = new BlockCompressedInputStream (file )) {
19
+ BufferedReader reader = new BufferedReader (new InputStreamReader (bgzInputStream ));
20
+ String line = reader .readLine ();
21
+ return line != null && !line .isEmpty ();
22
+ } catch (IOException e ) {
23
+ //file is not .vcf.bgz file
24
+ return false ;
25
+ }
26
+ }
27
+
28
+ }
You can’t perform that action at this time.
0 commit comments