line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Bio::Polloc::Genome - A group of sequences from the same organism |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 AUTHOR - Luis M. Rodriguez-R |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Email lmrodriguezr at gmail dot com |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 LICENSE |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This package is licensed under the Artistic License - see LICENSE.txt |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 IMPLEMENTS OR EXTENDS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=over |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=item * |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
L<Bio::Polloc::Polloc::Root> |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=back |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package Bio::Polloc::Genome; |
26
|
4
|
|
|
4
|
|
4694
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
162
|
|
27
|
4
|
|
|
4
|
|
22
|
use base qw(Bio::Polloc::Polloc::Root); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
905
|
|
28
|
4
|
|
|
4
|
|
2728
|
use Bio::SeqIO; |
|
4
|
|
|
|
|
229177
|
|
|
4
|
|
|
|
|
2819
|
|
29
|
|
|
|
|
|
|
our $VERSION = 1.0503; # [a-version] from Bio::Polloc::Polloc::Version |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Methods provided by the package |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 new |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
The basic initialization method |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item Arguments |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item -name I<str> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
The name of the genome (from file if not provided). |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item -file I<str> |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
The file containing the (multi-)fasta with the genome. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=back |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=back |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub new { |
63
|
5
|
|
|
5
|
1
|
812
|
my($caller,@args) = @_; |
64
|
5
|
|
|
|
|
44
|
my $self = $caller->SUPER::new(@args); |
65
|
5
|
|
|
|
|
18
|
$self->_initialize(@args); |
66
|
5
|
|
|
|
|
18
|
return $self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 build_set |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Builds a set of genomes. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item Arguments |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item -files I<arrayref> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
An arrayref containing the files from which genomes must be build. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item -names I<arrayref> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
An arrayref containing the names of the genomes (in the same order |
88
|
|
|
|
|
|
|
of the files). |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub build_set { |
97
|
0
|
|
|
0
|
1
|
0
|
my($self, @args) = @_; |
98
|
0
|
|
|
|
|
0
|
my($files, $names) = $self->_rearrange([qw(FILES NAMES)], @args); |
99
|
0
|
0
|
|
|
|
0
|
return unless defined $files; |
100
|
0
|
|
0
|
|
|
0
|
$names||= []; |
101
|
0
|
|
|
|
|
0
|
my $out = []; |
102
|
0
|
|
|
|
|
0
|
for my $i (0 .. $#$files){ |
103
|
0
|
|
|
|
|
0
|
push @$out, Bio::Polloc::Genome->new(-file=>$files->[$i], -name=>$names->[$i]); |
104
|
|
|
|
|
|
|
} |
105
|
0
|
|
|
|
|
0
|
return $out; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 file |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=over |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Sets/gets the file containing the genome |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=back |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub file { |
121
|
14
|
|
|
14
|
1
|
968
|
my($self, $value) = @_; |
122
|
14
|
100
|
|
|
|
50
|
if(defined $value){ |
123
|
5
|
|
|
|
|
13
|
$self->{'_file'} = $value; |
124
|
5
|
|
|
|
|
10
|
$self->{'_sequences'} = undef; |
125
|
|
|
|
|
|
|
} |
126
|
14
|
|
|
|
|
45
|
return $self->{'_file'}; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 get_sequences |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Gets the collection of sequences. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item Returns |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
An array of L<Bio::Seq> objects. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub get_sequences { |
146
|
8
|
|
|
8
|
1
|
1733
|
my $self = shift; |
147
|
8
|
100
|
|
|
|
47
|
return $self->{'_sequences'} if defined $self->{'_sequences'}; |
148
|
2
|
|
|
|
|
5
|
$self->{'_sequences'} = []; |
149
|
2
|
|
|
|
|
8
|
my $seqIO = Bio::SeqIO->new(-file=>$self->file, -format=>'Fasta'); |
150
|
2
|
|
|
|
|
53710
|
while(my $seq = $seqIO->next_seq){ |
151
|
8
|
|
|
|
|
24684
|
push @{ $self->{'_sequences'} }, $seq; |
|
8
|
|
|
|
|
45
|
|
152
|
|
|
|
|
|
|
} |
153
|
2
|
50
|
|
|
|
84
|
return wantarray ? @{$self->{'_sequences'}} : $self->{'_sequences'}; |
|
0
|
|
|
|
|
0
|
|
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 search_sequence |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=over |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Search a sequence by ID |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item Arguments |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The id (I<str>) of the sequence. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item Returns |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
The sequence (L<Bio::Seq>) or C<undef>. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=back |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub search_sequence { |
177
|
2
|
|
|
2
|
1
|
782
|
my($self, $value) = @_; |
178
|
2
|
50
|
|
|
|
9
|
return unless defined $value; |
179
|
2
|
|
|
|
|
3
|
for my $seq (@{$self->get_sequences}){ |
|
2
|
|
|
|
|
8
|
|
180
|
4
|
|
|
|
|
43
|
(my $sid = $seq->display_id) =~ s/^(?:[^\s]*\|)?([^\s^\|]+?)\|?$/$1/; |
181
|
4
|
100
|
66
|
|
|
73
|
return $seq if $seq->display_id eq $value or $sid eq $value; |
182
|
|
|
|
|
|
|
} |
183
|
0
|
|
|
|
|
0
|
return; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 name |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=over |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Gets/sets the name of the genome. If no name is set, tries to use the file instead. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=back |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub name { |
199
|
7
|
|
|
7
|
1
|
13
|
my ($self, $value) = @_; |
200
|
7
|
50
|
|
|
|
43
|
$self->{'_name'} = $value if defined $value; |
201
|
7
|
100
|
|
|
|
26
|
unless(defined $self->{'_name'}){ |
202
|
6
|
|
|
|
|
48
|
my $f = $self->file; |
203
|
6
|
100
|
|
|
|
20
|
return unless defined $f; |
204
|
1
|
|
|
|
|
5
|
$f =~ s/.*\///; |
205
|
1
|
|
|
|
|
6
|
$f =~ s/\.[^\.]+$//; |
206
|
1
|
|
|
|
|
3
|
$self->{'_name'} = $f; |
207
|
|
|
|
|
|
|
} |
208
|
2
|
|
|
|
|
9
|
return $self->{'_name'}; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 INTERNAL METHODS |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Methods intended to be used only within the scope of Bio::Polloc::* |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head2 _initialize |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub _initialize { |
220
|
5
|
|
|
5
|
|
14
|
my ($self, @args) = @_; |
221
|
5
|
|
|
|
|
39
|
my($name, $file) = $self->_rearrange([qw(NAME FILE)], @args); |
222
|
5
|
|
|
|
|
21
|
$self->name($name); |
223
|
5
|
|
|
|
|
13
|
$self->file($file); |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
1; |