line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# POD documentation - main docs before the code |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
GenOO::GenomicRegion - Object that corresponds to a region on a genome |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# This object represents a genomic region (location on the genome) |
10
|
|
|
|
|
|
|
# It extends the L<GenOO::Region> object |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Instantiate |
13
|
|
|
|
|
|
|
my $genomic_region = GenOO::GenomicRegion->new( |
14
|
|
|
|
|
|
|
name => undef, |
15
|
|
|
|
|
|
|
species => undef, |
16
|
|
|
|
|
|
|
strand => undef, #required |
17
|
|
|
|
|
|
|
chromosome => undef, #required |
18
|
|
|
|
|
|
|
start => undef, #required |
19
|
|
|
|
|
|
|
stop => undef, #required |
20
|
|
|
|
|
|
|
copy_number => undef, #defaults to 1 |
21
|
|
|
|
|
|
|
sequence => undef, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
A genomic region object is an area on a reference genome. It has a |
27
|
|
|
|
|
|
|
specific start and stop position and specific strand and chromosome. |
28
|
|
|
|
|
|
|
The main difference from the the L<GenOO::Region> role is that it has the |
29
|
|
|
|
|
|
|
"chromosome" attribute instead of the generic "rname". The copy number |
30
|
|
|
|
|
|
|
attribute is useful when counting aligned reads so that the number of |
31
|
|
|
|
|
|
|
reads in this specific location can be collapsed. It defaults to 1. |
32
|
|
|
|
|
|
|
See L<GenOO::Region> and for more available methods |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 EXAMPLES |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $genomic_region = GenOO::GenomicRegion->new( |
37
|
|
|
|
|
|
|
name => 'test_object_0', |
38
|
|
|
|
|
|
|
species => 'human', |
39
|
|
|
|
|
|
|
strand => '+', |
40
|
|
|
|
|
|
|
chromosome => 'chr1', |
41
|
|
|
|
|
|
|
start => 3, |
42
|
|
|
|
|
|
|
stop => 10, |
43
|
|
|
|
|
|
|
copy_number => 7, |
44
|
|
|
|
|
|
|
sequence => 'AGCTAGCU' |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
# Get the genomic location information |
47
|
|
|
|
|
|
|
$genomic_region->start; # 3 |
48
|
|
|
|
|
|
|
$genomic_region->stop; # 10 |
49
|
|
|
|
|
|
|
$genomic_region->strand; # 1 |
50
|
|
|
|
|
|
|
$genomic_region->chromosome; # chr1 |
51
|
|
|
|
|
|
|
$genomic_region->rname; # chr1 - this is always the same as chromosome |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Get the head (5p) position on the reference sequence |
54
|
|
|
|
|
|
|
$genomic_region->head_position; # 3 - this method comes from L<GenOO::Region> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Let the code begin... |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
package GenOO::GenomicRegion; |
61
|
|
|
|
|
|
|
$GenOO::GenomicRegion::VERSION = '1.4.6'; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
####################################################################### |
64
|
|
|
|
|
|
|
####################### Load External modules ##################### |
65
|
|
|
|
|
|
|
####################################################################### |
66
|
1
|
|
|
1
|
|
487
|
use Modern::Perl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
67
|
1
|
|
|
1
|
|
128
|
use autodie; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
68
|
1
|
|
|
1
|
|
4241
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
69
|
1
|
|
|
1
|
|
5028
|
use Moose::Util::TypeConstraints; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
70
|
1
|
|
|
1
|
|
1523
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
subtype 'RegionStrand', as 'Int', where {($_ == 1) or ($_ == -1)}; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
coerce 'RegionStrand', from 'Str', via { _sanitize_strand($_) }; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
####################################################################### |
78
|
|
|
|
|
|
|
####################### Interface attributes ###################### |
79
|
|
|
|
|
|
|
####################################################################### |
80
|
|
|
|
|
|
|
has 'name' => ( |
81
|
|
|
|
|
|
|
isa => 'Str', |
82
|
|
|
|
|
|
|
is => 'rw' |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has 'species' => ( |
86
|
|
|
|
|
|
|
isa => 'Str', |
87
|
|
|
|
|
|
|
is => 'rw' |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
has 'strand' => ( |
91
|
|
|
|
|
|
|
isa => 'RegionStrand', |
92
|
|
|
|
|
|
|
is => 'rw', |
93
|
|
|
|
|
|
|
required => 1, |
94
|
|
|
|
|
|
|
coerce => 1 |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
has 'chromosome' => ( |
98
|
|
|
|
|
|
|
isa => 'Str', |
99
|
|
|
|
|
|
|
is => 'rw', |
100
|
|
|
|
|
|
|
required => 1 |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
has 'start' => ( |
104
|
|
|
|
|
|
|
isa => 'Int', |
105
|
|
|
|
|
|
|
is => 'rw', |
106
|
|
|
|
|
|
|
required => 1 |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
has 'stop' => ( |
110
|
|
|
|
|
|
|
isa => 'Int', |
111
|
|
|
|
|
|
|
is => 'rw', |
112
|
|
|
|
|
|
|
required => 1 |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
has 'copy_number' => ( |
116
|
|
|
|
|
|
|
isa => 'Int', |
117
|
|
|
|
|
|
|
is => 'rw', |
118
|
|
|
|
|
|
|
default => 1, |
119
|
|
|
|
|
|
|
lazy => 1 |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
has 'sequence' => ( |
123
|
|
|
|
|
|
|
isa => 'Str', |
124
|
|
|
|
|
|
|
is => 'rw' |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
has 'extra' => ( |
128
|
|
|
|
|
|
|
is => 'rw' |
129
|
|
|
|
|
|
|
); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
####################################################################### |
133
|
|
|
|
|
|
|
########################## Consumed Roles ######################### |
134
|
|
|
|
|
|
|
####################################################################### |
135
|
|
|
|
|
|
|
with 'GenOO::Region'; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
####################################################################### |
139
|
|
|
|
|
|
|
######################## Interface Methods ######################## |
140
|
|
|
|
|
|
|
####################################################################### |
141
|
|
|
|
|
|
|
sub rname { |
142
|
1446
|
|
|
1446
|
0
|
2642
|
my ($self) = @_; |
143
|
|
|
|
|
|
|
|
144
|
1446
|
|
|
|
|
33551
|
return $self->chromosome; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub id { |
148
|
7
|
|
|
7
|
0
|
1332
|
my ($self) = @_; |
149
|
|
|
|
|
|
|
|
150
|
7
|
|
|
|
|
38
|
return $self->location; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
####################################################################### |
155
|
|
|
|
|
|
|
######################### Private methods ########################## |
156
|
|
|
|
|
|
|
####################################################################### |
157
|
|
|
|
|
|
|
sub _sanitize_strand { |
158
|
1190
|
|
|
1190
|
|
1158
|
my ($value) = @_; |
159
|
|
|
|
|
|
|
|
160
|
1190
|
100
|
|
|
|
2521
|
if ($value eq '+') { |
|
|
50
|
|
|
|
|
|
161
|
595
|
|
|
|
|
14695
|
return 1; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
elsif ($value eq '-') { |
164
|
595
|
|
|
|
|
14363
|
return -1; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
####################################################################### |
170
|
|
|
|
|
|
|
############################ Finalize ############################# |
171
|
|
|
|
|
|
|
####################################################################### |
172
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
173
|
|
|
|
|
|
|
1; |