From 62b6be90354389d3bec8db5bad7fe62dc0e36e06 Mon Sep 17 00:00:00 2001 From: Dennis Hendriksen Date: Mon, 7 Sep 2020 08:04:33 +0200 Subject: [PATCH] Fix tsv.gz score conversion --- .../capice/vcf/TsvToVcfMapperImpl.java | 2 +- .../java/org/molgenis/capice/vcf/AppIT.java | 17 +++++++++++++++++ .../resources/input_precomputed_scores.tsv.gz | Bin 0 -> 145 bytes 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/input_precomputed_scores.tsv.gz diff --git a/src/main/java/org/molgenis/capice/vcf/TsvToVcfMapperImpl.java b/src/main/java/org/molgenis/capice/vcf/TsvToVcfMapperImpl.java index 00ddaca1..730c5267 100644 --- a/src/main/java/org/molgenis/capice/vcf/TsvToVcfMapperImpl.java +++ b/src/main/java/org/molgenis/capice/vcf/TsvToVcfMapperImpl.java @@ -134,7 +134,7 @@ private float getPrediction(CSVRecord record) { } private static Reader createInputReader(Path inputTsvPath) throws IOException { - if (inputTsvPath.endsWith(".gz")) { + if (inputTsvPath.toString().endsWith(".gz")) { return new InputStreamReader( new GZIPInputStream(new FileInputStream(inputTsvPath.toFile())), UTF_8); } else { diff --git a/src/test/java/org/molgenis/capice/vcf/AppIT.java b/src/test/java/org/molgenis/capice/vcf/AppIT.java index fc9f61e8..e1c77145 100644 --- a/src/test/java/org/molgenis/capice/vcf/AppIT.java +++ b/src/test/java/org/molgenis/capice/vcf/AppIT.java @@ -51,4 +51,21 @@ void testPrecomputedScores() throws IOException { assertEquals(expected, actual); } + + @Test + void testPrecomputedScoresGzipped() throws IOException { + String inputFile = ResourceUtils.getFile("classpath:input_precomputed_scores.tsv.gz").toString(); + String outputFile = sharedTempDir.resolve("capice_precomputed_scores_actual.vcf.gz").toString(); + + String[] args = {"-i", inputFile, "-o", outputFile, "-f", "-t", "precomputed_scores"}; + SpringApplication.run(App.class, args); + + String actual = getVcfGzAsString(Path.of(outputFile)).replaceAll("##CAP=.*", "##CAP=test"); + Path expectedPath = Paths.get("src", "test", "resources", "capice_precomputed_scores.vcf"); + String expected = + Files.readString(expectedPath, StandardCharsets.UTF_8) + .replaceAll("\\n|\\r\\n", System.getProperty("line.separator")); + + assertEquals(expected, actual); + } } diff --git a/src/test/resources/input_precomputed_scores.tsv.gz b/src/test/resources/input_precomputed_scores.tsv.gz new file mode 100644 index 0000000000000000000000000000000000000000..d703e851905f8dccb215bc2a41382617ee6cfbe5 GIT binary patch literal 145 zcmV;C0B-*uiwFo;zExiU18Ht>b#z~Fa%E$0ZE$sTWn^D-V{dY0b1rmqb^v|N%LxN9 z3avxh4kOTega`nxep8kstQ@Mrf@Is+T9(!%%JgkYrHnxsAR~P z5svh< literal 0 HcmV?d00001