Skip to content

Commit

Permalink
update scripts to work with multiple workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjinp committed Aug 20, 2019
1 parent eee74d1 commit 309bbd5
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 76 deletions.
117 changes: 71 additions & 46 deletions apps/search-poc/scripts/createStudio.js
Expand Up @@ -58,6 +58,22 @@ const nexus = createNexusClient({

async function main() {
try {
const ThalamusWorkspaceConfig = {
name: 'Thalamus2019 Workspace',
filters: {
brainRegion: 'http://purl.obolibrary.org/obo/UBERON_0004703',
},
};
const NeocortexWorkspaceConfig = {
name: 'SSCx 2019 Workspace',
filters: {
brainRegion: 'http://purl.obolibrary.org/obo/UBERON_0008933',
},
};
const BBPOverviewConfig = {
name: 'BBP Overview Workspace',
};

// await nexus.Organization.create(config.orgName);
// await nexus.Project.create(config.orgName, config.projectName, {
// description: 'a nice studio',
Expand All @@ -72,52 +88,61 @@ async function main() {
config.projectName,
studioContext,
);
// WARNING: We need to wait for the context resource to be indexed
const { '@id': emodelDashboardId } = await nexus.Resource.create(
config.orgName,
config.projectName,
emodelsCollectionDashboard,
);
const { '@id': morphoDashboardId } = await nexus.Resource.create(
config.orgName,
config.projectName,
morphologyCollectionDashboard,
);
const { '@id': circuitsDashboardId } = await nexus.Resource.create(
config.orgName,
config.projectName,
circuitsDashboard,
);
const {
'@id': simulationsCampaignDashboardId,
} = await nexus.Resource.create(
config.orgName,
config.projectName,
simulationsCampaignDashboard,
);
const {
'@id': modelCellCollectionDashboardId,
} = await nexus.Resource.create(
config.orgName,
config.projectName,
modelCellCollectionDashboard,
);
const { '@id': thalamus2019WorkspaceId } = await nexus.Resource.create(
config.orgName,
config.projectName,
generateWorkspaceResource('Thalamus2019 Workspace', [
[emodelDashboardId, 'nxv:StudioSparqlView'],
[morphoDashboardId, 'nxv:StudioSparqlView'],
[circuitsDashboardId, 'nxv:StudioSparqlView'],
[simulationsCampaignDashboardId, 'nxv:StudioSparqlView'],
[modelCellCollectionDashboardId, 'nxv:StudioSparqlView'],
]),
);
await nexus.Resource.create(
config.orgName,
config.projectName,
generateStudioResource([thalamus2019WorkspaceId]),
);

// Generate each workspace!
[
ThalamusWorkspaceConfig,
BBPOverviewConfig,
NeocortexWorkspaceConfig,
].forEach(async workspaceConfig => {
// WARNING: We need to wait for the context resource to be indexed
const { '@id': emodelDashboardId } = await nexus.Resource.create(
config.orgName,
config.projectName,
emodelsCollectionDashboard(workspaceConfig.filters),
);
const { '@id': morphoDashboardId } = await nexus.Resource.create(
config.orgName,
config.projectName,
morphologyCollectionDashboard(workspaceConfig.filters),
);
const { '@id': circuitsDashboardId } = await nexus.Resource.create(
config.orgName,
config.projectName,
circuitsDashboard(workspaceConfig.filters),
);
const {
'@id': simulationsCampaignDashboardId,
} = await nexus.Resource.create(
config.orgName,
config.projectName,
simulationsCampaignDashboard(workspaceConfig.filters),
);
const {
'@id': modelCellCollectionDashboardId,
} = await nexus.Resource.create(
config.orgName,
config.projectName,
modelCellCollectionDashboard(workspaceConfig.filters),
);
const { '@id': workspaceId } = await nexus.Resource.create(
config.orgName,
config.projectName,
generateWorkspaceResource(workspaceConfig.name, [
[emodelDashboardId, 'nxv:StudioSparqlView'],
[morphoDashboardId, 'nxv:StudioSparqlView'],
[circuitsDashboardId, 'nxv:StudioSparqlView'],
[simulationsCampaignDashboardId, 'nxv:StudioSparqlView'],
[modelCellCollectionDashboardId, 'nxv:StudioSparqlView'],
]),
);
await nexus.Resource.create(
config.orgName,
config.projectName,
generateStudioResource([workspaceId]),
);
});

console.log('Success!');
} catch (e) {
console.error('Script has crashed... \n', e);
Expand Down
135 changes: 105 additions & 30 deletions apps/search-poc/scripts/resources.js
@@ -1,4 +1,14 @@
const emodelDataQuery = `
export type Filters = {
brainRegion?: string,
[filterKey: string]: string,
};

/**
*
*
* @param {{ brainRegion?: string }} Filters
*/
const emodelDataQuery = filters => `
prefix nxs: <https://neuroshapes.org/>
prefix nxv: <https://bluebrain.github.io/nexus/vocabulary/>
prefix schema: <http://schema.org/>
Expand All @@ -9,8 +19,12 @@ SELECT ?total ?self ?name ?speciesLabel ?brainRegionLabel ?description ?strainLa
Graph ?g {
?s rdf:type nxs:EModelCollection
}
Graph ?g {
?s nxs:brainLocation / nxs:brainRegion <http://purl.obolibrary.org/obo/UBERON_0004703>
${
filters.brainRegion
? `Graph ?g {
?s nxs:brainLocation / nxs:brainRegion <${filters.brainRegion}>
}`
: ''
}
Graph ?g {
?s nxv:self ?self .
Expand Down Expand Up @@ -41,7 +55,12 @@ SELECT ?total ?self ?name ?speciesLabel ?brainRegionLabel ?description ?strainLa
}
`;

const morphologyDataQuery = `
/**
*
*
* @param {{ brainRegion?: string }} Filters
*/
const morphologyDataQuery = filters => `
prefix nxs: <https://neuroshapes.org/>
prefix nxv: <https://bluebrain.github.io/nexus/vocabulary/>
prefix schema: <http://schema.org/>
Expand All @@ -53,8 +72,12 @@ SELECT ?total ?self ?name ?speciesLabel ?brainRegionLabel ?description ?strainLa
Graph ?g {
?s rdf:type nxs:ReconstructedNeuronMorphologyCollection
}
Graph ?g {
?s nxs:brainLocation / nxs:brainRegion <http://purl.obolibrary.org/obo/UBERON_0004703>
${
filters.brainRegion
? `Graph ?g {
?s nxs:brainLocation / nxs:brainRegion <${filters.brainRegion}>
}`
: ''
}
?s nxv:self ?self .
OPTIONAL { ?s schema:name ?name }
Expand Down Expand Up @@ -84,7 +107,12 @@ SELECT ?total ?self ?name ?speciesLabel ?brainRegionLabel ?description ?strainLa
}
`;

const circuitsDataQuery = `
/**
*
*
* @param {{ brainRegion?: string }} Filters
*/
const circuitsDataQuery = filters => `
prefix nxs: <https://neuroshapes.org/>
prefix nxv: <https://bluebrain.github.io/nexus/vocabulary/>
prefix schema: <http://schema.org/>
Expand All @@ -95,8 +123,12 @@ SELECT ?total ?self ?name ?speciesLabel ?brainRegionLabel ?description ?strainLa
Graph ?g {
?s rdf:type nxs:detailedcircuit
}
Graph ?g {
?s nxs:brainLocation / nxs:brainRegion <http://purl.obolibrary.org/obo/UBERON_0004703>
${
filters.brainRegion
? `Graph ?g {
?s nxs:brainLocation / nxs:brainRegion <${filters.brainRegion}>
}`
: ''
}
Graph ?g {
?s nxv:self ?self .
Expand Down Expand Up @@ -127,7 +159,12 @@ SELECT ?total ?self ?name ?speciesLabel ?brainRegionLabel ?description ?strainLa
}
`;

const simulationsDataQuery = `
/**
*
*
* @param {{ brainRegion?: string }} Filters
*/
const simulationsDataQuery = filters => `
prefix nxs: <https://neuroshapes.org/>
prefix nxv: <https://bluebrain.github.io/nexus/vocabulary/>
prefix schema: <http://schema.org/>
Expand All @@ -138,8 +175,12 @@ SELECT ?total ?self ?name ?speciesLabel ?brainRegionLabel ?description ?strainLa
Graph ?g {
?s rdf:type nxs:simulation_campaign
}
Graph ?g {
?s nxs:brainLocation / nxs:brainRegion <http://purl.obolibrary.org/obo/UBERON_0004703>
${
filters.brainRegion
? `Graph ?g {
?s nxs:brainLocation / nxs:brainRegion <${filters.brainRegion}>
}`
: ''
}
Graph ?g {
?s nxv:self ?self .
Expand Down Expand Up @@ -170,7 +211,12 @@ SELECT ?total ?self ?name ?speciesLabel ?brainRegionLabel ?description ?strainLa
}
`;

const modelCellCollectionsDataQuery = `
/**
*
*
* @param {{ brainRegion?: string }} Filters
*/
const modelCellCollectionsDataQuery = filters => `
prefix nxs: <https://neuroshapes.org/>
prefix nxv: <https://bluebrain.github.io/nexus/vocabulary/>
prefix schema: <http://schema.org/>
Expand All @@ -181,8 +227,12 @@ SELECT ?total ?self ?name ?speciesLabel ?brainRegionLabel ?description ?strainLa
Graph ?g {
?s rdf:type nxs:ModelCellCollection
}
Graph ?g {
?s nxs:brainLocation / nxs:brainRegion <http://purl.obolibrary.org/obo/UBERON_0004703>
${
filters.brainRegion
? `Graph ?g {
?s nxs:brainLocation / nxs:brainRegion <${filters.brainRegion}>
}`
: ''
}
Graph ?g {
?s nxv:self ?self .
Expand Down Expand Up @@ -286,45 +336,70 @@ const studioContext = {
'@id': 'https://bluebrainnexus.io/studio/context',
};

const emodelsCollectionDashboard = {
/**
*
*
* @param {{ brainRegion?: string }} Filters
*/
const emodelsCollectionDashboard = filters => ({
'@context': 'https://bluebrainnexus.io/studio/context',
'@type': 'StudioDashboard',
label: 'E-models Dashboard',
description: 'e-models curation',
dataQuery: emodelDataQuery,
};
dataQuery: emodelDataQuery(filters),
});

const morphologyCollectionDashboard = {
/**
*
*
* @param {{ brainRegion?: string }} Filters
*/
const morphologyCollectionDashboard = filters => ({
'@context': 'https://bluebrainnexus.io/studio/context',
'@type': 'StudioDashboard',
label: 'Morphology Dashboard',
description: 'Morphology curation',
dataQuery: morphologyDataQuery,
};
dataQuery: morphologyDataQuery(filters),
});

const circuitsDashboard = {
/**
*
*
* @param {{ brainRegion?: string }} Filters
*/
const circuitsDashboard = filters => ({
'@context': 'https://bluebrainnexus.io/studio/context',
'@type': 'StudioDashboard',
label: 'Circuits Dashboard',
description: 'Circuits curation',
dataQuery: circuitsDataQuery,
};
dataQuery: circuitsDataQuery(filters),
});

const simulationsCampaignDashboard = {
/**
*
*
* @param {{ brainRegion?: string }} Filters
*/
const simulationsCampaignDashboard = filters => ({
'@context': 'https://bluebrainnexus.io/studio/context',
'@type': 'StudioDashboard',
label: 'Simulation Campaigns Dashboard',
description: 'Collections of simulations rolled into a campaign',
dataQuery: simulationsDataQuery,
};
dataQuery: simulationsDataQuery(filters),
});

const modelCellCollectionDashboard = {
/**
*
*
* @param {{ brainRegion?: string }} Filters
*/
const modelCellCollectionDashboard = filters => ({
'@context': 'https://bluebrainnexus.io/studio/context',
'@type': 'StudioDashboard',
label: 'ME-Model Curation Dashboard',
description: 'ME model cell collections',
dataQuery: modelCellCollectionsDataQuery,
};
dataQuery: modelCellCollectionsDataQuery(filters),
});

module.exports = {
generateStudioResource,
Expand Down

0 comments on commit 309bbd5

Please sign in to comment.