From 40f853f2eadd8c10bc722e39ea795925e28e001a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Sch=C3=B6nherr?= Date: Fri, 31 May 2024 12:46:28 +0200 Subject: [PATCH] Fix missing contigs --- .../mut/commands/StatisticsCommand.java | 35 ++++++++----------- .../java/genepi/mut/steps/StatisticsTest.java | 19 +++++++++- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/main/java/genepi/mut/commands/StatisticsCommand.java b/src/main/java/genepi/mut/commands/StatisticsCommand.java index 02ccb37..960f596 100644 --- a/src/main/java/genepi/mut/commands/StatisticsCommand.java +++ b/src/main/java/genepi/mut/commands/StatisticsCommand.java @@ -99,7 +99,6 @@ public Integer call() throws IOException { try { reader = new BufferedReader(new FileReader(mapping)); } catch (FileNotFoundException e) { - // TODO Auto-generated catch block e.printStackTrace(); return -1; } @@ -129,7 +128,7 @@ public Integer call() throws IOException { } for (StatisticsFile sample : samples) { - + if (sample.getReadGroup() == null) { { countNoReadGroups++; @@ -223,26 +222,20 @@ public Integer call() throws IOException { text.append("Input Samples: " + samples.size() + "\n"); text.append("Passed Samples: " + validFiles + "\n"); - if (contigs.size() > 1) { - context.error("Different contigs have been detected"); - System.out.println("\n\nERROR: Different contigs have been detected for your input samples. Please upload them in different batches."); + + if (contigs.size() == 0) { + context.error("No valid mtDNA contigs with length 16569 have been detected in your input files."); + System.out.println("\n\nERROR: No valid mtDNA contigs detected."); return -1; - } else { - text.append("Detected contig name: " + contigs.get(0) + "\n"); } - - /* - * if (tool.equals("mutect2") || tool.equals("fusion")) { - * - * boolean found = false; for (String contig : allowed_contigs) { if - * (contig.equals(contigs.get(0))) { found = true; } } - * - * if (!found) { context. - * error("For Mutect2, please one of the following contig names for chromosome MT: " - * + allowed_contigs.toString()); return -1; } - * - * } - */ + + if (contigs.size() != 1) { + context.error("Different mtDNA contig names have been detected in your input files."); + System.out.println("\n\nERROR: Different contig names have been detected for your input samples. Please upload them in different batches."); + return -1; + } + + text.append("Detected mtDNA contig name: " + contigs.get(0) + "\n"); if (lowestMeanDepth != -1) { text.append("Min Mean Depth: " + lowestMeanDepth + "\n"); @@ -306,7 +299,7 @@ public Integer call() throws IOException { System.out.println("\n\nERROR: No input samples passed the QC step."); return -1; } else { - context.ok("Input Validation run succesfully, mtDNA analysis can be started."); + context.ok("Input Validation finished successfully, mtDNA analysis can be started."); return 0; } diff --git a/src/test/java/genepi/mut/steps/StatisticsTest.java b/src/test/java/genepi/mut/steps/StatisticsTest.java index 5bcb204..af8ffaa 100644 --- a/src/test/java/genepi/mut/steps/StatisticsTest.java +++ b/src/test/java/genepi/mut/steps/StatisticsTest.java @@ -48,7 +48,7 @@ public void testWithTwoContigs() throws Exception { CloudgeneReport CloudgeneLog = new CloudgeneReport(CLOUDGENE_LOG); - assertTrue(CloudgeneLog.hasInMemory("Different contigs have been detected")); + assertTrue(CloudgeneLog.hasInMemory("Different mtDNA contig names have been detected in your input files.")); assertTrue(CloudgeneLog.hasInMemory("[ERROR]")); @@ -106,6 +106,23 @@ public void testWithNoContig() throws Exception { assertTrue(CloudgeneLog.hasInMemory("Passed Samples: 1")); + } + + @Test + public void testWithMissingContig() throws Exception { + + String inputFolder = "test-data/statistics/sample_statistics_missing_contig.txt"; + + + StatisticsCommand command = new StatisticsCommand(); + command.setInput(inputFolder); + command.setOutput("excluded_samples.txt"); + + assertEquals(-1, (int) command.call()); + + + + }