6 0005_load_sol100_species.pl
10 this_script.pl [options]
14 -D <dbname> (mandatory)
17 -H <dbhost> (mandatory)
20 -p <script_executor_user> (mandatory)
21 username to run the script
23 -F force to run this script and don't stop it by
24 missing previous db_patches
26 Note: If the first time that you run this script, obviously
27 you have no previous dbversion row in the md_dbversion
28 table, so you need to force the execution of this script
33 Need to add 'sol100' organismprop to all species provided by Sandy Knaap and Rene
41 =head1 COPYRIGHT & LICENSE
43 Copyright 2010 Boyce Thompson Institute for Plant Research
45 This program is free software; you can redistribute it and/or modify
46 it under the same terms as Perl itself.
56 use CXGN
::DB
::InsertDBH
;
57 use Bio
::Chado
::Schema
;
59 use CXGN
::Metadata
::Dbversion
; ### Module to interact with the metadata.md_dbversion table
62 ## Declaration of the parameters used to run the script
64 our ($opt_H, $opt_D, $opt_p, $opt_F, $opt_h);
67 ## If is used -h <help> or none parameters is detailed print pod
69 if (!$opt_H && !$opt_D && !$opt_p && !$opt_F && !$opt_h) {
70 print STDOUT
"No optionas passed. Printing help\n\n";
78 ## Declaration of the name of the script and the description
80 my $patch_name = '0005load_sol100_species.pl';
81 my $patch_descr = 'This patch adds a sol100 organism prop to each species in the list provided';
83 print STDOUT
"\n+--------------------------------------------------------------------------------------------------+\n";
84 print STDOUT
"Executing the patch:\n $patch_name.\n\nDescription:\n $patch_descr.\n\nExecuted by:\n $opt_p.";
85 print STDOUT
"\n+--------------------------------------------------------------------------------------------------+\n\n";
87 ## And the requeriments if you want not use all
89 my @previous_requested_patches = ( ## ADD HERE
92 ## Specify the mandatory parameters
94 if (!$opt_H || !$opt_D) {
95 print STDOUT
"\nMANDATORY PARAMETER ERROR: -D <db_name> or/and -H <db_host> parameters has not been specified for $patch_name.\n";
99 print STDOUT
"\nMANDATORY PARAMETER ERROR: -p <script_executor_user> parameter has not been specified for $patch_name.\n";
102 ## Create the $schema object for the db_version object
103 ## This should be replace for CXGN::DB::DBICFactory as soon as it can use CXGN::DB::InsertDBH
105 my $dbh = CXGN
::DB
::InsertDBH
->new(
112 print STDOUT
"\nCreating the Metadata Schema object.\n";
114 my $metadata_schema = CXGN
::Metadata
::Schema
->connect(
116 { on_connect_do
=> ['SET search_path TO metadata;'] },
119 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
121 ### Now it will check if you have runned this patch or the previous patches
123 my $dbversion = CXGN
::Metadata
::Dbversion
->new($metadata_schema)
124 ->complete_checking( {
125 patch_name
=> $patch_name,
126 patch_descr
=> $patch_descr,
127 prepatch_req
=> \
@previous_requested_patches,
133 ### CREATE AN METADATA OBJECT and a new metadata_id in the database for this data
135 my $metadata = CXGN
::Metadata
::Metadbdata
->new($metadata_schema, $opt_p);
137 ### Get a new metadata_id (if you are using store function you only need to supply $metadbdata object)
139 my $metadata_id = $metadata->store()
142 ### Now you can insert the data using different options:
144 ## 1- By sql queryes using $dbh->do(<<EOSQL); and detailing in the tag the queries
146 ## 2- Using objects with the store function
148 ## 3- Using DBIx::Class first level objects
151 ## In this case we will use Bio::Chado::Schema DBIC
153 print STDERR
"\nExecuting the SQL commands.\n";
156 my $schema = Bio
::Chado
::Schema
->connect(
158 { on_connect_do
=> ['SET search_path TO public, metadata;'] },
161 while ( my $s = <DATA
> ) {
163 my $organism = $schema->resultset("Organism::Organism")->find(
166 warn "No organism found for species '$s' ! Check your database!\n "if !$organism;
167 $organism->create_organismprops( { sol100
=> '1' } , {autocreate
=> 1 } );
169 ## Now it will add this new patch information to the md_version table. It did the dbversion object before and
170 ## set the patch_name and the patch_description, so it only need to store it.
173 $dbversion->store($metadata);
175 print STDOUT
"DONE!\n";
183 # Solanum scabrum * NEED TO UPDATE TAXONOMY FOR THIS!
189 Duckeodendron cestroides
191 Metternichia principis
198 Nierembergia scoparia
199 Calibrachoa parviflora
202 Streptosolen jamesonii
204 Pantacantha ameghinoi
205 Protoschwenkia mandonii
216 Symonanthus bancroftii
219 Grabowskia boerhaviifolia
223 Jaborosa integrifolia
230 Przewalskia tangutica
231 Physochlaina orientalis
236 Dyssochroma viridiflora
239 Schultesianthus leucanthus
241 Mandragora officinarum
242 Mandragora caulescens
243 Discopodium penninervium
263 Witheringia solanacea
266 Chamaesaracha coronopus
269 Tubocapsicum anomalum
270 Salpichroa origanifolia
274 Lycianthes multiflora
277 Nicotiana benthamiana
280 Sclerophylax sp
. Nee
and Bohs
50857
282 Nothocestrum latifolium
283 Aureliana fasciculata