4 #### {"genome_project_funding_agencies":"TraitGenetics Inc.","genome_project_contact_person":"Martin Ganal, ganal@traitgenetics.de","genome_project_sequencing_center":"TraitGenetics","genome_project_dates":"2012","genome_project_genbank_link":"","genome_project_url":"traitgenetics.com","genome_project_sequenced_accessions":"Ailsa Craig"}
11 use Bio
::Chado
::Schema
;
12 use CXGN
::DB
::InsertDBH
;
14 use CXGN
::Stock
::SequencingInfo
;
20 if (!$opt_H || !$opt_D ) {
21 pod2usage
(-verbose
=> 2, -message
=> "Must provide options -H (hostname), -D (database name), -i (input file) \n");
27 my $dbh = CXGN
::DB
::InsertDBH
->new({
30 dbargs
=> {AutoCommit
=> 1, RaiseError
=> 1}
33 my $schema= Bio
::Chado
::Schema
->connect( sub { $dbh->get_actual_dbh() });
35 my $q = "SELECT organismprop_id, organism_id, type_id, value from organismprop where type_id=(SELECT cvterm_id FROM cvterm where name='organism_sequencing_metadata')";
37 my $h = $dbh->prepare($q);
40 while (my ($organismprop_id, $organism_id, $type_id, $value)= $h->fetchrow_array()) {
41 my $data = JSON
::Any
->decode($value);
43 my $row = $schema->resultset("Stock::Stock")->find( { organism_id
=> $organism_id, uniquename
=> $data->{genome_project_sequenced_accessions
} });
46 print STDERR
"accession $data->{genome_project_sequenced_accessions} FOUND in database!!!!\n";
47 my $si = CXGN
::Stock
::SequencingInfo
->new( { schema
=> $schema });
49 $si->funded_by($data->{genome_project_funding_agencies
});
50 $si->contact_email($data->{genome_project_contact_person
});
51 $si->organization($data->{genome_project_sequencing_center
});
52 $si->sequencing_year($data->{genome_project_dates
});
53 $si->genbank_accession($data->{genome_project_genbank_link
});
54 $si->website($data->{genome_project_url
});
55 $si->stock_id($row->stock_id());
60 print STDERR
"accession $data->{genome_project_sequenced_accessions} ***NOT*** FOUND in database!!!!\n";