generated from linkml/linkml-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2332 from microbiomedata/2330_metabolomics_category
Add slot and enumeration to `MetabolomicsAnalysis` and implements migrator
- Loading branch information
Showing
20 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from nmdc_schema.migrators.migrator_base import MigratorBase | ||
|
||
|
||
class Migrator(MigratorBase): | ||
r"""Migrates a database between two schemas.""" | ||
|
||
_from_version = "11.3.0" | ||
_to_version = "11.4.0" | ||
|
||
def upgrade(self): | ||
r"""Migrates the database from conforming to the original schema, to conforming to the new schema.""" | ||
|
||
self.adapter.process_each_document("workflow_execution_set", [self.set_metab_analysis_category]) | ||
|
||
def set_metab_analysis_category(self, workflow: dict) -> dict: | ||
r""" | ||
If the workflow execution record is of the type "nmdc:MetabolomicsAnalysis" and it has a `has_metabolite_identifications` field, | ||
add field `metabolomics_analysis_category` and assign it the value "gc_ms_metabolomics". If the record does not | ||
have a `has_metabolite_identifications` field, it is assigned the value "lc_ms_lipidomics". | ||
>>> m = Migrator() | ||
>>> m.set_metab_analysis_category({'id': 123, 'type': 'nmdc:MetabolomicsAnalysis', 'has_metabolite_identifications': []}) | ||
{'id': 123, 'type': 'nmdc:MetabolomicsAnalysis', 'has_metabolite_identifications': [], 'metabolomics_analysis_category': 'gc_ms_metabolomics'} | ||
>>> m.set_metab_analysis_category({'id': 123, 'type': 'nmdc:MetabolomicsAnalysis'}) # does not have has_metabolite_identifications field, therefore it's a lipid analysis | ||
{'id': 123, 'type': 'nmdc:MetabolomicsAnalysis', 'metabolomics_analysis_category': 'lc_ms_lipidomics'} | ||
>>> m.set_metab_analysis_category({'id': 123, 'type': 'nmdc:Metaproteomics'}) # not a metabolomics analysis | ||
{'id': 123, 'type': 'nmdc:Metaproteomics'} | ||
""" | ||
|
||
if workflow["type"] == "nmdc:MetabolomicsAnalysis": | ||
if "has_metabolite_identifications" in workflow: | ||
workflow["metabolomics_analysis_category"] = "gc_ms_metabolomics" | ||
else: | ||
workflow["metabolomics_analysis_category"] = "lc_ms_lipidomics" | ||
return workflow |
16 changes: 16 additions & 0 deletions
16
src/data/invalid/Database-MetabolomicsAnalysis-no_metabolomics_category.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# this example is invalid because the records in the workflow execution set do not have a metabolomics_analysis_category value | ||
workflow_execution_set: | ||
- id: nmdc:wfmb-99-ABCDEF.1 | ||
name: Metabolomics Analysis Activity for nmdc:wfmb-99-ABCDEF.1 | ||
started_at_time: '2021-08-05T14:48:51+00:00' | ||
ended_at_time: '2021-09-15T10:13:20+00:00' | ||
execution_resource: NERSC-Cori | ||
was_informed_by: nmdc:dgms-11-djad84 | ||
git_url: https://example.org/WorkflowExecutionActivity | ||
has_input: | ||
- nmdc:dobj-99-xxxxxx1 | ||
- nmdc:dobj-99-xxxxxx2 | ||
has_output: | ||
- nmdc:dobj-99-xxxxxx3 | ||
- nmdc:dobj-99-xxxxxx4 | ||
type: nmdc:MetabolomicsAnalysis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters