ResultsWriterUtils { public static String makeOutputFilename(Path vcfPath, String outputPrefix, OutputFormat outputFormat, ModeOfInheritance modeOfInheritance) { String moiAbbreviation = moiAbbreviation(modeOfInheritance); if (outputPrefix.isEmpty()) { String defaultOutputPrefix = String.format("%s/%s_exomiser", ResultsWriterUtils.DEFAULT_OUTPUT_DIR, vcfPath.getFileName()); logger.debug("Output prefix was unspecified. Will write out to: {}", defaultOutputPrefix); return String.format("%s%s.%s", defaultOutputPrefix, moiAbbreviation, outputFormat.getFileExtension()); } return String.format("%s%s.%s", outputPrefix, moiAbbreviation, outputFormat.getFileExtension()); } private  ResultsWriterUtils(); static String makeOutputFilename(Path vcfPath, String outputPrefix, OutputFormat outputFormat, ModeOfInheritance modeOfInheritance); static List<VariantEffectCount> makeVariantEffectCounters(List<String> sampleNames, List<VariantEvaluation> variantEvaluations); static List<FilterReport> makeFilterReports(Analysis analysis, AnalysisResults analysisResults); static List<Gene> getMaxPassedGenes(List<Gene> genes, int maxGenes);  }
@Test public void testThatSpecifiedTsvFileExtensionIsPresent() { OutputFormat testedFormat = OutputFormat.TSV_GENE; OutputSettings settings = OutputSettings.builder().build(); String expResult = String.format("%s/wibble_exomiser_AD.%s", DEFAULT_OUTPUT_DIR, testedFormat.getFileExtension()); String result = ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), testedFormat, ModeOfInheritance.AUTOSOMAL_DOMINANT); assertThat(result, equalTo(expResult)); }
@Test public void testThatSpecifiedVcfFileExtensionIsPresent() { OutputFormat testedFormat = OutputFormat.VCF; OutputSettings settings = OutputSettings.builder().build(); String expResult = String.format("%s/wibble_exomiser_AR.%s", DEFAULT_OUTPUT_DIR, testedFormat.getFileExtension()); String result = ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), testedFormat, ModeOfInheritance.AUTOSOMAL_RECESSIVE); assertThat(result, equalTo(expResult)); }
@Test public void testThatSpecifiedOutputFormatDoesNotOverwriteGivenOutputPrefixFileExtension() { OutputFormat testedFormat = OutputFormat.VCF; String outputPrefix = "/user/jules/exomes/analysis/slartibartfast.xml"; OutputSettings settings = OutputSettings.builder().outputPrefix(outputPrefix).build(); String expResult = String.format("%s_XD.%s", outputPrefix, testedFormat.getFileExtension()); String result = ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), testedFormat, ModeOfInheritance.X_DOMINANT); assertThat(result, equalTo(expResult)); }
@Test public void testDefaultOutputFormatIsNotDestroyedByIncorrectFileExtensionDetection() { OutputFormat testedFormat = OutputFormat.HTML; OutputSettings settings = OutputSettings.builder().build(); String expResult = DEFAULT_OUTPUT_DIR + "/wibble_exomiser.html"; String result = ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), testedFormat, ModeOfInheritance.ANY); assertThat(result, equalTo(expResult)); }
@Test public void testOutFileNameIsCombinationOfOutPrefixAndOutFormat() { OutputFormat outFormat = OutputFormat.TSV_GENE; String outFilePrefix = "user/subdir/geno/vcf/F0000009/F0000009"; OutputSettings settings = OutputSettings.builder().outputPrefix(outFilePrefix).build(); assertThat(ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), outFormat, ModeOfInheritance.AUTOSOMAL_DOMINANT), equalTo("user/subdir/geno/vcf/F0000009/F0000009_AD.genes.tsv")); }
@Test public void testOutputFileNameModeOfInheritanceExtensions() { OutputFormat testedFormat = OutputFormat.HTML; OutputSettings settings = OutputSettings.builder().build(); String any = ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), testedFormat, ModeOfInheritance.ANY); assertThat(any, equalTo(DEFAULT_OUTPUT_DIR + "/wibble_exomiser.html")); String autoDom = ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), testedFormat, ModeOfInheritance.AUTOSOMAL_DOMINANT); assertThat(autoDom, equalTo(DEFAULT_OUTPUT_DIR + "/wibble_exomiser_AD.html")); String autoRec = ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), testedFormat, ModeOfInheritance.AUTOSOMAL_RECESSIVE); assertThat(autoRec, equalTo(DEFAULT_OUTPUT_DIR + "/wibble_exomiser_AR.html")); String xDom = ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), testedFormat, ModeOfInheritance.X_DOMINANT); assertThat(xDom, equalTo(DEFAULT_OUTPUT_DIR + "/wibble_exomiser_XD.html")); String xRec = ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), testedFormat, ModeOfInheritance.X_RECESSIVE); assertThat(xRec, equalTo(DEFAULT_OUTPUT_DIR + "/wibble_exomiser_XR.html")); String mito = ResultsWriterUtils.makeOutputFilename(vcfPath, settings.getOutputPrefix(), testedFormat, ModeOfInheritance.MITOCHONDRIAL); assertThat(mito, equalTo(DEFAULT_OUTPUT_DIR + "/wibble_exomiser_MT.html")); }