-
Notifications
You must be signed in to change notification settings - Fork 45
Add year to cxgn time ontology #6100
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
Open
ktmeaton
wants to merge
6
commits into
solgenomics:master
Choose a base branch
from
BFF-AFIRMS:topic/add-time-ontology-year
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ac335dd
Add year to cxgn time ontology
ktmeaton 2055101
update expected trait count for brapi phenotyping test
ktmeaton 4a2e663
fix ontology definition and raise time root to 5000
ktmeaton 44e9b49
update conf to have new time in years ontology root
ktmeaton 708f016
add time in years to composable cvs
ktmeaton be88e1d
update compose trait to use new time in years accession
ktmeaton 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 hidden or 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,95 @@ | ||
| #!/usr/bin/env perl | ||
|
|
||
| =head1 NAME | ||
|
|
||
| AddTimeOntologyYear.pm | ||
|
|
||
| =head1 SYNOPSIS | ||
|
|
||
| mx-run AddTimeOntologyYear [options] [-F] | ||
|
|
||
| this is a subclass of L<CXGN::Metadata::Dbpatch> | ||
| see the perldoc of parent class for more details. | ||
|
|
||
| =head1 DESCRIPTION | ||
|
|
||
| This patch: | ||
| - Adds new cvterm for time ontology: year | ||
|
|
||
| =head1 AUTHOR | ||
|
|
||
| Katherine Eaton | ||
|
|
||
| =head1 COPYRIGHT & LICENSE | ||
|
|
||
| Copyright 2026 University of Alberta | ||
|
|
||
| This program is free software; you can redistribute it and/or modify | ||
| it under the same terms as Perl itself. | ||
|
|
||
| =cut | ||
|
|
||
| package AddTimeOntologyYear; | ||
|
|
||
| use Moose; | ||
| use Bio::Chado::Schema; | ||
| use SGN::Model::Cvterm; | ||
| extends 'CXGN::Metadata::Dbpatch'; | ||
|
|
||
| has '+description' => ( default => <<'' ); | ||
| Adds new cvterm for time ontology age in years: year 1-100. | ||
|
|
||
| sub patch { | ||
| my $self=shift; | ||
|
|
||
| print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " ."; | ||
|
|
||
| print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n"; | ||
|
|
||
| print STDOUT "\nExecuting the SQL commands.\n"; | ||
| my $schema = Bio::Chado::Schema->connect( sub { $self->dbh->clone } ); | ||
|
|
||
| print STDERR "INSERTING CV TERMS...\n"; | ||
| my $is_a_cvterm_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'is_a', 'relationship')->cvterm_id(); | ||
| my $time_ontology_rs = $schema->resultset("Cv::Cvterm")->find({name => "Time"}); | ||
|
|
||
| # Create the root cvterm | ||
| # next available dbxref accession in time ontology is '0000481' | ||
| my $dbxref_accession = 481; | ||
| my $time_in_years_rs = $schema->resultset("Cv::Cvterm")->create_with({ | ||
| name => "time in years", | ||
| definition=> "Time in years", | ||
| cv => 'cxgn_time_ontology', | ||
| db => 'TIME', | ||
| dbxref => sprintf("%07d", $dbxref_accession) | ||
| }); | ||
| # Link root cvterm to the time ontology | ||
| $schema->resultset("Cv::CvtermRelationship")->find_or_create({ | ||
| subject_id => $time_in_years_rs->cvterm_id(), | ||
| type_id => $is_a_cvterm_id, | ||
| object_id => $time_ontology_rs->cvterm_id() | ||
| }); | ||
|
|
||
| # Create years 1 through 100 | ||
| foreach my $year (1..100) { | ||
| $dbxref_accession += 1; | ||
| my $year_rs = $schema->resultset("Cv::Cvterm")->create_with({ | ||
| name => "year $year", | ||
| cv => 'cxgn_time_ontology', | ||
| db => 'TIME', | ||
| dbxref => sprintf("%07d", $dbxref_accession) | ||
| }); | ||
| # link to time in years root cvterm | ||
| $schema->resultset("Cv::CvtermRelationship")->find_or_create({ | ||
| subject_id => $year_rs->cvterm_id(), | ||
| type_id => $is_a_cvterm_id, | ||
| object_id => $time_in_years_rs->cvterm_id() | ||
| }); | ||
| } | ||
|
|
||
| print "You're done!\n"; | ||
| } | ||
|
|
||
| #### | ||
| 1; # | ||
| #### | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
I'm a little wary of hardcoding the next highest accession number in an ontology - I will need to fish around to see if other databases have messed with their time ontologies in such a way that it would break this
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.
That's a very good point, thank you. Initially I'd thought of using the
autocreated: year 1accession for thedbxrefaccession. But then I thought this might be inconsistent in a bad way, since all the other time ontology accessions have hard-coded numeric accessions. Another option might be to put it in its own ontology (ex.YEAR:000001). But that might also be consfusing if year is the only time unit to have its own ontology.I'm curious to see what you find out in the other databases!
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.
Hmm, maybe putting year in it's own time ontology was a bad suggestion. I imagine that will over complicate things downstream to have time in multiple ontologies (ex. plotting post-composed time traits #6096).
Uh oh!
There was an error while loading. Please reload this page.
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 think your general structure of placing a new root term in the TIME ontology and then assigning that root term to be a TIY composable ontology is the right approach. But I checked and it seems other breedbases have added additional time terms to their DB that throws off the accession numbers. I think the best approach would be to solve for the next highest accession number in the db patch and use that to form the root term, then start adding new accession numbers from that starting point. Changing sgn.conf to use 481 makes sense because sgn_local.conf can override that value for all the databases that have modified their TIME ontologies away from the default. We will just have to be careful to set the correct values in sgn_local.conf wherever relevant
Also, one more thing: I am pretty sure cvterm create_with() will ignore the definition parameter. When I wrote a dbpatch that created new ontologies, I had to manually update the definition after making it with create_with().
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've now changed the definition from inside create_with() to manual afterwards. Jumping over to Lukas' responses to discuss auto-detection of accession vs hard-coding a much larger root number.