remove old window opens
[sgn.git] / bin / load_field_coords.pl
blob48cf580df6b725f3e2e450b7929a9f2cb631a479
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
5 use Bio::Chado::Schema;
6 use Getopt::Std;
7 use CXGN::DB::InsertDBH;
10 our ($opt_H, $opt_D);
11 getopts("H:D:");
12 my $dbhost = $opt_H;
13 my $dbname = $opt_D;
14 my $file = shift;
18 my $dbh = CXGN::DB::InsertDBH->new( { dbhost=>$dbhost,
19 dbname=>$dbname,
20 dbargs => {AutoCommit => 1,
21 RaiseError => 1,
24 } );
27 my $schema= Bio::Chado::Schema->connect( sub { $dbh->get_actual_dbh() });
30 open (my $file_fh, "<", $file ) || die ("\nERROR: the file $file could not be found\n" );
32 my $header = <$file_fh>;
33 while (my $line = <$file_fh>) {
34 chomp $line;
35 my ($plot,$row,$col) = split("\t", $line);
38 my $rs = $schema->resultset("Stock::Stock")->search({uniquename=> $plot });
40 if ($rs->count()== 1) {
41 my $r = $rs->first();
42 print STDERR "The plots $plot was found.\n Loading row $row col $col\n";
43 $r->create_stockprops({row_number => $row, col_number => $col}, {autocreate => 1});
46 else {
48 print STDERR "WARNING! $plot was not found in the database.\n";