5 change_name_of_obsolete_stocks_matching_pattern.pl
9 change_name_of_obsolete_stocks_matching_pattern.pl -H [dbhost] -D [dbname] -f "Ug" -r "UG"
11 =head1 COMMAND-LINE OPTIONS
16 -r replace string with this
23 Jeremy D. Edwards (jde22@cornell.edu)
29 Add support for other spreadsheet formats
38 use Bio
::Chado
::Schema
;
39 use CXGN
::DB
::InsertDBH
;
40 use CXGN
::DB
::Connection
;
44 our ($opt_H, $opt_D, $opt_f, $opt_r);
49 print STDERR
"A script to rename obsolete stocks\nUsage: change_name_of_obsolete_stocks_matching_pattern.pl -D [database name] -H [database host, e.g., localhost] -f [find string] -r [replace string with this]\n";
53 if (!$opt_D || !$opt_H || !$opt_f ) {
55 die("Exiting: options missing\n");
58 my $dbh = CXGN
::DB
::InsertDBH
62 dbargs
=> {AutoCommit
=> 1,
66 my $chado_schema = Bio
::Chado
::Schema
->connect( sub { $dbh->get_actual_dbh() } );
68 my $rs = $chado_schema->resultset('Stock::Stock')->search({'uniquename' => {like
=> $opt_f.'%'}});
71 foreach my $stock ($rs->all()) {
72 print STDERR
"Original name: ".$stock->uniquename()."\n";
75 print STDERR
"\nFound $count accessions\n";
78 foreach my $stock ($rs->all()) {
79 my $stockid = $stock->stock_id();
80 my $uniquename = $stock->uniquename();
81 my $newname = $uniquename."obsolete";
82 print STDERR
"new name: $newname\n";
83 if ($stock->is_obsolete()) {
84 print STDERR
"$stockid changing name $uniquename to $newname\n";
85 $stock->uniquename($newname);