Skip to content

Commit

Permalink
Fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
seppinho committed Jan 18, 2021
1 parent fd456ea commit bf9348f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 89 deletions.
50 changes: 5 additions & 45 deletions src/main/java/genepi/mut/commands/ReportCommand.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
package genepi.mut.commands;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.Callable;

import genepi.mut.objects.ReportObject;
import genepi.mut.objects.Sample;
import genepi.mut.objects.Variant;
import genepi.mut.util.MutationServerReader;
import lukfor.reports.HtmlReport;
import lukfor.tables.Table;
import lukfor.tables.columns.IBuildValueFunction;
import lukfor.tables.columns.types.StringColumn;
import lukfor.tables.io.TableBuilder;
import lukfor.tables.io.TableWriter;
import lukfor.tables.rows.Row;
import genepi.mut.tasks.ReportTask;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

Expand All @@ -39,35 +24,10 @@ public Integer call() throws Exception {
return 1;
}

HtmlReport report = new HtmlReport("/report");
report.setSelfContained(true);
report.set("title", "mtDNA Server Report v2 (Beta)");

List<ReportObject> variants = new ArrayList<ReportObject>();
MutationServerReader reader = new MutationServerReader(input);
HashMap<String, Sample> samples = reader.parse();

for (Sample sample : samples.values()) {

for (ArrayList<Variant> a : sample.getVariants()) {

for(Variant variant : a) {
ReportObject reportObject = new ReportObject();
reportObject.setCoverage(variant.getCoverage());
reportObject.setId(sample.getId());
reportObject.setPos(variant.getPos());
reportObject.setFilter(variant.getFilter().name());
reportObject.setRef(variant.getRef());
reportObject.setVar(variant.getVariant());
variants.add(reportObject);

}
}
}

report.set("variants", variants);
report.generate(new File(output));

ReportTask task = new ReportTask();
task.setInput(input);
task.setOutput(output);
task.createReport();
return 0;
}

Expand Down
49 changes: 5 additions & 44 deletions src/test/java/genepi/mut/steps/report/ReportGeneratorTest.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
package genepi.mut.steps.report;

import java.io.File;
import java.io.FileReader;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import genepi.io.FileUtil;
import genepi.mut.objects.ReportObject;
import genepi.mut.objects.Sample;
import genepi.mut.objects.Variant;
import genepi.mut.util.MutationServerReader;
import lukfor.reports.HtmlReport;
import genepi.mut.tasks.ReportTask;

public class ReportGeneratorTest {

Expand All @@ -27,35 +13,10 @@ public void testGenerate() throws Exception {
String input = "test-data/mtdna/report/1000g.txt";
String output = "test-data/mtdna/report/out.html";

HtmlReport report = new HtmlReport("/report");
report.setSelfContained(true);
report.set("title", "mtDNA Server Report v2 (Beta)");

List<ReportObject> objects = new ArrayList<ReportObject>();
MutationServerReader reader = new MutationServerReader(input);
HashMap<String, Sample> samples = reader.parse();

for (Sample sample : samples.values()) {

for (ArrayList<Variant> variants : sample.getVariants()) {

for (Variant variant : variants) {
ReportObject reportObject = new ReportObject();
reportObject.setCoverage(variant.getCoverage());
reportObject.setId(sample.getId());
reportObject.setPos(variant.getPos());
reportObject.setFilter(variant.getFilter().name());
reportObject.setRef(variant.getRef());
reportObject.setVar(variant.getVariant());
reportObject.setLevel(variant.getLevel());
reportObject.setType(variant.getType());
objects.add(reportObject);
}
}
}

report.set("variants", objects);
report.generate(new File(output));
ReportTask task = new ReportTask();
task.setInput(input);
task.setOutput(output);
task.createReport();

FileUtil.deleteFile(output);

Expand Down

1 comment on commit bf9348f

@vercel
Copy link

@vercel vercel bot commented on bf9348f Jan 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.