Skip to content

Commit

Permalink
Fix missing contigs
Browse files Browse the repository at this point in the history
  • Loading branch information
seppinho committed May 31, 2024
1 parent 283a435 commit 40f853f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
35 changes: 14 additions & 21 deletions src/main/java/genepi/mut/commands/StatisticsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -129,7 +128,7 @@ public Integer call() throws IOException {
}

for (StatisticsFile sample : samples) {

if (sample.getReadGroup() == null) {
{
countNoReadGroups++;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}

Expand Down
19 changes: 18 additions & 1 deletion src/test/java/genepi/mut/steps/StatisticsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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]"));


Expand Down Expand Up @@ -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());




}


Expand Down

0 comments on commit 40f853f

Please sign in to comment.