6 UpdateNdExperimentProperty.pm
10 mx-run ThisPackageName [options] -H hostname -D dbname -u username [-F]
12 this is a subclass of L<CXGN::Metadata::Dbpatch>
13 see the perldoc of parent class for more details.
16 This patch updates the cvterm "crossing_metadata_json" by changing from cv = "nd_experiment_property" to cv = "stock_property" and removes unused cvterms related to crossing experiments.
17 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
21 Titima Tantikanjana<tt15@cornell.edu>
23 =head1 COPYRIGHT & LICENSE
25 Copyright 2010 Boyce Thompson Institute for Plant Research
27 This program is free software; you can redistribute it and/or modify
28 it under the same terms as Perl itself.
33 package UpdateNdExperimentProperty
;
36 use Bio
::Chado
::Schema
;
37 use SGN
::Model
::Cvterm
;
39 extends
'CXGN::Metadata::Dbpatch';
43 has
'+description' => ( default => <<'' );
44 This patch updates the cvterm
"crossing_metadata_json" by changing from cv
= "nd_experiment_property" to cv
= "stock_property" and removes unused cvterms related to crossing experiments
.
48 ['AddCrossingExperimentCvterms', 'AddNewCrossCvterms', 'AddSystemCvterms'],
56 print STDOUT
"Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
58 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
60 print STDOUT
"\nExecuting the SQL commands.\n";
61 my $schema = Bio
::Chado
::Schema
->connect( sub { $self->dbh->clone } );
63 # update crossing_metadata_json cvterm
65 my $crossing_metadata_json_cvterm = $schema->resultset("Cv::Cvterm")->find(
66 { name
=> 'crossing_metadata_json'});
68 my $stock_property_cv = $schema->resultset("Cv::Cv")->find(
69 { name
=> 'stock_property'});
71 $crossing_metadata_json_cvterm->update({cv_id
=> $stock_property_cv->cv_id});
73 # delete unused cvterms related to crossing experiment
75 my $nd_experiment_property_id = $schema->resultset("Cv::Cv")->find(
76 { name
=> 'nd_experiment_property'})->cv_id();
78 my $cvterm_rs = $schema->resultset("Cv::Cvterm")->search(
79 { cv_id
=> $nd_experiment_property_id,
81 name
=> ['date_of_embryo_rescue',
83 'date_of_pollination',
84 'date_of_seed_extraction',
85 'days_from_extraction_to_embryo_rescue',
86 'days_from_harvest_to_extraction',
88 'number_of_embryos_contaminated',
89 'number_of_embryos_germinated',
90 'number_of_embryos_rescued',
93 'number_of_nonviable_seeds',
94 'number_of_seedlings_transplanted',
96 'number_of_seeds_extracted',
97 'number_of_seeds_germinated',
98 'number_of_seeds_planted',
99 'number_of_viable_seeds'],
102 $cvterm_rs->delete_all;
104 print "You're done!\n";