### Question:
Deconvolution { public void readInputData() throws IllegalAccessException, IOException { outputFolder = commandLineOptions.getOutfolder(); cellCounts = new CellCount(); cellCounts.readCellCountData(commandLineOptions.getCellcountFile()); geneSnpPairs = Utils.parseSnpPerGeneFile(commandLineOptions.getSnpsToTestFile()); String expressionFile = commandLineOptions.getExpressionFile(); DeconvolutionLogger.log.info(String.format("Parse expression data from %s",expressionFile)); expressionData = new ExpressionData(expressionFile); DeconvolutionLogger.log.info("Done"); String genotypeFile = commandLineOptions.getGenotypeFile(); DeconvolutionLogger.log.info(String.format("Parse genotype data from %s",genotypeFile)); genotypeData = new GenotypeData(genotypeFile); DeconvolutionLogger.log.info("Done"); if (!expressionData.getSampleNames().equals(genotypeData.getSampleNames())){ ArrayList<String> differences = Utils.getDifferencesBetweenLists(expressionData.getSampleNames(), genotypeData.getSampleNames()); throw new RuntimeException(String.format("Samplenames not the same in expression and genotype file, or not in the same order."+ "\nexpression samples not in genotypes (%d): %s\ngenotype samples not in expression (%d): %s\n", differences.get(0).length(), differences.get(0), differences.get(1).length(), differences.get(1))); } } Deconvolution(CommandLineOptions commandLineOptions); void readInputData(); List<DeconvolutionResult> runDeconPerGeneSnpPair(); void writeDeconvolutionResults(List<DeconvolutionResult> deconvolutionResults); public CellCount cellCounts; public ExpressionData expressionData; public HashMap<String,ArrayList<String>> geneSnpPairs; public GenotypeData genotypeData; }### Answer:
@Test public void readInputDataTest() throws Exception { File cellCountsSmall = new File("src/test/resources/cellcount_files/cellcounts_small.txt"); String[] args = {"-o",outputDir+"deconvolutionTestResults","-c",counts,cellCountsSmall.getAbsolutePath(), "-e",expression, "-g", genotypes, "-sn", geneSnpList}; commandLineOptions.parseCommandLine(args); Deconvolution deconvolution = new Deconvolution(commandLineOptions); deconvolution.readInputData(); }
@Test public void readInputDataWrongNamesTest() throws Exception { File expTableWrongNames = new File("src/test/resources/expression_files/expression_levels_wrong_names.txt"); String[] args = {"-o",outputDir+"deconvolutionTestResults","-c",counts,"-e", expTableWrongNames.getAbsolutePath(), "-g", genotypes, "-sn", geneSnpList}; commandLineOptions.parseCommandLine(args); Deconvolution deconvolution = new Deconvolution(commandLineOptions); try { deconvolution.readInputData(); fail( "My method didn't throw when I expected it to" ); } catch (RuntimeException expectedException) { assertThat(expectedException.getMessage(), CoreMatchers.containsString("Samplenames not the same in expression and genotype file, or not in the same order")); } }