| 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::BED::Record - Object representing a record of a bed file |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Object representing a record of a bed file |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# To initialize |
|
12
|
|
|
|
|
|
|
my $record = GenOO::Data::File::BED::Record->new({ |
|
13
|
|
|
|
|
|
|
rname => undef, |
|
14
|
|
|
|
|
|
|
start => undef, |
|
15
|
|
|
|
|
|
|
stop_1based => undef, |
|
16
|
|
|
|
|
|
|
name => undef, |
|
17
|
|
|
|
|
|
|
score => undef, |
|
18
|
|
|
|
|
|
|
strand_symbol => undef, |
|
19
|
|
|
|
|
|
|
thick_start => undef, |
|
20
|
|
|
|
|
|
|
thick_stop_1based => undef, |
|
21
|
|
|
|
|
|
|
rgb => undef, |
|
22
|
|
|
|
|
|
|
block_count => undef, |
|
23
|
|
|
|
|
|
|
block_sizes => undef, |
|
24
|
|
|
|
|
|
|
block_starts => undef, |
|
25
|
|
|
|
|
|
|
copy_number => undef, |
|
26
|
|
|
|
|
|
|
}); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This object represents a record of a bed file and offers methods for accessing the different attributes. |
|
32
|
|
|
|
|
|
|
It implements several additional methods that transform original attributes in more manageable attributes. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 EXAMPLES |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Return strand |
|
37
|
|
|
|
|
|
|
my $strand = $record->strand; # -1 |
|
38
|
|
|
|
|
|
|
my $strand_symbol = $record->strand_symbol; # - |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Return stop position |
|
41
|
|
|
|
|
|
|
my $stop = $record->stop; #10 |
|
42
|
|
|
|
|
|
|
my $stop_1based = $record->stop_1based; #11 |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Return location |
|
45
|
|
|
|
|
|
|
my $location = $record->location; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Let the code begin... |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
package GenOO::Data::File::BED::Record; |
|
52
|
|
|
|
|
|
|
$GenOO::Data::File::BED::Record::VERSION = '1.4.6'; |
|
53
|
1
|
|
|
1
|
|
5
|
use Moose; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
8
|
|
|
54
|
1
|
|
|
1
|
|
5423
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Define the attributes |
|
57
|
|
|
|
|
|
|
has 'rname' => (isa => 'Str', is => 'ro', required => 1); |
|
58
|
|
|
|
|
|
|
has 'start' => (isa => 'Int', is => 'ro', required => 1); |
|
59
|
|
|
|
|
|
|
has 'stop' => (isa => 'Int', is => 'ro', required => 1); |
|
60
|
|
|
|
|
|
|
has 'name' => (isa => 'Str', is => 'ro', required => 1); |
|
61
|
|
|
|
|
|
|
has 'score' => (isa => 'Num', is => 'ro', required => 1); |
|
62
|
|
|
|
|
|
|
has 'strand' => (isa => 'Int', is => 'ro', required => 1); |
|
63
|
|
|
|
|
|
|
has 'thick_start' => (isa => 'Int', is => 'ro'); |
|
64
|
|
|
|
|
|
|
has 'thick_stop_1based' => (isa => 'Int', is => 'ro'); |
|
65
|
|
|
|
|
|
|
has 'rgb' => (isa => 'Str', is => 'ro'); |
|
66
|
|
|
|
|
|
|
has 'block_count' => (isa => 'Int', is => 'ro'); |
|
67
|
|
|
|
|
|
|
has 'block_sizes' => ( |
|
68
|
|
|
|
|
|
|
traits => ['Array'], |
|
69
|
|
|
|
|
|
|
is => 'ro', |
|
70
|
|
|
|
|
|
|
isa => 'ArrayRef[Int]', |
|
71
|
|
|
|
|
|
|
default => sub { [] }, |
|
72
|
|
|
|
|
|
|
handles => { |
|
73
|
|
|
|
|
|
|
all_block_sizes => 'elements', |
|
74
|
|
|
|
|
|
|
add_block_size => 'push', |
|
75
|
|
|
|
|
|
|
map_block_sizes => 'map', |
|
76
|
|
|
|
|
|
|
filter_block_sizes => 'grep', |
|
77
|
|
|
|
|
|
|
find_block_size => 'first', |
|
78
|
|
|
|
|
|
|
get_block_size => 'get', |
|
79
|
|
|
|
|
|
|
join_block_sizes => 'join', |
|
80
|
|
|
|
|
|
|
count_block_sizes => 'count', |
|
81
|
|
|
|
|
|
|
has_block_sizes => 'count', |
|
82
|
|
|
|
|
|
|
has_no_block_sizes => 'is_empty', |
|
83
|
|
|
|
|
|
|
sorted_block_sizes => 'sort', |
|
84
|
|
|
|
|
|
|
}, |
|
85
|
|
|
|
|
|
|
); |
|
86
|
|
|
|
|
|
|
has 'block_starts' => ( |
|
87
|
|
|
|
|
|
|
traits => ['Array'], |
|
88
|
|
|
|
|
|
|
is => 'ro', |
|
89
|
|
|
|
|
|
|
isa => 'ArrayRef[Int]', |
|
90
|
|
|
|
|
|
|
default => sub { [] }, |
|
91
|
|
|
|
|
|
|
handles => { |
|
92
|
|
|
|
|
|
|
all_block_starts => 'elements', |
|
93
|
|
|
|
|
|
|
add_block_start => 'push', |
|
94
|
|
|
|
|
|
|
map_block_starts => 'map', |
|
95
|
|
|
|
|
|
|
filter_block_starts => 'grep', |
|
96
|
|
|
|
|
|
|
find_block_start => 'first', |
|
97
|
|
|
|
|
|
|
get_block_start => 'get', |
|
98
|
|
|
|
|
|
|
join_block_starts => 'join', |
|
99
|
|
|
|
|
|
|
count_block_starts => 'count', |
|
100
|
|
|
|
|
|
|
has_block_starts => 'count', |
|
101
|
|
|
|
|
|
|
has_no_block_starts => 'is_empty', |
|
102
|
|
|
|
|
|
|
sorted_block_starts => 'sort', |
|
103
|
|
|
|
|
|
|
}, |
|
104
|
|
|
|
|
|
|
); |
|
105
|
|
|
|
|
|
|
has 'extra' => (is => 'rw'); |
|
106
|
|
|
|
|
|
|
has 'copy_number' => (isa => 'Int', is => 'ro', default => 1, lazy => 1); |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Consume roles |
|
109
|
|
|
|
|
|
|
with 'GenOO::Region'; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Before object creation edit the hash with the arguments to resolve 1 based and strand symbol |
|
112
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
113
|
|
|
|
|
|
|
my $orig = shift; |
|
114
|
|
|
|
|
|
|
my $class = shift; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my $argv_hash_ref = $class->$orig(@_); |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
if (exists $argv_hash_ref->{stop_1based}) { |
|
119
|
|
|
|
|
|
|
$argv_hash_ref->{stop} = $argv_hash_ref->{stop_1based} - 1; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
if (exists $argv_hash_ref->{strand_symbol}) { |
|
122
|
|
|
|
|
|
|
if ($argv_hash_ref->{strand_symbol} eq '+') { |
|
123
|
|
|
|
|
|
|
$argv_hash_ref->{strand} = 1; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
elsif ($argv_hash_ref->{strand_symbol} eq '-') { |
|
126
|
|
|
|
|
|
|
$argv_hash_ref->{strand} = -1; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
return $argv_hash_ref; |
|
131
|
|
|
|
|
|
|
}; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
####################################################################### |
|
134
|
|
|
|
|
|
|
######################## Interface Methods ######################## |
|
135
|
|
|
|
|
|
|
####################################################################### |
|
136
|
|
|
|
|
|
|
sub stop_1based { |
|
137
|
1
|
|
|
1
|
0
|
720
|
my ($self) = @_; |
|
138
|
1
|
|
|
|
|
48
|
return $self->stop + 1; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub to_string { |
|
142
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
my @fields = ( |
|
145
|
|
|
|
|
|
|
$self->rname, |
|
146
|
|
|
|
|
|
|
$self->start, |
|
147
|
|
|
|
|
|
|
$self->stop_1based, |
|
148
|
|
|
|
|
|
|
$self->name, |
|
149
|
|
|
|
|
|
|
$self->score, |
|
150
|
|
|
|
|
|
|
$self->strand_symbol); |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
0
|
|
|
|
|
push @fields, $self->thick_start if defined $self->thick_start; |
|
153
|
0
|
0
|
|
|
|
|
push @fields, $self->thick_stop_1based if defined $self->thick_stop_1based; |
|
154
|
0
|
0
|
|
|
|
|
push @fields, $self->rgb if defined $self->rgb; |
|
155
|
0
|
0
|
|
|
|
|
push @fields, $self->block_count if defined $self->block_count; |
|
156
|
0
|
0
|
|
|
|
|
push @fields, $self->join_block_sizes(",") if $self->has_block_sizes; |
|
157
|
0
|
0
|
|
|
|
|
push @fields, $self->join_block_starts(",") if $self->has_block_starts; |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
return join("\t", @fields); |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
####################################################################### |
|
163
|
|
|
|
|
|
|
############################ Finalize ############################# |
|
164
|
|
|
|
|
|
|
####################################################################### |
|
165
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; |