Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/html report #584

Open
wants to merge 15 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ public int getFailed() {
return failed;
}

public double getPercentageFilteredFromBeginning(double originalSize) {
return ((originalSize - (double) passed) / originalSize) * 100;
}

public double getPercentageFilteredFromReports(double originalSize) {
return (failed / originalSize) * 100;
}

public double getPercentageFilteredFromReport(double originalSize) {
return (failed / originalSize) * 100;
}

public int getTotalEvaluationCount() {
return passed + failed;
}

@Override
public int hashCode() {
int hash = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public enum FilterType {

FAILED_VARIANT_FILTER("filter", "Failed previous VCF filters"),
FAILED_VARIANT_FILTER("filter", "VCF Quality Filter"),
QUALITY_FILTER("quality", "Quality"),
INTERVAL_FILTER("interval", "Interval"),
ENTREZ_GENE_ID_FILTER("gene-id", "Gene id"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
import org.monarchinitiative.exomiser.core.prioritisers.model.GeneModelPhenotypeMatch;

import javax.annotation.Nullable;
import java.lang.reflect.Array;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toMap;

Expand Down Expand Up @@ -289,51 +291,51 @@ public String getHTMLCode() {
StringBuilder stringBuilder = new StringBuilder();

for (GeneModelPhenotypeMatch geneModelPhenotypeMatch : phenotypeEvidence.values()) {
stringBuilder.append("<div class=\"pheno-match-card card col-sm-5\">");
switch (geneModelPhenotypeMatch.getOrganism()) {
case HUMAN:
GeneDiseaseModel geneDiseaseModel = (GeneDiseaseModel) geneModelPhenotypeMatch.getModel();
String diseaseLink = makeDiseaseLink(geneDiseaseModel.getDiseaseId(), geneDiseaseModel.getDiseaseTerm());
stringBuilder.append(String.format("<dl><dt>Phenotypic similarity %.3f to %s associated with %s.</dt>", geneModelPhenotypeMatch
.getScore(), diseaseLink, geneModelPhenotypeMatch.getHumanGeneSymbol()));
stringBuilder.append(String.format("<h5 class=\"card-header\"><span class=\"badge bg-secondary\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" title=\"Phenotype Score\">%.3f</span>%s <a href=\"https://useast.ensembl.org/Homo_sapiens/Gene/Summary?g=%s\" target=\"_blank\" class=\"text-decoration-none\">%s</a></h5>", geneModelPhenotypeMatch
.getScore(), diseaseLink, geneModelPhenotypeMatch.getHumanGeneSymbol(), geneModelPhenotypeMatch.getHumanGeneSymbol()));
break;
case MOUSE:
stringBuilder.append(String.format("<dl><dt>Phenotypic similarity %.3f to mouse mutant involving <a href=\"http://www.informatics.jax.org/searchtool/Search.do?query=%s\">%s</a>.</dt>", geneModelPhenotypeMatch
stringBuilder.append(String.format("<h5 class=\"card-header\"><span class=\"badge bg-secondary\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" title=\"Phenotype Score\">%.3f</span><span>Mouse Mutant</span> <a class=\"text-decoration-none\" target=\"_blank\" href=\"https://www.informatics.jax.org/searchtool/Search.do?query=%s\">%s</a></h5>", geneModelPhenotypeMatch
.getScore(), geneModelPhenotypeMatch.getHumanGeneSymbol(), geneModelPhenotypeMatch.getHumanGeneSymbol()));
break;
case FISH:
stringBuilder.append(String.format("<dl><dt>Phenotypic similarity %.3f to zebrafish mutant involving <a href=\"http://zfin.org/action/quicksearch/query?query=%s\">%s</a>.</dt>", geneModelPhenotypeMatch
stringBuilder.append(String.format("<h5 class=\"card-header\"><span class=\"badge bg-secondary\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" title=\"Phenotype Score\">%.3f</span><span>Zebrafish Mutant</span> <a class=\"text-decoration-none\" target=\"_blank\" href=\"https://zfin.org/action/quicksearch/query?query=%s\">%s</a></h5>", geneModelPhenotypeMatch
.getScore(), geneModelPhenotypeMatch.getHumanGeneSymbol(), geneModelPhenotypeMatch.getHumanGeneSymbol()));
break;
}
Map<PhenotypeTerm, PhenotypeMatch> bestMatchesForModel = getPhenotypeTermPhenotypeMatchMap(geneModelPhenotypeMatch);
makeBestPhenotypeMatchHtml(stringBuilder, bestMatchesForModel);
stringBuilder.append("</dl>");
stringBuilder.append("</div>");
}

for (GeneModelPhenotypeMatch geneModelPhenotypeMatch : ppiEvidence) {
String stringDbLink = "http://version10.string-db.org/newstring_cgi/show_network_section.pl?identifiers=" + geneSymbol + "%0D" + geneModelPhenotypeMatch
.getHumanGeneSymbol() + "&required_score=700&network_flavor=evidence&species=9606&limit=20";

stringBuilder.append("<div class=\"pheno-match-card card col-sm-5\">");
switch (geneModelPhenotypeMatch.getOrganism()) {
case HUMAN:
GeneDiseaseModel geneDiseaseModel = (GeneDiseaseModel) geneModelPhenotypeMatch.getModel();
String diseaseLink = makeDiseaseLink(geneDiseaseModel.getDiseaseId(), geneDiseaseModel.getDiseaseTerm());
stringBuilder.append(String.format("<dl><dt>Proximity score %.3f in <a href=\"%s\">interactome to %s</a> and phenotypic similarity %.3f to %s associated with %s.</dt>", ppiScore, stringDbLink, geneModelPhenotypeMatch
.getHumanGeneSymbol(), geneModelPhenotypeMatch.getScore(), diseaseLink, geneModelPhenotypeMatch
stringBuilder.append(String.format("<h5 class=\"card-header\"><div class=\"d-flex ai-c\"><span class=\"badge bg-secondary\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" title=\"Phenotype Score\">%.3f</span>&nbsp;&nbsp;%s</div> via <div class=\"d-flex ai-c\"><span class=\"badge bg-secondary\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" title=\"Proximity Score\">%.3f</span>&nbsp;&nbsp;<a class=\"text-decoration-none\" target=\"_blank\" href=\"%s\">Interactome Proximity</a></div> to <a href=\"https://useast.ensembl.org/Homo_sapiens/Gene/Summary?g=%s\" target=\"_blank\" class=\"text-decoration-none\">%s</a></h5>", geneModelPhenotypeMatch.getScore(), diseaseLink, ppiScore, stringDbLink, geneModelPhenotypeMatch
.getHumanGeneSymbol(), geneModelPhenotypeMatch
.getHumanGeneSymbol()));
break;
case MOUSE:
stringBuilder.append(String.format("<dl><dt>Proximity score %.3f in <a href=\"%s\">interactome to %s</a> and phenotypic similarity %.3f to mouse mutant of %s.</dt>", ppiScore, stringDbLink, geneModelPhenotypeMatch
.getHumanGeneSymbol(), geneModelPhenotypeMatch.getScore(), geneModelPhenotypeMatch.getHumanGeneSymbol()));
stringBuilder.append(String.format("<h5 class=\"card-header\"><div class=\"d-flex ai-c\"><span class=\"badge bg-secondary\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" title=\"Phenotype Score\">%.3f</span><span>&nbsp;&nbsp;Mouse Mutant</span></div> via <div class=\"d-flex ai-c\"><span class=\"badge bg-secondary\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" title=\"Proximity Score\">%.3f</span>&nbsp;&nbsp;<a class=\"text-decoration-none\" target=\"_blank\" href=\"%s\">Interactome Proximity</a></div> to <a href=\"https://useast.ensembl.org/Homo_sapiens/Gene/Summary?g=%s\" target=\"_blank\" class=\"text-decoration-none\">%s</a></h5>", geneModelPhenotypeMatch.getScore(), ppiScore, stringDbLink, geneModelPhenotypeMatch.getHumanGeneSymbol(), geneModelPhenotypeMatch.getHumanGeneSymbol()));
break;
case FISH:
stringBuilder.append(String.format("<dl><dt>Proximity score %.3f in <a href=\"%s\">interactome to %s</a> and phenotypic similarity %.3f to fish mutant of %s.</dt>", ppiScore, stringDbLink, geneModelPhenotypeMatch
.getHumanGeneSymbol(), geneModelPhenotypeMatch.getScore(), geneModelPhenotypeMatch.getHumanGeneSymbol()));
stringBuilder.append(String.format("<h5 class=\"card-header\"><div class=\"d-flex ai-c\"><span class=\"badge bg-secondary\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" title=\"Phenotype Score\">%.3f</span>&nbsp;&nbsp;<span>Zebrafish</span></div> via <div class=\"d-flex ai-c\"><span class=\"badge bg-secondary\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" title=\"Proximity Score\">%.3f</span>&nbsp;&nbsp;<a class=\"text-decoration-none\" target=\"_blank\" href=\"%s\">Interactome Proximity</a></div> to <a href=\"https://useast.ensembl.org/Homo_sapiens/Gene/Summary?g=%s\" target=\"_blank\" class=\"text-decoration-none\">%s</a></h5>", geneModelPhenotypeMatch.getScore(), ppiScore, stringDbLink, geneModelPhenotypeMatch.getHumanGeneSymbol(), geneModelPhenotypeMatch
.getHumanGeneSymbol()));
break;
}
Map<PhenotypeTerm, PhenotypeMatch> bestModelPhenotypeMatches = getPhenotypeTermPhenotypeMatchMap(geneModelPhenotypeMatch);
makeBestPhenotypeMatchHtml(stringBuilder, bestModelPhenotypeMatches);
stringBuilder.append("</dl>");
stringBuilder.append("</div>");
}
String html = stringBuilder.toString();
if (html.isEmpty()) {
Expand All @@ -353,26 +355,52 @@ private void makeBestPhenotypeMatchText(StringBuilder stringBuilder, Map<Phenoty
}

private void makeBestPhenotypeMatchHtml(StringBuilder stringBuilder, Map<PhenotypeTerm, PhenotypeMatch> bestModelPhenotypeMatches) {
stringBuilder.append("<dt>Best Phenotype Matches:</dt>");
Collection<PhenotypeMatch> matches = new ArrayList<>();
int unmatched = 0;
stringBuilder.append("<div class=\"card-body\">");
stringBuilder.append("<div class=\"d-flex px-2\"><div class=\"flex-grow-1 fw-bold\">Sample</div><div class=\"fw-bold\">Reference</div></div>");
for (PhenotypeTerm queryTerm : queryPhenotypeTerms) {
if (bestModelPhenotypeMatches.containsKey(queryTerm)) {
PhenotypeMatch match = bestModelPhenotypeMatches.get(queryTerm);
PhenotypeTerm matchTerm = match.getMatchPhenotype();
stringBuilder.append(String.format("<dd>%s, %s - %s, %s</dd>", queryTerm.getId(), queryTerm.getLabel(), matchTerm.getId(), matchTerm.getLabel()));
matches.add(match);
} else {
stringBuilder.append(String.format("<dd>%s, %s -</dd>", queryTerm.getId(), queryTerm.getLabel()));
unmatched++;
}
}

matches = matches.stream()
.sorted((a, b) -> {
boolean aMatches = a.getMatchPhenotypeId().equals(a.getQueryPhenotypeId());
boolean bMatches = b.getMatchPhenotypeId().equals(b.getQueryPhenotypeId());
int compare = Boolean.compare(bMatches, aMatches);
if (compare == 0) {
return Double.compare(b.getSimJ(), a.getSimJ());
}
return compare;
})
.collect(Collectors.toList());

for (PhenotypeMatch match: matches){
stringBuilder.append(String.format(
"<div class=\"matched-set\"><div class=\"match\"><div class=\"match-left text-sm\"><div class=\"match-id\">%s</div><div class=\"match-name px-2\">%s</div></div>" +
"<div class=\"align-self-center\"><span class=\"badge bg-success\">%.3f</span></div>" +
"<div class=\"match-right text-sm\"><div class=\"match-id\">%s</div><div class=\"match-name px-2\">%s</div></div></div></div>", match.getQueryPhenotypeId(), match.getQueryPhenotype().getLabel(), match.getSimJ(), match.getMatchPhenotype().getId(), match.getMatchPhenotype().getLabel()));
}

stringBuilder.append("</div>");
if (unmatched > 0) {
stringBuilder.append(String.format("<div class=\"card-footer text-muted text-end\">%s of %s phenotypes unmatched.</div>", unmatched, queryPhenotypeTerms.size()));
}
}

private String makeDiseaseLink(String diseaseId, String diseaseTerm) {
String[] databaseNameAndIdentifier = diseaseId.split(":");
String databaseName = databaseNameAndIdentifier[0];
String id = databaseNameAndIdentifier[1];
if (databaseName.equals("OMIM")) {
return "<a href=\"http://www.omim.org/entry/" + id + "\">" + diseaseTerm + "</a>";
return "<a class=\"text-decoration-none\" href=\"http://www.omim.org/entry/" + id + "\" target=\"_blank\">" + diseaseTerm + "</a>";
} else {
return "<a href=\"http://www.orpha.net/consor/cgi-bin/OC_Exp.php?lng=en&Expert=" + id + "\">" + diseaseTerm + "</a>";
return "<a class=\"text-decoration-none\" href=\"http://www.orpha.net/consor/cgi-bin/OC_Exp.php?lng=en&Expert=" + id + "\" target=\"_blank\">" + diseaseTerm + "</a>";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ private Context buildContext(AnalysisResults analysisResults, OutputSettings out
//write out the analysis reports section
List<FilterReport> analysisStepReports = ResultsWriterUtils.makeFilterReports(analysis, analysisResults);
context.setVariable("filterReports", analysisStepReports);
context.setVariable("filterReportEvalCount", !analysisStepReports.isEmpty() ? analysisStepReports.get(0).getTotalEvaluationCount() : 0.00);
//write out the variant type counters
List<String> sampleNames = analysisResults.getSampleNames();
List<VariantEffectCount> variantTypeCounters = ResultsWriterUtils.makeVariantEffectCounters(sampleNames, analysisResults
Expand Down
1,469 changes: 934 additions & 535 deletions exomiser-core/src/main/resources/templates/results.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,10 @@ public void testToString() {
assertThat(instance.toString(), equalTo(expResult));
}

@Test
public void testPercentageFailed(){
double expected = ((double)(345 - 12) / 345) * 100;
assertThat(instance.getPercentageFilteredFromBeginning(345), equalTo(expected));
}

}
Loading