Skip to content

Commit

Permalink
Merge pull request #75 from molgenis/feat/hpoCategorical
Browse files Browse the repository at this point in the history
feat:HPO categorical, bump version to 3.2.0
  • Loading branch information
dennishendriksen authored May 25, 2022
2 parents c2d50d4 + 88b7c54 commit 9f42efd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@molgenis/vip-report-api",
"version": "3.1.0",
"version": "3.2.0",
"description": "TypeScript Report API for Variant Call Format (VCF) Report Templates",
"scripts": {
"build": "tsc --build",
Expand Down
35 changes: 27 additions & 8 deletions src/ApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,35 @@ export class ApiClient implements Api {
}

// make VIPC categorical with categories based on tree exit nodes
const categories = Object.values(reportData.decisionTree.nodes)
.filter((node) => node.type === "LEAF")
.map((node) => (node as LeafNode).class);
const csqItem = csqItems.find((item) => item.id === "VIPC");
if (!csqItem) {
return reportData;
if (csqItem) {
csqItem.type = "CATEGORICAL";
csqItem.categories = Object.values(reportData.decisionTree.nodes)
.filter((node) => node.type === "LEAF")
.map((node) => (node as LeafNode).class);
csqItem.required = true;
}
csqItem.type = "CATEGORICAL";
csqItem.categories = categories;
csqItem.required = true;

// make HPO categorical with categories based on phenotypes
const hpoItem = csqItems.find((item) => item.id === "HPO");
if (hpoItem) {
const categories = reportData.data.phenotypes
? (reportData.data.phenotypes as Phenotype[])
.flatMap((phenotype) => phenotype.phenotypicFeaturesList)
.map((phenotype) => phenotype.type.id)
.filter((v, i, a) => a.indexOf(v) === i)
.sort()
: [];
if (categories.length > 0) {
hpoItem.type = "CATEGORICAL";
hpoItem.categories = (reportData.data.phenotypes as Phenotype[])
.flatMap((phenotype) => phenotype.phenotypicFeaturesList)
.map((phenotype) => phenotype.type.id)
.filter((v, i, a) => a.indexOf(v) === i)
.sort();
}
}

return reportData;
}

Expand Down

0 comments on commit 9f42efd

Please sign in to comment.