Skip to content

Commit

Permalink
fix(reporter): fix links to uncallable genes in section 3
Browse files Browse the repository at this point in the history
  • Loading branch information
markwoon committed Jul 26, 2023
1 parent 4e2ea20 commit f1d4da2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ public static boolean rxInferred(Genotype genotype) {
.noneMatch(g -> g.equals("DPYD"));
}

public static String rxGenotype(Genotype genotype, AnnotationReport annotationReport,
GuidelineReport guidelineReport) {
public static String rxGenotype(Genotype genotype, AnnotationReport annotationReport, GuidelineReport guidelineReport,
SortedSet<String> noDataGenes) {
if (genotype.getDiplotypes().size() == 0) {
return TextConstants.UNKNOWN_GENOTYPE;
}
StringBuilder builder = new StringBuilder()
.append(renderRxDiplotypes(genotype.getDiplotypes(), false));
.append(renderRxDiplotypes(genotype.getDiplotypes(), false, noDataGenes));
if (annotationReport.getHighlightedVariants().size() > 0) {
for (String var : annotationReport.getHighlightedVariants()) {
if (builder.length() > 0) {
Expand All @@ -258,7 +258,8 @@ public static String rxGenotype(Genotype genotype, AnnotationReport annotationRe
return builder.toString();
}

public static String rxGenotypeDebug(Genotype genotype, GuidelineReport guidelineReport) {
public static String rxGenotypeDebug(Genotype genotype, GuidelineReport guidelineReport,
SortedSet<String> noDataGenes) {
if (!s_debugMode) {
return "";
}
Expand All @@ -269,14 +270,14 @@ public static String rxGenotypeDebug(Genotype genotype, GuidelineReport guidelin
return "<div class=\"alert alert-debug\">" +
"<div class=\"hint\">Inferred:</div>" +
"<span class=\"nowrap\">" +
renderRxDiplotypes(genotype.getDiplotypes(), true) +
renderRxDiplotypes(genotype.getDiplotypes(), true, noDataGenes) +
"</span></div>";
}
return "";
}

public static String rxUnmatchedDiplotypes(SortedSet<Diplotype> diplotypes) {
return renderRxDiplotypes(diplotypes, true, false, "rx-unmatched-dip");
public static String rxUnmatchedDiplotypes(SortedSet<Diplotype> diplotypes, SortedSet<String> noDataGenes) {
return renderRxDiplotypes(diplotypes, true, false, "rx-unmatched-dip", noDataGenes);
}

public static boolean rxUnmatchedDiplotypesInferred(Report report) {
Expand All @@ -285,12 +286,13 @@ public static boolean rxUnmatchedDiplotypesInferred(Report report) {
}


private static String renderRxDiplotypes(Collection<Diplotype> diplotypes, boolean forDebug) {
return renderRxDiplotypes(diplotypes, false, forDebug, "rx-dip");
private static String renderRxDiplotypes(Collection<Diplotype> diplotypes, boolean forDebug,
SortedSet<String> noDataGenes) {
return renderRxDiplotypes(diplotypes, false, forDebug, "rx-dip", noDataGenes);
}

private static String renderRxDiplotypes(Collection<Diplotype> diplotypes, boolean noLengthLimit, boolean forDebug,
String dipClass) {
String dipClass, SortedSet<String> noDataGenes) {
SortedSet<Diplotype> displayDiplotypes = new TreeSet<>();
for (Diplotype diplotype : diplotypes) {
if (!forDebug && diplotype.getInferredSourceDiplotypes() != null) {
Expand All @@ -311,11 +313,17 @@ private static String renderRxDiplotypes(Collection<Diplotype> diplotypes, boole
.append(dipClass)
.append("\"");
}
builder.append("><a href=\"#")
.append(diplotype.getGene())
.append("\">")
.append(diplotype.getGene())
.append("</a>:");
builder.append(">");
if (noDataGenes != null && noDataGenes.contains(diplotype.getGene())) {
builder.append(diplotype.getGene());
} else {
builder.append("<a href=\"#")
.append(diplotype.getGene())
.append("\">")
.append(diplotype.getGene())
.append("</a>");
}
builder.append(":");
String call = diplotype.getLabel();
if (noLengthLimit || call.length() <= 15) {
builder.append(call);
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/org/pharmgkb/pharmcat/reporter/report.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@
{{#each genotypes}}
<li>
<span class="noWrap">
{{{rxGenotype this ../this ../../this}}}
{{{rxGenotype this ../this ../../this noDataGenes}}}
{{#if (rxInferred this)}}<sup><a href="#rx-dagger-{{../../../drug}}" title="Inferred">&dagger;</a></sup>{{/if}}
{{#if (rxDpydInferred this)}}<sup><a href="#rx-ddagger-{{../../../drug}}" title="Inferred">&ddagger;</a></sup>{{/if}}
</span>
{{{rxGenotypeDebug this ../../this}}}
{{{rxGenotypeDebug this ../../this noDataGenes}}}
</li>
{{/each}}
</ul>
Expand Down Expand Up @@ -302,7 +302,7 @@
</div>
<div>
<div class="hint">{{pluralize "Genotype" unmatchedDiplotypes}}</div>
{{{rxUnmatchedDiplotypes unmatchedDiplotypes}}}
{{{rxUnmatchedDiplotypes unmatchedDiplotypes noDataGenes}}}
{{#if unmatchedInferred}}<sup><a href="#rx-dagger-{{../../../drug}}" title="Inferred">&dagger;</a></sup>{{/if}}
{{#if unmatchedDpydInferred}}<sup><a href="#rx-ddagger-{{../../../drug}}" title="Inferred">&ddagger;</a></sup>{{/if}}
</div>
Expand Down

0 comments on commit f1d4da2

Please sign in to comment.