File Coverage

blib/lib/Bio/KEGGI.pm
Criterion Covered Total %
statement 15 32 46.8
branch 0 4 0.0
condition n/a
subroutine 5 7 71.4
pod 1 1 100.0
total 21 44 47.7


line stmt bran cond sub pod time code
1             package Bio::KEGGI;
2            
3             =head1 NAME
4            
5             Bio::KEGGI - Perl module to parse KEGG genome, ko and pathway files.
6            
7             =head1 VERSION
8            
9             Version 0.1.5
10            
11             =head1 SYNOPSIS
12            
13             use Bio::KEGGI;
14            
15             my $keggi = Bio::KEGGI->new(
16             -file => 'keggfilename',
17             -type => 'filetype',
18             );
19            
20             while (my $kegg = $keggi->next_rec) {
21             print $kegg->id, "\n";
22             }
23            
24             Now supported KEGG file type are "genome", "ko", "pathway" and "gene".
25            
26             =head1 DESCRIPTION
27            
28             Bio::KEGGI is used to parse KEGG files:
29            
30             =over
31            
32             =item genome
33            
34             ftp://ftp.genome.jp/pub/kegg/genes/genome
35            
36             =item ko
37            
38             ftp://ftp.genome.jp/pub/kegg/genes/ko
39            
40             =item pathway
41            
42             ftp://ftp.genome.jp/pub/kegg/pathway/pathway
43            
44             =item gene
45            
46             Organism gene entries. such as:
47            
48             ftp://ftp.genome.jp/pub/kegg/genes/organisms/aac/A.acidocaldarius.ent
49            
50             =back
51            
52             KEGG data details could be retrieved by module L.
53            
54             =head1 SEE ALSO
55            
56             L also provides a KEGG sequence input/output stream.
57            
58             =head1 AUTHOR
59            
60             Haizhou Liu, zeroliu-at-gmail-dot-com
61            
62             =head1 BUGS
63            
64             This module works for Unix text file format only, which lines end with a
65             "\n".
66            
67             Please use other softwares, such as dos2unix to convert input file if
68             necessary.
69            
70             =head1 METHODS
71            
72             =head2 new
73            
74             Name: new
75             Desc: A constructor for a KEGGI object.
76             Usage: Bio::KEGGI->new(
77             -file => $file,
78             -type => $type, # A fake parameter
79             );
80             Args: $file: A KEGG file: genome, ko, pathway
81             $type: 'genome', 'ko', 'pathway' or 'gene'
82             Return: A Bio::KEGGI object
83            
84             =cut
85            
86 1     1   31632 use strict;
  1         3  
  1         45  
87 1     1   5 use warnings;
  1         1  
  1         33  
88            
89             # use Smart::Comments;
90            
91 1     1   955 use Switch;
  1         79504  
  1         8  
92 1     1   8332 use Text::Trim;
  1         2034  
  1         101  
93            
94 1     1   1113 use Bio::KEGG;
  1         3  
  1         278  
95            
96             our $VERSION = "v0.1.5";
97            
98             =begin new
99             Name: new
100             Desc: A constructor for a KEGGI object.
101             Usage: Bio::KEGGI->new(
102             -file => $file,
103             -type => $type, # A fake parameter
104             );
105             Args: $file: A KEGG file: genome, ko, pathway
106             $type: 'genome', 'ko', 'pathway' or 'gene'
107             Return: A Bio::KEGGI object
108             =cut
109            
110             sub new {
111 0     0 1   my ($class, %args) = @_;
112            
113 0           my $self = {};
114            
115 0           my $infile = $args{'-file'};
116 0           my $type = $args{'-type'};
117            
118             # Open file
119 0           eval {
120 0 0         open(INF, $infile) or die;
121             };
122 0 0         if ($@) {
123 0           warn "FATAL: Open KEGG file '$infile' failed!\n$!.\n";
124 0           exit 1;
125             }
126            
127 0           $self->{'_FH'} = *INF;
128            
129 0           my $type_module = $class . '::' . $type;
130            
131 0           eval "require $type_module";
132            
133             # bless($self, $class.'::'.$type);
134 0           bless($self, $type_module);
135            
136 0           return $self;
137             }
138            
139             =begin DESTROY
140             Name: DESTROY
141             Desc: Destructor, Private method
142             Return: None
143             =cut
144            
145             sub DESTROY {
146 0     0     my $self = shift;
147            
148 0           my $fh = $self->{'_FH'};
149            
150 0           close $fh;
151             }
152            
153            
154             1;