4 use CXGN
::DB
::InsertDBH
;
5 use Bio
::Chado
::Schema
;
7 use CXGN
::Chado
::Publication
;
8 use CXGN
::Tools
::Pubmed
;
12 use vars qw
| $opt_H $opt_D |;
16 my $dbh = CXGN
::DB
::InsertDBH
->new( {
23 my $schema = Bio
::Chado
::Schema
->connect( sub { $dbh->get_actual_dbh() }, { on_connect_do
=> ['SET search_path TO public;'] , autocommit
=> 1 } );
25 print STDERR
"finding dbxrefs for all publications\n";
26 my $dbxref_rs = $schema->resultset("General::Dbxref")->search(
31 join => [ 'db', 'pub_dbxrefs' ] ,
32 "+select" => [ "pub_dbxrefs.pub_id" ],
33 "+as" => [ "pub_id" ],
38 while (my $dbxref = $dbxref_rs->next ) {
40 my $accession = $dbxref->accession;
41 my $pub_id = $dbxref->get_column("pub_id");
43 warn "No pub_id exists for accession $accession! Skipping ! \n\n";
46 my $pub = CXGN
::Chado
::Publication
->new( $dbh, $pub_id );
47 $pub->set_accession($accession);
48 my $pubmed = CXGN
::Tools
::Pubmed
->new($pub);
50 my $eid = $pub->get_eid;
51 my $title = $pub->get_title;
54 print STDERR
"Found DOI $eid\n";
55 my $db = $schema->resultset("General::Db")->find_or_create(
58 urlprefix
=> 'http://',
62 my $e_dbxref = $db->find_or_create_related("dbxrefs" , { accession
=> $eid } );
63 $e_dbxref->find_or_create_related("pub_dbxrefs", { pub_id
=> $pub_id } ) ;
65 print STDERR
"Loaded DOI $eid for publication $pub_id (accession $accession) dbxref id = " . $e_dbxref->get_column('dbxref_id') . " **\n";
67 print STDERR
"no DOI for pub_id $pub_id , pubmed accession = $accession\n";
71 print STDERR
"\nDONE. Found $pub_count publications, $doi_count DOIs \n\n";