Merge pull request #3124 from solgenomics/topic/drone_imagery_analysis
[sgn.git] / db / 00073 / AddComposedCvtypeCv.pm
bloba634400f1ac6e05f25f5a73ed697f402085a5c34
1 #!/usr/bin/env perl
4 =head1 NAME
6 AddComposedCvtypeCv
8 =head1 SYNOPSIS
10 mx-run AddComposedCvtypeCv [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.
15 =head1 DESCRIPTION
17 Adds a cv type cv for distinguisihing composable ontologies
18 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
20 =head1 AUTHOR
22 Bryan Ellerbrock<bje24@cornell.edu>
24 =head1 COPYRIGHT & LICENSE
26 Copyright 2011 Boyce Thompson Institute for Plant Research
28 This program is free software; you can redistribute it and/or modify
29 it under the same terms as Perl itself.
31 =cut
34 package AddComposedCvtypeCv;
36 use Moose;
37 extends 'CXGN::Metadata::Dbpatch';
40 has '+description' => ( default => <<'' );
41 Adds a cv type cv for distinguisihing postcomposed ontologies
45 sub patch {
46 my $self=shift;
48 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
50 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
52 print STDOUT "\nExecuting the SQL commands.\n";
54 $self->dbh->do(<<EOSQL);
55 --do your SQL here
57 -- add cv and db for composed traits
59 INSERT into cv (name) values ('composable_cvtypes');
60 ALTER TABLE sgn.cvprop SET SCHEMA public;
61 GRANT ALL ON cvprop to web_usr;
62 INSERT into dbxref (db_id, accession) select db_id, 'trait_ontology' from db where name = 'null';
63 INSERT into cvterm (cv_id,name,dbxref_id) select cv_id, 'trait_ontology', dbxref_id from cv join dbxref on true where cv.name = 'composable_cvtypes' and dbxref.accession = 'trait_ontology';
64 INSERT into dbxref (db_id, accession) select db_id, 'composed_trait_ontology' from db where name = 'null';
65 INSERT into cvterm (cv_id,name,dbxref_id) select cv_id, 'composed_trait_ontology', dbxref_id from cv join dbxref on true where cv.name = 'composable_cvtypes' and dbxref.accession = 'composed_trait_ontology';
66 INSERT into dbxref (db_id, accession) select db_id, 'object_ontology' from db where name = 'null';
67 INSERT into cvterm (cv_id,name,dbxref_id) select cv_id, 'object_ontology', dbxref_id from cv join dbxref on true where cv.name = 'composable_cvtypes' and dbxref.accession = 'object_ontology';
68 INSERT into dbxref (db_id, accession) select db_id, 'attribute_ontology' from db where name = 'null';
69 INSERT into cvterm (cv_id,name,dbxref_id) select cv_id, 'attribute_ontology', dbxref_id from cv join dbxref on true where cv.name = 'composable_cvtypes' and dbxref.accession = 'attribute_ontology';
70 INSERT into dbxref (db_id, accession) select db_id, 'method_ontology' from db where name = 'null';
71 INSERT into cvterm (cv_id,name,dbxref_id) select cv_id, 'method_ontology', dbxref_id from cv join dbxref on true where cv.name = 'composable_cvtypes' and dbxref.accession = 'method_ontology';
72 INSERT into dbxref (db_id, accession) select db_id, 'unit_ontology' from db where name = 'null';
73 INSERT into cvterm (cv_id,name,dbxref_id) select cv_id, 'unit_ontology', dbxref_id from cv join dbxref on true where cv.name = 'composable_cvtypes' and dbxref.accession = 'unit_ontology';
74 INSERT into dbxref (db_id, accession) select db_id, 'time_ontology' from db where name = 'null';
75 INSERT into cvterm (cv_id,name,dbxref_id) select cv_id, 'time_ontology', dbxref_id from cv join dbxref on true where cv.name = 'composable_cvtypes' and dbxref.accession = 'time_ontology';
77 EOSQL
79 print "You're done!\n";
83 ####
84 1; #
85 ####