File Coverage

lib/Bio/KEGG/API.pm
Criterion Covered Total %
statement 28 76 36.8
branch 3 42 7.1
condition 0 18 0.0
subroutine 8 13 61.5
pod 0 6 0.0
total 39 155 25.1


line stmt bran cond sub pod time code
1             package Bio::KEGG::API;
2              
3 1     1   22343 use v5.12;
  1         4  
4 1     1   5 use strict;
  1         2  
  1         18  
5 1     1   5 use warnings;
  1         10  
  1         31  
6 1     1   923 use Moose;
  1         475354  
  1         7  
7 1     1   7821 use namespace::autoclean;
  1         8202  
  1         5  
8 1     1   934 use REST::Client;
  1         72889  
  1         37  
9 1     1   809 use Net::FTP::Tiny qw(ftp_get);
  1         6719  
  1         1039  
10              
11             our $VERSION = '0.02';
12              
13             has 'client' => (
14             is => 'rw',
15             isa => 'REST::Client',
16             default => sub {
17             my $self = shift;
18             return my $obj = REST::Client->new({host=> "http://rest.kegg.jp", timeout => 30,});
19             }
20             );
21              
22             has 'operation' => (
23             is => 'rw',
24             isa => 'Str',
25             );
26              
27             has 'database' => (
28             is => 'rw',
29             isa => 'Str',
30             );
31              
32             has 'organism' => (
33             is => 'rw',
34             isa => 'Str',
35             );
36              
37              
38             sub database_info {
39 1     1 0 8037 my $self = shift;
40 1         4 my %param = @_;
41              
42 1         30 $self->operation('/info/');
43 1 50       30 $self->database($param{'database'}) if defined $param{'database'};
44 1 50       4 $self->organism($param{'organism'}) if defined $param{'organism'};
45              
46 1 50       4 if ( $param{'database'} ) {
    0          
47            
48 1         27 $self->client->GET($self->operation.$param{'database'});
49              
50             } elsif ( $param{'organism'} ) {
51              
52 0         0 $self->client->GET($self->operation.$param{'organism'});
53             }
54              
55 1         4378732 return $self->client->responseContent;
56             }
57              
58              
59             sub entry_list {
60 0     0 0   my $self = shift;
61 0           my %param = @_;
62              
63 0           $self->operation('/list/');
64 0 0         $self->database($param{'database'}) if defined $param{'database'};
65 0 0         $self->organism($param{'organism'}) if defined $param{'organism'};
66              
67 0 0 0       if ( $param{'database'} && $param{'organism'} ) {
    0          
    0          
68            
69 0           $self->client->GET($self->operation.$param{'database'}."/".$param{'organism'});
70            
71             } elsif ( $param{'database'} ) {
72            
73 0           $self->client->GET($self->operation.$param{'database'});
74              
75             } elsif ( $param{'organism'} ) {
76              
77 0           $self->client->GET($self->operation.$param{'organism'});
78              
79             }
80              
81 0           my @result = split(/\n/, $self->client->responseContent);
82 0           return @result;
83              
84             }
85              
86              
87             sub data_search {
88 0     0 0   my $self = shift;
89 0           my %param = @_;
90              
91 0           $self->operation('/find/');
92              
93 0 0         $self->database($param{'database'}) if defined $param{'database'};
94 0 0         $self->organism($param{'organism'}) if defined $param{'organism'};
95 0 0         $self->organism($param{'query'}) if defined $param{'query'};
96              
97 0 0 0       if ( $param{'database'} && $param{'query'} ) {
    0 0        
    0 0        
98            
99 0           $self->client->GET($self->operation . $param{'database'} . "/" . $param{'query'});
100              
101             } elsif ( $param{'organism'} && $param{'query'}) {
102              
103 0           $self->client->GET($self->operation . $param{'organism'} . "/" . $param{'query'});
104              
105             } elsif ( $param{'database'} && $param{'organism'}) {
106            
107 0           $self->client->GET($self->operation.$param{'database'}."/".$param{'organism'});
108              
109             };
110              
111 0           my @result = split(/\n/, $self->client->responseContent);
112 0           return @result;
113              
114             }
115              
116              
117             sub id_convertion {
118 0     0 0   my $self = shift;
119 0           my %param = @_;
120              
121 0           $self->operation('/conv/');
122              
123 0 0         $self->database($param{'target'}) if defined $param{'target'};
124 0 0         $self->organism($param{'source'}) if defined $param{'source'};
125              
126 0 0 0       if ( $param{'target'} && $param{'source'} ) {
127            
128 0           $self->client->GET($self->operation.$param{'target'}."/".$param{'source'});
129              
130             }
131              
132 0           my @result = split(/\t/, $self->client->responseContent );
133              
134 0           for my $elem ( @result ) {
135            
136 0           $elem =~ s/\n/\t/g;
137             }
138              
139 0           return @result;
140              
141             }
142              
143              
144             sub data_retrieval {
145 0     0 0   my $self = shift;
146 0           my $param = @_;
147              
148             }
149              
150              
151             sub linked_entries {
152 0     0 0   my $self = shift;
153 0           my %param = @_;
154              
155 0           $self->operation('/link/');
156              
157 0 0         $self->database($param{'target'}) if defined $param{'target'};
158 0 0         $self->organism($param{'source'}) if defined $param{'source'};
159              
160 0 0 0       if ( $param{'target'} && $param{'source'} ) {
161            
162 0           $self->client->GET($self->operation.$param{'target'}."/".$param{'source'});
163              
164             }
165              
166 0           my @result = split(/\t/, $self->client->responseContent );
167              
168 0           for my $elem ( @result ) {
169            
170 0           $elem =~ s/\n/\t/g;
171             }
172              
173 0           return @result;
174              
175             }
176              
177              
178              
179             1;