line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Palantir::Explorer::ClusterFasta; |
2
|
|
|
|
|
|
|
# ABSTRACT: Explorer internal class for handling ClusterFasta objects |
3
|
|
|
|
|
|
|
$Bio::Palantir::Explorer::ClusterFasta::VERSION = '0.201670'; |
4
|
1
|
|
|
1
|
|
8
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
7290
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
95
|
use Data::UUID; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
75
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
537
|
use Bio::MUST::Core; |
|
1
|
|
|
|
|
3928263
|
|
|
1
|
|
|
|
|
68
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
12
|
use aliased 'Bio::MUST::Core::Ali'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
12
|
1
|
|
|
1
|
|
217
|
use aliased 'Bio::Palantir::Explorer::GeneFasta'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
13
|
|
|
|
|
|
|
extends 'Bio::FastParsers::Base'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# public attributes |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has $_ => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => 'Num', |
21
|
|
|
|
|
|
|
init_arg => undef, |
22
|
|
|
|
|
|
|
writer => '_set_' . $_, |
23
|
|
|
|
|
|
|
) for qw(begin end size); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'coordinates' => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => 'ArrayRef[Num]', |
28
|
|
|
|
|
|
|
init_arg => undef, |
29
|
|
|
|
|
|
|
writer => '_set_coordinates', |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'uui' => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
isa => 'Str', |
35
|
|
|
|
|
|
|
init_arg => undef, |
36
|
|
|
|
|
|
|
default => sub { |
37
|
|
|
|
|
|
|
my $self = shift; |
38
|
|
|
|
|
|
|
my $ug = Data::UUID->new; |
39
|
|
|
|
|
|
|
my $uui = $ug->create_str; |
40
|
|
|
|
|
|
|
return $uui; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# private attributes |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# public array(s) of composed objects |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has 'genes' => ( |
52
|
|
|
|
|
|
|
traits => ['Array'], |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => 'ArrayRef[Bio::Palantir::Explorer::GeneFasta]', |
55
|
|
|
|
|
|
|
writer => '_set_genes', |
56
|
|
|
|
|
|
|
init_arg => undef, |
57
|
|
|
|
|
|
|
handles => { |
58
|
|
|
|
|
|
|
count_genes => 'count', |
59
|
|
|
|
|
|
|
all_genes => 'elements', |
60
|
|
|
|
|
|
|
get_gene => 'get', |
61
|
|
|
|
|
|
|
next_gene => 'shift', |
62
|
|
|
|
|
|
|
}, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
## no critic (ProhibitUnusedPrivateSubroutines) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
## use critic |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub BUILD { |
73
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $ali = Ali->load($self->file); |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $end = 0; |
78
|
0
|
|
|
|
|
|
my ($i, @genes_fasta); |
79
|
0
|
|
|
|
|
|
for my $gene ($ali->all_seqs) { |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $seq = $gene->seq; |
82
|
0
|
|
|
|
|
|
my $begin = $end + 1; |
83
|
0
|
|
|
|
|
|
$end = $begin + length $seq; |
84
|
0
|
|
|
|
|
|
my $size = $end - $begin + 1; |
85
|
0
|
|
|
|
|
|
my @coordinates = ($begin, $end); |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
push @genes_fasta, GeneFasta->new( |
88
|
|
|
|
|
|
|
rank => ++$i, |
89
|
|
|
|
|
|
|
name => $gene->full_id, |
90
|
|
|
|
|
|
|
gene_begin => 1, |
91
|
|
|
|
|
|
|
gene_end => $size, |
92
|
|
|
|
|
|
|
size => $size, |
93
|
|
|
|
|
|
|
coordinates => \@coordinates, |
94
|
|
|
|
|
|
|
protein_sequence => $seq, |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$self->_set_genes(\@genes_fasta); |
99
|
0
|
|
|
|
|
|
$self->_update_ranks; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$self->_set_begin(1); |
102
|
0
|
|
|
|
|
|
$self->_set_end($end); |
103
|
0
|
|
|
|
|
|
$self->_set_coordinates([1, $end]); |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
return; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _update_ranks { |
109
|
0
|
|
|
0
|
|
|
my $self = shift; |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $rank = 1; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
for my $gene ($self->all_genes) { |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my @sorted_domains = |
116
|
0
|
|
|
|
|
|
sort { $a->begin <=> $b->begin } $gene->all_domains; |
|
0
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
for my $i (0..(scalar @sorted_domains - 1)) { |
119
|
0
|
|
|
|
|
|
$sorted_domains[$i]->_set_rank($rank++); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
return; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
__END__ |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=pod |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 NAME |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Bio::Palantir::Explorer::ClusterFasta - Explorer internal class for handling ClusterFasta objects |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 VERSION |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
version 0.201670 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 SYNOPSIS |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# TODO |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 DESCRIPTION |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# TODO |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 genes |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
ArrayRef of L<Bio::Palantir::Explorer::GeneFasta> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 METHODS |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 count_genes |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Returns the number of Genes of the Cluster. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# $cluster is a Bio::Palantir::Explorer::ClusterFasta |
163
|
|
|
|
|
|
|
my $count = $cluster->count_genes; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This method does not accept any arguments. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 all_genes |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Returns all the Genes of the Cluster (not an array reference). |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# $cluster is a Bio::Palantir::Explorer::ClusterFasta |
172
|
|
|
|
|
|
|
my @genes = $cluster->all_genes; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This method does not accept any arguments. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 get_gene |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Returns one Gene of the Cluster by its index. You can also use |
179
|
|
|
|
|
|
|
negative index numbers, just as with Perl's core array handling. If the |
180
|
|
|
|
|
|
|
specified Gene does not exist, this method will return C<undef>. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# $cluster is a Bio::Palantir::Explorer::ClusterFasta |
183
|
|
|
|
|
|
|
my $gene = $cluster->get_gene($index); |
184
|
|
|
|
|
|
|
croak "Gene $index not found!" unless defined $gene; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This method accepts just one argument (and not an array slice). |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 next_gene |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Shifts the first Gene of the array off and returns it, shortening the |
191
|
|
|
|
|
|
|
array by 1 and moving everything down. If there are no more Genes in |
192
|
|
|
|
|
|
|
the array, returns C<undef>. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# $cluster is a Bio::Palantir::Explorer::ClusterFasta |
195
|
|
|
|
|
|
|
while (my $gene = $cluster->next_gene) { |
196
|
|
|
|
|
|
|
# process $gene |
197
|
|
|
|
|
|
|
# ... |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This method does not accept any arguments. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 AUTHOR |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Loic MEUNIER <lmeunier@uliege.be> |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
This software is copyright (c) 2019 by University of Liege / Unit of Eukaryotic Phylogenomics / Loic MEUNIER and Denis BAURAIN. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
211
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |