5 drone_image_frame_shift_change.pl
9 load_locations.pl -H [dbhost] -D [dbname] -i [infile] -j [drone run id]
11 =head1 COMMAND-LINE OPTIONS
13 -H host name (required) e.g. "localhost"
14 -D database name (required) e.g. "cxgn_cassava"
15 -i path to infile (required)
16 -j drone run project id (required)
24 Nicolas Morales (nm529@cornell.edu)
34 use Bio
::Chado
::Schema
;
35 use CXGN
::DB
::InsertDBH
;
36 use CXGN
::DroneImagery
::ImagesSearch
;
38 our ($opt_H, $opt_D, $opt_i, $opt_j);
42 if (!$opt_H || !$opt_D || !$opt_i || !$opt_j) {
43 pod2usage
(-verbose
=> 2, -message
=> "Must provide options -H (hostname), -D (database name), -i (input file) \n");
49 my $dbh = CXGN
::DB
::InsertDBH
->new({
52 dbargs
=> {AutoCommit
=> 1, RaiseError
=> 1}
55 my $schema= Bio
::Chado
::Schema
->connect( sub { $dbh->get_actual_dbh() } );
56 $dbh->do('SET search_path TO public,sgn');
58 my $q = "UPDATE phenome.stock_image SET stock_id = ? WHERE stock_image_id = ?;";
59 my $q2 = "UPDATE metadata.md_image SET obsolete='t' WHERE image_id = ?;";
60 my $h = $schema->storage->dbh()->prepare($q);
61 my $h2 = $schema->storage->dbh()->prepare($q2);
63 open(my $F, "<", $opt_i) || die " Can't open file $opt_i\n";
64 while (my $line = <$F>) {
66 my @row = split ',', $line;
67 my $plot_name_old = $row[0];
68 my $plot_name_new = $row[1];
70 my $old_plot_id = $schema->resultset("Stock::Stock")->find({uniquename
=>$plot_name_old})->stock_id();
71 #my $new_plot_id = $schema->resultset("Stock::Stock")->find({uniquename=>$plot_name_new})->stock_id();
73 my $images_search = CXGN
::DroneImagery
::ImagesSearch
->new({
75 drone_run_project_id_list
=>[$opt_j],
76 stock_id_list
=>[$old_plot_id]
78 my ($result, $total_count) = $images_search->search();
81 print STDERR Dumper
$_->{drone_run_band_project_name
};
82 print STDERR Dumper
$_->{project_image_type_name
};
83 print STDERR Dumper
$_->{stock_uniquename
};
85 my $image_id = $_->{image_id
};
86 my $stock_image_id = $_->{stock_image_id
};
87 $h->execute($new_plot_id, $stock_image_id);
88 #$h2->execute($image_id);
93 print STDERR
"Script Complete.\n";