From 9980ee43ca95b975c5912dfb1c944d846fa3852c Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Tue, 5 Mar 2024 13:13:25 +0100 Subject: [PATCH] wip --- apps/nar-v3/src/components/DatasetCard.jsx | 28 +-- apps/nar-v3/src/datastore.js | 11 +- apps/nar-v3/src/globals.js | 1 + apps/nar-v3/src/routes/dataset.jsx | 195 ++++++++++++++++++--- 4 files changed, 196 insertions(+), 39 deletions(-) diff --git a/apps/nar-v3/src/components/DatasetCard.jsx b/apps/nar-v3/src/components/DatasetCard.jsx index 372cb86..4b2f962 100644 --- a/apps/nar-v3/src/components/DatasetCard.jsx +++ b/apps/nar-v3/src/components/DatasetCard.jsx @@ -132,7 +132,7 @@ function SubjectCard(props) {
{subject.studiedState[0].ageCategory}
Pathologies
- {subject.studiedState[0].pathology + {subject.studiedState[0].pathology.length > 0 ? subject.studiedState[0].pathology[0].name : "none"}
@@ -161,15 +161,15 @@ function SlicePreparationCard(props) {

{activity.label}

Device name
-
{activity.deviceUsage[0].device.name}
+
{activity.device[0].device.name}
Device type
-
{activity.deviceUsage[0].device.deviceType.name}
+
{activity.device[0].device.deviceType.name}
Manufacturer
-
{activity.deviceUsage[0].device.manufacturer.fullName}
+
{activity.device[0].device.manufacturer.fullName}
Slice thickness
-
{formatQuant(activity.deviceUsage[0].sliceThickness)}
+
{formatQuant(activity.device[0].sliceThickness)}
Slicing plane
-
{activity.deviceUsage[0].slicingPlane.name}
+
{activity.device[0].slicingPlane.name}
Study targets
{activity.studyTargets.map((item) => item.name).join(", ")}
Temperature
@@ -243,26 +243,26 @@ function CellPatchingCard(props) {
Electrode description
-
{activity.deviceUsage[0].device.description}
- {/* activity.deviceUsage[0].device.deviceType.name */} - {/* activity.deviceUsage[0].device.manufacturer.fullName */} +
{activity.device[0].device.description}
+ {/* activity.device[0].device.deviceType.name */} + {/* activity.device[0].device.manufacturer.fullName */}
Pipette solution (more details to come)
-
{activity.deviceUsage[0].pipetteSolution.name}
+
{activity.device[0].pipetteSolution.name}
Seal resistance
- {activity.deviceUsage[0].sealResistance.values + {activity.device[0].sealResistance.values .map((item) => formatQuant(item)) .join(", ")}
Series resistance
- {activity.deviceUsage[0].seriesResistance.values + {activity.device[0].seriesResistance.values .map((item) => formatQuant(item)) .join(", ")}
Holding potential
- {activity.deviceUsage[0].holdingPotential.values + {activity.device[0].holdingPotential.values .map((item) => formatQuant(item)) .join(", ")}
@@ -444,7 +444,7 @@ function DatasetCard(props) { const getSlices = (subjectIndex) => { const slicePrep = getSlicePreparation(subjectIndex); if (slicePrep) { - return slicePrep.slices; + return slicePrep.output; } else { return null; } diff --git a/apps/nar-v3/src/datastore.js b/apps/nar-v3/src/datastore.js index adacb23..e54cf8f 100644 --- a/apps/nar-v3/src/datastore.js +++ b/apps/nar-v3/src/datastore.js @@ -1,4 +1,4 @@ -import { kgUrl } from "./globals"; +import { kgUrl, kgDefaultStage } from "./globals"; import { buildKGQuery, simpleProperty as S, linkProperty as L, reverseLinkProperty as R } from "./queries"; import { uuidFromUri } from "./utility.js"; import examplePatchClampData from "./example_data/example_patch_clamp_dataset.json"; @@ -31,7 +31,8 @@ class DataStore { "patch clamp recordings summary": {}, "patch clamp recordings detail": {} }; - this.cache["datasets detail"][uuidFromUri(examplePatchClampData["@id"])] = examplePatchClampData; + //this.cache["datasets detail"][uuidFromUri(examplePatchClampData["@id"])] = examplePatchClampData; + this.cache["datasets detail"]["example"] = examplePatchClampData; } buildRequestConfig(method="GET", body={}) { @@ -58,7 +59,7 @@ class DataStore { return result; } - async getKGItem(cacheLabel, kgQuery, instanceId, stage = "RELEASED") { + async getKGItem(cacheLabel, kgQuery, instanceId, stage = kgDefaultStage) { console.log("getKGItem " + cacheLabel + instanceId); if (!this.cache[cacheLabel][instanceId]) { const searchParams = {stage: stage, instanceId: instanceId}; @@ -69,7 +70,7 @@ class DataStore { return this.cache[cacheLabel][instanceId]; } - async getKGData(cacheLabel, kgQuery, searchFilters, stage = "RELEASED", size = 1000, from = 0) { + async getKGData(cacheLabel, kgQuery, searchFilters, stage = kgDefaultStage, size = 1000, from = 0) { console.log("getKGData " + cacheLabel); if (isEmpty(this.cache[cacheLabel])) { // if the cache is empty we need to fill it @@ -94,7 +95,7 @@ class DataStore { return itemArray } - async count(kgQuery, searchFilters, stage = "RELEASED") { + async count(kgQuery, searchFilters, stage = kgDefaultStage) { let searchParams = { returnTotalResults: true, stage: stage, diff --git a/apps/nar-v3/src/globals.js b/apps/nar-v3/src/globals.js index 47a78d9..02a99e0 100644 --- a/apps/nar-v3/src/globals.js +++ b/apps/nar-v3/src/globals.js @@ -1 +1,2 @@ export const kgUrl = "https://core.kg.ebrains.eu/v3"; +export const kgDefaultStage = "IN_PROGRESS"; \ No newline at end of file diff --git a/apps/nar-v3/src/routes/dataset.jsx b/apps/nar-v3/src/routes/dataset.jsx index 5944683..8aec68d 100644 --- a/apps/nar-v3/src/routes/dataset.jsx +++ b/apps/nar-v3/src/routes/dataset.jsx @@ -13,14 +13,40 @@ import Navigation from "../components/Navigation"; import DatasetCard from "../components/DatasetCard"; import ProgressIndicator from "../components/ProgressIndicator"; +const MULTIPLE = { expectSingle: false }; + const actorQuery = [ S("@id"), S("@type"), S("givenName"), S("familyName"), S("fullName"), - S("shortName") -] + S("shortName"), +]; + +const quantValQuery = [ + S("value"), + S("minValue"), + S("maxValue"), + L("unit/name"), + L("minValueUnit/name"), + L("maxValueUnit/name"), +]; + +const solutionQuery = [ + S("name"), + L("hasPart", [S("amount"), L("chemicalProduct/name")], MULTIPLE), +]; + +const deviceQuery = L("device", [ + S("lookupLabel"), + S("name"), + S("@type"), + S("internalIdentifier"), + S("description"), + L("deviceType/name"), + L("manufacturer", [S("shortName", S("longName"))]), +]); const query = buildKGQuery("core/DatasetVersion", [ S("@id"), @@ -31,40 +57,169 @@ const query = buildKGQuery("core/DatasetVersion", [ L("ethicsAssessment/name"), L("license/shortName"), S("releaseDate"), - L("custodian", actorQuery, { expectSingle: false }), - L("author", actorQuery, { expectSingle: false }), + L("custodian", actorQuery, MULTIPLE), + L("author", actorQuery, MULTIPLE), R("isVersionOf", "hasVersion", [ S("fullName"), S("description"), S("shortName"), - L("custodian", actorQuery, { expectSingle: false }), - L("author", actorQuery, { expectSingle: false }), + L("custodian", actorQuery, MULTIPLE), + L("author", actorQuery, MULTIPLE), ]), L( "studiedSpecimen", [ S("lookupLabel"), - L("species", [ - S("name"), - L("species/name") - ]), + L("species", [S("name"), L("species/name")]), L("biologicalSex/name"), L( "studiedState", [ S("lookupLabel"), - L("age", [ - S("value"), - S("minValue"), - S("maxValue"), - L("unit/name"), - L("minValueUnit/name"), - L("maxValueUnit/name"), - ]), + L("age", quantValQuery), L("ageCategory/name"), - L("pathology", [], { expectSingle: false }), + L("pathology", [S("name")], MULTIPLE), + R( + "slicePreparation", + "input", + [ + // slice preparation + S("lookupLabel"), + S("@type"), + L( + "device", + [ + // device usage + S("lookupLabel"), + deviceQuery, + L("sliceThickness", quantValQuery), + L("slicingPlane/name"), + ], + MULTIPLE + ), + L("studyTarget/name", [], MULTIPLE), + L("temperature", [S("name"), L("unit/name")]), + L("tissueBathSolution", solutionQuery), + L( + "output", + [ + // slices + S("lookupLabel"), + S("internalIdentifier"), + R("slice", "studiedState", [ + S("lookupLabel"), + S("@type"), + S("internalIdentifier"), + L("anatomicalLocation", [S("name"), S("@type")]), + L("type/name"), + ]), + R("cellPatching", "input", [ + S("lookupLabel"), + S("@type"), + L("device", [ + // device usage + S("lookupLabel"), + deviceQuery, + L("pipetteSolution", solutionQuery), + L("sealResistance", [ + L("values", quantValQuery, MULTIPLE), + ]), + L("seriesResistance", [ + L("values", quantValQuery, MULTIPLE), + ]), + L("holdingPotential", [ + L("values", quantValQuery, MULTIPLE), + ]), + ]), + L("tissueBathSolution", solutionQuery), + L("bathTemperature", quantValQuery), + S("description"), + L("variation/name"), + L("output", [ + // patched cells + S("lookupLabel"), + S("@type"), + R("cell", "studiedState", [ + S("internalIdentifier"), + L("type/name"), + L("anatomicalLocation/name", [], MULTIPLE), + ]), + R( + "recordingActivity", + "input", + [ + S("lookupLabel"), + S("@type"), + S("description"), + S("internalIdentifier"), + L("device", [ + R("metadata", "recordedWith", [ + S("name"), + S("additionalRemarks"), + L("samplingFrequency", quantValQuery), + L( + "channel", + [S("internalIdentifier"), L("unit/name")], + MULTIPLE + ), + ]), + ]), + L( + "output", + [ + S("@id"), + S("name"), + S("IRI"), + S("dataType/name"), + S("format/name"), + L( + "hash", + [S("algorithm"), S("digest")], + MULTIPLE + ), + L("storageSize", [S("value"), L("unit/name")]), + ], + MULTIPLE + ), + ], + { type: "ephys/RecordingActivity", expectSingle: false } + ), + R( + "stimulationActivity", + "input", + [ + S("lookupLabel"), + S("@type"), + L( + "stimulus", + [ + S("lookupLabel"), + S("@type"), + L("epoch", quantValQuery), + S("internalIdentifier"), + L("specification", [ + S("lookupLabel"), + S("configuration"), + ]), + ], + MULTIPLE + ), + ], + { + type: "stimulation/StimulationActivity", + expectSingle: false, + } + ), + ]), + ]), + ], + MULTIPLE + ), + ], + MULTIPLE + ), ], - { expectSingle: false } + MULTIPLE ), ], { type: "core/Subject", expectSingle: false }