add addiitional refresh option for all views except genoview
[sgn.git] / bin / load_locus_publications.pl
blob0f1a0fc502c8f76501e23fa8636f8dbe0b5963d4
2 =head1 NAME
3 load_locus_publications.pl - a script to associate publications (pubmed IDs) with locus
5 =head1 SYNOPSYS
7 load_locus_publications.pl -p [person_id] -H [hostname] -D [database name] file
9 where file contains a column with locus names and a column with associated pubmed_ids.
11 =head1 AUTHOR
13 Lukas Mueller <lam87@cornell.edu>
15 =cut
17 use strict;
18 use warnings;
20 use Getopt::Std;
21 use File::Slurp qw | slurp |;
22 use CXGN::DB::InsertDBH;
23 use CXGN::Phenome::Locus;
24 use CXGN::Chado::Dbxref;
26 our %opts;
27 getopts('p:H:D:', \%opts);
29 my $file = shift;
31 my @lines = slurp($file);
32 chomp(@lines);
34 my $dbh = CXGN::DB::InsertDBH->new( { dbname => $opts{D},
35 dbhost => $opts{H},
36 });
40 foreach my $l (@lines) {
41 my ($locus_name, $pubmed_id) = split /\t/, $l;
42 my $sth = $dbh->prepare("SELECT locus_id FROM phenome.locus WHERE locus_name = ?");
43 $sth->execute($locus_name);
44 my ($locus_id) = $sth->fetchrow_array();
45 my $locus = CXGN::Phenome::Locus->new($dbh, $locus_id);
47 my $pub = CXGN::Chado::Publication->get_pub_by_accession($dbh, $pubmed_id);
49 my ($dbxref, @more_dbxrefs) = $pub->get_dbxrefs();
50 print STDERR "Adding dbxref ".($dbxref->get_dbxref_id())."...\n";
51 my $dbxref = CXGN::Chado::Dbxref->new($dbh, $dbxref->get_dbxref_id);
53 $locus->add_locus_dbxref($dbxref, undef, $opts{p});
56 $dbh->commit();