6 DeleteMullLocalSynonyms
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.
17 This patch deletes the ubiquitous 'synonym' cvterms with cv_id of 'null' or 'local'
18 synonyms should be loaded with an explicit cv_id providing the right context, e.g. cvterm.name = stock_synoym cv_id = stock_property, organism_synonym cv_id = organism_property
19 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
23 Naama Menda<nm249@cornell.edu>
25 =head1 COPYRIGHT & LICENSE
27 Copyright 2010 Boyce Thompson Institute for Plant Research
29 This program is free software; you can redistribute it and/or modify
30 it under the same terms as Perl itself.
35 package DeleteNullLocalSynonyms
;
38 use Bio
::Chado
::Schema
;
41 extends
'CXGN::Metadata::Dbpatch';
44 has
'+description' => ( default => <<'' );
45 This patch will find cvterms with name ilike synonyms
and cv
.name
46 local or null
and will
delete those
.
47 this is important
for using only synonyms with an explicit cvterm
.name
and cv
.name
.
51 ['UpdateOrganismSynonymCvterms', 'UpdateStockSynonymCvterms' ],
58 print STDOUT
"Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
60 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
62 print STDOUT
"\nExecuting the SQL commands.\n";
63 my $schema = Bio
::Chado
::Schema
->connect( sub { $self->dbh->clone } );
66 #find or create cvterm with name stock_synonym
67 #make sure it has a dbxref of autocreated:stock_synonym and db = null
68 ##there might be an existing dbxref with accession = autocreated:synonym
69 #we will not be using that one anymore for distincting between synonyms of different entities.
73 ###########################
75 #find all cvterms with name ilike 'synonym%' and cv.name = local
76 # delete the cvterm of name = synonym and cv name = "local" or "null"
78 my $local_syn_cvterms = $schema->resultset("Cv::Cvterm")->search(
80 'me.name' => { ilike
=> 'synonym%' },
88 print "** found " . $local_syn_cvterms->count . " cv.name=local cvterms \n\n";
90 if ($local_syn_cvterms ) {
91 print "**Deleting ... \n";
92 $local_syn_cvterms->delete;
94 #############################
96 my $null_syn_cvterms = $schema->resultset("Cv::Cvterm")->search(
98 'me.name' => { ilike
=> 'synonym%' },
106 print "** found " . $null_syn_cvterms->count . " cv.name=null cvterms \n\n";
108 if ($null_syn_cvterms) {
109 print "**Deleting ... \n";
110 $null_syn_cvterms->delete;
113 ###############################
116 print "Trial mode! Rolling back transaction\n\n";
117 $schema->txn_rollback;
124 $schema->txn_do($coderef);
127 die "Load failed! " . $_ . "\n" ;
131 print "You're done!\n";