blib/lib/WWW/Search/PharmGKB.pm

filter: Statementstmt 8.4% 18 / 212 Branchbran 0.0% 0 / 90 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 45.4% 5 / 11 Podpod 0.0% 0 / 5 totaltotal 7.2% 23 / 318 CC 51 SCAR 51.3
CC
51
Cov
6%
publication_search
272.0
drug_search
210.0
gene_search
156.0
CRAP 169.0
↑ Summary
1 package WWW::Search::PharmGKB;
2  
3 1 ▶use SOAP::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 import SOAP::Data 'type';
5 1 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 $VERSION = '2.04';
11  
12 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
13 0 my $class = shift;
14 0 my $self = bless {
15 proxy => 'http://www.pharmgkb.org/services/PharmGKBItem',
16 uri => 'PharmGKBItem',
17 readable => 1,
18 },
19 $class;
20 0 return $self;
21 }
22  
23 0 ▶sub gene_search {
Subroutine gene_search: not called CC=12 SCAR=50.5
Pod undocumented
24  
25 0 my $self = shift;
26 0 my($gene) = @_;
27 0 my $result_obj = {};
28 0 my $pharm_ids = $self->_search($gene, 'Gene');
29 0 ▶ if($pharm_ids) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pharm_ids) { } 0 0 0
30  
31 0 foreach my $gene_id(@{$pharm_ids}) {
32 0 my $local_hash = {};
33 my $soap_service = SOAP::Lite
34 -> readable ($self->{readable})
35 -> uri($self->{uri})
36 -> proxy($self->{proxy})
37 0 -> searchGene ($gene_id);
38 0 my $search_result = $soap_service->result;
39 0 $local_hash->{'alternate_names'} = '';
40 0 $local_hash->{'drugs'} = '';
41 0 $local_hash->{'diseases'} = '';
42 0 $local_hash->{'phenotypes'} = '';
43 0 $local_hash->{'pathways'} = '';
44 0 $local_hash->{'alternate_symbols'} = '';
45 0 $local_hash->{'name'} = '';
46 0 $local_hash->{symbol} = '';
47  
48 0 my @pathways = ();
49 0 ▶ if($search_result->{'geneRelatedPathways'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"geneRelatedPathways"}) 0 0 0
50 0 my $pathway_result = $search_result->{'geneRelatedPathways'};
51  
52 0 ▶ for(my $i = 0; $i <scalar(@{$pathway_result}); $i+= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$pathway_result;}) 0 0 0
53 0 push(@pathways, {$pathway_result->[$i] => $pathway_result->[$i+1]});
54 }
55 }
56 0 $local_hash->{'pathways'} = \@pathways;
57 0 ▶ if($search_result->{geneName}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"geneName"}) 0 0 0
58 0 $local_hash->{name} = $search_result->{geneName};
59 }
60 0 ▶ if($search_result->{geneSymbol}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"geneSymbol"}) 0 0 0
61 0 $local_hash->{symbol} = $search_result->{geneSymbol};
62 }
63 0 ▶ if($search_result->{'geneAlternateNames'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"geneAlternateNames"}) 0 0 0
64 0 $local_hash->{'alternate_names'} = $search_result->{'geneAlternateNames'};
65 }
66 0 ▶ if($search_result->{'geneRelatedDrugs'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"geneRelatedDrugs"}) 0 0 0
67 0 $local_hash->{'drugs'} = $search_result->{'geneRelatedDrugs'};
68 }
69 0 ▶ if($search_result->{'geneRelatedDiseases'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"geneRelatedDiseases"}) 0 0 0
70 0 $local_hash->{'diseases'} = $search_result->{'geneRelatedDiseases'};
71 }
72 0 ▶ if($search_result->{'geneAlternateSymbols'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"geneAlternateSymbols"}) 0 0 0
73 0 $local_hash->{'alternate_symbols'} = $search_result->{'geneAlternateSymbols'};
74 }
75 0 ▶ if($search_result->{'geneRelatedPhenotypeDatasets'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"geneRelatedPhenotypeDatasets"}) 0 0 0
76 0 $local_hash->{'phenotypes'} = $search_result->{'geneRelatedPhenotypeDatasets'};
77 }
78  
79 0 $result_obj->{$gene_id} = $local_hash;
80 }
81 }
82 else {
83 0 print "Gene $gene was not found in PharmGKB!\n";
84 }
85 0 return $result_obj;
86 }
87  
88 0 ▶sub disease_search {
Subroutine disease_search: not called CC=10 SCAR=47.0
Pod undocumented
89  
90 0 my $self = shift;
91 0 my($disease) = @_;
92 0 my $result_obj = {};
93 0 my $pharm_ids;
94 0 ▶ if($disease) {
Branch: 1 branch
BranchTrueFalseTotal
if ($disease) { } 0 0 0
95 0 $pharm_ids = $self->_search($disease, 'Disease');
96 }
97 else {
98 0 print "\'$disease\' is weird. I can't search that\n";
99 0 return 0;
100 }
101  
102 0 ▶ if($pharm_ids) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pharm_ids) { } 0 0 0
103  
104 0 foreach my $disease_id(@{$pharm_ids}) {
105 0 my $local_hash = {};
106 my $soap_service = SOAP::Lite
107 -> readable (1)
108 -> uri($self->{uri})
109 -> proxy($self->{proxy})
110 0 -> searchDisease ($disease_id);
111
112
113 0 my $search_result = $soap_service->result;
114 0 $local_hash->{'names'} = '';
115 0 $local_hash->{'drugs'} = '';
116 0 $local_hash->{'genes'} = '';
117 0 $local_hash->{'phenotypes'} = '';
118 0 $local_hash->{'pathways'} = '';
119  
120 0 my @pathways = ();
121 0 ▶ if($search_result->{'diseaseRelatedPathways'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"diseaseRelatedPathways"}) 0 0 0
122 0 my $pathway_result = $search_result->{'diseaseRelatedPathways'};
123  
124 0 ▶ for(my $i = 0; $i <scalar(@{$pathway_result}); $i+= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$pathway_result;}) 0 0 0
125 0 push(@pathways, {$pathway_result->[$i] => $pathway_result->[$i+1]});
126 }
127 }
128 0 $local_hash->{'pathways'} = \@pathways;
129 0 ▶ if($search_result->{'diseaseAlternateNames'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"diseaseAlternateNames"}) 0 0 0
130 0 $local_hash->{'names'} = $search_result->{'diseaseAlternateNames'};
131 }
132 0 ▶ if($search_result->{'diseaseRelatedDrugs'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"diseaseRelatedDrugs"}) 0 0 0
133 0 $local_hash->{'drugs'} = $search_result->{'diseaseRelatedDrugs'};
134 }
135 0 ▶ if($search_result->{'diseaseRelatedGenes'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"diseaseRelatedGenes"}) 0 0 0
136 0 $local_hash->{'genes'} = $search_result->{'diseaseRelatedGenes'};
137 }
138 0 ▶ if($search_result->{'diseaseRelatedPhenotypeDatasets'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"diseaseRelatedPhenotypeDatasets"}) 0 0 0
139 0 $local_hash->{'phenotypes'} = $search_result->{'diseaseRelatedPhenotypeDatasets'};
140 }
141  
142 0 $result_obj->{$disease_id} = $local_hash;
143 }
144 }
145 else {
146 0 print "Disease $disease was not found in PharmGKB!\n";
147 }
148 0 return $result_obj;
149 }
150  
151 0 ▶sub drug_search {
Subroutine drug_search: not called CC=14 SCAR=53.5
Pod undocumented
152 0 my $self = shift;
153 0 my($drug) = @_;
154 0 my $result_obj = {};
155 0 my $pharm_ids;
156 0 ▶ if($drug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($drug) { } 0 0 0
157 0 $pharm_ids = $self->_search($drug, 'Drug');
158 }
159 else {
160 0 print "\'$drug\' is weird. I can't search that\n";
161 0 return 0;
162 }
163 0 ▶ if($pharm_ids) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pharm_ids) { } 0 0 0
164 0 foreach my $drug_id(@{$pharm_ids}) {
165 0 my $local_hash = {};
166 my $soap_service = SOAP::Lite
167 -> readable (1)
168 -> uri($self->{uri})
169 -> proxy($self->{proxy})
170 0 -> searchDrug ($drug_id);
171
172 0 my $search_result = $soap_service->result;
173 0 $local_hash->{'generic_names'} = '';
174 0 $local_hash->{'trade_names'} = '';
175 0 $local_hash->{'category'} = '';
176 0 $local_hash->{'classification'} = '';
177 0 $local_hash->{'genes'} = '';
178 0 $local_hash->{'diseases'} = '';
179 0 $local_hash->{'phenotypes'} = '';
180 0 $local_hash->{'pathways'} = '';
181 0 $local_hash->{'name'} = '';
182 0 my @pathways = ();
183 0 ▶ if($search_result->{'drugRelatedPathways'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"drugRelatedPathways"}) 0 0 0
184 0 my $pathway_result = $search_result->{'drugRelatedPathways'};
185  
186 0 ▶ for(my $i = 0; $i < scalar(@{$pathway_result}); $i+= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$pathway_result;}) 0 0 0
187 0 push(@pathways, {$pathway_result->[$i] => $pathway_result->[$i+1]});
188 }
189 }
190 0 $local_hash->{'pathways'} = \@pathways;
191 0 ▶ if($search_result->{'drugName'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"drugName"}) 0 0 0
192 0 $local_hash->{'name'} = $search_result->{'drugName'};
193 }
194 0 ▶ if($search_result->{'drugGenericNames'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"drugGenericNames"}) 0 0 0
195 0 $local_hash->{'generic_names'} = $search_result->{'drugGenericNames'};
196 }
197 0 ▶ if($search_result->{'drugTradeNames'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"drugTradeNames"}) 0 0 0
198 0 $local_hash->{'trade_names'} = $search_result->{'drugTradeNames'};
199 }
200 0 ▶ if($search_result->{'drugCategory'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"drugCategory"}) 0 0 0
201 0 $local_hash->{'category'} = $search_result->{'drugCategory'};
202 }
203 0 ▶ if($search_result->{'drugVaClassifications'}){
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"drugVaClassifications"}) 0 0 0
204 0 $local_hash->{'classification'} = $search_result->{'drugVaClassifications'};
205 }
206 0 ▶ if($search_result->{'drugRelatedGenes'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"drugRelatedGenes"}) 0 0 0
207 0 $local_hash->{'genes'} = $search_result->{'drugRelatedGenes'};
208 }
209 0 ▶ if($search_result->{'drugRelatedDiseases'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"drugRelatedDiseases"}) 0 0 0
210 0 $local_hash->{'diseases'} = $search_result->{'drugRelatedDiseases'};
211 }
212 0 ▶ if($search_result->{'drugRelatedPhenotypeDatasets'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"drugRelatedPhenotypeDatasets"}) 0 0 0
213 0 $local_hash->{'phenotypes'} = $search_result->{'drugRelatedPhenotypeDatasets'};
214 }
215  
216 0 $result_obj->{$drug_id} = $local_hash;
217 }
218 }
219 else {
220 0 print "Drug $drug was not found in PharmGKB!\n";
221 }
222 0 return $result_obj;
223 }
224  
225 0 ▶sub publication_search {
Subroutine publication_search: not called CC=16 SCAR=56.1
Pod undocumented
226  
227 0 my $self = shift;
228 0 my($search_term) = @_;
229 0 my $pharm_ids;
230 0 my $result_obj = {};
231 0 ▶ if($search_term) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_term) { } 0 0 0
232 0 $pharm_ids = $self->_search($search_term, 'Publication');
233 }
234 else {
235 0 print "\'$search_term\' is weird. I can't search that\n";
236 0 return 0;
237 }
238 0 ▶ if($pharm_ids) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pharm_ids) { } 0 0 0
239 0 foreach my $id(@{$pharm_ids}) {
240 0 my $local_hash = {};
241 my $soap_service = SOAP::Lite
242 -> readable ($self->{readable})
243 -> uri($self->{uri})
244 -> proxy($self->{proxy})
245 0 -> searchPublication ($id);
246  
247 0 my $search_result = $soap_service->result;
248 0 $local_hash->{'grant_id'} = '';
249 0 $local_hash->{'journal'} = '';
250 0 $local_hash->{'title'} = '';
251 0 $local_hash->{'month'} = '';
252 0 $local_hash->{'abstract'} = '';
253 0 $local_hash->{'authors'} = '';
254 0 $local_hash->{'volume'} = '';
255 0 $local_hash->{'page'} = '';
256 0 $local_hash->{'cross_reference'} = '';
257 0 $local_hash->{'year'} = '';
258 0 ▶ if($search_result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result) 0 0 0
259 0 ▶ if($search_result->{publicationGrantIds}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"publicationGrantIds"}) 0 0 0
260 0 $local_hash->{'grants_id'} = $search_result->{publicationGrantIds};
261 }
262 0 ▶ if($search_result->{publicationJournal}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"publicationJournal"}) 0 0 0
263 0 $local_hash->{journal} = $search_result->{publicationJournal};
264 }
265 0 ▶ if($search_result->{publicationName}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"publicationName"}) 0 0 0
266 0 $local_hash->{title} = $search_result->{publicationName};
267 }
268 0 ▶ if($search_result->{publicationMonth}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"publicationMonth"}) 0 0 0
269 0 $local_hash->{month} = $search_result->{publicationMonth};
270 }
271 0 ▶ if($search_result->{publicationAbstract}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"publicationAbstract"}) 0 0 0
272 0 $local_hash->{'abstract'} = $search_result->{publicationAbstract};
273 }
274 0 ▶ if($search_result->{publicationAuthors}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"publicationAuthors"}) 0 0 0
275 0 $local_hash->{authors} = $search_result->{publicationAuthors};
276 }
277 0 ▶ if($search_result->{publicationVolume}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"publicationVolume"}) 0 0 0
278 0 $local_hash->{volume} = $search_result->{publicationVolume};
279 }
280 0 ▶ if($search_result->{publicationPage}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"publicationPage"}) 0 0 0
281 0 $local_hash->{page} = $search_result->{publicationPage};
282 }
283 0 ▶ if($search_result->{publicationAnnotationCrossReference}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"publicationAnnotationCrossReference"}) 0 0 0
284 0 my $references = $search_result->{publicationAnnotationCrossReference};
285 0 my @references_array = ();
286 0 ▶ for(my $i=0; $i < scalar(@{$references});$i+=2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$references;}) 0 0 0
287 0 push(@references_array, {$references->[$i] => $references->[$i+1]});
288 }
289 0 $local_hash->{'cross_reference'} = \@references_array;
290 }
291 0 ▶ if($search_result->{publicationYear}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_result->{"publicationYear"}) 0 0 0
292 0 $local_hash->{year} = $search_result->{publicationYear};
293 }
294 }
295 0 $result_obj->{$id} = $local_hash;
296 }
297 }
298 else {
299 0 print "No results found for $search_term\n";
300 }
301 0 return $result_obj;
302 }
303  
304  
305 0 ▶sub _search {
Subroutine _search: not called CC=3 SCAR=24.8
306 0 my $self = shift;
307 0 my($search_term, $key) = @_;
308 0 my @pharm_id = ();
309  
310 my $soap_service = SOAP::Lite
311 -> readable ($self->{readable})
312 0 -> uri('SearchService')
313 -> proxy('http://www.pharmgkb.org/services/SearchService')
314 -> search ($search_term);
315 0 my $search_result = $soap_service->result;
316 0 foreach my $search_obj(@{$search_result}) {
317 0 ▶ if($search_obj->[1] =~ m/$key/ig) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_obj->[1] =~ /$key/gi) 0 0 0
318 0 push(@pharm_id, $search_obj->[0]);
319 }
320 }
321 0 return \@pharm_id;
322  
323 }
324  
325 1 1;
326  
327  
328 =head1 NAME
329  
330 WWW::Search::PharmGKB - Search and retrieve information from the PharmGKB database
331  
332 =head1 VERSION
333  
334 Version 2.02
335  
336 =cut
337  
338 =head1 SYNOPSIS
339  
340 This module will not work. The PharmGKB API doesn't exist anymore. PLEASE DO NOT USE.
341  
342 =cut
343  
344 =head1 AUTHOR
345  
346 Arun Venkataraman, C<< <arvktr at gmail.com> >>
347  
348 =head1 BUGS
349  
350 Please report any bugs or feature requests to C<bug-www-search-pharmgkb at rt.cpan.org>, or through
351 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Search-PharmGKB>. I will be notified, and then you'll
352 automatically be notified of progress on your bug as I make changes.
353  
354  
355  
356  
357 =head1 SUPPORT
358  
359 You can find documentation for this module with the perldoc command.
360  
361 perldoc WWW::Search::PharmGKB
362  
363 You can also look for information at:
364  
365 =over 4
366  
367 =item * RT: CPAN's request tracker
368  
369 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Search-PharmGKB>
370  
371 =item * AnnoCPAN: Annotated CPAN documentation
372  
373 L<http://annocpan.org/dist/WWW-Search-PharmGKB>
374  
375 =item * CPAN Ratings
376  
377 L<http://cpanratings.perl.org/d/WWW-Search-PharmGKB>
378  
379 =item * Search CPAN
380  
381 L<http://search.cpan.org/dist/WWW-Search-PharmGKB>
382  
383 =back
384  
385 You can contact the author for any issues or suggestions you come accross using this module.
386  
387 =head1 ACKNOWLEDGEMENTS
388  
389 This module is based on the perl client written by Andrew MacBride (andrew@helix.stanford.edu) for PharmGKB's web services.
390  
391 =head1 COPYRIGHT & LICENSE
392  
393 Copyright 2010 Arun Venkataraman C<arvktr@cpan.org>, all rights reserved.
394  
395 This program is free software; you can redistribute it and/or modify it
396 under the same terms as Perl itself.
397  
398  
399 =cut
↑ Summary