From ac335ddfcecefcba6fedf4fad3d4c13d6524039b Mon Sep 17 00:00:00 2001 From: Katherine Eaton Date: Fri, 8 May 2026 11:05:31 -0600 Subject: [PATCH 1/6] Add year to cxgn time ontology --- db/00205/AddTimeOntologyYear.pm | 95 +++++++++++++++++++++++++++ js/source/legacy/CXGN/ComposeTrait.js | 3 + lib/SGN/Controller/AJAX/Onto.pm | 4 +- lib/SGN/Controller/Ontology.pm | 2 + mason/ontology/compose_trait.mas | 26 ++++++-- mason/ontology/compose_treatment.mas | 24 +++++-- sgn.conf | 1 + sgn_test.conf | 4 +- t/selenium2/tools/compose_trait.t | 84 +++++++++++++++++++++++ 9 files changed, 231 insertions(+), 12 deletions(-) create mode 100644 db/00205/AddTimeOntologyYear.pm create mode 100644 t/selenium2/tools/compose_trait.t diff --git a/db/00205/AddTimeOntologyYear.pm b/db/00205/AddTimeOntologyYear.pm new file mode 100644 index 0000000000..f8d05f65ee --- /dev/null +++ b/db/00205/AddTimeOntologyYear.pm @@ -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 +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; # +#### diff --git a/js/source/legacy/CXGN/ComposeTrait.js b/js/source/legacy/CXGN/ComposeTrait.js index 908f1fb471..e35be3270f 100644 --- a/js/source/legacy/CXGN/ComposeTrait.js +++ b/js/source/legacy/CXGN/ComposeTrait.js @@ -40,6 +40,7 @@ function get_component_ids () { if (jQuery("#experiment_treatment_select").val()) { component_ids.push(jQuery("#experiment_treatment_select").val()); } if (jQuery("#tod_select").val()) { component_ids.push(jQuery("#tod_select").val()); } if (jQuery("#toy_select").val()) { component_ids.push(jQuery("#toy_select").val()); } + if (jQuery("#tiy_select").val()) { component_ids.push(jQuery("#tiy_select").val()); } if (jQuery("#gen_select").val()) { component_ids.push(jQuery("#gen_select").val()); } if (jQuery("#evt_select").val()) { component_ids.push(jQuery("#evt_select").val()); } if (jQuery("#meta_select").val()) { component_ids.push(jQuery("#meta_select").val()); } @@ -62,6 +63,7 @@ function retrieve_matching_traits (component_ids) { } ids["tod_ids"] = jQuery("#tod_select").val(); ids["toy_ids"] = jQuery("#toy_select").val(); + ids["tiy_ids"] = jQuery("#tiy_select").val(); ids["gen_ids"] = jQuery("#gen_select").val(); ids["evt_ids"] = jQuery("#evt_select").val(); ids["meta_ids"] = jQuery("#meta_select").val(); @@ -76,6 +78,7 @@ jQuery.ajax( { 'trait_ids': ids["trait_ids"], 'tod_ids': ids["tod_ids"], 'toy_ids': ids["toy_ids"], + 'tiy_ids': ids["tiy_ids"], 'gen_ids': ids["gen_ids"], 'evt_ids': ids["evt_ids"], 'meta_ids': ids["meta_ids"], diff --git a/lib/SGN/Controller/AJAX/Onto.pm b/lib/SGN/Controller/AJAX/Onto.pm index 7fbb874d67..1fd912b536 100644 --- a/lib/SGN/Controller/AJAX/Onto.pm +++ b/lib/SGN/Controller/AJAX/Onto.pm @@ -362,11 +362,12 @@ sub get_traits_from_component_categories: Path('/ajax/onto/get_traits_from_compo my @trait_ids = $c->req->param("trait_ids[]"); my @tod_ids = $c->req->param("tod_ids[]"); my @toy_ids = $c->req->param("toy_ids[]"); + my @tiy_ids = $c->req->param("tiy_ids[]"); my @gen_ids = $c->req->param("gen_ids[]"); my @evt_ids = $c->req->param("evt_ids[]"); my @meta_ids = $c->req->param("meta_ids[]"); - print STDERR "Obj ids are @object_ids\n Attr ids are @attribute_ids\n Method ids are @method_ids\n unit ids are @unit_ids\n trait ids are @trait_ids\n tod ids are @tod_ids\n toy ids are @toy_ids\n gen ids are @gen_ids\n evt ids are @evt_ids\n metadata ids are @meta_ids\n"; + print STDERR "Obj ids are @object_ids\n Attr ids are @attribute_ids\n Method ids are @method_ids\n unit ids are @unit_ids\n trait ids are @trait_ids\n tod ids are @tod_ids\n toy ids are @toy_ids\n tiy ids are @tiy_ids\n gen ids are @gen_ids\n evt ids are @evt_ids\n metadata ids are @meta_ids\n"; my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); my $traits = SGN::Model::Cvterm->get_traits_from_component_categories($schema, \@allowed_composed_cvs, $composable_cvterm_delimiter, $composable_cvterm_format, { @@ -377,6 +378,7 @@ sub get_traits_from_component_categories: Path('/ajax/onto/get_traits_from_compo trait => \@trait_ids, tod => \@tod_ids, toy => \@toy_ids, + tiy => \@tiy_ids, gen => \@gen_ids, evt => \@evt_ids, meta => \@meta_ids, diff --git a/lib/SGN/Controller/Ontology.pm b/lib/SGN/Controller/Ontology.pm index 078d9a7cc1..845ade4149 100644 --- a/lib/SGN/Controller/Ontology.pm +++ b/lib/SGN/Controller/Ontology.pm @@ -119,6 +119,7 @@ sub compose_trait : Path('/tools/compose_trait') :Args(0) { $c->stash->{composable_cvs_allowed_combinations} = $c->config->{composable_cvs_allowed_combinations}; $c->stash->{composable_tod_root_cvterm} = $c->config->{composable_tod_root_cvterm}; $c->stash->{composable_toy_root_cvterm} = $c->config->{composable_toy_root_cvterm}; + $c->stash->{composable_tiy_root_cvterm} = $c->config->{composable_tiy_root_cvterm}; $c->stash->{composable_gen_root_cvterm} = $c->config->{composable_gen_root_cvterm}; $c->stash->{composable_evt_root_cvterm} = $c->config->{composable_evt_root_cvterm}; $c->stash->{composable_meta_root_cvterm} = $c->config->{composable_meta_root_cvterm}; @@ -205,6 +206,7 @@ sub compose_treatment : Path('/tools/compose_treatment') :Args(0) { $c->stash->{composable_cvs_allowed_combinations} = $c->config->{composable_cvs_allowed_combinations}; $c->stash->{composable_tod_root_cvterm} = $c->config->{composable_tod_root_cvterm}; $c->stash->{composable_toy_root_cvterm} = $c->config->{composable_toy_root_cvterm}; + $c->stash->{composable_tiy_root_cvterm} = $c->config->{composable_tiy_root_cvterm}; $c->stash->{composable_gen_root_cvterm} = $c->config->{composable_gen_root_cvterm}; $c->stash->{composable_evt_root_cvterm} = $c->config->{composable_evt_root_cvterm}; $c->stash->{composable_meta_root_cvterm} = $c->config->{composable_meta_root_cvterm}; diff --git a/mason/ontology/compose_trait.mas b/mason/ontology/compose_trait.mas index 94fb868491..d74babacd8 100644 --- a/mason/ontology/compose_trait.mas +++ b/mason/ontology/compose_trait.mas @@ -11,6 +11,7 @@ $composable_cvs => undef $composable_cvs_allowed_combinations => undef $composable_tod_root_cvterm => undef $composable_toy_root_cvterm => undef +$composable_tiy_root_cvterm => undef $composable_gen_root_cvterm => undef $composable_evt_root_cvterm => undef $composable_meta_root_cvterm => undef @@ -115,6 +116,14 @@ $composable_meta_root_cvterm => undef + +