From 19db1ba3f63ed9e240043982a7e9e5da7eb6caad Mon Sep 17 00:00:00 2001 From: Josef Hardi Date: Thu, 2 May 2024 17:05:44 -0700 Subject: [PATCH] Include the organ partonomy and not just the class hierarchy --- src/enrichment/enrich-2d-ftu.js | 49 ++++++++++++------------------ src/enrichment/enrich-landmark.js | 23 ++++++-------- src/enrichment/enrich-ref-organ.js | 34 ++++++++------------- 3 files changed, 42 insertions(+), 64 deletions(-) diff --git a/src/enrichment/enrich-2d-ftu.js b/src/enrichment/enrich-2d-ftu.js index 8808e29..89987a7 100644 --- a/src/enrichment/enrich-2d-ftu.js +++ b/src/enrichment/enrich-2d-ftu.js @@ -3,15 +3,17 @@ import { resolve } from 'path'; import { error, header, info, more } from '../utils/logging.js'; import { convert, filter, merge, query } from '../utils/robot.js'; import { throwOnError } from '../utils/sh-exec.js'; -import { - cleanTemporaryFiles, +import { + cleanTemporaryFiles, convertNormalizedMetadataToRdf, convertNormalizedDataToOwl, isFileEmpty, collectEntities, extractClassHierarchy, + extractOntologySubset, excludeTerms, - logOutput + logOutput, + push } from './utils.js'; export function enrich2dFtuMetadata(context) { @@ -29,50 +31,39 @@ export function enrich2dFtuData(context) { const normalizedPath = resolve(obj.path, 'normalized/normalized.yaml'); const baseInputPath = resolve(obj.path, 'enriched/base-input.ttl'); convertNormalizedDataToOwl(context, normalizedPath, baseInputPath); - logOutput(baseInputPath); let inputPaths = []; // variable to hold input files for merging const enrichedWithOntologyPath = resolve(obj.path, 'enriched/enriched-with-ontology.owl'); - inputPaths.push(baseInputPath); // Set the enriched path as the initial - - info('Getting concept details from reference ontologies...') - const uberonEntitiesPath = collectEntities(context, 'uberon', baseInputPath); - if (!isFileEmpty(uberonEntitiesPath)) { - info('Extracting UBERON.'); - const uberonExtractPath = extractClassHierarchy( - context, - 'uberon', - 'http://purl.obolibrary.org/obo/UBERON_0001062', - uberonEntitiesPath - ); - logOutput(uberonExtractPath); - inputPaths.push(uberonExtractPath); - } + push(inputPaths, baseInputPath); // Set the enriched path as the initial + push(inputPaths, extractOntologySubset( + context, 'uberon', baseInputPath, + ["BFO:0000050", "RO:0001025"] // part of, located in + )); const fmaEntitiesPath = collectEntities(context, 'fma', baseInputPath); if (!isFileEmpty(fmaEntitiesPath)) { info('Extracting FMA.'); const fmaExtractPath = extractClassHierarchy( - context, - 'fma', - 'http://purl.org/sig/ont/fma/fma62955', + context, + 'fma', + 'http://purl.org/sig/ont/fma/fma62955', fmaEntitiesPath); logOutput(fmaExtractPath); - inputPaths.push(fmaExtractPath); + push(inputPaths, fmaExtractPath); } const clEntitiesPath = collectEntities(context, 'cl', baseInputPath); if (!isFileEmpty(clEntitiesPath)) { info('Extracting CL.'); const clExtractPath = extractClassHierarchy( - context, - 'cl', - 'http://purl.obolibrary.org/obo/CL_0000000', + context, + 'cl', + 'http://purl.obolibrary.org/obo/CL_0000000', clEntitiesPath); logOutput(clExtractPath); - inputPaths.push(clExtractPath); + push(inputPaths, clExtractPath); } const pclEntitiesPath = collectEntities(context, 'pcl', baseInputPath); @@ -85,7 +76,7 @@ export function enrich2dFtuData(context) { pclEntitiesPath ); logOutput(pclExtractPath); - inputPaths.push(pclExtractPath); + push(inputPaths, pclExtractPath); } info('Merging files:'); @@ -109,7 +100,7 @@ export function enrich2dFtuData(context) { // Clean up info('Cleaning up temporary files...'); cleanTemporaryFiles(context); - more("Done.") + info('Done.'); } } diff --git a/src/enrichment/enrich-landmark.js b/src/enrichment/enrich-landmark.js index 86b9b54..6f4bc3f 100644 --- a/src/enrichment/enrich-landmark.js +++ b/src/enrichment/enrich-landmark.js @@ -7,8 +7,10 @@ import { convertNormalizedDataToOwl, convertNormalizedMetadataToRdf, extractClassHierarchy, + extractOntologySubset, isFileEmpty, logOutput, + push } from './utils.js'; export function enrichLandmarkMetadata(context) { @@ -33,21 +35,13 @@ export function enrichLandmarkData(context) { const enrichedWithOntologyPath = resolve(obj.path, 'enriched/enriched-with-ontology.owl'); - inputPaths.push(baseInputPath); // Set the enriched path as the initial + push(inputPaths, baseInputPath); // Set the enriched path as the initial info('Getting concept details from reference ontologies...'); - const uberonEntitiesPath = collectEntities(context, 'uberon', baseInputPath); - if (!isFileEmpty(uberonEntitiesPath)) { - info('Extracting UBERON.'); - const uberonExtractPath = extractClassHierarchy( - context, - 'uberon', - 'http://purl.obolibrary.org/obo/UBERON_0001062', - uberonEntitiesPath - ); - logOutput(uberonExtractPath); - inputPaths.push(uberonExtractPath); - } + push(inputPaths, extractOntologySubset( + context, 'uberon', baseInputPath, + ["BFO:0000050", "RO:0001025"] // part of, located in + )); const fmaEntitiesPath = collectEntities(context, 'fma', baseInputPath); if (!isFileEmpty(fmaEntitiesPath)) { @@ -59,7 +53,7 @@ export function enrichLandmarkData(context) { fmaEntitiesPath ); logOutput(fmaExtractPath); - inputPaths.push(fmaExtractPath); + push(inputPaths, fmaExtractPath); } info(`Creating landmark: ${enrichedPath}`); @@ -70,5 +64,6 @@ export function enrichLandmarkData(context) { // Clean up info('Cleaning up temporary files.'); cleanTemporaryFiles(context); + info('Done.'); } } diff --git a/src/enrichment/enrich-ref-organ.js b/src/enrichment/enrich-ref-organ.js index dbb0342..edd6925 100644 --- a/src/enrichment/enrich-ref-organ.js +++ b/src/enrichment/enrich-ref-organ.js @@ -10,8 +10,10 @@ import { isFileEmpty, collectEntities, extractClassHierarchy, + extractOntologySubset, excludeTerms, - logOutput + logOutput, + push } from './utils.js'; export function enrichRefOrganMetadata(context) { @@ -24,7 +26,6 @@ export function enrichRefOrganMetadata(context) { export function enrichRefOrganData(context) { try { const { selectedDigitalObject: obj } = context; - const normalizedPath = resolve(obj.path, 'normalized/normalized.yaml'); const ontologyPath = resolve(obj.path, 'enriched/ontology.ttl'); const baseInputPath = resolve(obj.path, 'enriched/base-input.ttl'); @@ -35,32 +36,22 @@ export function enrichRefOrganData(context) { const enrichedWithOntologyPath = resolve(obj.path, 'enriched/enriched-with-ontology.owl'); - inputPaths.push(baseInputPath); // Set the enriched path as the initial - - info('Getting concept details from reference ontologies...') - const uberonEntitiesPath = collectEntities(context, 'uberon', baseInputPath); - if (!isFileEmpty(uberonEntitiesPath)) { - info('Extracting UBERON.'); - const uberonExtractPath = extractClassHierarchy( - context, - 'uberon', - 'http://purl.obolibrary.org/obo/UBERON_0001062', - uberonEntitiesPath - ); - logOutput(uberonExtractPath); - inputPaths.push(uberonExtractPath); - } + push(inputPaths, baseInputPath); // Set the enriched path as the initial + push(inputPaths, extractOntologySubset( + context, 'uberon', baseInputPath, + ["BFO:0000050", "RO:0001025"] // part of, located in + )); const fmaEntitiesPath = collectEntities(context, 'fma', baseInputPath); if (!isFileEmpty(fmaEntitiesPath)) { info('Extracting FMA.'); const fmaExtractPath = extractClassHierarchy( - context, - 'fma', - 'http://purl.org/sig/ont/fma/fma62955', + context, + 'fma', + 'http://purl.org/sig/ont/fma/fma62955', fmaEntitiesPath); logOutput(fmaExtractPath); - inputPaths.push(fmaExtractPath); + push(inputPaths, fmaExtractPath); } info('Merging files:'); @@ -83,5 +74,6 @@ export function enrichRefOrganData(context) { // Clean up info('Cleaning up temporary files.'); cleanTemporaryFiles(context); + info('Done.'); } }