Merge pull request #5177 from solgenomics/topic/solgs/refactor-solgs-pipeline
[sgn.git] / db / 00066 / AddNewCrossCvterms.pm
blob7b90e4bc54abf71a0491e57549ffb15b3c112e11
1 #!/usr/bin/env perl
3 =head1 NAME
5 AddNewCrossCvterms.pm
7 =head1 SYNOPSIS
9 mx-run AddNewCrossCvterms [options] -H hostname -D dbname -u username [-F]
11 this is a subclass of L<CXGN::Metadata::Dbpatch>
12 see the perldoc of parent class for more details.
14 =head1 DESCRIPTION
16 This patch adds new cross cvterms so that they can be stored in the nd_experimentprop table.
18 =head1 AUTHOR
20 Bryan Ellerbrock<bje24@cornell.edu>
22 =head1 COPYRIGHT & LICENSE
24 Copyright 2010 Boyce Thompson Institute for Plant Research
26 This program is free software; you can redistribute it and/or modify
27 it under the same terms as Perl itself.
29 =cut
32 package AddNewCrossCvterms;
34 use Moose;
35 use Bio::Chado::Schema;
36 use Try::Tiny;
37 extends 'CXGN::Metadata::Dbpatch';
40 has '+description' => ( default => <<'' );
41 This patch adds new cross cvterms so that they can be stored in the nd_experimentprop table.
44 sub patch {
45 my $self=shift;
47 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
49 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
51 print STDOUT "\nExecuting the SQL commands.\n";
53 my $schema = Bio::Chado::Schema->connect( sub { $self->dbh->clone } );
55 my $coderef = sub {
57 my $date_of_pollination = $schema->resultset("Cv::Cvterm")->create_with({
58 name => 'date_of_pollination',
59 cv => 'nd_experiment_property',
60 });
62 my $date_of_harvest = $schema->resultset("Cv::Cvterm")->create_with({
63 name => 'date_of_harvest',
64 cv => 'nd_experiment_property',
65 });
67 my $date_of_seed_extraction = $schema->resultset("Cv::Cvterm")->create_with({
68 name => 'date_of_seed_extraction',
69 cv => 'nd_experiment_property',
70 });
72 my $number_of_seeds_extracted = $schema->resultset("Cv::Cvterm")->create_with({
73 name => 'number_of_seeds_extracted',
74 cv => 'nd_experiment_property',
75 });
77 my $number_of_viable_seeds = $schema->resultset("Cv::Cvterm")->create_with({
78 name => 'number_of_viable_seeds',
79 cv => 'nd_experiment_property',
80 });
82 my $number_of_nonviable_seeds = $schema->resultset("Cv::Cvterm")->create_with({
83 name => 'number_of_nonviable_seeds',
84 cv => 'nd_experiment_property',
85 });
87 my $date_of_embryo_rescue = $schema->resultset("Cv::Cvterm")->create_with({
88 name => 'date_of_embryo_rescue',
89 cv => 'nd_experiment_property',
90 });
92 my $number_of_embryos_rescued = $schema->resultset("Cv::Cvterm")->create_with({
93 name => 'number_of_embryos_rescued',
94 cv => 'nd_experiment_property',
95 });
97 my $number_of_embryos_germinated = $schema->resultset("Cv::Cvterm")->create_with({
98 name => 'number_of_embryos_germinated',
99 cv => 'nd_experiment_property',
102 my $number_of_embryos_contaminated = $schema->resultset("Cv::Cvterm")->create_with({
103 name => 'number_of_embryos_contaminated',
104 cv => 'nd_experiment_property',
107 my $number_of_seeds_planted = $schema->resultset("Cv::Cvterm")->create_with({
108 name => 'number_of_seeds_planted',
109 cv => 'nd_experiment_property',
112 my $number_of_seeds_germinated = $schema->resultset("Cv::Cvterm")->create_with({
113 name => 'number_of_seeds_germinated',
114 cv => 'nd_experiment_property',
117 my $days_to_maturity = $schema->resultset("Cv::Cvterm")->create_with({
118 name => 'days_to_maturity',
119 cv => 'nd_experiment_property',
122 my $days_from_harvest_to_extraction = $schema->resultset("Cv::Cvterm")->create_with({
123 name => 'days_from_harvest_to_extraction',
124 cv => 'nd_experiment_property',
127 my $days_from_extraction_to_embryo_rescue = $schema->resultset("Cv::Cvterm")->create_with({
128 name => 'days_from_extraction_to_embryo_rescue',
129 cv => 'nd_experiment_property',
132 my $number_of_progeny = $schema->resultset("Cv::Cvterm")->create_with({
133 name => 'number_of_progeny',
134 cv => 'nd_experiment_property',
139 try {
140 $schema->txn_do($coderef);
141 } catch {
142 die "Load failed! " . $_ . "\n" ;
145 print "You're done!\n";
149 ####
150 1; #
151 ####