Bio::Biblio::IO
pubmedxml
Toolbar
Summary
Bio::Biblio::IO::pubmedxml - A converter of XML files with PUBMED citations
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
Do not use this object directly, it is recommended to access it and use
it through the
Bio::Biblio::IO module:
use Bio::Biblio::IO;
my $io = new Bio::Biblio::IO (-format => 'pubmedxml');
Description
This object reads bibliographic citations in XML/MEDLINE format and
converts them into Bio::Biblio::RefI objects. It is an
implementation of methods defined in Bio::Biblio::IO.
Methods
BEGIN | | Code |
_initialize | No description | Code |
handle_end | No description | Code |
handle_start | No description | Code |
Methods description
None available.
Methods code
BEGIN { $VERSION = do { my @r = (q$$Revision: 1.4 $ =~ /\d+/g); sprintf "%d.%-02d", @r };
$Revision = q$$Id: pubmedxml.pm,v 1.4 2002/10/22 07:45:13 lapp Exp $; } |
sub _initialize
{ my ($self, @args) = @_;
my %param = @args;
@param { map { lc $_ } keys %param } = values %param;
my $new_key;
foreach my $key (keys %param) {
($new_key = $key) =~ s/^-/_/;
$self->{ lc $new_key } = $param { $key };
}
my $result = $self->{'_result'} || 'pubmed2ref';
$result = "\L$result";
unless ($result eq 'raw') {
if (defined &Bio::Biblio::IO::_load_format_module ($result)) {
$Bio::Biblio::IO::medlinexml::Convert = "Bio::Biblio::IO::$result"->new (@args);
}
}
$self->{'_xml_parser'} = new XML::Parser (Handlers => {Init =>\& Bio::Biblio::IO::medlinexml::handle_doc_start,
Start =>\& handle_start,
End =>\& handle_end,
Char =>\& Bio::Biblio::IO::medlinexml::handle_char,
Final =>\& Bio::Biblio::IO::medlinexml::handle_doc_end})
unless $self->{'_xml_parser'};
if ($SUPER::Callback = $self->{'_callback'}) {
$self->_parse;
}
}
%PCDATA_NAMES =
(
'PublicationStatus' => 1,
'ProviderId' => 1,
'ArticleId' => 1,
'URL' => 1,
);
%SIMPLE_TREATMENT =
(
'History' => 1,
'PubMedArticle' => 1,
'PubmedArticle' => 1,
'PubmedData' => 1,
);
%POP_DATA_AND_PEEK_OBJ =
(
'Year' => 1,
'Month' => 1,
'Day' => 1,
'Hour' => 1,
'Minute' => 1,
'Second' => 1,
'ProviderId' => 1,
'PublicationStatus' => 1,
);
%POP_AND_ADD_DATA_ELEMENT =
(
'PubMedPubDate' => 'pubDates',
'History' => 'histories',
); } |
sub handle_end
{ my ($expat, $e) = @_;
if ($e eq 'ArticleId') {
&Bio::Biblio::IO::medlinexml::_data2obj ('id');
&Bio::Biblio::IO::medlinexml::_add_element ('pubmedArticleIds', pop @Bio::Biblio::IO::medlinexml::ObjectStack);
return;
}
if ($e eq 'URL') {
&Bio::Biblio::IO::medlinexml::_data2obj ('URL');
&Bio::Biblio::IO::medlinexml::_add_element ('pubmedURLs', pop @Bio::Biblio::IO::medlinexml::ObjectStack);
return;
}
if (exists $POP_DATA_AND_PEEK_OBJ{$e}) {
&Bio::Biblio::IO::medlinexml::_data2obj ("\l$e");
} elsif (exists $POP_AND_ADD_DATA_ELEMENT{$e}) {
&Bio::Biblio::IO::medlinexml::_add_element ($POP_AND_ADD_DATA_ELEMENT{$e}, pop @Bio::Biblio::IO::medlinexml::ObjectStack);
} elsif ($e eq 'MedlineCitation' ||
$e eq 'NCBIArticle') {
&Bio::Biblio::IO::medlinexml::_obj2obj ('Citation');
} elsif ($e eq 'PubmedData') {
&Bio::Biblio::IO::medlinexml::_obj2obj ('PubmedData');
} elsif ($e eq 'PubMedArticle' ||
$e eq 'PubmedArticle') {
&Bio::Biblio::IO::medlinexml::_process_citation (pop @Bio::Biblio::IO::medlinexml::ObjectStack);
} else {
&Bio::Biblio::IO::medlinexml::handle_end ($expat, $e);
}
}
1;
__END__ } |
sub handle_start
{ my ($expat, $e, %attrs) = @_;
if ($e eq 'ArticleId') {
my %p = ();
$p{'idType'} = (defined $attrs{'IdType'} ? $attrs{'IdType'} : 'pubmed');
push (@Bio::Biblio::IO::medlinexml::ObjectStack,\% p);
}
if ($e eq 'URL') {
my %p = ();
$p{'type'} = $attrs{'type'} if $attrs{'type'};
$p{'lang'} = $attrs{'lang'} if $attrs{'lang'};
push (@Bio::Biblio::IO::medlinexml::ObjectStack,\% p);
}
if (exists $PCDATA_NAMES{$e}) {
push (@Bio::Biblio::IO::medlinexml::PCDataStack, '');
} elsif (exists $SIMPLE_TREATMENT{$e}) {
push (@Bio::Biblio::IO::medlinexml::ObjectStack, {});
} elsif ($e eq 'ArticleIdList') {
;
} elsif ($e eq 'PubMedPubDate') {
my %p = ();
$p{'pubStatus'} = $attrs{'PubStatus'} if $attrs{'PubStatus'};
push (@Bio::Biblio::IO::medlinexml::ObjectStack,\% p);
} else {
&Bio::Biblio::IO::medlinexml::handle_start ($expat, $e, %attrs);
} } |
General documentation
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/MailList.shtml - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
email or the web:
bioperl-bugs@bioperl.org
http://bugzilla.bioperl.org/
Copyright (c) 2002 European Bioinformatics Institute. All Rights Reserved.
This module is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
This software is provided "as is" without warranty of any kind.
The main documentation details are to be found in
Bio::Biblio::IO.
Here is the rest of the object methods. Internal methods are preceded
with an underscore _.
Usage : print $Bio::Biblio::IO::pubmedxml::VERSION;
print $Bio::Biblio::IO::pubmedxml::Revision;