JsonResultsWriter implements ResultsWriter { @Override public void writeFile(ModeOfInheritance modeOfInheritance, Analysis analysis, AnalysisResults analysisResults, OutputSettings settings) { String outFileName = ResultsWriterUtils.makeOutputFilename(analysis.getVcfPath(), settings.getOutputPrefix(), OUTPUT_FORMAT, modeOfInheritance); Path outFile = Paths.get(outFileName); ObjectWriter objectWriter = new ObjectMapper().writer(); try (Writer bufferedWriter = Files.newBufferedWriter(outFile, StandardCharsets.UTF_8)) { writeData(modeOfInheritance, analysisResults, settings.outputContributingVariantsOnly(), objectWriter, bufferedWriter); } catch (IOException ex) { logger.error("Unable to write results to file {}", outFileName, ex); } logger.debug("{} {} results written to file {}", OUTPUT_FORMAT, (modeOfInheritance.getAbbreviation() == null) ? "ALL" : modeOfInheritance .getAbbreviation(), outFileName); }  @Override void writeFile(ModeOfInheritance modeOfInheritance, Analysis analysis, AnalysisResults analysisResults, OutputSettings settings); @Override String writeString(ModeOfInheritance modeOfInheritance, Analysis analysis, AnalysisResults analysisResults, OutputSettings settings);  }
@Test public void writeToFileOutputFullAnyModeOfInheritancePassOnlyVariants() throws IOException { Analysis analysis = this.analysisBuilder.analysisMode(AnalysisMode.FULL).build(); AnalysisResults analysisResults = this.analysisResultsBuilder.build(); Path outPath = Files.createTempFile("exomiser_test", ""); OutputSettings outputSettings = settingsBuilder.outputPrefix(outPath + "testWrite").build(); JsonResultsWriter instance = new JsonResultsWriter(); instance.writeFile(ModeOfInheritance.ANY, analysis, analysisResults, outputSettings); Path anyOutputPath = Paths.get(outPath + "testWrite.json"); assertThat(anyOutputPath.toFile().exists(), is(true)); assertThat(anyOutputPath.toFile().delete(), is(true)); instance.writeFile(ModeOfInheritance.AUTOSOMAL_RECESSIVE, analysis, analysisResults, outputSettings); Path arOutputPath = Paths.get(outPath + "testWrite_AR.json"); assertThat(arOutputPath.toFile().exists(), is(true)); assertThat(arOutputPath.toFile().delete(), is(true)); instance.writeFile(ModeOfInheritance.AUTOSOMAL_DOMINANT, analysis, analysisResults, outputSettings); Path adOutputPath = Paths.get(outPath + "testWrite_AD.json"); assertThat(adOutputPath.toFile().exists(), is(true)); assertThat(adOutputPath.toFile().delete(), is(true)); Files.delete(outPath); }