Skip to content

Commit

Permalink
Fix tsv.gz score conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
dennishendriksen committed Sep 7, 2020
1 parent 6a38105 commit 62b6be9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/org/molgenis/capice/vcf/AppIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Binary file added src/test/resources/input_precomputed_scores.tsv.gz
Binary file not shown.

0 comments on commit 62b6be9

Please sign in to comment.