forked from microbiomedata/nmdc-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[POST-berkeley
-MERGER] Update FunctionalAnnotationAggMember
class for compatibility with MetaP Aggregation tables
#242
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
16fa4f2
Change metagenom_annotation_id slot to was_generated_by on Functional…
kheal 7124ec7
Make was_generated_by requiured on FunctionalAnnotationAggMember thro…
kheal c1fc821
Add migrator for FunctionalAnnotationAggMember slot move
kheal d112ce6
Move count requirement from slot to rule
kheal 6f4e151
Fix rule on FunctionalAnnotationAggMember
kheal 38c708d
Add invalid example to test rule on FunctionalAnnotationAggMember
kheal e56667e
Remove count rule from FunctionalAnnotationAggMember, leaving require…
kheal ccffe4a
Update tests
kheal 6d00c76
Merge branch 'main' into 1253_metap_aggtable
kheal 737e626
Update metatranscriptome functional aggregation example
kheal 2671984
Fix count slot requirement
kheal 02f993a
Fix typo in nmdc.yaml
kheal cae9ef8
Merge main into 1253 branch
kheal eb083d9
Add unique_keys to FunctionalAnnotationAggMember
kheal 6256e3d
Add unique_keys to FunctionalAnnotationAggMember
kheal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,32 @@ | ||
from nmdc_schema.migrators.migrator_base import MigratorBase | ||
|
||
|
||
class Migrator(MigratorBase): | ||
r"""Migrates a database between two schemas.""" | ||
|
||
_from_version = "XX" | ||
_to_version = "XX" # PR242 | ||
|
||
def upgrade(self): | ||
r"""Migrates the database from conforming to the original schema, to conforming to the new schema.""" | ||
|
||
self.adapter.process_each_document( | ||
"functional_annotation_agg", [self.move_metagenome_id_to_was_generated_by] | ||
) | ||
|
||
def move_metagenome_id_to_was_generated_by(self, fun_agg: dict) -> dict: | ||
r""" | ||
Updates the `FunctionalAnnotationAggMember` records so the value originally in its `metagenome_annotation_id` field | ||
is stored in a new field named `was_generated_by`; and removes the `metagenome_annotation_id` field. | ||
|
||
`metagenome_annotation_id` is required on these records and has the same value as `was_generated_by` in the new schema, | ||
so no data is lost in this migration nor do we need to check for the existence of the field. | ||
|
||
>>> m = Migrator() | ||
>>> m.move_metagenome_id_to_was_generated_by({'id': 123, 'metagenome_annotation_id': 'mgm123', 'count': 1}) | ||
{'id': 123, 'count': 1, 'was_generated_by': 'mgm123'} | ||
|
||
""" | ||
self.logger.info(f"Migrating Extraction: {fun_agg['id']}") | ||
fun_agg["was_generated_by"] = fun_agg.pop("metagenome_annotation_id") | ||
return fun_agg |
4 changes: 4 additions & 0 deletions
4
src/data/invalid/FunctionalAnnotationAggMember-invalid-no_count.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,4 @@ | ||
# This example is invalid because the count field is and it is required. | ||
type: nmdc:FunctionalAnnotationAggMember | ||
was_generated_by: nmdc:wfmgan-99-123456.1 | ||
gene_function_id: KEGG.ORTHOLOGY:K00627 |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
functional_annotation_agg: | ||
- metagenome_annotation_id: nmdc:wfmgan-99-123456.1 | ||
- was_generated_by: nmdc:wfmgan-99-123456.1 | ||
gene_function_id: KEGG.ORTHOLOGY:K00627 | ||
count: 120 | ||
type: nmdc:FunctionalAnnotationAggMember |
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
2 changes: 1 addition & 1 deletion
2
src/data/valid/FunctionalAnnotationAggMember-metatranscriptome.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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
metagenome_annotation_id: nmdc:wfmgan-99-123456.1 | ||
was_generated_by: nmdc:wfmgan-99-123456.1 | ||
gene_function_id: KEGG.ORTHOLOGY:K00627 | ||
count: 120 | ||
type: nmdc:FunctionalAnnotationAggMember |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leaving a note here to make sure @turbomam or @sierra-moxon review this use of unique_keys (in response to microbiomedata#2155)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we discussed this at all? @kheal do you still want to discuss the use of
unique_keys
even though the PR is closed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved this PR to the nmdc-schema repo: microbiomedata#2203. I'd appreciate input on the
unique_keys
use there.