4 use Bio
::Chado
::Schema
;
5 use CXGN
::DB
::InsertDBH
;
7 use File
::Slurp qw
| read_file
|;
9 use vars qw
| $opt_H $opt_D $opt_f |;
13 my $dbh = CXGN
::DB
::InsertDBH
->new( {
19 my @lines = read_file
($file);
21 my $schema = Bio
::Chado
::Schema
->connect( sub { $dbh->get_actual_dbh() } );
24 foreach my $l (@lines) {
29 my ($old_name, $transcript_name, $species, $abbr) = split /\t/, $l;
31 my $q = "SELECT blast_db_id FROM sgn.blast_db WHERE title=?";
33 my $h = $dbh->prepare($q);
34 $h->execute($old_name);
36 while (my ($blast_db_id) = $h->fetchrow_array()) {
37 print STDERR
"Found $old_name ($blast_db_id).\n";
38 my $q2 = "UPDATE sgn.blast_db set title=? where blast_db_id=?";
39 my $new_name = "$species ($abbr)";
40 my $h2 = $dbh->prepare($q2);
41 $h2->execute($new_name, $blast_db_id);
42 print STDERR
"Stored new name $new_name\n";
48 print STDERR
"An error occurred. Rolling everything back. ($@)\n";
53 print STDERR
"Done. Committing...\n";