Skip to content

Commit

Permalink
building up dataset query
Browse files Browse the repository at this point in the history
  • Loading branch information
apdavison committed Mar 4, 2024
1 parent 1a04e7d commit fb2ebbc
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 64 deletions.
34 changes: 18 additions & 16 deletions apps/nar-v3/src/components/DatasetCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function SubjectCard(props) {
)}
</Stack>
<Box sx={styles.entity} component={Paper} variant="outlined">
<h2>Subject {subject.label}</h2>
<h2>Subject {subject.lookupLabel}</h2>
<p>
({props.index + 1} of {props.subjects.length})
</p>
Expand All @@ -109,14 +109,14 @@ function SubjectCard(props) {
<dd>TO DO</dd>
<dt>Age</dt>
<dd>
<AgeDisplay age={subject.states[0].age} />
<AgeDisplay age={subject.studiedState[0].age} />
</dd>
<dt>Age category</dt>
<dd>{subject.states[0].ageCategory.name}</dd>
<dd>{subject.studiedState[0].ageCategory.name}</dd>
<dt>Pathologies</dt>
<dd>
{subject.states[0].pathologies[0]
? subject.states[0].pathologies[0].name
{subject.studiedState[0].pathologies[0]
? subject.studiedState[0].pathologies[0].name
: "none"}
</dd>
</dl>
Expand Down Expand Up @@ -343,11 +343,13 @@ function DataFileCard(props) {

function DatasetCard(props) {
const dataset = props.dataset;
const subjects = dataset.studiedSpecimen;

const [subjectIndex, _setSubjectIndex] = useState(0);
const [sliceIndex, _setSliceIndex] = useState(0);

const setSubjectIndex = (index) => {
if (index >= 0 && index < dataset.subjects.length) {
if (index >= 0 && index < subjects.length) {
_setSubjectIndex(index);
setSliceIndex(0);
}
Expand All @@ -357,7 +359,7 @@ function DatasetCard(props) {
if (
index >= 0 &&
index <
dataset.subjects[subjectIndex].states[0].slicePreparation[0].slices
subjects[subjectIndex].studiedState[0].slicePreparation[0].slices
.length
) {
_setSliceIndex(index);
Expand All @@ -379,15 +381,15 @@ function DatasetCard(props) {
</Link>
</h2>

{dataset.subjects ? (
{subjects ? (
<Stack
direction="column"
alignItems="center"
spacing={2}
sx={{ marginBottom: 5 }}
>
<SubjectCard
subjects={dataset.subjects}
subjects={subjects}
index={subjectIndex}
setIndex={setSubjectIndex}
/>
Expand All @@ -396,15 +398,15 @@ function DatasetCard(props) {

<SlicePreparationCard
activity={
dataset.subjects[subjectIndex].states[0].slicePreparation[0]
subjects[subjectIndex].studiedState[0].slicePreparation[0]
}
/>

<Connection />

<SliceCard
slices={
dataset.subjects[subjectIndex].states[0].slicePreparation[0]
subjects[subjectIndex].studiedState[0].slicePreparation[0]
.slices
}
index={sliceIndex}
Expand All @@ -415,7 +417,7 @@ function DatasetCard(props) {

<CellPatchingCard
activity={
dataset.subjects[subjectIndex].states[0].slicePreparation[0]
subjects[subjectIndex].studiedState[0].slicePreparation[0]
.slices[sliceIndex].cellPatching[0]
}
/>
Expand All @@ -424,7 +426,7 @@ function DatasetCard(props) {

<PatchedCellCard
cell={
dataset.subjects[subjectIndex].states[0].slicePreparation[0]
subjects[subjectIndex].studiedState[0].slicePreparation[0]
.slices[sliceIndex].cellPatching[0].patchedCells[0]
}
/>
Expand All @@ -433,12 +435,12 @@ function DatasetCard(props) {

<RecordingCard
recording={
dataset.subjects[subjectIndex].states[0].slicePreparation[0]
subjects[subjectIndex].studiedState[0].slicePreparation[0]
.slices[sliceIndex].cellPatching[0].patchedCells[0]
.recordingActivity[0]
}
stimulation={
dataset.subjects[subjectIndex].states[0].slicePreparation[0]
subjects[subjectIndex].studiedState[0].slicePreparation[0]
.slices[sliceIndex].cellPatching[0].patchedCells[0]
.stimulationActivity[0]
}
Expand All @@ -448,7 +450,7 @@ function DatasetCard(props) {

<DataFileCard
fileObj={
dataset.subjects[subjectIndex].states[0].slicePreparation[0]
subjects[subjectIndex].studiedState[0].slicePreparation[0]
.slices[sliceIndex].cellPatching[0].patchedCells[0]
.recordingActivity[0].files[0]
}
Expand Down
80 changes: 40 additions & 40 deletions apps/nar-v3/src/example_data/example_patch_clamp_dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"@type": [
"https://openminds.ebrains.eu/core/DatasetVersion"
],
"subjects": [
"studiedSpecimen": [
{
"label": "AD-Ctrl_s95",
"lookupLabel": "AD-Ctrl_s95",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "AD-Ctrl_s95-state01",
"lookupLabel": "AD-Ctrl_s95-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -1937,13 +1937,13 @@
]
},
{
"label": "AD-Ctrl_s86",
"lookupLabel": "AD-Ctrl_s86",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "AD-Ctrl_s86-state01",
"lookupLabel": "AD-Ctrl_s86-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -2947,13 +2947,13 @@
]
},
{
"label": "AD-Ctrl_s76",
"lookupLabel": "AD-Ctrl_s76",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "AD-Ctrl_s76-state01",
"lookupLabel": "AD-Ctrl_s76-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -4417,13 +4417,13 @@
]
},
{
"label": "AD-Ctrl_s75",
"lookupLabel": "AD-Ctrl_s75",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "AD-Ctrl_s75-state01",
"lookupLabel": "AD-Ctrl_s75-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -5197,13 +5197,13 @@
]
},
{
"label": "AD-Ctrl-s27",
"lookupLabel": "AD-Ctrl-s27",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "AD-Ctrl-s27-state01",
"lookupLabel": "AD-Ctrl-s27-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -5747,13 +5747,13 @@
]
},
{
"label": "AD-Ctrl-s31",
"lookupLabel": "AD-Ctrl-s31",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "AD-Ctrl-s31-state01",
"lookupLabel": "AD-Ctrl-s31-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -6987,13 +6987,13 @@
]
},
{
"label": "AD-Ctrl-s24",
"lookupLabel": "AD-Ctrl-s24",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "AD-Ctrl-s24-state01",
"lookupLabel": "AD-Ctrl-s24-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -8457,13 +8457,13 @@
]
},
{
"label": "APPPS_s96",
"lookupLabel": "APPPS_s96",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "APPPS_s96-state01",
"lookupLabel": "APPPS_s96-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -10161,13 +10161,13 @@
]
},
{
"label": "APPPS_s87",
"lookupLabel": "APPPS_s87",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "APPPS_s87-state01",
"lookupLabel": "APPPS_s87-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -12095,13 +12095,13 @@
]
},
{
"label": "APPPS_s77",
"lookupLabel": "APPPS_s77",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "APPPS_s77-state01",
"lookupLabel": "APPPS_s77-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -13799,13 +13799,13 @@
]
},
{
"label": "APPPS_s26",
"lookupLabel": "APPPS_s26",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "APPPS_s26-state01",
"lookupLabel": "APPPS_s26-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -14353,13 +14353,13 @@
]
},
{
"label": "APPPS_s22",
"lookupLabel": "APPPS_s22",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "APPPS_s22-state01",
"lookupLabel": "APPPS_s22-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down Expand Up @@ -15827,13 +15827,13 @@
]
},
{
"label": "APPPS_s23",
"lookupLabel": "APPPS_s23",
"@type": [
"https://openminds.ebrains.eu/core/Subject"
],
"states": [
"studiedState": [
{
"label": "APPPS_s23-state01",
"lookupLabel": "APPPS_s23-state01",
"@type": [
"https://openminds.ebrains.eu/core/SubjectState"
],
Expand Down
15 changes: 13 additions & 2 deletions apps/nar-v3/src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ function linkProperty(name, structure, options) {
const defaultOptions = {
expectSingle: true,
filter: "",
required: false
required: false,
type: null
}
const {expectSingle, filter, required} = {...defaultOptions, ...options}
const {expectSingle, filter, required, type} = {...defaultOptions, ...options}
let prop = simpleProperty(name);

if (expectSingle) {
Expand All @@ -70,6 +71,16 @@ function linkProperty(name, structure, options) {
if (structure && structure.length > 0) {
prop.structure = structure
}
if (type) {
if (typeof prop.path === 'string') {
prop.path = [{
"@id": prop.path
}]
}
prop.path[0].typeFilter = {
"@id": `https://openminds.ebrains.eu/${type}`
}
}
if (filter) {
prop.filter = {
op: "CONTAINS",
Expand Down
Loading

0 comments on commit fb2ebbc

Please sign in to comment.