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