| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Bio::Polloc::TypingIO - I/O interface for genotyping methods (L<Bio::Polloc::TypingI>) |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 AUTHOR - Luis M. Rodriguez-R |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Email lmrodriguezr at gmail dot com |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 IMPLEMENTS OR EXTENDS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=over |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=item * |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
L<Bio::Polloc::Polloc::Root> |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=item * |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
L<Bio::Polloc::Polloc::IO> |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=back |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package Bio::Polloc::TypingIO; |
|
26
|
2
|
|
|
2
|
|
1397
|
use base qw(Bio::Polloc::Polloc::Root Bio::Polloc::Polloc::IO); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1094
|
|
|
27
|
2
|
|
|
2
|
|
15
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1353
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = 1.0503; # [a-version] from Bio::Polloc::Polloc::Version |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Methods provided by the package |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 new |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
The basic initialization method |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
B<Arguments> |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
The same arguments of L<Bio::Polloc::Polloc::IO>, plus: |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=over |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item -format |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
The format of the file |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=back |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new { |
|
56
|
2
|
|
|
2
|
1
|
1633
|
my($caller,@args) = @_; |
|
57
|
2
|
|
33
|
|
|
49
|
my $class = ref($caller) || $caller; |
|
58
|
|
|
|
|
|
|
|
|
59
|
2
|
50
|
|
|
|
8
|
if($class !~ m/Bio::Polloc::TypingIO::(\S+)/){ |
|
60
|
2
|
|
|
|
|
11
|
my $bme = Bio::Polloc::Polloc::Root->new(@args); |
|
61
|
2
|
|
|
|
|
16
|
my($format,$file) = $bme->_rearrange([qw(FORMAT FILE)], @args); |
|
62
|
|
|
|
|
|
|
|
|
63
|
2
|
50
|
33
|
|
|
16
|
if(!$format && $file){ |
|
64
|
2
|
|
|
|
|
8
|
$format = $file; |
|
65
|
2
|
|
|
|
|
11
|
$format =~ s/.*\.//; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
2
|
50
|
|
|
|
8
|
if($format){ |
|
68
|
2
|
|
|
|
|
7
|
$format = Bio::Polloc::TypingIO->_qualify_format($format); |
|
69
|
2
|
50
|
|
|
|
19
|
$class = "Bio::Polloc::TypingIO::" . $format if $format; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
2
|
50
|
|
|
|
19
|
if($class =~ m/Bio::Polloc::TypingIO::(\S+)/){ |
|
74
|
2
|
50
|
|
|
|
15
|
if(Bio::Polloc::TypingIO->_load_module($class)){; |
|
75
|
2
|
|
|
|
|
26
|
my $self = $class->SUPER::new(@args); |
|
76
|
2
|
|
|
|
|
27
|
$self->debug("Got the TypingIO class $class ($1)"); |
|
77
|
2
|
|
|
|
|
16
|
$self->format($1); |
|
78
|
2
|
|
|
|
|
6
|
$self->_initialize(@args); |
|
79
|
2
|
|
|
|
|
18
|
return $self; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
0
|
|
|
|
|
0
|
my $bme = Bio::Polloc::Polloc::Root->new(@args); |
|
82
|
0
|
|
|
|
|
0
|
$bme->throw("Impossible to load the module", $class); |
|
83
|
|
|
|
|
|
|
} else { |
|
84
|
0
|
|
|
|
|
0
|
my $bme = Bio::Polloc::Polloc::Root->new(@args); |
|
85
|
0
|
|
|
|
|
0
|
$bme->throw("Impossible to load the proper Bio::Polloc::TypingIO class with [". |
|
86
|
|
|
|
|
|
|
join("; ",@args)."]", $class); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 format |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Sets/gets the format. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub format { |
|
97
|
3
|
|
|
3
|
1
|
1259
|
my($self,$value) = @_; |
|
98
|
3
|
|
|
|
|
27
|
$value = $self->_qualify_format($value); |
|
99
|
3
|
100
|
|
|
|
12
|
$self->{'_format'} = $value if $value; |
|
100
|
3
|
|
|
|
|
11
|
return $self->{'_format'}; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 read |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub read { |
|
108
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
109
|
0
|
|
|
|
|
0
|
$self->throw("read",$self,"Bio::Polloc::Polloc::NotImplementedException"); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 typing |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Sets/gets the L<Bio::Polloc::TypingI> object |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
B<Arguments> |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
A L<Bio::Polloc::TypingI> object (optional). |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
B<Returns> |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
A L<Bio::Polloc::TypingI> object or C<undef>. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
B<Throws> |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L<Bio::Polloc::Polloc::Error> if trying to set some value |
|
128
|
|
|
|
|
|
|
other than a L<Bio::Polloc::TypingI> object. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub typing { |
|
133
|
10
|
|
|
10
|
1
|
19
|
my($self, $value) = @_; |
|
134
|
10
|
100
|
|
|
|
27
|
if(defined $value){ |
|
135
|
2
|
50
|
33
|
|
|
34
|
$self->throw('Unexpected object type', $value) |
|
136
|
|
|
|
|
|
|
unless UNIVERSAL::can($value, 'isa') |
|
137
|
|
|
|
|
|
|
and $value->isa('Bio::Polloc::TypingI'); |
|
138
|
2
|
|
|
|
|
8
|
$self->{'_typing'} = $value; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
10
|
|
|
|
|
55
|
return $self->{'_typing'}; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 safe_value |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Sets/gets a parameter of arbitrary name and value. Serves to provide a |
|
146
|
|
|
|
|
|
|
safe interface for setting values from the parsed file. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
B<Arguments> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=over |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item -param |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
The parameter's name (case insensitive) |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item -value |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The value of the parameter (optional) |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=back |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
B<Returns> |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
The value of the parameter or undef |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub safe_value { |
|
169
|
0
|
|
|
0
|
1
|
0
|
my ($self,@args) = @_; |
|
170
|
0
|
|
|
|
|
0
|
my($param,$value) = $self->_rearrange([qw(PARAM VALUE)], @args); |
|
171
|
0
|
|
0
|
|
|
0
|
$self->{'_values'} ||= {}; |
|
172
|
0
|
0
|
|
|
|
0
|
return unless $param; |
|
173
|
0
|
|
|
|
|
0
|
$param = lc $param; |
|
174
|
0
|
0
|
|
|
|
0
|
if(defined $value){ |
|
175
|
0
|
|
|
|
|
0
|
$self->{'_values'}->{$param} = $value; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
0
|
|
|
|
|
0
|
return $self->{'_values'}->{$param}; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 INTERNAL METHODS |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Methods intended to be used only within the scope of Bio::Polloc::* |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 _initialize |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub _initialize { |
|
189
|
0
|
|
|
0
|
|
0
|
my($self,@args) = @_; |
|
190
|
0
|
|
|
|
|
0
|
$self->throw("_initialize", $self, "Bio::Polloc::Polloc::NotImplementedException"); |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head2 _qualify_format |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub _qualify_format { |
|
198
|
5
|
|
|
5
|
|
10
|
my($caller, $format) = @_; |
|
199
|
5
|
100
|
|
|
|
17
|
return unless $format; |
|
200
|
4
|
|
|
|
|
12
|
$format = lc $format; |
|
201
|
4
|
|
|
|
|
13
|
$format =~ s/[^a-z]//g; |
|
202
|
4
|
100
|
|
|
|
24
|
$format = "cfg" if $format =~ /^(conf|config|bme)$/; |
|
203
|
4
|
|
|
|
|
13
|
return $format; |
|
204
|
0
|
|
|
|
|
|
return; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
1; |