~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to Bio/Biblio/IO/pubmed2ref.pm

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# BioPerl module Bio::Biblio::IO::pubmed2ref.pm
3
 
#
4
 
# Please direct questions and support issues to <bioperl-l@bioperl.org> 
5
 
#
6
 
# Cared for by Martin Senger <senger@ebi.ac.uk>
7
 
# For copyright and disclaimer see below.
8
 
 
9
 
# POD documentation - main docs before the code
10
 
 
11
 
=head1 NAME
12
 
 
13
 
Bio::Biblio::IO::pubmed2ref - A converter of a raw hash to PUBMED citations
14
 
 
15
 
=head1 SYNOPSIS
16
 
 
17
 
 # to be written
18
 
 
19
 
=head1 DESCRIPTION
20
 
 
21
 
 # to be written
22
 
 
23
 
=head1 FEEDBACK
24
 
 
25
 
=head2 Mailing Lists
26
 
 
27
 
User feedback is an integral part of the evolution of this and other
28
 
Bioperl modules. Send your comments and suggestions preferably to
29
 
the Bioperl mailing list.  Your participation is much appreciated.
30
 
 
31
 
  bioperl-l@bioperl.org                  - General discussion
32
 
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
33
 
 
34
 
=head2 Support 
35
 
 
36
 
Please direct usage questions or support issues to the mailing list:
37
 
 
38
 
I<bioperl-l@bioperl.org>
39
 
 
40
 
rather than to the module maintainer directly. Many experienced and 
41
 
reponsive experts will be able look at the problem and quickly 
42
 
address it. Please include a thorough description of the problem 
43
 
with code and data examples if at all possible.
44
 
 
45
 
=head2 Reporting Bugs
46
 
 
47
 
Report bugs to the Bioperl bug tracking system to help us keep track
48
 
of the bugs and their resolution. Bug reports can be submitted via the
49
 
web:
50
 
 
51
 
  https://redmine.open-bio.org/projects/bioperl/
52
 
 
53
 
=head1 AUTHOR
54
 
 
55
 
Martin Senger (senger@ebi.ac.uk)
56
 
 
57
 
=head1 COPYRIGHT
58
 
 
59
 
Copyright (c) 2002 European Bioinformatics Institute. All Rights Reserved.
60
 
 
61
 
This module is free software; you can redistribute it and/or modify
62
 
it under the same terms as Perl itself.
63
 
 
64
 
=head1 DISCLAIMER
65
 
 
66
 
This software is provided "as is" without warranty of any kind.
67
 
 
68
 
=head1 APPENDIX
69
 
 
70
 
Here is the rest of the object methods.  Internal methods are preceded
71
 
with an underscore _.
72
 
 
73
 
=cut
74
 
 
75
 
 
76
 
# Let the code begin...
77
 
 
78
 
 
79
 
package Bio::Biblio::IO::pubmed2ref;
80
 
 
81
 
use strict;
82
 
 
83
 
use base qw(Bio::Biblio::IO::medline2ref);
84
 
 
85
 
 
86
 
# ---------------------------------------------------------------------
87
 
#
88
 
#   Here is the core...
89
 
#
90
 
# ---------------------------------------------------------------------
91
 
 
92
 
sub _load_instance {
93
 
    my ($self, $source) = @_;
94
 
 
95
 
    my $result;
96
 
    my $article = $$source{'article'};
97
 
    if (defined $article) {
98
 
        if (defined $$article{'journal'}) {
99
 
            $result = $self->_new_instance ('Bio::Biblio::PubmedJournalArticle');
100
 
            $result->type ('JournalArticle');
101
 
        } elsif (defined $$article{'book'}) {
102
 
            $result = $self->_new_instance ('Bio::Biblio::PubmedBookArticle');
103
 
            $result->type ('BookArticle');
104
 
        } else {
105
 
            $result->type ('PubmedArticle');
106
 
        }
107
 
    }
108
 
    $result = $self->_new_instance ('Bio::Biblio::Ref') unless defined $result;
109
 
    return $result;
110
 
}
111
 
 
112
 
sub convert {
113
 
    my ($self, $source) = @_;
114
 
    my $result = $self->SUPER::convert ($source->{'Citation'}); 
115
 
 
116
 
    # here we do PUBMED's specific stuff
117
 
    my $pubmed_data = $$source{'PubmedData'};
118
 
    if (defined $pubmed_data) {
119
 
 
120
 
        # ... just take it (perhaps rename it)
121
 
        $result->pubmed_status ($$pubmed_data{'publicationStatus'}) if defined $$pubmed_data{'publicationStatus'};
122
 
        $result->pubmed_provider_id ($$pubmed_data{'providerId'}) if defined $$pubmed_data{'providerId'};
123
 
        $result->pubmed_article_id_list ($$pubmed_data{'pubmedArticleIds'}) if defined $$pubmed_data{'pubmedArticleIds'};
124
 
        $result->pubmed_url_list ($$pubmed_data{'pubmedURLs'}) if defined $$pubmed_data{'pubmedURLs'};
125
 
 
126
 
        # ... put all dates from all 'histories' into one array
127
 
        if (defined $$pubmed_data{'histories'}) {
128
 
            my @history_list;
129
 
            foreach my $history ( @{ $$pubmed_data{'histories'} } ) {
130
 
                my $ra_pub_dates = $$history{'pubDates'};
131
 
                foreach my $pub_date ( @{ $ra_pub_dates } ) {
132
 
                    my %history = ();
133
 
                    my $converted_date = &Bio::Biblio::IO::medline2ref::_convert_date ($pub_date);
134
 
                    $history{'date'} = $converted_date if defined $converted_date;
135
 
                    $history{'pub_status'} = $$pub_date{'pubStatus'} if defined $$pub_date{'pubStatus'};
136
 
                    push (@history_list, \%history);
137
 
                }
138
 
            }
139
 
            $result->pubmed_history_list (\@history_list);
140
 
        }
141
 
    }
142
 
 
143
 
    # Done!
144
 
    return $result;
145
 
}
146
 
 
147
 
1;
148
 
__END__