line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Bio::Polloc::Typing::bandingPattern - banding-pattern-based methods |
4
|
|
|
|
|
|
|
for typing assessment |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 DESCRIPTION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Category 1 of genotyping methods in: |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Li, W., Raoult, D., & Fournier, P.-E. (2009). |
11
|
|
|
|
|
|
|
Bacterial strain typing in the genomic era. |
12
|
|
|
|
|
|
|
FEMS Microbiology Reviews, 33(5), 892-916. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 AUTHOR - Luis M. Rodriguez-R |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Email lmrodriguezr at gmail dot com |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package Bio::Polloc::Typing::bandingPattern; |
21
|
2
|
|
|
2
|
|
11
|
use base qw(Bio::Polloc::TypingI); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
163
|
|
22
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2149
|
|
23
|
|
|
|
|
|
|
our $VERSION = 1.0503; # [a-version] from Bio::Polloc::Polloc::Version |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 APPENDIX |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Methods provided by the package |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Generic initialization method |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new { |
37
|
0
|
|
|
0
|
1
|
0
|
my($caller,@args) = @_; |
38
|
0
|
|
|
|
|
0
|
my $self = $caller->SUPER::new(@args); |
39
|
0
|
|
|
|
|
0
|
$self->_initialize(@args); |
40
|
0
|
|
|
|
|
0
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 METHODS FROM Bio::Polloc::TypingI |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 scan |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
See L<Bio::Polloc::TypingI-E<gt>scan>. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
L<fragments> must be implemented by the C<Bio::Polloc::Typing::bandingPattern::*> |
50
|
|
|
|
|
|
|
object. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub scan { |
55
|
0
|
|
|
0
|
1
|
0
|
my ($self, @args) = @_; |
56
|
0
|
|
|
|
|
0
|
my ($locigroup) = $self->_rearrange([qw(LOCIGROUP)], @args); |
57
|
0
|
|
0
|
|
|
0
|
$locigroup ||= $self->locigroup; |
58
|
0
|
|
|
|
|
0
|
return $self->_scan_locigroup($self->fragments(-locigroup=>$locigroup)); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 cluster |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 typing_value |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
See L<Bio::Polloc::TypingI-E<gt>typing_value>. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns the size of the loci between the minimum (L<min_size>) |
68
|
|
|
|
|
|
|
and the maximum (L<max_size>) size. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head3 Returns |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
A reference to an array of integers. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub typing_value { |
77
|
0
|
|
|
0
|
1
|
0
|
my($self, @args) = @_; |
78
|
0
|
|
|
|
|
0
|
my($loci) = $self->_rearrange([qw(LOCI)], @args); |
79
|
0
|
0
|
0
|
|
|
0
|
$self->throw("Impossible to analyze loci", $loci) |
|
|
|
0
|
|
|
|
|
80
|
|
|
|
|
|
|
unless defined $loci and ref($loci) and ref($loci)=~/ARRAY/i; |
81
|
0
|
|
|
|
|
0
|
my $out = []; |
82
|
0
|
|
|
|
|
0
|
for my $l (@$loci){ |
83
|
0
|
|
|
|
|
0
|
my $size = abs($l->to - $l->from); |
84
|
0
|
0
|
0
|
|
|
0
|
push @$out, $size if $size<=$self->max_size and $size>=$self->min_size; |
85
|
|
|
|
|
|
|
} |
86
|
0
|
|
|
|
|
0
|
return $out; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 graph_content |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Generates the expected gel. See L<Bio::Polloc::TypingI-E<gt>graph>. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub graph_content { |
96
|
0
|
|
|
0
|
1
|
0
|
my($self, $locigroup, $width, $height, $font) = @_; |
97
|
0
|
0
|
|
|
|
0
|
return unless defined $locigroup; |
98
|
0
|
0
|
|
|
|
0
|
return unless $self->_load_module('GD::Simple'); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Prepare data |
101
|
0
|
|
|
|
|
0
|
my $struc = $locigroup->structured_loci; |
102
|
0
|
|
|
|
|
0
|
my $genomes = $locigroup->genomes; |
103
|
0
|
0
|
|
|
|
0
|
$self->throw("You must define the genomes of the loci group in order to create a gel") |
104
|
|
|
|
|
|
|
unless defined $genomes; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Set the gel up |
107
|
0
|
|
|
|
|
0
|
my $below = 50; |
108
|
0
|
|
|
|
|
0
|
my($iw, $ih, $nameh, $maxa) = ($width, $height-$below, 75, $self->max_size); |
109
|
0
|
0
|
|
|
|
0
|
$maxa = 5e3 if $maxa > 5e10; |
110
|
0
|
|
|
|
|
0
|
my($lw, $lh, $nh) = ($iw/($#$genomes+1), int($maxa/750), ($ih-$nameh)/$maxa); |
111
|
0
|
|
|
|
|
0
|
my $img = GD::Simple->new($width, $height); |
112
|
0
|
|
|
|
|
0
|
$img->bgcolor('black'); |
113
|
0
|
|
|
|
|
0
|
$img->fgcolor('black'); |
114
|
0
|
|
|
|
|
0
|
$img->rectangle(0, $nameh, $iw, $ih+$below); |
115
|
0
|
|
|
|
|
0
|
$img->font($font); |
116
|
0
|
|
|
|
|
0
|
my $white = $img->alphaColor(255,255,255,0); |
117
|
0
|
|
|
|
|
0
|
my $b1 = $img->alphaColor(130, 130, 130 ,0); |
118
|
0
|
|
|
|
|
0
|
$self->debug("GEL iw:$iw ih:$ih nameh:$nameh maxa:$maxa lw:$lw lh:$lh nh:$nh"); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Draw bands |
121
|
0
|
|
|
|
|
0
|
for my $g (0 .. $#$struc){ |
122
|
0
|
|
|
|
|
0
|
$img->fgcolor('black'); |
123
|
0
|
|
|
|
|
0
|
$img->moveTo(int($lw*($g+0.2)), int($nameh*0.9)); |
124
|
0
|
|
|
|
|
0
|
$img->fontsize(8); |
125
|
0
|
|
|
|
|
0
|
$img->angle(-45); |
126
|
0
|
|
|
|
|
0
|
$img->string($genomes->[$g]->name); |
127
|
0
|
|
|
|
|
0
|
$img->angle(0); |
128
|
0
|
|
|
|
|
0
|
my $x1 = int($lw*($g+0.1)); |
129
|
0
|
|
|
|
|
0
|
my $x2 = $x1+int($lw*0.8); |
130
|
0
|
|
|
|
|
0
|
$self->debug("Lane from $x1 to $x2"); |
131
|
0
|
|
|
|
|
0
|
for my $l (@{$struc->[$g]}){ |
|
0
|
|
|
|
|
0
|
|
132
|
0
|
0
|
0
|
|
|
0
|
$self->throw("Bad loci structure (g:$g)", $struc->[$g], "Bio::Polloc::Polloc::UnexpectedException") |
133
|
|
|
|
|
|
|
unless UNIVERSAL::can($l, 'isa') and $l->isa('Bio::Polloc::LocusI'); |
134
|
0
|
|
|
|
|
0
|
my $y1 = $nameh + int($nh*($maxa - $l->length)); |
135
|
0
|
|
|
|
|
0
|
my $y2 = $y1 + $lh; |
136
|
0
|
|
0
|
|
|
0
|
my $S = ($l->score || 100) * 255 / 100; |
137
|
0
|
|
|
|
|
0
|
my $b1 = $img->alphaColor($S, $S, $S, 0); |
138
|
0
|
|
|
|
|
0
|
my $b2 = $img->alphaColor($S/2, $S/2, $S/2, 0); |
139
|
0
|
|
|
|
|
0
|
$img->bgcolor($b2); |
140
|
0
|
|
|
|
|
0
|
$img->fgcolor($b2); |
141
|
0
|
|
|
|
|
0
|
$img->rectangle($x1, $y1-int($lh*0.75), $x2, $y2+int($lh*0.75)); |
142
|
0
|
|
|
|
|
0
|
$img->bgcolor($b1); |
143
|
0
|
|
|
|
|
0
|
$img->fgcolor($b1); |
144
|
0
|
|
|
|
|
0
|
$img->rectangle($x1, $y1, $x2, $y2); |
145
|
0
|
|
|
|
|
0
|
$self->debug("Band from $y1 to $y2"); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} |
148
|
0
|
|
|
|
|
0
|
return $img; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SPECIFIC METHODS |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 fragments |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Generates fragments. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head3 Arguments |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=over |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item -locigroup I<Bio::Polloc::LociGroup> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
The group of loci to be used as base to design the protocol. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head3 Returns |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
A L<Bio::Polloc::LociGrop>, where each locus is a fragment. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head3 Throws |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
A L<Bio::Polloc::Polloc::NotImplementedException> unless implemented |
175
|
|
|
|
|
|
|
by the specific C<Bio::Polloc::Typing::bandingPattern::*> object. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
0
|
1
|
0
|
sub fragments { $_[0]->throw("fragments", $_[0], "Bio::Polloc::Polloc::NotImplementedException") } |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 max_size |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Gets/sets the maximum locus size. No limit (C<inf>) by default. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub max_size { |
188
|
3
|
|
|
3
|
1
|
5
|
my($self, $value) = @_; |
189
|
3
|
100
|
|
|
|
14
|
$self->{'_max_size'} = $value+0 if defined $value; |
190
|
3
|
50
|
|
|
|
9
|
$self->{'_max_size'} = 0 + "Inf" unless defined $self->{'_max_size'}; |
191
|
3
|
|
|
|
|
8
|
return $self->{'_max_size'}; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 min_size |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Gets/sets the minimum locus size. 1 by default. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub min_size { |
201
|
3
|
|
|
3
|
1
|
7
|
my($self, $value) = @_; |
202
|
3
|
100
|
|
|
|
41
|
$self->{'_min_size'} = $value+0 if defined $value; |
203
|
3
|
50
|
|
|
|
11
|
$self->{'_min_size'} = 1 unless defined $self->{'_min_size'}; |
204
|
3
|
|
|
|
|
8
|
return $self->{'_min_size'}; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 INTERNAL METHODS |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Methods intended to be used only within the scope of Bio::Polloc::* |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head2 _initialize |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub _initialize { |
216
|
2
|
|
|
2
|
|
9
|
my($self,@args) = @_; |
217
|
2
|
|
|
|
|
10
|
my($minSize, $maxSize) = $self->_rearrange([qw(MINSIZE MAXSIZE)], @args); |
218
|
2
|
|
|
|
|
20
|
$self->type('bandingPattern'); |
219
|
2
|
|
|
|
|
14
|
$self->min_size($minSize); |
220
|
2
|
|
|
|
|
15
|
$self->max_size($maxSize); |
221
|
2
|
|
|
|
|
9
|
$self->_initialize_method(@args); |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head2 _initialize_method |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=cut |
227
|
|
|
|
|
|
|
|
228
|
0
|
|
|
0
|
|
|
sub _initialize_method { } |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
1; |