GenOO/Transcript.pm

filter: Statementstmt 94.2% 66 / 70 Branchbran 56.6% 17 / 30 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 2 totaltotal 75.7% 97 / 128 CC 19 SCAR 16.0
CC
19
Cov
79%
_find_or_create_utr5
7.8
_find_or_create_utr3
7.8
exons_split_by_function
5.3
CRAP 5.0
« GenOO/RegionCollection/Type/DBIC.pm ↑ Summary GenOO/Data/File/GFF/Record.pm »
1 # POD documentation - main docs before the code
2  
3 =head1 NAME
4  
5 GenOO::Transcript - Corresponds to a gene transcript
6  
7 =head1 SYNOPSIS
8  
9 # The class represents a transcript of a gene.
10 # It extends the L<GenOO::GenomicRegion> class
11
12 # Instantiate
13 my $transcript = GenOO::Transcript->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 splice_starts => undef, #required
23 splice_stops => undef, #required
24 id => undef, #required
25 gene => undef, #GenOO::Gene
26 utr5 => undef, #GenOO::Transcript::UTR5
27 cds => undef, #GenOO::Transcript::CDS
28 utr3 => undef, #GenOO::Transcript::UTR3
29 biotype => undef,
30 );
31  
32 =head1 DESCRIPTION
33  
34 The Transcript class describes a transcript of a gene. It can have a backreference
35 to the gene in which it belongs. Protein coding transcripts have functional regions
36 such as 5'UTR, CDS and 3'UTR. The transcript class extends the L<GenOO::GenomicRegion>
37 and implements the L<GenOO::Spliceable> role.
38  
39 =head1 EXAMPLES
40  
41 # Get the exons of the transcript
42 $transcript->exons
43
44 # Get the introns of the transcript
45 $transcript->introns
46
47 # Check if the transcript codes for a protein
48 $transcript->is_coding # 0 / 1
49 $transcript->cds # undef / GenOO::Transcript::CDS
50  
51 =cut
52  
53 # Let the code begin...
54  
55 package GenOO::Transcript;
56 1 $GenOO::Transcript::VERSION = '1.4.9';
57 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
59  
60 1 ▶use GenOO::Transcript::UTR5;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 1 ▶use GenOO::Transcript::CDS;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 1 ▶use GenOO::Transcript::UTR3;
Subroutine BEGIN: called CC=1 SCAR=0.0
63  
64 1 extends 'GenOO::GenomicRegion';
65  
66 1 has 'id' => (
67 is => 'rw',
68 required => 1
69 );
70  
71 1 has 'coding_start' => (
72 isa => 'Int',
73 is => 'rw'
74 );
75  
76 1 has 'coding_stop' => (
77 isa => 'Int',
78 is => 'rw'
79 );
80  
81 1 has 'biotype' => (
82 isa => 'Str',
83 is => 'rw',
84 builder => '_find_biotype',
85 lazy => 1,
86 );
87  
88 1 has 'gene' => (
89 isa => 'GenOO::Gene',
90 is => 'rw',
91 weak_ref => 1
92 );
93  
94 1 has 'utr5' => (
95 isa => 'Maybe[GenOO::Transcript::UTR5]',
96 is => 'rw',
97 builder => '_find_or_create_utr5',
98 lazy => 1
99 );
100  
101 1 has 'cds' => (
102 isa => 'Maybe[GenOO::Transcript::CDS]',
103 is => 'rw',
104 builder => '_find_or_create_cds',
105 lazy => 1
106 );
107  
108 1 has 'utr3' => (
109 isa => 'Maybe[GenOO::Transcript::UTR3]',
110 is => 'rw',
111 builder => '_find_or_create_utr3',
112 lazy => 1
113 );
114  
115 1 with 'GenOO::Spliceable';
116  
117 #######################################################################
118 ############################# Methods #############################
119 #######################################################################
120 sub exons_split_by_function {
121 1 ▶ my ($self) = @_;
Subroutine exons_split_by_function: called CC=5 SCAR=16.7
Pod undocumented
122
123 1 ▶ if ($self->is_coding) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_coding) { } 1 0 1
124 1 my @exons;
125 1 ▶ if (defined $self->utr5) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->utr5) 1 0 1
126 1 push @exons,@{$self->utr5->exons};
127 }
128 1 ▶ if (defined $self->cds) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->cds) 1 0 1
129 1 push @exons,@{$self->cds->exons};
130 }
131 1 ▶ if (defined $self->utr3) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->utr3) 1 0 1
132 1 push @exons,@{$self->utr3->exons};
133 }
134 1 return \@exons;
135 }
136 else {
137 0 return $self->exons;
138 }
139 }
140  
141 sub is_coding {
142 12 ▶ my ($self) = @_;
Subroutine is_coding: called CC=2 SCAR=6.9
Pod undocumented
143
144 12 ▶ if ($self->biotype eq 'coding') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->biotype eq 'coding') { } 10 2 12
145 10 return 1;
146 }
147 else {
148 2 return 0;
149 }
150 }
151  
152 #######################################################################
153 ######################### Private methods ##########################
154 #######################################################################
155 sub _find_or_create_utr5 {
156 2 ▶ my ($self) = @_;
Subroutine _find_or_create_utr5: called CC=6 SCAR=20.5
157
158 2 ▶ if (defined $self->coding_start and defined $self->coding_stop) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->coding_start and defined $self->coding_stop) 2 0 2
Condition33%1/3
defined $self->coding_start and defined $self->coding_stop
!ll&&!rl&&r
002
MC/DC0%0/2
defined $self->coding_start and defined $self->coding_stop
defined $self->coding_start defined $self->coding_stop
Truth table33%1/3
A and B
A= defined $self->coding_startB= defined $self->coding_stop
ABresult
0X0
100
111
159 2 ▶ my $utr5_start = ($self->strand == 1) ? $self->start : $self->coding_stop + 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->strand == 1 ? : 0 2 2
160 2 ▶ my $utr5_stop = ($self->strand == 1) ? $self->coding_start - 1 : $self->stop;
Branch: 1 branch
BranchTrueFalseTotal
$self->strand == 1 ? : 0 2 2
161
162 2 ▶ return undef if $utr5_start > $utr5_stop; # there is no 5'UTR
Branch: 1 branch
BranchTrueFalseTotal
if $utr5_start > $utr5_stop 0 2 2
163
164 2 my ($splice_starts, $splice_stops) = _sanitize_splice_coords_within_limits(
165 $self->splice_starts,
166 $self->splice_stops,
167 $utr5_start,
168 $utr5_stop
169 );
170
171 2 return GenOO::Transcript::UTR5->new({
172 strand => $self->strand,
173 chromosome => $self->chromosome,
174 start => $utr5_start,
175 stop => $utr5_stop,
176 splice_starts => $splice_starts,
177 splice_stops => $splice_stops,
178 transcript => $self
179 });
180 }
181
182 0 return undef;
183 }
184  
185 sub _find_or_create_cds {
186 2 ▶ my ($self) = @_;
Subroutine _find_or_create_cds: called CC=3 SCAR=12.7
187
188 2 ▶ if (defined $self->coding_start and defined $self->coding_stop) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->coding_start and defined $self->coding_stop) 2 0 2
Condition33%1/3
defined $self->coding_start and defined $self->coding_stop
!ll&&!rl&&r
002
MC/DC0%0/2
defined $self->coding_start and defined $self->coding_stop
defined $self->coding_start defined $self->coding_stop
Truth table33%1/3
A and B
A= defined $self->coding_startB= defined $self->coding_stop
ABresult
0X0
100
111
189 2 my ($splice_starts, $splice_stops) = _sanitize_splice_coords_within_limits(
190 $self->splice_starts,
191 $self->splice_stops,
192 $self->coding_start,
193 $self->coding_stop
194 );
195
196 2 return GenOO::Transcript::CDS->new({
197 strand => $self->strand,
198 chromosome => $self->chromosome,
199 start => $self->coding_start,
200 stop => $self->coding_stop,
201 splice_starts => $splice_starts,
202 splice_stops => $splice_stops,
203 transcript => $self
204 });
205 }
206
207 0 return undef;
208 }
209  
210 sub _find_or_create_utr3 {
211 2 ▶ my ($self) = @_;
Subroutine _find_or_create_utr3: called CC=6 SCAR=20.5
212
213 2 ▶ if (defined $self->coding_start and defined $self->coding_stop) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->coding_start and defined $self->coding_stop) 2 0 2
Condition33%1/3
defined $self->coding_start and defined $self->coding_stop
!ll&&!rl&&r
002
MC/DC0%0/2
defined $self->coding_start and defined $self->coding_stop
defined $self->coding_start defined $self->coding_stop
Truth table33%1/3
A and B
A= defined $self->coding_startB= defined $self->coding_stop
ABresult
0X0
100
111
214 2 ▶ my $utr3_start = ($self->strand == 1) ? $self->coding_stop + 1 : $self->start;
Branch: 1 branch
BranchTrueFalseTotal
$self->strand == 1 ? : 0 2 2
215 2 ▶ my $utr3_stop = ($self->strand == 1) ? $self->stop : $self->coding_start - 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->strand == 1 ? : 0 2 2
216
217 2 ▶ return undef if $utr3_start > $utr3_stop; # there is no 3'UTR
Branch: 1 branch
BranchTrueFalseTotal
if $utr3_start > $utr3_stop 0 2 2
218
219 2 my ($splice_starts, $splice_stops) = _sanitize_splice_coords_within_limits(
220 $self->splice_starts,
221 $self->splice_stops,
222 $utr3_start,
223 $utr3_stop
224 );
225
226 2 return GenOO::Transcript::UTR3->new({
227 strand => $self->strand,
228 chromosome => $self->chromosome,
229 start => $utr3_start,
230 stop => $utr3_stop,
231 splice_starts => $splice_starts,
232 splice_stops => $splice_stops,
233 transcript => $self
234 });
235 }
236
237 0 return undef;
238 }
239  
240 sub _find_biotype {
241 2 ▶ my ($self) = @_;
Subroutine _find_biotype: called CC=2 SCAR=6.9
242
243 2 ▶ if (defined $self->coding_start) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->coding_start) 1 1 2
244 1 return 'coding';
245 }
246 }
247  
248 1 __PACKAGE__->meta->make_immutable;
249  
250 1 1;
« GenOO/RegionCollection/Type/DBIC.pm ↑ Summary GenOO/Data/File/GFF/Record.pm »