5 load_composed_cvprops.pl
9 load_composed_cvprops.pl -H [dbhost] -D [dbname] -T [trait_ontology cv name] -c [composed_trait_ontology cv name] -o [object_ontology cv name] -a [attribute_ontology cv name] -m [method_ontology cv name] -u [unit_ontology cv name] -t [time_ontology cv name]
11 =head1 COMMAND-LINE OPTIONS
17 -T [trait_ontology cv name]
18 -c [composed_trait_ontology cv name]
19 -o [object_ontology cv name]
20 -a [attribute_ontology cv name]
21 -m [method_ontology cv name]
22 -u [unit_ontology cv name]
23 -t [time_ontology cv name]
30 Bryan Ellerbrock (bje24@cornell.edu)
40 use Bio
::Chado
::Schema
;
41 use CXGN
::DB
::InsertDBH
;
42 use CXGN
::DB
::Connection
;
45 our ( $opt_H, $opt_D, $opt_T, $opt_c, $opt_o, $opt_a, $opt_m, $opt_u, $opt_t );
46 getopts
('H:D:T:c:o:a:m:u:t:');
50 "A script to load composed cvprops\nUsage: load_composed_cvprops.pl -H [dbhost] -D [dbname] -T [trait_ontology cv name] -c [composed_trait_ontology cv name] -o [object_ontology cv name] -a [attribute_ontology cv name] -m [method_ontology cv name] -u [unit_ontology cv name] -t [time_ontology cv name] \n";
53 if ( !$opt_D || !$opt_H ) {
55 die("Exiting: -H [dbhost] and -D [dbname] options missing\n");
58 my $dbh = CXGN
::DB
::InsertDBH
->new(
69 my $schema = Bio
::Chado
::Schema
->connect( sub { $dbh->get_actual_dbh() } );
72 trait_ontology
=> $opt_T,
73 composed_trait_ontology
=> $opt_c,
74 object_ontology
=> $opt_o,
75 attribute_ontology
=> $opt_a,
76 method_ontology
=> $opt_m,
77 unit_ontology
=> $opt_u,
78 time_ontology
=> $opt_t
83 my $composable_cvtypes =
84 $schema->resultset("Cv::Cv")->find( { name
=> 'composable_cvtypes' } );
85 if ( !$composable_cvtypes ) {
87 "No cv found for composable_cvtypes in database '$opt_D'.\n Run patch AddComposedCvtypeCv.pm on this database to load missing composable_cvtype cv.";
90 my ( $ontology, $ontology_cvtype, $new_ontology_cvprop );
91 while ( my ( $key, $value ) = each %cvprop_hash ) {
95 $schema->resultset("Cv::Cv")->find( { name
=> $value } );
99 "No cv was found with the name '$value' in database '$opt_D'.\n";
102 $ontology_cvtype = $schema->resultset("Cv::Cvterm")->find(
105 cv_id
=> $composable_cvtypes->cv_id()
109 if ( !$ontology_cvtype ) {
111 "No term found for composable_cvtype '$key' in database '$opt_D'.\n Skipping cv '$value'.\n Run patch AddComposedCvtypeCv.pm on this database to load missing composable_cvtypes.\n";
115 $new_ontology_cvprop =
116 $schema->resultset("Cv::Cvprop")->find_or_new(
118 cv_id
=> $ontology->cv_id(),
119 type_id
=> $ontology_cvtype->cvterm_id()
123 if ( !$new_ontology_cvprop->in_storage ) {
125 "Giving cv with name '$value' the cvprop '$key'... \n";
126 $new_ontology_cvprop->insert;
130 "The Cv with name '$value' already has the cvprop '$key'... \n";
138 $schema->txn_do($coderef);
142 die "Load failed! " . $_ . "\n";
145 print "You're done!\n";