Skip to content

Commit

Permalink
wip: dispatching different queries for different techniques
Browse files Browse the repository at this point in the history
  • Loading branch information
apdavison committed Mar 6, 2024
1 parent eac7e30 commit 3ba1655
Show file tree
Hide file tree
Showing 3 changed files with 254 additions and 245 deletions.
234 changes: 12 additions & 222 deletions apps/nar-v3/src/routes/dataset.jsx
Original file line number Diff line number Diff line change
@@ -1,236 +1,26 @@
import React from "react";
import { Await, defer, useLoaderData } from "react-router-dom";

import {
buildKGQuery,
simpleProperty as S,
linkProperty as L,
reverseLinkProperty as R,
} from "../queries";
import { datastore } from "../datastore";
import { uuidFromUri } from "../utility.js";
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"),
];

const quantValQuery = [
S("value"),
S("minValue"),
S("maxValue"),
L("unit/name"),
L("minValueUnit/name"),
L("maxValueUnit/name"),
];

const solutionQuery = [
S("name"),
S("@id"),
L(
"hasPart",
[L("amount", quantValQuery), L("chemicalProduct", [S("name"), S("@id"), S("@type")])],
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"),
S("fullName"),
S("description"),
S("shortName"),
S("versionIdentifier"),
L("ethicsAssessment/name"),
L("license/shortName"),
S("releaseDate"),
L("technique/name", [], MULTIPLE),
L("custodian", actorQuery, MULTIPLE),
L("author", actorQuery, MULTIPLE),
R("isVersionOf", "hasVersion", [
S("fullName"),
S("description"),
S("shortName"),
L("custodian", actorQuery, MULTIPLE),
L("author", actorQuery, MULTIPLE),
]),
L(
"studiedSpecimen",
[
S("lookupLabel"),
L("species", [S("name"), L("species/name")]),
L("biologicalSex/name"),
L(
"studiedState",
[
S("lookupLabel"),
L("age", quantValQuery),
L("ageCategory/name"),
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("value"), 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")], MULTIPLE),
L("type/name"),
]),
R(
"cellPatching",
"input",
[
S("lookupLabel"),
S("@type"),
L(
"device",
[
// device usage
S("lookupLabel"),
deviceQuery,
L("pipetteSolution", solutionQuery),
L("sealResistance", [L("value", quantValQuery, MULTIPLE)]),
L("seriesResistance", [L("value", quantValQuery, MULTIPLE)]),
L("holdingPotential", [L("value", quantValQuery, MULTIPLE)]),
],
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("anatomicalLocation", [S("name"), S("@type")], MULTIPLE),
L("type/name"),
]),
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"),
S("description"),
L("epoch", quantValQuery),
S("internalIdentifier"),
L("specification", [S("lookupLabel"), S("configuration")]),
],
MULTIPLE
),
],
{
type: "stimulation/StimulationActivity",
expectSingle: false,
}
),
],
MULTIPLE
),
],
MULTIPLE
),
],
MULTIPLE
),
],
MULTIPLE
),
],
MULTIPLE
),
],
{ type: "core/Subject", expectSingle: false }
),
]);
import { patchClampDatasetQuery, techniquesQuery } from "./queryLibrary";

export async function loader({ params }) {
const datasetPromise = datastore.getKGItem("datasets detail", query, params.datasetId);
const techniques = await datastore.getKGItem(
"dataset techniques",
techniquesQuery,
params.datasetId
);
console.log(techniques);
const datasetPromise = datastore.getKGItem(
"dataset detail",
patchClampDatasetQuery,
params.datasetId
);
console.log(datasetPromise);
return defer({ dataset: datasetPromise });
}
Expand Down
25 changes: 2 additions & 23 deletions apps/nar-v3/src/routes/datasets.jsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
import React from "react";
import { Await, defer, useLoaderData } from "react-router-dom";

import {
buildKGQuery,
simpleProperty as S,
linkProperty as L,
reverseLinkProperty as R,
} from "../queries";
import { datastore } from "../datastore";
import Navigation from "../components/Navigation";
import DatasetList from "../components/DatasetList";
import ProgressIndicator from "../components/ProgressIndicator";

const MULTIPLE = { expectSingle: false };

const query = buildKGQuery("core/DatasetVersion", [
S("@id"),
S("fullName"),
S("description"),
S("shortName"),
S("versionIdentifier"),
R("isVersionOf", "hasVersion", [S("fullName"), S("description"), S("shortName")]),
L("accessibility/name", [], { filter: "free access", required: true }),
L("experimentalApproach/name", [], { filter: "electrophysiology", required: true }),
L("technique/name", [], MULTIPLE),
L("studiedSpecimen", [S("lookupLabel")], { type: "core/Subject", expectSingle: false }),
R("activities", "isPartOf", [S("@id"), S("@type")], MULTIPLE),
]);
import { ephysDatasetsQuery } from "./queryLibrary";

export async function loader() {
const datasetsPromise = datastore.getKGData("datasets summary", query);
const datasetsPromise = datastore.getKGData("datasets summary", ephysDatasetsQuery);
console.log(datasetsPromise);
return defer({ datasets: datasetsPromise });
}
Expand Down
Loading

0 comments on commit 3ba1655

Please sign in to comment.