1 package CXGN
::Tools
::Pubmed
;
5 use CXGN
::Chado
::Publication
;
6 use CXGN
::Chado
::Pubauthor
;
8 =head1 CXGN::Tools::Pubmed
10 get data from pubmed and parse the fields that should be loaded in Chado schema
24 Usage: my $pubmed = CXGN::Tools::Pubmed->new($publication_obj);
27 Args: $publication_object
33 our $pub_object=undef;
40 my $self = bless $args, $class;
43 $self->set_pub_object($pub_object);
45 my $accession= $pub_object->get_accession();
47 $self->fetch($accession);
56 my $pub_xml = `wget "eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=$accession&rettype=xml&retmode=text" -O - `;
59 my $twig=XML
::Twig
->new(
62 'Article/ArticleTitle' => \
&title
,
63 'JournalIssue/Volume' => \
&volume
,
64 'JournalIssue/Issue' => \
&issue
,
65 'DateCompleted/Year' => \
&pyear
,
66 'PubDate/Year' => \
&pyear
,
67 'Pagination/MedlinePgn' => \
&pages
,
68 'Journal/Title' => \
&journal_name
,
69 'PublicationTypeList/PublicationType' => \
&pub_type
,
70 'Abstract/AbstractText' => \
&abstract
,
72 ELocationID
=> \
&e_id
,
76 # AbstractText => \&abstract,
79 pretty_print
=> 'indented', # output will be nicely formatted
82 $twig->parse($pub_xml ); # build it
85 my $uniquename= $accession . ":" . $self->get_pub_object->get_title();
86 if (!$pub_object->get_uniquename() ) { $pub_object->set_uniquename($uniquename); }
87 #$pub_object->set_db_name('PMID');
88 if (!$pub_object->get_cvterm_name) {
89 $pub_object->set_cvterm_name('journal');
90 $pub_object->d("!No cvtermname found for publication $accession. Setting to default 'journal'! ");
94 my $message= "Error in transaction or NCBI server seems to be down. Please check your input for accession $accession or try again later.\n $@";
95 $pub_object->set_message($message);
96 }else { return undef ; }
112 return $self->{pub_object
};
116 =head2 set_pub_object
129 $self->{pub_object
}=shift;
135 Desc: get the title of the article
145 return $self->{articleTitle
};
151 Desc: set the title of the article
161 my ($twig, $elt)= @_;
162 $pub_object->set_title($elt->text) ;
179 my ($twig, $elt)= @_;
180 $pub_object->set_volume($elt->text) ;
198 return $self->{issue
};
214 my ($twig, $elt)= @_;
215 $pub_object->set_issue($elt->text) ;
233 return $self->{pyear
};
249 my ($twig, $elt)= @_;
250 my $pyear = $elt->text;
251 $pub_object->set_pyear($pyear) if !$pub_object->get_pyear() ;
252 #$pub_object->d("DEBUG:pyear is '$pyear'!!!!");
269 return $self->{pages
};
285 my ($twig, $elt)= @_;
286 $pub_object->set_pages($elt->text) ;
294 =head2 get_journal_name
305 sub get_journal_name
{
307 return $self->{journal_name
};
323 my ($twig, $elt)= @_;
324 $pub_object->set_series_name($elt->text) ;
342 return $self->{pub_type
};
359 my ($twig, $elt)= @_;
360 my $pub_type= $elt->text;
361 if ($pub_type =~ m/Journal/i) {
362 $pub_type = 'journal' ;
363 $pub_object->set_cvterm_name($pub_type) ;
364 $pub_object->d("DEBUG:found pub_type '$pub_type' . Setting cvterm_name to 'journal' !!\n");
367 #$pub_object->d("DEBUG:pub_type $pub_type is not a recognizeable cvterm!!\n");
386 return $self->{abstract
};
402 my ($twig, $elt)= @_;
403 $pub_object->set_abstract($elt->text) ;
422 my ($twig, $elt)= @_;
424 my $lastname=$elt->children_text('LastName');
425 my $initials=$elt->children_text('Initials'); #sometimes the firstname has no initials but full first name 'ForName'..
427 if (!$initials) { $initials=$elt->children_text('ForeName') || $elt->children_text('FirstName') ; }
430 my $author_data= $lastname ."|" . $initials ; #.",".$initials ;
432 $pub_object->add_author($author_data) ;
443 Side Effects: sets eid for the publication object
449 my ($twig, $elt)= @_;
450 $pub_object->set_eid($elt->text) ;