Skip to content

Commit

Permalink
fix(reporter): show function in section 3 even when there is a no call
Browse files Browse the repository at this point in the history
  • Loading branch information
markwoon committed Jul 26, 2023
1 parent 65a1309 commit 4e2ea20
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public Map<DataSource, SortedMap<String, DrugReport>> getDrugReports() {
/**
* Gets the set of all {@link GeneReport} objects that are reported in this context
*/
public Map<DataSource, SortedMap<String, GeneReport>> getGeneReports() {
public SortedMap<DataSource, SortedMap<String, GeneReport>> getGeneReports() {
return m_geneReports;
}

Expand Down
23 changes: 11 additions & 12 deletions src/main/java/org/pharmgkb/pharmcat/reporter/format/HtmlFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ private Map<String,Object> compile(ReportContext reportContext) {
boolean hasUndocumentedVariationsAsReference = false;

SortedSetMultimap<String, GeneReport> geneReportMap = TreeMultimap.create();
for (DataSource source : reportContext.getGeneReports().keySet()) {
Map<String, Map<String, String>> functionMap = new HashMap<>();
for (DataSource source : new TreeSet<>(reportContext.getGeneReports().keySet())) {
if (!m_sources.contains(source)) {
continue;
}
Expand All @@ -129,12 +130,21 @@ private Map<String,Object> compile(ReportContext reportContext) {
if (geneReport.isIgnored()) {
continue;
}

String symbol = geneReport.getGeneDisplay();
totalGenes.add(symbol);
if (!m_compact) {
geneReportMap.put(symbol, geneReport);
}

// CPIC gets sorted first, this will pick CPIC over DPWG
if (!functionMap.containsKey(symbol)) {
GenePhenotype genePhenotype = getEnv().getPhenotype(symbol, source);
if (genePhenotype != null) {
functionMap.put(symbol, genePhenotype.getHaplotypes());
}
}

if (geneReport.isNoData()) {
noDataGenes.add(symbol);
continue;
Expand Down Expand Up @@ -168,7 +178,6 @@ private Map<String,Object> compile(ReportContext reportContext) {
List<Map<String, Object>> summaries = new ArrayList<>();
List<GeneReport> geneReports = new ArrayList<>();
Multimap<String, Map<String, Object>> geneSummariesByDrug = HashMultimap.create();
Map<String, Map<String, String>> functionMap = new HashMap<>();
for (String symbol : genes) {
if (noDataGenes.contains(symbol)) {
continue;
Expand All @@ -195,16 +204,6 @@ private Map<String,Object> compile(ReportContext reportContext) {
((Set<String>)geneSummary.get("relatedDrugs"))
.forEach(d -> geneSummariesByDrug.put(d, geneSummary));
geneReports.add(reports.first());

// CPIC gets sorted first, this will pick CPIC over DPWG
for (GeneReport gr : reports) {
GenePhenotype genePhenotype = getEnv().getPhenotype(symbol, gr.getPhenotypeSource());
if (genePhenotype == null) {
continue;
}
functionMap.put(symbol, genePhenotype.getHaplotypes());
break;
}
}
result.put("genes", genes);
result.put("noDataGenes", noDataGenes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.stream.Stream;
import com.google.common.html.HtmlEscapers;
import org.apache.commons.lang3.StringUtils;
import org.pharmgkb.pharmcat.phenotype.model.GenePhenotype;
import org.pharmgkb.pharmcat.reporter.TextConstants;
import org.pharmgkb.pharmcat.reporter.format.html.Report;
import org.pharmgkb.pharmcat.reporter.model.DataSource;
Expand Down Expand Up @@ -407,7 +408,7 @@ public static String amdAlleleFunction(Map<String, Map<String, String>> function
return allele + " - " + function;
}
}
return allele + " - Unassigned function";
return allele + " - " + GenePhenotype.UNASSIGNED_FUNCTION;
}

public static String amdNoDataMessage(Collection<String> compactNoDataGenes) {
Expand Down

0 comments on commit 4e2ea20

Please sign in to comment.