| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# POD documentation - main docs before the code |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
GenOO::Data::File::GFF::Record - Object representing a record of a gff file |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Object representing a record of a gff file |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# To initialize |
|
12
|
|
|
|
|
|
|
my $record = GenOO::Data::File::GFF::Record->new( |
|
13
|
|
|
|
|
|
|
seqname => undef, |
|
14
|
|
|
|
|
|
|
source => undef, |
|
15
|
|
|
|
|
|
|
feature => undef, |
|
16
|
|
|
|
|
|
|
start_1_based => undef, |
|
17
|
|
|
|
|
|
|
stop_1_based => undef, |
|
18
|
|
|
|
|
|
|
score => undef, |
|
19
|
|
|
|
|
|
|
strand => undef, |
|
20
|
|
|
|
|
|
|
frame => undef, |
|
21
|
|
|
|
|
|
|
attributes => undef, |
|
22
|
|
|
|
|
|
|
comment => undef, |
|
23
|
|
|
|
|
|
|
extra_info => undef, |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This object represents a record of a gff file and offers methods for accessing the different attributes. |
|
30
|
|
|
|
|
|
|
It transforms original attributes into ones compatible with the rest of the framework eg 1-based to 0-based. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 EXAMPLES |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Return 1 or -1 for the strand |
|
35
|
|
|
|
|
|
|
my $strand = $record->strand(); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Let the code begin... |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
package GenOO::Data::File::GFF::Record; |
|
43
|
|
|
|
|
|
|
$GenOO::Data::File::GFF::Record::VERSION = '1.5.2'; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
####################################################################### |
|
46
|
|
|
|
|
|
|
####################### Load External modules ##################### |
|
47
|
|
|
|
|
|
|
####################################################################### |
|
48
|
1
|
|
|
1
|
|
8
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
49
|
1
|
|
|
1
|
|
6875
|
use Moose::Util::TypeConstraints; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
8
|
|
|
50
|
1
|
|
|
1
|
|
2256
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
13
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
####################################################################### |
|
54
|
|
|
|
|
|
|
####################### Subtypes & Coercions ###################### |
|
55
|
|
|
|
|
|
|
####################################################################### |
|
56
|
|
|
|
|
|
|
subtype 'GenOO::Data::File::GFF::Record::Strand', as 'Int', where {($_ == 1) or ($_ == -1) or ($_ == 0)}; |
|
57
|
|
|
|
|
|
|
coerce 'GenOO::Data::File::GFF::Record::Strand', from 'Str', via { _sanitize_strand($_) }; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
####################################################################### |
|
61
|
|
|
|
|
|
|
####################### Interface attributes ###################### |
|
62
|
|
|
|
|
|
|
####################################################################### |
|
63
|
|
|
|
|
|
|
has 'seqname' => ( |
|
64
|
|
|
|
|
|
|
isa => 'Str', |
|
65
|
|
|
|
|
|
|
is => 'ro', |
|
66
|
|
|
|
|
|
|
required => 1 |
|
67
|
|
|
|
|
|
|
); # The name of the sequence |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has 'source' => ( |
|
70
|
|
|
|
|
|
|
isa => 'Str', |
|
71
|
|
|
|
|
|
|
is => 'ro', |
|
72
|
|
|
|
|
|
|
required => 1 |
|
73
|
|
|
|
|
|
|
); # The source of the feature |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has 'feature' => ( |
|
76
|
|
|
|
|
|
|
isa => 'Str', |
|
77
|
|
|
|
|
|
|
is => 'ro', |
|
78
|
|
|
|
|
|
|
required => 1 |
|
79
|
|
|
|
|
|
|
); # The feature type name |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
has 'start_1_based' => ( |
|
82
|
|
|
|
|
|
|
isa => 'Int', |
|
83
|
|
|
|
|
|
|
is => 'ro', |
|
84
|
|
|
|
|
|
|
required => 1 |
|
85
|
|
|
|
|
|
|
); # 1-based |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
has 'stop_1_based' => ( |
|
88
|
|
|
|
|
|
|
isa => 'Int', |
|
89
|
|
|
|
|
|
|
is => 'ro', |
|
90
|
|
|
|
|
|
|
required => 1 |
|
91
|
|
|
|
|
|
|
); # 1-based |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
has 'score' => ( |
|
94
|
|
|
|
|
|
|
is => 'ro', |
|
95
|
|
|
|
|
|
|
required => 1 |
|
96
|
|
|
|
|
|
|
); # A floating point value. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
has 'strand' => ( |
|
99
|
|
|
|
|
|
|
isa => 'GenOO::Data::File::GFF::Record::Strand', |
|
100
|
|
|
|
|
|
|
is => 'ro', |
|
101
|
|
|
|
|
|
|
required => 1, |
|
102
|
|
|
|
|
|
|
coerce => 1 |
|
103
|
|
|
|
|
|
|
); # One of +, - or . |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
has 'frame' => ( |
|
106
|
|
|
|
|
|
|
is => 'ro', |
|
107
|
|
|
|
|
|
|
required => 1 |
|
108
|
|
|
|
|
|
|
); # 0, 1, 2, .. Is region in frame? |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
has 'comment' => ( |
|
111
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
|
112
|
|
|
|
|
|
|
is => 'ro', |
|
113
|
|
|
|
|
|
|
required => 1 |
|
114
|
|
|
|
|
|
|
); # A comment |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
has 'attributes' => ( |
|
117
|
|
|
|
|
|
|
traits => ['Hash'], |
|
118
|
|
|
|
|
|
|
is => 'ro', |
|
119
|
|
|
|
|
|
|
isa => 'HashRef[Str]', |
|
120
|
|
|
|
|
|
|
default => sub { {} }, |
|
121
|
|
|
|
|
|
|
handles => { |
|
122
|
|
|
|
|
|
|
set_attribute => 'set', |
|
123
|
|
|
|
|
|
|
attribute => 'get', |
|
124
|
|
|
|
|
|
|
}, |
|
125
|
|
|
|
|
|
|
); # Hash with attribute-value (strings) |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
has 'rname' => ( |
|
128
|
|
|
|
|
|
|
isa => 'Str', |
|
129
|
|
|
|
|
|
|
is => 'ro', |
|
130
|
|
|
|
|
|
|
builder => '_set_rname', |
|
131
|
|
|
|
|
|
|
lazy => 1 |
|
132
|
|
|
|
|
|
|
); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
has 'start' => ( |
|
135
|
|
|
|
|
|
|
isa => 'Int', |
|
136
|
|
|
|
|
|
|
is => 'ro', |
|
137
|
|
|
|
|
|
|
builder => '_calculate_start', |
|
138
|
|
|
|
|
|
|
lazy => 1 |
|
139
|
|
|
|
|
|
|
); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
has 'stop' => ( |
|
142
|
|
|
|
|
|
|
isa => 'Int', |
|
143
|
|
|
|
|
|
|
is => 'ro', |
|
144
|
|
|
|
|
|
|
builder => '_calculate_stop', |
|
145
|
|
|
|
|
|
|
lazy => 1 |
|
146
|
|
|
|
|
|
|
); |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
with 'GenOO::Region'; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
####################################################################### |
|
152
|
|
|
|
|
|
|
############################ Accessors ############################ |
|
153
|
|
|
|
|
|
|
####################################################################### |
|
154
|
|
|
|
|
|
|
sub copy_number { |
|
155
|
0
|
|
|
0
|
0
|
0
|
return 1; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub strand_symbol { |
|
159
|
1
|
|
|
1
|
0
|
1119
|
my ($self) = @_; |
|
160
|
|
|
|
|
|
|
|
|
161
|
1
|
|
|
|
|
38
|
my $strand = $self->strand; |
|
162
|
1
|
50
|
|
|
|
5
|
if (defined $strand) { |
|
163
|
1
|
50
|
|
|
|
5
|
if ($strand == 1) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
164
|
1
|
|
|
|
|
6
|
return '+'; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
elsif ($strand == -1) { |
|
167
|
0
|
|
|
|
|
0
|
return '-'; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
elsif ($strand == 0) { |
|
170
|
0
|
|
|
|
|
0
|
return '.'; |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
else { |
|
174
|
0
|
|
|
|
|
0
|
return undef; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
####################################################################### |
|
179
|
|
|
|
|
|
|
######################### Private methods ########################## |
|
180
|
|
|
|
|
|
|
####################################################################### |
|
181
|
|
|
|
|
|
|
sub _sanitize_strand { |
|
182
|
10958
|
|
|
10958
|
|
20503
|
my ($value) = @_; |
|
183
|
|
|
|
|
|
|
|
|
184
|
10958
|
100
|
|
|
|
25483
|
if ($value eq '+') { |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
185
|
6036
|
|
|
|
|
168190
|
return 1; |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
elsif ($value eq '-') { |
|
188
|
4922
|
|
|
|
|
138358
|
return -1; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
elsif ($value eq '.') { |
|
191
|
0
|
|
|
|
|
0
|
return 0; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub _set_rname { |
|
196
|
966
|
|
|
966
|
|
1752
|
my ($self) = @_; |
|
197
|
|
|
|
|
|
|
|
|
198
|
966
|
|
|
|
|
26782
|
return $self->seqname; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub _calculate_start { |
|
202
|
8461
|
|
|
8461
|
|
14296
|
my ($self) = @_; |
|
203
|
|
|
|
|
|
|
|
|
204
|
8461
|
|
|
|
|
233298
|
return $self->start_1_based - 1; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub _calculate_stop { |
|
208
|
8461
|
|
|
8461
|
|
13812
|
my ($self) = @_; |
|
209
|
|
|
|
|
|
|
|
|
210
|
8461
|
|
|
|
|
230655
|
return $self->stop_1_based - 1; |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
####################################################################### |
|
214
|
|
|
|
|
|
|
############################ Finalize ############################# |
|
215
|
|
|
|
|
|
|
####################################################################### |
|
216
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
1; |