Skip to content

Commit

Permalink
[ENH] Added Assessment Tool annoatatoins to the JSON output file (#588
Browse files Browse the repository at this point in the history
)

* Implemented `getAssessmentToolJSONOutput`  getter

* Implemented unit test for `getAssessmentToolJSONOutput` getter

* Added `Assessment Tool` annotations to the JSON output

* Addressed comments from PR review
  • Loading branch information
rmanaem authored Oct 26, 2023
1 parent b7455ab commit 9536598
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/annot-tool-groups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:title="label">
<annot-single-tool
:name="identifier"
:uniqueColumnValues="provideUniqueValues(identifier)"
:unique-column-values="provideUniqueValues(identifier)"
@declareMissing="changeMissingStatus(Object.assign($event, {markAsMissing: true}))" />
</b-tab>

Expand Down
15 changes: 12 additions & 3 deletions cypress/e2e/app/simple-e2etest.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ describe("End to end test using a simple UI path through the app", () => {

["Subject ID", 1],
["Age", 1],
["Diagnosis", 1]
["Diagnosis", 1],
["Assessment Tool", 1]
]
};

Expand Down Expand Up @@ -79,6 +80,12 @@ describe("End to end test using a simple UI path through the app", () => {
// D. Categorize "age" as "Age" and "group" as "Diagnosis"
cy.categorizeColumn("Age", p_dataset["category_columns"]["Age"][0]);
cy.categorizeColumn("Diagnosis", p_dataset["category_columns"]["Diagnosis"][0]);
cy.categorizeColumn("Assessment Tool", p_dataset["category_columns"]["Assessment Tool"][0]);

cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}");
cy.get("[data-cy='assessment-tool-table']").contains("MOCA").click();
cy.get("[data-cy='assessment-column-table']").contains("iq").click();


// Since Age and subject ID have been categorized
// annotation page is no accessible.
Expand Down Expand Up @@ -116,8 +123,6 @@ describe("End to end test using a simple UI path through the app", () => {
cy.get("[data-cy='isControlButton_1']").type("Acute{enter}");
cy.get("[data-cy='categoricalSelector_2']").type("Hearing{enter}");



// D. Assert that next page nav and button are enabled for download page
cy.assertNextPageAccess("download", true);

Expand All @@ -138,6 +143,10 @@ describe("End to end test using a simple UI path through the app", () => {
cy.readFile('cypress/downloads/' + folderStateAfter[folderStateAfter.length - 1]).then((fileContent) => {
expect(fileContent.group.Annotations.Levels.HC.Label).to.eq("Healthy Control");
expect(fileContent.group.Annotations.Levels.HC.TermURL).to.eq("ncit:C94342");
expect(fileContent.iq.Annotations.IsAbout.Label).to.eq("Assessment tool");
expect(fileContent.iq.Annotations.IsAbout.TermURL).to.eq("nb:Assessment");
expect(fileContent.iq.Annotations.IsPartOf.Label).to.eq("MOCA");
expect(fileContent.iq.Annotations.IsPartOf.TermURL).to.eq("cogAtlas:MOCA");
});
});

Expand Down
51 changes: 51 additions & 0 deletions cypress/unit/store-getter-getAssessmentToolJSONOutput.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { getters } from "~/store";

let store = {

getters: getters,

state: {
dataDictionary: {
annotated: {
column1: {
Description: "Some cool description here.",
missingValues: ["Missing"]
}
}
},
toolTerms: [
{
label: "MOCA",
identifier: "cogAtlas:MOCA",
selected: false
}
],
columnToToolMap: {
column1: "cogAtlas:MOCA"
}

}
};

describe("getAssessmentToolJSONOutput", () => {

it("Make sure Assessment tool json output is schema compliant", () => {

const output = store.getters.getAssessmentToolJSONOutput(store.state)("column1");
expect(output).to.deep.equal(
{
Annotations: {
IsAbout: {
"TermURL": "nb:Assessment",
"Label": "Assessment tool"
},
"IsPartOf": {
"TermURL": "cogAtlas:MOCA",
"Label": "MOCA"
},
MissingValues: ["Missing"]
},
Description: "Some cool description here."
});
});
});
43 changes: 43 additions & 0 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,44 @@ export const getters = {
return p_state.categories[p_category].componentName;
},

getAssessmentToolJSONOutput: (p_state) => (p_columnName) => {
const annotatedDictColumn = p_state.dataDictionary.annotated[p_columnName];
const formattedOutput = {
Annotations: {
IsAbout: {
TermURL: "nb:Assessment",
Label: "Assessment tool"
},
IsPartOf: {
TermURL: "",
Label: ""
},
MissingValues: []
}
};
const tool = p_state.columnToToolMap[p_columnName];

p_state.toolTerms.forEach(term => {
if ( term.identifier === tool ) {
formattedOutput.Annotations.IsPartOf.Label = term.label;
formattedOutput.Annotations.IsPartOf.TermURL = term.identifier;
}
});

// Add existing keys from user provided dictionary
Object.keys(annotatedDictColumn).forEach(columnEntry => {

if ( "missingValues" !== columnEntry && "valueMap" !== columnEntry ) {

formattedOutput[columnEntry] = annotatedDictColumn[columnEntry];
}
});

formattedOutput.Annotations.MissingValues = annotatedDictColumn.missingValues;

return formattedOutput;
},

getCategoricalJsonOutput: (p_state) => (p_columnName) => {

// 0. Initialize output object
Expand Down Expand Up @@ -456,6 +494,11 @@ export const getters = {
Identifies: "participant"
}
};
break;

case "annot-tool-groups":
columnOutput = p_getters.getAssessmentToolJSONOutput(columnName);
break;
}

}
Expand Down

0 comments on commit 9536598

Please sign in to comment.