lib/Bio/ToolBox/Parser/ucsc/builder.pm

filter: Statementstmt 60.4% 254 / 420 Branchbran 52.0% 125 / 240 Conditioncond 31.6% 45 / 142 MC/DCmcdc 18.2% 15 / 82 Subroutinesub 93.3% 28 / 30 Podpod 100% 28 / 28 totaltotal 52.5% 495 / 942 CC 181 SCAR 60.3
CC
181
Cov
53%
new
1237.0
add_codons
210.0
add_utrs
96.6
CRAP 416.9
« script/get_features.pl ↑ Summary lib/Bio/ToolBox/big_helper.pm »
1 package Bio::ToolBox::Parser::ucsc::builder;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '2.00';
7  
8 173 ▶sub new {
Subroutine new: called CC=65 SCAR=71.2
Pod documented
9 173 my ( $class, $linedata, $ucsc ) = @_;
10 173 my %self;
11 my $format;
12  
13 # we're identifying the type of table based on the number of columns
14 # may not be the best or accurate method, but it generally works for valid formats
15  
16 ### Extended Gene Prediction Table ###
17 173 ▶ if ( scalar @{$linedata} == 16 ) {
Branch: 5 branches
BranchTrueFalseTotal
if (scalar @{$linedata;} == 16) { } 87 86 173
elsif (scalar @{$linedata;} == 15) { } 0 86 86
elsif (scalar @{$linedata;} == 12) { } 0 86 86
elsif (scalar @{$linedata;} == 11) { } 0 86 86
elsif (scalar @{$linedata;} == 10) { } 86 0 86
18  
19 # an extended gene prediction table, e.g. refGene, ensGene, xenoRefGene
20 # as downloaded from the UCSC Table Browser or FTP site
21 # includes the bin number as the first column
22  
23 # 0 bin
24 # 1 name
25 # 2 chrom
26 # 3 strand
27 # 4 txStart
28 # 5 txEnd
29 # 6 cdsStart
30 # 7 cdsEnd
31 # 8 exonCount
32 # 9 exonStarts
33 # 10 exonEnds
34 # 11 score
35 # 12 name2
36 # 13 cdsStartStat
37 # 14 cdsEndStat
38 # 15 exonFrames
39  
40 87 $format = 'genePredExt with bin';
41 87 $self{name} = $linedata->[1];
42 87 $self{chrom} = $linedata->[2];
43 87 $self{strand} = $linedata->[3];
44 87 $self{txStart} = $linedata->[4] + 1;
45 87 $self{txEnd} = $linedata->[5];
46 87 $self{cdsStart} = $linedata->[6] + 1;
47 87 $self{cdsEnd} = $linedata->[7];
48 87 $self{exonCount} = $linedata->[8];
49 87 $self{exonStarts} = $linedata->[9];
50 87 $self{exonEnds} = $linedata->[10];
51 87 $self{name2} = $linedata->[12];
52  
53 87 ▶ if ( exists $ucsc->{ensembldata}->{ $linedata->[1] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'ensembldata'}{$linedata->[1]}) { } 53 34 87
54 53 ▶ if ( $ucsc->{ensembldata}->{ $linedata->[1] }->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->{'ensembldata'}{$linedata->[1]}[0]) { } 36 17 53
55 36 $self{gene_name} = $ucsc->{ensembldata}->{ $linedata->[1] }->[0];
56 }
57 else {
58 17 $self{gene_name} = $linedata->[12];
59 }
60 }
61 else {
62 34 $self{gene_name} = $linedata->[12];
63 }
64  
65 87 ▶ if ( exists $ucsc->{refseqsum}->{ $linedata->[1] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'refseqsum'}{$linedata->[1]}) { } 0 87 87
66 0 ▶ $self{note} = $ucsc->{refseqsum}->{ $linedata->[1] }->[1] || q();
Condition0%0/2
$ucsc->{'refseqsum'}{$linedata->[1]}[1] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqsum'}{$linedata->[1]}[1] || ''
$ucsc->{'refseqsum'}{$linedata->[1]}[1]
Truth table0%0/2
A
A= $ucsc->{'refseqsum'}{$linedata->[1]}[1]
Aresult
11
00
67 0 ▶ $self{completeness} = $ucsc->{refseqsum}->{ $linedata->[1] }->[0] || q();
Condition0%0/2
$ucsc->{'refseqsum'}{$linedata->[1]}[0] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqsum'}{$linedata->[1]}[0] || ''
$ucsc->{'refseqsum'}{$linedata->[1]}[0]
Truth table0%0/2
A
A= $ucsc->{'refseqsum'}{$linedata->[1]}[0]
Aresult
11
00
68 }
69 else {
70 87 $self{note} = q();
71 87 $self{completeness} = q();
72 }
73  
74 87 ▶ if ( exists $ucsc->{refseqstat}->{ $linedata->[1] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'refseqstat'}{$linedata->[1]}) { } 0 87 87
75 0 ▶ $self{status} = $ucsc->{refseqstat}->{ $linedata->[1] }->[0] || q();
Condition0%0/2
$ucsc->{'refseqstat'}{$linedata->[1]}[0] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqstat'}{$linedata->[1]}[0] || ''
$ucsc->{'refseqstat'}{$linedata->[1]}[0]
Truth table0%0/2
A
A= $ucsc->{'refseqstat'}{$linedata->[1]}[0]
Aresult
11
00
76 }
77 else {
78 87 $self{status} = q();
79 }
80  
81 87 ▶ if ( $linedata->[1] =~ /^N[MR]_\d+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($linedata->[1] =~ /^N[MR]_\d+/) 0 87 87
82 0 $self{refseq} = $linedata->[1];
83 }
84 }
85 ### Extended Gene Prediction Table ###
86 86 elsif ( scalar @{$linedata} == 15 ) {
87  
88 # an extended gene prediction table, e.g. refGene, ensGene, xenoRefGene
89 # without the bin value
90  
91 # 0 name
92 # 1 chrom
93 # 2 strand
94 # 3 txStart
95 # 4 txEnd
96 # 5 cdsStart
97 # 6 cdsEnd
98 # 7 exonCount
99 # 8 exonStarts
100 # 9 exonEnds
101 # 10 score
102 # 11 name2
103 # 12 cdsStartStat
104 # 13 cdsEndStat
105 # 14 exonFrames
106  
107 0 $format = 'genePredExt';
108 0 $self{name} = $linedata->[0];
109 0 $self{chrom} = $linedata->[1];
110 0 $self{strand} = $linedata->[2];
111 0 $self{txStart} = $linedata->[3] + 1;
112 0 $self{txEnd} = $linedata->[4];
113 0 $self{cdsStart} = $linedata->[5] + 1;
114 0 $self{cdsEnd} = $linedata->[6];
115 0 $self{exonCount} = $linedata->[7];
116 0 $self{exonStarts} = $linedata->[8];
117 0 $self{exonEnds} = $linedata->[9];
118 0 $self{name2} = $linedata->[11];
119  
120 0 ▶ if ( exists $ucsc->{ensembldata}->{ $linedata->[0] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'ensembldata'}{$linedata->[0]}) { } 0 0 0
121 0 ▶ if ( $ucsc->{ensembldata}->{ $linedata->[0] }->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->{'ensembldata'}{$linedata->[0]}[0]) { } 0 0 0
122 0 $self{gene_name} = $ucsc->{ensembldata}->{ $linedata->[0] }->[0];
123 }
124 else {
125 0 $self{gene_name} = $linedata->[11];
126 }
127 }
128 else {
129 0 $self{gene_name} = $linedata->[11];
130 }
131  
132 0 ▶ if ( exists $ucsc->{refseqsum}->{ $linedata->[0] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'refseqsum'}{$linedata->[0]}) { } 0 0 0
133 0 ▶ $self{note} = $ucsc->{refseqsum}->{ $linedata->[0] }->[1] || q();
Condition0%0/2
$ucsc->{'refseqsum'}{$linedata->[0]}[1] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqsum'}{$linedata->[0]}[1] || ''
$ucsc->{'refseqsum'}{$linedata->[0]}[1]
Truth table0%0/2
A
A= $ucsc->{'refseqsum'}{$linedata->[0]}[1]
Aresult
11
00
134 0 ▶ $self{completeness} = $ucsc->{refseqsum}->{ $linedata->[0] }->[0] || q();
Condition0%0/2
$ucsc->{'refseqsum'}{$linedata->[0]}[0] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqsum'}{$linedata->[0]}[0] || ''
$ucsc->{'refseqsum'}{$linedata->[0]}[0]
Truth table0%0/2
A
A= $ucsc->{'refseqsum'}{$linedata->[0]}[0]
Aresult
11
00
135 }
136 else {
137 0 $self{note} = q();
138 0 $self{completeness} = q();
139 }
140  
141 0 ▶ if ( exists $ucsc->{refseqstat}->{ $linedata->[0] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'refseqstat'}{$linedata->[0]}) { } 0 0 0
142 0 ▶ $self{status} = $ucsc->{refseqstat}->{ $linedata->[0] }->[0] || q();
Condition0%0/2
$ucsc->{'refseqstat'}{$linedata->[0]}[0] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqstat'}{$linedata->[0]}[0] || ''
$ucsc->{'refseqstat'}{$linedata->[0]}[0]
Truth table0%0/2
A
A= $ucsc->{'refseqstat'}{$linedata->[0]}[0]
Aresult
11
00
143 }
144 else {
145 0 $self{status} = q();
146 }
147  
148 0 ▶ if ( $linedata->[0] =~ /^N[MR]_\d+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($linedata->[0] =~ /^N[MR]_\d+/) 0 0 0
149 0 $self{refseq} = $linedata->[0];
150 }
151 }
152 ### Known Gene Table ###
153 86 elsif ( scalar @{$linedata} == 12 ) {
154  
155 # 0 name known gene identifier
156 # 1 chrom Reference sequence chromosome or scaffold
157 # 2 strand + or - for strand
158 # 3 txStart Transcription start position
159 # 4 txEnd Transcription end position
160 # 5 cdsStart Coding region start
161 # 6 cdsEnd Coding region end
162 # 7 exonCount Number of exons
163 # 8 exonStarts Exon start positions
164 # 9 exonEnds Exon end positions
165 # 10 proteinID UniProt display ID for Known Genes, UniProt accession or RefSeq protein ID for UCSC Genes
166 # 11 alignID Unique identifier for each (known gene, alignment position) pair
167  
168 0 $format = 'knownGene';
169 0 $self{name} = $linedata->[0];
170 0 $self{chrom} = $linedata->[1];
171 0 $self{strand} = $linedata->[2];
172 0 $self{txStart} = $linedata->[3] + 1;
173 0 $self{txEnd} = $linedata->[4];
174 0 $self{cdsStart} = $linedata->[5] + 1;
175 0 $self{cdsEnd} = $linedata->[6];
176 0 $self{exonCount} = $linedata->[7];
177 0 $self{exonStarts} = $linedata->[8];
178 0 $self{exonEnds} = $linedata->[9];
179 0 $self{name2} = $linedata->[0];
180  
181 0 ▶ if ( exists $ucsc->{kgxref}->{ $linedata->[0] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'kgxref'}{$linedata->[0]}) { } 0 0 0
182 0 $self{name} = $ucsc->{kgxref}->{ $linedata->[0] }->[0];
183 $self{gene_name} =
184 $ucsc->{kgxref}->{ $linedata->[0] }->[3] || # geneSymbol
185 $ucsc->{kgxref}->{ $linedata->[0] }->[0] || # mRNA id
186 0 ▶ $ucsc->{kgxref}->{ $linedata->[0] }->[4] || # refSeq id
Condition0%0/9
$ucsc->{'kgxref'}{$linedata->[0]}[3] || $ucsc->{'kgxref'}{$linedata->[0]}[0] || $ucsc->{'kgxref'}{$linedata->[0]}[4] || $linedata->[0]
l!l&&r!l&&!r
000
$ucsc->{"kgxref"}{$linedata->[0]}[3] or $ucsc->{"kgxref"}{$linedata->[0]}[0] or $ucsc->{"kgxref"}{$linedata->[0]}[4]
l!l&&r!l&&!r
000
$ucsc->{"kgxref"}{$linedata->[0]}[3] or $ucsc->{"kgxref"}{$linedata->[0]}[0]
l!l&&r!l&&!r
000
MC/DC0%0/4
$ucsc->{'kgxref'}{$linedata->[0]}[3] || $ucsc->{'kgxref'}{$linedata->[0]}[0] || $ucsc->{'kgxref'}{$linedata->[0]}[4] || $linedata->[0]
$ucsc->{"kgxref"}{$linedata->[0]}[3] $ucsc->{"kgxref"}{$linedata->[0]}[0] $ucsc->{"kgxref"}{$linedata->[0]}[4] $linedata->[0]
Truth table0%0/5
A or B or C || D
A= $ucsc->{"kgxref"}{$linedata->[0]}[3]B= $ucsc->{"kgxref"}{$linedata->[0]}[0]C= $ucsc->{"kgxref"}{$linedata->[0]}[4]D= $linedata->[0]
ABCDresult
1XXX1
01XX1
001X1
00011
00000
187 $linedata->[0]; # ugly default
188 0 ▶ $self{note} = $ucsc->{kgxref}->{ $linedata->[0] }->[6] || q();
Condition0%0/2
$ucsc->{'kgxref'}{$linedata->[0]}[6] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'kgxref'}{$linedata->[0]}[6] || ''
$ucsc->{'kgxref'}{$linedata->[0]}[6]
Truth table0%0/2
A
A= $ucsc->{'kgxref'}{$linedata->[0]}[6]
Aresult
11
00
189 0 ▶ $self{refseq} = $ucsc->{kgxref}->{ $linedata->[0] }->[4] || q();
Condition0%0/2
$ucsc->{'kgxref'}{$linedata->[0]}[4] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'kgxref'}{$linedata->[0]}[4] || ''
$ucsc->{'kgxref'}{$linedata->[0]}[4]
Truth table0%0/2
A
A= $ucsc->{'kgxref'}{$linedata->[0]}[4]
Aresult
11
00
190 0 ▶ $self{spid} = $ucsc->{kgxref}->{ $linedata->[0] }->[1] || q();
Condition0%0/2
$ucsc->{'kgxref'}{$linedata->[0]}[1] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'kgxref'}{$linedata->[0]}[1] || ''
$ucsc->{'kgxref'}{$linedata->[0]}[1]
Truth table0%0/2
A
A= $ucsc->{'kgxref'}{$linedata->[0]}[1]
Aresult
11
00
191 0 ▶ $self{spdid} = $ucsc->{kgxref}->{ $linedata->[0] }->[2] || q();
Condition0%0/2
$ucsc->{'kgxref'}{$linedata->[0]}[2] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'kgxref'}{$linedata->[0]}[2] || ''
$ucsc->{'kgxref'}{$linedata->[0]}[2]
Truth table0%0/2
A
A= $ucsc->{'kgxref'}{$linedata->[0]}[2]
Aresult
11
00
192 0 ▶ $self{protacc} = $ucsc->{kgxref}->{ $linedata->[0] }->[5] || q();
Condition0%0/2
$ucsc->{'kgxref'}{$linedata->[0]}[5] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'kgxref'}{$linedata->[0]}[5] || ''
$ucsc->{'kgxref'}{$linedata->[0]}[5]
Truth table0%0/2
A
A= $ucsc->{'kgxref'}{$linedata->[0]}[5]
Aresult
11
00
193 }
194 else {
195 0 $self{gene_name} = $linedata->[0]; # ugly default
196 0 $self{note} = q();
197 0 $self{refseq} = q();
198 }
199  
200 0 ▶ if ( exists $self{refseq}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self{"refseq"} and $self{"refseq"} and exists $ucsc->{"refseqstat"}{$self{"refseq"}}) 0 0 0
Condition0%0/6
exists $self{"refseq"} and $self{"refseq"} and exists $ucsc->{"refseqstat"}{$self{"refseq"}}
!ll&&!rl&&r
000
exists $self{"refseq"} and $self{"refseq"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $self{"refseq"} and $self{"refseq"} and exists $ucsc->{"refseqstat"}{$self{"refseq"}}
exists $self{"refseq"} $self{"refseq"} exists $ucsc->{"refseqstat"}{$self{"refseq"}}
Truth table0%0/4
A and B and C
A= exists $self{"refseq"}B= $self{"refseq"}C= exists $ucsc->{"refseqstat"}{$self{"refseq"}}
ABCresult
0XX0
10X0
1100
1111
201 and $self{refseq}
202 and exists $ucsc->{refseqstat}->{ $self{refseq} } )
203 {
204 0 ▶ $self{status} = $ucsc->{refseqstat}->{ $self{refseq} }->[0] || q();
Condition0%0/2
$ucsc->{'refseqstat'}{$self{'refseq'}}[0] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqstat'}{$self{'refseq'}}[0] || ''
$ucsc->{'refseqstat'}{$self{'refseq'}}[0]
Truth table0%0/2
A
A= $ucsc->{'refseqstat'}{$self{'refseq'}}[0]
Aresult
11
00
205 0 ▶ $self{completeness} = $ucsc->{refseqsum}->{ $self{refseq} }->[0] || q();
Condition0%0/2
$ucsc->{'refseqsum'}{$self{'refseq'}}[0] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqsum'}{$self{'refseq'}}[0] || ''
$ucsc->{'refseqsum'}{$self{'refseq'}}[0]
Truth table0%0/2
A
A= $ucsc->{'refseqsum'}{$self{'refseq'}}[0]
Aresult
11
00
206 }
207  
208 }
209 ### refFlat or Gene Prediction Table ###
210 86 elsif ( scalar @{$linedata} == 11 ) {
211  
212 # 0 name2 or gene name
213 # 1 name or transcript name
214 # 2 chrom
215 # 3 strand
216 # 4 txStart
217 # 5 txEnd
218 # 6 cdsStart
219 # 7 cdsEnd
220 # 8 exonCount
221 # 9 exonStarts
222 # 10 exonEnds
223  
224 0 $format = 'refFlat';
225 0 $self{gene_name} = $linedata->[0];
226 0 $self{name2} = $linedata->[0];
227 0 $self{name} = $linedata->[1];
228 0 $self{chrom} = $linedata->[2];
229 0 $self{strand} = $linedata->[3];
230 0 $self{txStart} = $linedata->[4] + 1;
231 0 $self{txEnd} = $linedata->[5];
232 0 $self{cdsStart} = $linedata->[6] + 1;
233 0 $self{cdsEnd} = $linedata->[7];
234 0 $self{exonCount} = $linedata->[8];
235 0 $self{exonStarts} = $linedata->[9];
236 0 $self{exonEnds} = $linedata->[10];
237  
238 0 ▶ if ( exists $ucsc->{ensembldata}->{ $linedata->[1] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{"ensembldata"}{$linedata->[1]}) 0 0 0
239 0 ▶ if ( $ucsc->{ensembldata}->{ $linedata->[1] }->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->{'ensembldata'}{$linedata->[1]}[0]) { } 0 0 0
240 0 $self{gene_name} = $ucsc->{ensembldata}->{ $linedata->[1] }->[0];
241 }
242 else {
243 0 $self{gene_name} = $linedata->[0];
244 }
245 }
246  
247 0 ▶ if ( exists $ucsc->{refseqsum}->{ $linedata->[1] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'refseqsum'}{$linedata->[1]}) { } 0 0 0
248 0 ▶ $self{note} = $ucsc->{refseqsum}->{ $linedata->[1] }->[1] || q();
Condition0%0/2
$ucsc->{'refseqsum'}{$linedata->[1]}[1] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqsum'}{$linedata->[1]}[1] || ''
$ucsc->{'refseqsum'}{$linedata->[1]}[1]
Truth table0%0/2
A
A= $ucsc->{'refseqsum'}{$linedata->[1]}[1]
Aresult
11
00
249 0 ▶ $self{completeness} = $ucsc->{refseqsum}->{ $linedata->[1] }->[0] || q();
Condition0%0/2
$ucsc->{'refseqsum'}{$linedata->[1]}[0] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqsum'}{$linedata->[1]}[0] || ''
$ucsc->{'refseqsum'}{$linedata->[1]}[0]
Truth table0%0/2
A
A= $ucsc->{'refseqsum'}{$linedata->[1]}[0]
Aresult
11
00
250 }
251 else {
252 0 $self{note} = q();
253 0 $self{completeness} = q();
254 }
255  
256 0 ▶ if ( exists $ucsc->{refseqstat}->{ $linedata->[1] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'refseqstat'}{$linedata->[1]}) { } 0 0 0
257 0 ▶ $self{status} = $ucsc->{refseqstat}->{ $linedata->[1] }->[0] || q();
Condition0%0/2
$ucsc->{'refseqstat'}{$linedata->[1]}[0] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqstat'}{$linedata->[1]}[0] || ''
$ucsc->{'refseqstat'}{$linedata->[1]}[0]
Truth table0%0/2
A
A= $ucsc->{'refseqstat'}{$linedata->[1]}[0]
Aresult
11
00
258 }
259 else {
260 0 $self{status} = q();
261 }
262  
263 0 ▶ if ( $linedata->[1] =~ /^N[MR]_\d+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($linedata->[1] =~ /^N[MR]_\d+/) 0 0 0
264 0 $self{refseq} = $linedata->[1];
265 }
266 }
267 ### Gene Prediction Table ###
268 86 elsif ( scalar @{$linedata} == 10 ) {
269  
270 # a simple gene prediction table, e.g. refGene, ensGene, xenoRefGene
271  
272 # 0 name
273 # 1 chrom
274 # 2 strand
275 # 3 txStart
276 # 4 txEnd
277 # 5 cdsStart
278 # 6 cdsEnd
279 # 7 exonCount
280 # 8 exonStarts
281 # 9 exonEnds
282  
283 86 $format = 'genePred';
284 86 $self{name} = $linedata->[0];
285 86 $self{chrom} = $linedata->[1];
286 86 $self{strand} = $linedata->[2];
287 86 $self{txStart} = $linedata->[3] + 1;
288 86 $self{txEnd} = $linedata->[4];
289 86 $self{cdsStart} = $linedata->[5] + 1;
290 86 $self{cdsEnd} = $linedata->[6];
291 86 $self{exonCount} = $linedata->[7];
292 86 $self{exonStarts} = $linedata->[8];
293 86 $self{exonEnds} = $linedata->[9];
294 86 $self{name2} = $linedata->[0]; # re-use transcript name
295 86 $self{gene_name} = $linedata->[0]; # re-use transcript name
296  
297 86 ▶ if ( exists $ucsc->{refseqsum}->{ $linedata->[0] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'refseqsum'}{$linedata->[0]}) { } 0 86 86
298 0 ▶ $self{note} = $ucsc->{refseqsum}->{ $linedata->[0] }->[1] || q();
Condition0%0/2
$ucsc->{'refseqsum'}{$linedata->[0]}[1] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqsum'}{$linedata->[0]}[1] || ''
$ucsc->{'refseqsum'}{$linedata->[0]}[1]
Truth table0%0/2
A
A= $ucsc->{'refseqsum'}{$linedata->[0]}[1]
Aresult
11
00
299 0 ▶ $self{completeness} = $ucsc->{refseqsum}->{ $linedata->[0] }->[0] || q();
Condition0%0/2
$ucsc->{'refseqsum'}{$linedata->[0]}[0] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqsum'}{$linedata->[0]}[0] || ''
$ucsc->{'refseqsum'}{$linedata->[0]}[0]
Truth table0%0/2
A
A= $ucsc->{'refseqsum'}{$linedata->[0]}[0]
Aresult
11
00
300 }
301 else {
302 86 $self{note} = q();
303 86 $self{completeness} = q();
304 }
305  
306 86 ▶ if ( exists $ucsc->{refseqstat}->{ $linedata->[0] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'refseqstat'}{$linedata->[0]}) { } 0 86 86
307 0 ▶ $self{status} = $ucsc->{refseqstat}->{ $linedata->[0] }->[0] || q();
Condition0%0/2
$ucsc->{'refseqstat'}{$linedata->[0]}[0] || ''
l!l
00
MC/DC0%0/1
$ucsc->{'refseqstat'}{$linedata->[0]}[0] || ''
$ucsc->{'refseqstat'}{$linedata->[0]}[0]
Truth table0%0/2
A
A= $ucsc->{'refseqstat'}{$linedata->[0]}[0]
Aresult
11
00
308 }
309 else {
310 86 $self{status} = q();
311 }
312  
313 86 ▶ if ( $linedata->[0] =~ /^N[MR]_\d+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($linedata->[0] =~ /^N[MR]_\d+/) 0 86 86
314 0 $self{refseq} = $linedata->[0];
315 }
316 }
317 else {
318 # unrecognized line format
319 printf STDERR "ERROR: unrecognized format, line has %d elements\n",
320 0 scalar @{$linedata};
321 0 return;
322 }
323  
324 # verify
325 173 my @errors;
326 173 ▶ push @errors, 'strand' unless $self{strand} =~ /^[\+\-\.]$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self{"strand"} =~ /^[\+\-\.]$/ 0 173 173
327 173 ▶ push @errors, 'txStart' unless $self{txStart} =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self{"txStart"} =~ /^\d+$/ 0 173 173
328 173 ▶ push @errors, 'txEnd' unless $self{txEnd} =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self{"txEnd"} =~ /^\d+$/ 0 173 173
329 173 ▶ push @errors, 'cdsStart' unless $self{cdsStart} =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self{"cdsStart"} =~ /^\d+$/ 0 173 173
330 173 ▶ push @errors, 'cdsEnd' unless $self{cdsEnd} =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self{"cdsEnd"} =~ /^\d+$/ 0 173 173
331 173 ▶ push @errors, 'exonCount' unless $self{exonCount} =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self{"exonCount"} =~ /^\d+$/ 0 173 173
332 173 ▶ push @errors, 'exonStarts' unless $self{exonStarts} =~ /^[\d,]+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self{"exonStarts"} =~ /^[\d,]+$/ 0 173 173
333 173 ▶ push @errors, 'exonEnds' unless $self{exonEnds} =~ /^[\d,]+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self{"exonEnds"} =~ /^[\d,]+$/ 0 173 173
334  
335 173 ▶ if (@errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (@errors) 0 173 173
336 0 printf STDERR "ERROR: line format for %s has the following errors: %s\n",
337 $format, join( ", ", @errors );
338 0 return;
339 }
340  
341 # fix values
342 173 ▶ $self{strand} = $self{strand} eq '+' ? 1 : $self{strand} eq '-' ? -1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
$self{'strand'} eq '+' ? : 139 34 173
$self{'strand'} eq '-' ? : 18 16 34
343 173 $self{exonStarts} = [ map { $_ += 1 } ( split /,/, $self{exonStarts} ) ];
344 173 $self{exonEnds} = [ ( split /,/, $self{exonEnds} ) ];
345  
346 # Attempt to identify the transcript type
347 173 ▶ if ( $self{cdsStart} - 1 == $self{cdsEnd} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self{'cdsStart'} - 1 == $self{'cdsEnd'}) { } 63 110 173
348  
349 # there appears to be no coding potential when
350 # txEnd = cdsStart = cdsEnd
351 # if you'll look, all of the exon phases should also be -1
352  
353 # otherwise, we may be able to infer some certain
354 # types from the gene name
355 63 ▶ if ( $self{name2} =~ /^mir/i ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self{'name2'} =~ /^mir/i) { } 0 63 63
elsif ($self{'name2'} =~ /^snr/i) { } 0 63 63
elsif ($self{'name2'} =~ /^sno/i) { } 0 63 63
356  
357 # a noncoding gene whose name begins with mir is likely a micro RNA
358 0 $self{type} = 'miRNA';
359 }
360 elsif ( $self{name2} =~ /^snr/i ) {
361  
362 # a noncoding gene whose name begins with snr is likely a snRNA
363 0 $self{type} = 'snRNA';
364 }
365 elsif ( $self{name2} =~ /^sno/i ) {
366  
367 # a noncoding gene whose name begins with sno is likely a snoRNA
368 0 $self{type} = 'snoRNA';
369 }
370 else {
371 # a generic ncRNA
372 63 $self{type} = 'ncRNA';
373 }
374 }
375 else {
376 # the transcript has an identifiable CDS so likely a mRNA
377 110 $self{type} = 'mRNA';
378 }
379  
380 # add the ucsc object
381 173 $self{ucsc} = $ucsc;
382  
383 173 return bless \%self, $class;
384 }
385  
386 572 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
387 572 return shift->{name};
388 }
389  
390 229 ▶sub name2 {
Subroutine name2: called CC=1 SCAR=0.0
Pod documented
391 229 return shift->{name2};
392 }
393  
394 323 ▶sub gene_name {
Subroutine gene_name: called CC=1 SCAR=0.0
Pod documented
395 323 return shift->{gene_name};
396 }
397  
398 243 ▶sub chrom {
Subroutine chrom: called CC=1 SCAR=0.0
Pod documented
399 243 return shift->{chrom};
400 }
401  
402 291 ▶sub txStart {
Subroutine txStart: called CC=1 SCAR=0.0
Pod documented
403 291 return shift->{txStart};
404 }
405  
406 295 ▶sub txEnd {
Subroutine txEnd: called CC=1 SCAR=0.0
Pod documented
407 295 return shift->{txEnd};
408 }
409  
410 243 ▶sub strand {
Subroutine strand: called CC=1 SCAR=0.0
Pod documented
411 243 return shift->{strand};
412 }
413  
414 811 ▶sub cdsStart {
Subroutine cdsStart: called CC=1 SCAR=0.0
Pod documented
415 811 return shift->{cdsStart};
416 }
417  
418 409 ▶sub cdsEnd {
Subroutine cdsEnd: called CC=1 SCAR=0.0
Pod documented
419 409 return shift->{cdsEnd};
420 }
421  
422 942 ▶sub exonCount {
Subroutine exonCount: called CC=1 SCAR=0.0
Pod documented
423 942 return shift->{exonCount};
424 }
425  
426 1412 ▶sub exonStarts {
Subroutine exonStarts: called CC=1 SCAR=0.0
Pod documented
427 1412 return shift->{exonStarts};
428 }
429  
430 1014 ▶sub exonEnds {
Subroutine exonEnds: called CC=1 SCAR=0.0
Pod documented
431 1014 return shift->{exonEnds};
432 }
433  
434 173 ▶sub type {
Subroutine type: called CC=1 SCAR=0.0
Pod documented
435 173 return shift->{type};
436 }
437  
438 243 ▶sub refseq {
Subroutine refseq: called CC=3 SCAR=13.3
Pod documented
439 243 my $self = shift;
440 243 ▶ if ( exists $self->{refseq} and $self->{refseq} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'refseq'} and $self->{'refseq'}) { } 0 243 243
Condition33%1/3
exists $self->{"refseq"} and $self->{"refseq"}
!ll&&!rl&&r
24300
MC/DC0%0/2
exists $self->{"refseq"} and $self->{"refseq"}
exists $self->{"refseq"} $self->{"refseq"}
Truth table33%1/3
A and B
A= exists $self->{"refseq"}B= $self->{"refseq"}
ABresult
0X0
100
111
441 0 return $self->{refseq};
442 }
443 else {
444 243 return q();
445 }
446 }
447  
448 243 ▶sub note {
Subroutine note: called CC=3 SCAR=13.3
Pod documented
449 243 my $self = shift;
450 243 ▶ if ( exists $self->{note} and $self->{note} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'note'} and $self->{'note'}) { } 0 243 243
Condition33%1/3
exists $self->{"note"} and $self->{"note"}
!ll&&!rl&&r
02430
MC/DC0%0/2
exists $self->{"note"} and $self->{"note"}
exists $self->{"note"} $self->{"note"}
Truth table33%1/3
A and B
A= exists $self->{"note"}B= $self->{"note"}
ABresult
0X0
100
111
451 0 return $self->{note};
452 }
453 else {
454 243 return q();
455 }
456 }
457  
458 346 ▶sub status {
Subroutine status: called CC=3 SCAR=13.3
Pod documented
459 346 my $self = shift;
460 346 ▶ if ( exists $self->{status} and $self->{status} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'status'} and $self->{'status'}) { } 0 346 346
Condition33%1/3
exists $self->{"status"} and $self->{"status"}
!ll&&!rl&&r
03460
MC/DC0%0/2
exists $self->{"status"} and $self->{"status"}
exists $self->{"status"} $self->{"status"}
Truth table33%1/3
A and B
A= exists $self->{"status"}B= $self->{"status"}
ABresult
0X0
100
111
461 0 return $self->{status};
462 }
463 else {
464 346 return q();
465 }
466 }
467  
468 346 ▶sub completeness {
Subroutine completeness: called CC=3 SCAR=13.3
Pod documented
469 346 my $self = shift;
470 346 ▶ if ( exists $self->{completeness} and $self->{completeness} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'completeness'} and $self->{'completeness'}) { } 0 346 346
Condition33%1/3
exists $self->{"completeness"} and $self->{"completeness"}
!ll&&!rl&&r
03460
MC/DC0%0/2
exists $self->{"completeness"} and $self->{"completeness"}
exists $self->{"completeness"} $self->{"completeness"}
Truth table33%1/3
A and B
A= exists $self->{"completeness"}B= $self->{"completeness"}
ABresult
0X0
100
111
471 0 return $self->{completeness};
472 }
473 else {
474 346 return q();
475 }
476 }
477  
478 385 ▶sub ucsc {
Subroutine ucsc: called CC=1 SCAR=0.0
Pod documented
479 385 return shift->{ucsc};
480 }
481  
482 70 ▶sub build_gene {
Subroutine build_gene: called CC=13 SCAR=27.4
Pod documented
483 70 my $self = shift;
484  
485 # shortcuts
486 70 my $ucsc = $self->ucsc;
487 70 my $id2count = $ucsc->{id2count};
488  
489 # find a pre-existing gene to update or build a new one
490 70 my $gene;
491 70 my $name = $self->gene_name;
492 70 ▶ if ( exists $ucsc->{gene2seqf}->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{"gene2seqf"}{$name}) 48 22 70
493  
494 # we found a gene with the same name
495 # pull out the gene seqfeature(s) array reference
496 # there may actually be more than one gene
497 48 my $genes = $ucsc->{gene2seqf}->{$name};
498  
499 # check that the current transcript intersects with the gene
500 # sometimes we can have two separate transcripts with the
501 # same gene name, but located on opposite ends of the chromosome
502 # part of a gene family, but unlikely the same gene 200 Mb in
503 # length
504 48 foreach my $g ( @{$genes} ) {
505 48 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($g->seq_id eq $self->chrom and $g->strand == $self->strand and not $g->start > $self->txEnd || $g->end < $self->txStart) 48 0 48
Condition33%3/9
$g->seq_id eq $self->chrom and $g->strand == $self->strand and not $g->start > $self->txEnd || $g->end < $self->txStart
!ll&&!rl&&r
0048
$g->seq_id eq $self->chrom and $g->strand == $self->strand
!ll&&!rl&&r
0048
$g->start > $self->txEnd || $g->end < $self->txStart
l!l&&r!l&&!r
0048
MC/DC0%0/4
$g->seq_id eq $self->chrom and $g->strand == $self->strand and not $g->start > $self->txEnd || $g->end < $self->txStart
$g->seq_id eq $self->chrom $g->strand == $self->strand $g->start > $self->txEnd $g->end < $self->txStart
Truth table20%1/5
A and B and not(C || D)
A= $g->seq_id eq $self->chromB= $g->strand == $self->strandC= $g->start > $self->txEndD= $g->end < $self->txStart
ABCDresult
0XXX0
10XX0
111X0
11010
11001
506 # overlap method borrowed from Bio::RangeI
507 $g->seq_id eq $self->chrom
508 and ( $g->strand == $self->strand )
509 and not( $g->start > $self->txEnd
510 or $g->end < $self->txStart )
511 )
512 {
513 # gene and transcript overlap on the same strand
514 # we found the intersecting gene
515 48 $gene = $g;
516 48 last;
517 }
518 }
519 }
520  
521 # process the gene
522 70 ▶ if ($gene) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gene) { } 48 22 70
523  
524 # update coordinates as necessary
525 48 ▶ if ( ( $self->txStart ) < $gene->start ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->txStart < $gene->start) 0 48 48
526 0 $gene->start( $self->txStart );
527 }
528 48 ▶ if ( $self->txEnd > $gene->end ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->txEnd > $gene->end) 4 44 48
529 4 $gene->end( $self->txEnd );
530 }
531 }
532 else {
533 # build a new gene object
534 $gene = $ucsc->{sfclass}->new(
535 22 -seq_id => $self->chrom,
536 -source => $ucsc->source,
537 -primary_tag => 'gene',
538 -start => $self->txStart,
539 -end => $self->txEnd,
540 -strand => $self->strand,
541 -phase => '.',
542 -display_name => $self->gene_name,
543 );
544  
545 # Add a unique primary ID
546 22 my $id = $self->name2;
547 22 ▶ if ( exists $id2count->{ lc $id } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$id2count{lc $id}) { } 0 22 22
548  
549 # we've encountered this gene ID before
550  
551 # then make name unique by appending the count number
552 0 $id2count->{ lc $id } += 1;
553 0 $id .= '.' . $id2count->{ lc $id };
554 }
555 else {
556 # this is the first transcript with this id
557 # set the id counter
558 22 $id2count->{ lc $id } = 0;
559 }
560 22 $gene->primary_id($id);
561  
562 # Add to the gene2seqf hash - this is based on gene name, not unique id
563 22 ▶ if ( exists $ucsc->{gene2seqf}{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ucsc->{'gene2seqf'}{$name}) { } 0 22 22
564  
565 # more than one gene with this name, add it to the list
566 0 push @{ $ucsc->{gene2seqf}{$name} }, $gene;
567 }
568 else {
569 # inaugural member for the gene name
570 22 $ucsc->{gene2seqf}{$name} = [$gene];
571 }
572  
573 # Add an alias
574 22 ▶ if ( $self->name2 ne $self->gene_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->name2 ne $self->gene_name) 12 10 22
575 12 $gene->add_tag_value( 'Alias', $self->name2 );
576 }
577  
578 # add to the gene count
579 22 $ucsc->{counts}{'gene'} += 1;
580 }
581  
582 # now build the transcript for the gene
583 70 my $transcript = $self->build_transcript($gene);
584 70 $gene->add_SeqFeature($transcript);
585 70 $transcript->add_tag_value( 'Parent', $gene->primary_id );
586  
587 # update extra attributes as necessary
588 70 $self->update_attributes($gene);
589  
590 # finished
591 70 return $gene;
592 }
593  
594 173 ▶sub build_transcript {
Subroutine build_transcript: called CC=15 SCAR=27.5
Pod documented
595 173 my ( $self, $gene ) = @_; # gene is not required
596  
597 # shortcuts
598 173 my $ucsc = $self->ucsc;
599 173 my $id2count = $ucsc->{id2count};
600 173 my $ensembldata = $ucsc->{ensembldata};
601  
602 # Uniqueify the transcript ID but only if a gene is not present
603 173 my $id = $self->name;
604 173 ▶ if ( exists $id2count->{ lc $id } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$id2count{lc $id}) { } 0 173 173
605  
606 # we've encountered this transcript ID before
607  
608 # now need to make ID unique by appending a number
609 0 $id2count->{ lc $id } += 1;
610 0 $id .= '.' . $id2count->{ lc $id };
611 }
612 else {
613 # this is the first transcript with this id
614 173 $id2count->{ lc $id } = 0;
615 }
616  
617 # Generate the transcript SeqFeature object
618 my $transcript = $ucsc->{sfclass}->new(
619 173 -seq_id => $self->chrom,
620 -source => $ucsc->source,
621 -primary_tag => $self->type,
622 -start => $self->txStart,
623 -end => $self->txEnd,
624 -strand => $self->strand,
625 -phase => '.',
626 -display_name => $self->name,
627 -primary_id => $id,
628 );
629  
630 # add gene name as an alias
631 173 ▶ if ( $self->gene_name ne $self->name2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->gene_name ne $self->name2) 36 137 173
632 36 $transcript->add_tag_value( 'Alias', $self->gene_name );
633 }
634  
635 # adjust the primary_tag and biotype values as necessary
636 173 ▶ if ( exists $ensembldata->{ $self->name } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$ensembldata{$self->name}) 53 120 173
637 53 ▶ my $t = $ensembldata->{ $self->name }->[1] || q();
Condition50%1/2
$$ensembldata{$self->name}[1] || ''
l!l
530
MC/DC0%0/1
$$ensembldata{$self->name}[1] || ''
$$ensembldata{$self->name}[1]
Truth table50%1/2
A
A= $$ensembldata{$self->name}[1]
Aresult
11
00
638 53 ▶ if ( $t =~ /protein.coding/xi ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($t =~ /protein.coding/xi) { } 26 27 53
elsif ($t =~ /(?: rna | transcript )/xi) { } 15 12 27
elsif ($t) { } 12 0 12
639 26 $transcript->primary_tag('mRNA');
640 26 $transcript->add_tag_value( 'biotype', $t );
641 }
642 elsif ( $t =~ /(?: rna | transcript )/xi ) {
643 15 $transcript->primary_tag($t); # this is redundant????
644 15 $transcript->add_tag_value( 'biotype', $t );
645 }
646 elsif ($t) {
647 12 $transcript->primary_tag('transcript');
648 12 $transcript->add_tag_value( 'biotype', $t );
649 }
650 }
651  
652 # update extra attributes as necessary
653 173 $self->update_attributes($transcript);
654  
655 # add transcript specific attributes
656 173 ▶ if ( defined $self->completeness ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->completeness) 173 0 173
657 173 $transcript->add_tag_value( 'completeness', $self->completeness );
658 }
659 173 ▶ if ( defined $self->status ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->status) 173 0 173
660 173 $transcript->add_tag_value( 'status', $self->status );
661 }
662  
663 # add the exons
664 173 ▶ if ( $ucsc->do_exon ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->do_exon) 122 51 173
665 122 $self->add_exons( $transcript, $gene );
666 }
667  
668 # add CDS, UTRs, and codons if necessary
669 173 ▶ if ( $self->cdsStart - 1 != $self->cdsEnd ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cdsStart - 1 != $self->cdsEnd) 110 63 173
670  
671 110 ▶ if ( $ucsc->do_utr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->do_utr) 10 100 110
672 10 $self->add_utrs( $transcript, $gene );
673 }
674  
675 110 ▶ if ( $ucsc->do_codon ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->do_codon) 0 110 110
676 0 $self->add_codons( $transcript, $gene );
677 }
678  
679 110 ▶ if ( $ucsc->do_cds ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->do_cds) 10 100 110
680 10 $self->add_cds($transcript);
681 }
682 }
683  
684 # record the type of transcript
685 173 $ucsc->{counts}{ $transcript->primary_tag } += 1;
686  
687 # transcript is complete
688 173 return $transcript;
689 }
690  
691 243 ▶sub update_attributes {
Subroutine update_attributes: called CC=9 SCAR=30.6
Pod documented
692 243 my ( $self, $seqf ) = @_;
693  
694 # add Note if possible
695 243 ▶ if ( $self->note ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->note) 0 243 243
696 0 $self->add_unique_attribute( $seqf, 'Note', $self->note );
697 }
698  
699 # add refSeq identifier if possible
700 243 ▶ if ( $self->refseq ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->refseq) 0 243 243
701 0 $self->add_unique_attribute( $seqf, 'Dbxref', 'RefSeq:' . $self->refseq );
702 }
703  
704 # add SwissProt identifier if possible
705 243 ▶ if ( exists $self->{spid} and $self->{spid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"spid"} and $self->{"spid"}) 0 243 243
Condition33%1/3
exists $self->{"spid"} and $self->{"spid"}
!ll&&!rl&&r
24300
MC/DC0%0/2
exists $self->{"spid"} and $self->{"spid"}
exists $self->{"spid"} $self->{"spid"}
Truth table33%1/3
A and B
A= exists $self->{"spid"}B= $self->{"spid"}
ABresult
0X0
100
111
706 0 $self->add_unique_attribute( $seqf, 'Dbxref', 'Swiss-Prot:' . $self->{spid} );
707 }
708  
709 # add SwissProt display identifier if possible
710 243 ▶ if ( exists $self->{spdid} and $self->{spdid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"spdid"} and $self->{"spdid"}) 0 243 243
Condition33%1/3
exists $self->{"spdid"} and $self->{"spdid"}
!ll&&!rl&&r
24300
MC/DC0%0/2
exists $self->{"spdid"} and $self->{"spdid"}
exists $self->{"spdid"} $self->{"spdid"}
Truth table33%1/3
A and B
A= exists $self->{"spdid"}B= $self->{"spdid"}
ABresult
0X0
100
111
711 0 $self->add_unique_attribute( $seqf, 'swiss-prot_display_id', $self->{spdid} );
712 }
713  
714 # add NCBI protein access identifier if possible
715 243 ▶ if ( exists $self->{protacc} and $self->{protacc} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"protacc"} and $self->{"protacc"}) 0 243 243
Condition33%1/3
exists $self->{"protacc"} and $self->{"protacc"}
!ll&&!rl&&r
24300
MC/DC0%0/2
exists $self->{"protacc"} and $self->{"protacc"}
exists $self->{"protacc"} $self->{"protacc"}
Truth table33%1/3
A and B
A= exists $self->{"protacc"}B= $self->{"protacc"}
ABresult
0X0
100
111
716 0 $self->add_unique_attribute( $seqf, 'Dbxref', 'RefSeq:' . $self->{protacc} );
717 }
718 }
719  
720 0 ▶sub add_unique_attribute {
Subroutine add_unique_attribute: not called CC=4 SCAR=30.0
Pod documented
721 0 my ( $self, $seqf, $tag, $value ) = @_;
722  
723 # look for a pre-existing identical tag value
724 0 my $check = 1;
725 0 foreach ( $seqf->get_tag_values($tag) ) {
726 0 ▶ if ( $_ eq $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq $value) 0 0 0
727 0 $check = 0;
728 0 last;
729 }
730 }
731  
732 # add it if our value is unique
733 0 ▶ $seqf->add_tag_value( $tag, $value ) if $check;
Branch: 1 branch
BranchTrueFalseTotal
if $check 0 0 0
734 }
735  
736 122 ▶sub add_exons {
Subroutine add_exons: called CC=7 SCAR=19.5
Pod documented
737 122 my ( $self, $transcript, $gene ) = @_;
738 122 my $ucsc = $self->ucsc;
739  
740 # Add the exons
741 EXON_LOOP:
742 122 ▶ for ( my $i = 0; $i < $self->exonCount; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $self->exonCount) 595 122 717
743  
744 # first look for existing
745 595 ▶ if ( $ucsc->share and $gene ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->share and $gene) 277 318 595
Condition100%3/3
$ucsc->share and $gene
!ll&&!rl&&r
22989277
MC/DC100%2/2
$ucsc->share and $gene
$ucsc->share $gene
Truth table100%3/3
A and B
A= $ucsc->shareB= $gene
ABresult
0X0
100
111
746 277 my $exon = $self->find_existing_subfeature(
747 $gene, 'exon',
748 $self->exonStarts->[$i],
749 $self->exonEnds->[$i]
750 );
751 277 ▶ if ($exon) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exon) 156 121 277
752  
753 # we found an existing exon to reuse
754 # associate with this transcript
755 156 $transcript->add_SeqFeature($exon);
756 156 next EXON_LOOP;
757 }
758 }
759  
760 # transform index for reverse strands
761 # this will allow numbering from 5'->3'
762 439 my $number;
763 439 ▶ if ( $transcript->strand == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($transcript->strand == 1) { } 386 53 439
764  
765 # forward strand
766 386 $number = $i;
767 }
768 else {
769 # reverse strand
770 53 $number = abs( $i - $self->exonCount + 1 );
771 }
772  
773 # build the exon seqfeature
774 my $exon = $ucsc->{sfclass}->new(
775 439 -seq_id => $transcript->seq_id,
776 -source => $transcript->source,
777 -primary_tag => 'exon',
778 -start => $self->exonStarts->[$i],
779 -end => $self->exonEnds->[$i],
780 -strand => $transcript->strand,
781 -primary_id => $transcript->primary_id . ".exon$number",
782 );
783  
784 # add name if requested
785 439 ▶ if ( $ucsc->do_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->do_name) 0 439 439
786 0 $exon->display_name( $transcript->display_name . ".exon$number" );
787 }
788  
789 # associate with transcript
790 439 $transcript->add_SeqFeature($exon);
791 }
792 }
793  
794 10 ▶sub add_utrs {
Subroutine add_utrs: called CC=31 SCAR=45.7
Pod documented
795 10 my ( $self, $transcript, $gene ) = @_;
796 10 my $ucsc = $self->ucsc;
797  
798 # we will scan each exon and look for a potential utr and build it
799 10 my @utrs;
800 UTR_LOOP:
801 10 ▶ for ( my $i = 0; $i < $self->exonCount; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $self->exonCount) 76 10 86
802  
803 # transform index for reverse strands
804 # this will allow numbering from 5'->3'
805 76 my $number;
806 76 ▶ if ( $transcript->strand == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($transcript->strand == 1) { } 76 0 76
807  
808 # forward strand
809 76 $number = $i;
810 }
811 else {
812 # reverse strand
813 0 $number = abs( $i - $self->exonCount + 1 );
814 }
815  
816 # identify UTRs
817 # we will identify by comparing the cdsStart and cdsStop relative
818 # to the exon coordinates
819 # the primary tag is determined by the exon strand orientation
820 76 my ( $start, $stop, $tag );
821  
822 # in case we need to build two UTRs
823 76 my ( $start2, $stop2, $tag2 );
824  
825 # Split 5'UTR, CDS, and 3'UTR all on the same exon
826 76 ▶ if ( $self->exonStarts->[$i] < $self->cdsStart
Branch: 6 branches
BranchTrueFalseTotal
if ($self->exonStarts->[$i] < $self->cdsStart and $self->exonEnds->[$i] > $self->cdsEnd) { } 0 76 76
elsif ($self->exonStarts->[$i] < $self->cdsStart and $self->exonEnds->[$i] < $self->cdsStart) { } 3 73 76
elsif ($self->exonStarts->[$i] < $self->cdsStart and $self->exonEnds->[$i] >= $self->cdsStart) { } 9 64 73
elsif ($self->exonStarts->[$i] >= $self->cdsStart and $self->exonEnds->[$i] <= $self->cdsEnd) { } 50 14 64
elsif ($self->exonStarts->[$i] <= $self->cdsEnd and $self->exonEnds->[$i] > $self->cdsEnd) { } 7 7 14
elsif ($self->exonStarts->[$i] > $self->cdsEnd and $self->exonEnds->[$i] > $self->cdsEnd) { } 7 0 7
Condition66%2/3
$self->exonStarts->[$i] < $self->cdsStart and $self->exonEnds->[$i] > $self->cdsEnd
!ll&&!rl&&r
64120
MC/DC0%0/2
$self->exonStarts->[$i] < $self->cdsStart and $self->exonEnds->[$i] > $self->cdsEnd
$self->exonStarts->[$i] < $self->cdsStart $self->exonEnds->[$i] > $self->cdsEnd
Truth table66%2/3
A and B
A= $self->exonStarts->[$i] < $self->cdsStartB= $self->exonEnds->[$i] > $self->cdsEnd
ABresult
0X0
100
111
827 and $self->exonEnds->[$i] > $self->cdsEnd )
828 {
829 # the CDS is entirely within the exon, resulting in two UTRs
830 # on either side of the exon
831 # we must build two UTRs
832  
833 # the left UTR
834 0 $start = $self->exonStarts->[$i];
835 0 $stop = $self->cdsStart - 1;
836 0 ▶ $tag = $transcript->strand == 1 ? 'five_prime_UTR' : 'three_prime_UTR';
Branch: 1 branch
BranchTrueFalseTotal
$transcript->strand == 1 ? : 0 0 0
837  
838 # the right UTR
839 0 $start2 = $self->cdsEnd + 1;
840 0 $stop2 = $self->exonEnds->[$i];
841 0 ▶ $tag2 = $transcript->strand == 1 ? 'three_prime_UTR' : 'five_prime_UTR';
Branch: 1 branch
BranchTrueFalseTotal
$transcript->strand == 1 ? : 0 0 0
842 }
843  
844 # 5'UTR forward, 3'UTR reverse
845 ▶ elsif ( $self->exonStarts->[$i] < $self->cdsStart
Condition100%3/3
$self->exonStarts->[$i] < $self->cdsStart and $self->exonEnds->[$i] < $self->cdsStart
!ll&&!rl&&r
6493
MC/DC100%2/2
$self->exonStarts->[$i] < $self->cdsStart and $self->exonEnds->[$i] < $self->cdsStart
$self->exonStarts->[$i] < $self->cdsStart $self->exonEnds->[$i] < $self->cdsStart
Truth table100%3/3
A and B
A= $self->exonStarts->[$i] < $self->cdsStartB= $self->exonEnds->[$i] < $self->cdsStart
ABresult
0X0
100
111
846 and $self->exonEnds->[$i] < $self->cdsStart )
847 {
848 # the exon start/end is entirely before the cdsStart
849 3 $start = $self->exonStarts->[$i];
850 3 $stop = $self->exonEnds->[$i];
851 3 ▶ $tag = $transcript->strand == 1 ? 'five_prime_UTR' : 'three_prime_UTR';
Branch: 1 branch
BranchTrueFalseTotal
$transcript->strand == 1 ? : 3 0 3
852 }
853  
854 # Split 5'UTR & CDS on forward, 3'UTR & CDS
855 ▶ elsif ( $self->exonStarts->[$i] < $self->cdsStart
Condition66%2/3
$self->exonStarts->[$i] < $self->cdsStart and $self->exonEnds->[$i] >= $self->cdsStart
!ll&&!rl&&r
6409
MC/DC50%1/2
$self->exonStarts->[$i] < $self->cdsStart and $self->exonEnds->[$i] >= $self->cdsStart
$self->exonStarts->[$i] < $self->cdsStart $self->exonEnds->[$i] >= $self->cdsStart
Truth table66%2/3
A and B
A= $self->exonStarts->[$i] < $self->cdsStartB= $self->exonEnds->[$i] >= $self->cdsStart
ABresult
0X0
100
111
856 and $self->exonEnds->[$i] >= $self->cdsStart )
857 {
858 # the start/stop codon is in this exon
859 # we need to make the UTR out of a portion of this exon
860 9 $start = $self->exonStarts->[$i];
861 9 $stop = $self->cdsStart - 1;
862 9 ▶ $tag = $transcript->strand == 1 ? 'five_prime_UTR' : 'three_prime_UTR';
Branch: 1 branch
BranchTrueFalseTotal
$transcript->strand == 1 ? : 9 0 9
863 }
864  
865 # CDS only
866 ▶ elsif ( $self->exonStarts->[$i] >= $self->cdsStart
Condition66%2/3
$self->exonStarts->[$i] >= $self->cdsStart and $self->exonEnds->[$i] <= $self->cdsEnd
!ll&&!rl&&r
01450
MC/DC50%1/2
$self->exonStarts->[$i] >= $self->cdsStart and $self->exonEnds->[$i] <= $self->cdsEnd
$self->exonStarts->[$i] >= $self->cdsStart $self->exonEnds->[$i] <= $self->cdsEnd
Truth table66%2/3
A and B
A= $self->exonStarts->[$i] >= $self->cdsStartB= $self->exonEnds->[$i] <= $self->cdsEnd
ABresult
0X0
100
111
867 and $self->exonEnds->[$i] <= $self->cdsEnd )
868 {
869 # CDS only exon
870 50 next UTR_LOOP;
871 }
872  
873 # Split 3'UTR & CDS on forward, 5'UTR & CDS
874 ▶ elsif ( $self->exonStarts->[$i] <= $self->cdsEnd
Condition66%2/3
$self->exonStarts->[$i] <= $self->cdsEnd and $self->exonEnds->[$i] > $self->cdsEnd
!ll&&!rl&&r
707
MC/DC50%1/2
$self->exonStarts->[$i] <= $self->cdsEnd and $self->exonEnds->[$i] > $self->cdsEnd
$self->exonStarts->[$i] <= $self->cdsEnd $self->exonEnds->[$i] > $self->cdsEnd
Truth table66%2/3
A and B
A= $self->exonStarts->[$i] <= $self->cdsEndB= $self->exonEnds->[$i] > $self->cdsEnd
ABresult
0X0
100
111
875 and $self->exonEnds->[$i] > $self->cdsEnd )
876 {
877 # the stop/start codon is in this exon
878 # we need to make the UTR out of a portion of this exon
879 7 $start = $self->cdsEnd + 1;
880 7 $stop = $self->exonEnds->[$i];
881 7 ▶ $tag = $transcript->strand == 1 ? 'three_prime_UTR' : 'five_prime_UTR';
Branch: 1 branch
BranchTrueFalseTotal
$transcript->strand == 1 ? : 7 0 7
882 }
883  
884 # 3'UTR forward, 5'UTR reverse
885 ▶ elsif ( $self->exonStarts->[$i] > $self->cdsEnd
Condition33%1/3
$self->exonStarts->[$i] > $self->cdsEnd and $self->exonEnds->[$i] > $self->cdsEnd
!ll&&!rl&&r
007
MC/DC0%0/2
$self->exonStarts->[$i] > $self->cdsEnd and $self->exonEnds->[$i] > $self->cdsEnd
$self->exonStarts->[$i] > $self->cdsEnd $self->exonEnds->[$i] > $self->cdsEnd
Truth table33%1/3
A and B
A= $self->exonStarts->[$i] > $self->cdsEndB= $self->exonEnds->[$i] > $self->cdsEnd
ABresult
0X0
100
111
886 and $self->exonEnds->[$i] > $self->cdsEnd )
887 {
888 # the exon start/end is entirely after the cdsStop
889 # we have a 3'UTR
890 7 $start = $self->exonStarts->[$i];
891 7 $stop = $self->exonEnds->[$i];
892 7 ▶ $tag = $transcript->strand == 1 ? 'three_prime_UTR' : 'five_prime_UTR';
Branch: 1 branch
BranchTrueFalseTotal
$transcript->strand == 1 ? : 7 0 7
893 }
894  
895 # Something else?
896 else {
897 0 printf STDERR
898 "Warning: A malformed UTR that doesn't match known criteria: cdsStart %d, cdsEnd %d, exonStart %d, exonEnd %d\n",
899 $self->cdsStart, $self->cdsEnd, $self->exonStarts->[$i],
900 $self->exonEnds->[$i];
901 0 next UTR_LOOP;
902 }
903  
904 ## Generate the UTR objects
905 26 my $utr;
906  
907 # look for existing utr
908 26 ▶ if ( $ucsc->share and $gene ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->share and $gene) 26 0 26
Condition33%1/3
$ucsc->share and $gene
!ll&&!rl&&r
0026
MC/DC0%0/2
$ucsc->share and $gene
$ucsc->share $gene
Truth table33%1/3
A and B
A= $ucsc->shareB= $gene
ABresult
0X0
100
111
909 26 $utr = $self->find_existing_subfeature( $gene, $tag, $start, $stop );
910 }
911  
912 # otherwise build the UTR object
913 26 ▶ unless ($utr) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($utr) 19 7 26
914 $utr = $ucsc->{sfclass}->new(
915 19 -seq_id => $transcript->seq_id,
916 -source => $transcript->source,
917 -start => $start,
918 -end => $stop,
919 -strand => $transcript->strand,
920 -phase => '.',
921 -primary_tag => $tag,
922 -primary_id => $transcript->primary_id . ".utr$number",
923 );
924 19 ▶ $utr->display_name( $transcript->display_name . ".utr$number" )
Branch: 1 branch
BranchTrueFalseTotal
if $ucsc->do_name 0 19 19
925 if $ucsc->do_name;
926 }
927  
928 # store this utr seqfeature in a temporary array
929 26 push @utrs, $utr;
930  
931 # build a second UTR object as necessary
932 26 ▶ if ($start2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start2) 0 26 26
933 0 my $utr2;
934  
935 # look for existing utr
936 0 ▶ if ( $ucsc->share and $gene ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->share and $gene) 0 0 0
Condition0%0/3
$ucsc->share and $gene
!ll&&!rl&&r
000
MC/DC0%0/2
$ucsc->share and $gene
$ucsc->share $gene
Truth table0%0/3
A and B
A= $ucsc->shareB= $gene
ABresult
0X0
100
111
937 0 $utr2 = $self->find_existing_subfeature( $gene, $tag2, $start2, $stop2 );
938 }
939  
940 # otherwise build the utr
941 0 ▶ unless ($utr2) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($utr2) 0 0 0
942 $utr2 = $ucsc->{sfclass}->new(
943 0 -seq_id => $transcript->seq_id,
944 -source => $transcript->source,
945 -start => $start2,
946 -end => $stop2,
947 -strand => $transcript->strand,
948 -phase => '.',
949 -primary_tag => $tag2,
950 -primary_id =>
951 sprintf( "%s.utr%da", $transcript->primary_id, $number ),
952 );
953 0 ▶ $utr2->display_name(
Branch: 1 branch
BranchTrueFalseTotal
if $ucsc->do_name 0 0 0
954 sprintf( "%s.utr%da", $transcript->display_name, $number ) )
955 if $ucsc->do_name;
956 }
957  
958 # store this utr seqfeature in a temporary array
959 0 push @utrs, $utr2;
960 }
961 }
962  
963 # associate found UTRs with the transcript
964 10 foreach my $utr (@utrs) {
965 26 $transcript->add_SeqFeature($utr);
966 }
967 }
968  
969 10 ▶sub add_cds {
Subroutine add_cds: called CC=17 SCAR=29.9
Pod documented
970 10 my ( $self, $transcript ) = @_;
971 10 my $ucsc = $self->ucsc;
972  
973 # we will NOT collapse CDS features since we cannot guarantee that a shared
974 # CDS will have the same phase, since phase is dependent on the translation
975 # start
976  
977 # we will scan each exon and look for a potential CDS and build it
978 10 my @cdss;
979 10 my $phase = 0; # initialize CDS phase and keep track as we process CDSs
980 CDS_LOOP:
981 10 ▶ for ( my $i = 0; $i < $self->exonCount; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $self->exonCount) 76 10 86
982  
983 # transform index for reverse strands
984 76 my $j;
985 76 ▶ if ( $transcript->strand == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($transcript->strand == 1) { } 76 0 76
986  
987 # forward strand
988 76 $j = $i;
989 }
990 else {
991 # reverse strand
992 # flip the index for exon starts and stops so that we
993 # always progress 5' -> 3'
994 # this ensures the phase is accurate from the start codon
995 0 $j = abs( $i - $self->exonCount + 1 );
996 }
997  
998 # identify CDSs
999 # we will identify by comparing the cdsStart and cdsStop relative
1000 # to the exon coordinates
1001 76 my ( $start, $stop );
1002  
1003 # Split 5'UTR, CDS, and 3'UTR all on the same exon
1004 76 ▶ if ( $self->exonStarts->[$j] < $self->cdsStart
Branch: 6 branches
BranchTrueFalseTotal
if ($self->exonStarts->[$j] < $self->cdsStart and $self->exonEnds->[$j] > $self->cdsEnd) { } 0 76 76
elsif ($self->exonStarts->[$j] < $self->cdsStart and $self->exonEnds->[$j] < $self->cdsStart) { } 3 73 76
elsif ($self->exonStarts->[$j] < $self->cdsStart and $self->exonEnds->[$j] >= $self->cdsStart) { } 9 64 73
elsif ($self->exonStarts->[$j] >= $self->cdsStart and $self->exonEnds->[$j] <= $self->cdsEnd) { } 50 14 64
elsif ($self->exonStarts->[$j] <= $self->cdsEnd and $self->exonEnds->[$j] > $self->cdsEnd) { } 7 7 14
elsif ($self->exonStarts->[$j] > $self->cdsEnd and $self->exonEnds->[$j] > $self->cdsEnd) { } 7 0 7
Condition66%2/3
$self->exonStarts->[$j] < $self->cdsStart and $self->exonEnds->[$j] > $self->cdsEnd
!ll&&!rl&&r
64120
MC/DC0%0/2
$self->exonStarts->[$j] < $self->cdsStart and $self->exonEnds->[$j] > $self->cdsEnd
$self->exonStarts->[$j] < $self->cdsStart $self->exonEnds->[$j] > $self->cdsEnd
Truth table66%2/3
A and B
A= $self->exonStarts->[$j] < $self->cdsStartB= $self->exonEnds->[$j] > $self->cdsEnd
ABresult
0X0
100
111
1005 and $self->exonEnds->[$j] > $self->cdsEnd )
1006 {
1007 # exon contains the entire CDS
1008 0 $start = $self->cdsStart;
1009 0 $stop = $self->cdsEnd;
1010 }
1011  
1012 # 5'UTR forward, 3'UTR reverse
1013 ▶ elsif ( $self->exonStarts->[$j] < $self->cdsStart
Condition100%3/3
$self->exonStarts->[$j] < $self->cdsStart and $self->exonEnds->[$j] < $self->cdsStart
!ll&&!rl&&r
6493
MC/DC100%2/2
$self->exonStarts->[$j] < $self->cdsStart and $self->exonEnds->[$j] < $self->cdsStart
$self->exonStarts->[$j] < $self->cdsStart $self->exonEnds->[$j] < $self->cdsStart
Truth table100%3/3
A and B
A= $self->exonStarts->[$j] < $self->cdsStartB= $self->exonEnds->[$j] < $self->cdsStart
ABresult
0X0
100
111
1014 and $self->exonEnds->[$j] < $self->cdsStart )
1015 {
1016 # no CDS in this exon
1017 3 next CDS_LOOP;
1018 }
1019  
1020 # Split 5'UTR & CDS on forward, 3'UTR & CDS
1021 ▶ elsif ( $self->exonStarts->[$j] < $self->cdsStart
Condition66%2/3
$self->exonStarts->[$j] < $self->cdsStart and $self->exonEnds->[$j] >= $self->cdsStart
!ll&&!rl&&r
6409
MC/DC50%1/2
$self->exonStarts->[$j] < $self->cdsStart and $self->exonEnds->[$j] >= $self->cdsStart
$self->exonStarts->[$j] < $self->cdsStart $self->exonEnds->[$j] >= $self->cdsStart
Truth table66%2/3
A and B
A= $self->exonStarts->[$j] < $self->cdsStartB= $self->exonEnds->[$j] >= $self->cdsStart
ABresult
0X0
100
111
1022 and $self->exonEnds->[$j] >= $self->cdsStart )
1023 {
1024 # the start/stop codon is in this exon
1025 # we need to make the CDS out of a portion of this exon
1026 9 $start = $self->cdsStart;
1027 9 $stop = $self->exonEnds->[$j];
1028 }
1029  
1030 # CDS only
1031 ▶ elsif ( $self->exonStarts->[$j] >= $self->cdsStart
Condition66%2/3
$self->exonStarts->[$j] >= $self->cdsStart and $self->exonEnds->[$j] <= $self->cdsEnd
!ll&&!rl&&r
01450
MC/DC50%1/2
$self->exonStarts->[$j] >= $self->cdsStart and $self->exonEnds->[$j] <= $self->cdsEnd
$self->exonStarts->[$j] >= $self->cdsStart $self->exonEnds->[$j] <= $self->cdsEnd
Truth table66%2/3
A and B
A= $self->exonStarts->[$j] >= $self->cdsStartB= $self->exonEnds->[$j] <= $self->cdsEnd
ABresult
0X0
100
111
1032 and $self->exonEnds->[$j] <= $self->cdsEnd )
1033 {
1034 # entire exon is CDS
1035 50 $start = $self->exonStarts->[$j];
1036 50 $stop = $self->exonEnds->[$j];
1037 }
1038  
1039 # Split 3'UTR & CDS on forward, 5'UTR & CDS
1040 ▶ elsif ( $self->exonStarts->[$j] <= $self->cdsEnd
Condition66%2/3
$self->exonStarts->[$j] <= $self->cdsEnd and $self->exonEnds->[$j] > $self->cdsEnd
!ll&&!rl&&r
707
MC/DC50%1/2
$self->exonStarts->[$j] <= $self->cdsEnd and $self->exonEnds->[$j] > $self->cdsEnd
$self->exonStarts->[$j] <= $self->cdsEnd $self->exonEnds->[$j] > $self->cdsEnd
Truth table66%2/3
A and B
A= $self->exonStarts->[$j] <= $self->cdsEndB= $self->exonEnds->[$j] > $self->cdsEnd
ABresult
0X0
100
111
1041 and $self->exonEnds->[$j] > $self->cdsEnd )
1042 {
1043 # the stop/start codon is in this exon
1044 # we need to make the CDS out of a portion of this exon
1045 7 $start = $self->exonStarts->[$j];
1046 7 $stop = $self->cdsEnd;
1047 }
1048  
1049 # 3'UTR forward, 5'UTR reverse
1050 ▶ elsif ( $self->exonStarts->[$j] > $self->cdsEnd
Condition33%1/3
$self->exonStarts->[$j] > $self->cdsEnd and $self->exonEnds->[$j] > $self->cdsEnd
!ll&&!rl&&r
007
MC/DC0%0/2
$self->exonStarts->[$j] > $self->cdsEnd and $self->exonEnds->[$j] > $self->cdsEnd
$self->exonStarts->[$j] > $self->cdsEnd $self->exonEnds->[$j] > $self->cdsEnd
Truth table33%1/3
A and B
A= $self->exonStarts->[$j] > $self->cdsEndB= $self->exonEnds->[$j] > $self->cdsEnd
ABresult
0X0
100
111
1051 and $self->exonEnds->[$j] > $self->cdsEnd )
1052 {
1053 # the exon start/end is entirely after the cdsStop
1054 # we have entirely 5' or 3'UTR, no CDS
1055 7 next CDS_LOOP;
1056 }
1057  
1058 # Something else?
1059 else {
1060 0 printf STDERR
1061 "Warning: A malformed CDS that doesn't match known criteria: cdsStart %d, cdsEnd %d, exonStart %d, exonEnd %d\n",
1062 $self->cdsStart, $self->cdsEnd, $self->exonStarts->[$j],
1063 $self->exonEnds->[$j];
1064 0 next CDS_LOOP;
1065 }
1066  
1067 # build the CDS object
1068 my $cds = $ucsc->{sfclass}->new(
1069 66 -seq_id => $transcript->seq_id,
1070 -source => $transcript->source,
1071 -start => $start,
1072 -end => $stop,
1073 -strand => $transcript->strand,
1074 -phase => $phase,
1075 -primary_tag => 'CDS',
1076 -primary_id => sprintf( "%s.cds%d", $transcript->primary_id, $i ),
1077 -display_name => sprintf( "%s.cds%d", $transcript->display_name, $i ),
1078 );
1079  
1080 # the id and name still use $i for labeling to ensure numbering from 0
1081  
1082 # store this utr seqfeature in a temporary array
1083 66 push @cdss, $cds;
1084  
1085 # reset the phase for the next CDS
1086 # phase + (3 - (length % 3)), readjust to 0..2 if necessary
1087 # adapted from Barry Moore's gtf2gff3.pl script
1088 66 $phase = $phase + ( 3 - ( $cds->length % 3 ) );
1089 66 ▶ $phase -= 3 if $phase > 2;
Branch: 1 branch
BranchTrueFalseTotal
if $phase > 2 46 20 66
1090 }
1091  
1092 # associate found UTRs with the transcript
1093 10 foreach my $cds (@cdss) {
1094 66 $transcript->add_SeqFeature($cds);
1095 }
1096 }
1097  
1098 0 ▶sub add_codons {
Subroutine add_codons: not called CC=14 SCAR=53.5
Pod documented
1099 0 my ( $self, $transcript, $gene ) = @_;
1100 0 my $ucsc = $self->ucsc;
1101  
1102 # generate the start and stop codons
1103 0 my ( $start_codon, $stop_codon );
1104 0 ▶ if ( $transcript->strand == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($transcript->strand == 1) { } 0 0 0
1105  
1106 # forward strand
1107  
1108 # share codons if possible
1109 0 ▶ if ( $ucsc->share and $gene ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->share and $gene) 0 0 0
Condition0%0/3
$ucsc->share and $gene
!ll&&!rl&&r
000
MC/DC0%0/2
$ucsc->share and $gene
$ucsc->share $gene
Truth table0%0/3
A and B
A= $ucsc->shareB= $gene
ABresult
0X0
100
111
1110 0 $start_codon = $self->find_existing_subfeature( $gene, 'start_codon',
1111 $self->cdsStart, $self->cdsStart + 2 );
1112 0 $stop_codon =
1113 $self->find_existing_subfeature( $gene, 'stop_codon', $self->cdsEnd - 2,
1114 $self->cdsEnd );
1115 }
1116  
1117 # start codon
1118 0 ▶ unless ($start_codon) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($start_codon) 0 0 0
1119 $start_codon = $ucsc->{sfclass}->new(
1120 0 -seq_id => $transcript->seq_id,
1121 -source => $transcript->source,
1122 -primary_tag => 'start_codon',
1123 -start => $self->cdsStart,
1124 -end => $self->cdsStart + 2,
1125 -strand => 1,
1126 -phase => 0,
1127 -primary_id => $transcript->primary_id . '.start_codon',
1128 );
1129 0 ▶ $start_codon->display_name( $transcript->display_name . '.start_codon' )
Branch: 1 branch
BranchTrueFalseTotal
if $ucsc->do_name 0 0 0
1130 if $ucsc->do_name;
1131 }
1132  
1133 # stop codon
1134 0 ▶ unless ($stop_codon) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($stop_codon) 0 0 0
1135 $stop_codon = $ucsc->{sfclass}->new(
1136 0 -seq_id => $transcript->seq_id,
1137 -source => $transcript->source,
1138 -primary_tag => 'stop_codon',
1139 -start => $self->cdsEnd - 2,
1140 -end => $self->cdsEnd,
1141 -strand => 1,
1142 -phase => 0,
1143 -primary_id => $transcript->primary_id . '.stop_codon',
1144 );
1145 0 ▶ $stop_codon->display_name( $transcript->display_name . '.stop_codon' )
Branch: 1 branch
BranchTrueFalseTotal
if $ucsc->do_name 0 0 0
1146 if $ucsc->do_name;
1147 }
1148 }
1149  
1150 else {
1151 # reverse strand
1152  
1153 # share codons if possible
1154 0 ▶ if ( $ucsc->share and $gene ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucsc->share and $gene) 0 0 0
Condition0%0/3
$ucsc->share and $gene
!ll&&!rl&&r
000
MC/DC0%0/2
$ucsc->share and $gene
$ucsc->share $gene
Truth table0%0/3
A and B
A= $ucsc->shareB= $gene
ABresult
0X0
100
111
1155 0 $stop_codon = $self->find_existing_subfeature( $gene, 'stop_codon',
1156 $self->cdsStart, $self->cdsStart + 2 );
1157 0 $start_codon =
1158 $self->find_existing_subfeature( $gene, 'start_codon', $self->cdsEnd - 2,
1159 $self->cdsEnd );
1160 }
1161  
1162 # stop codon
1163 0 ▶ unless ($stop_codon) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($stop_codon) 0 0 0
1164 $stop_codon = $ucsc->{sfclass}->new(
1165 0 -seq_id => $transcript->seq_id,
1166 -source => $transcript->source,
1167 -primary_tag => 'stop_codon',
1168 -start => $self->cdsStart,
1169 -end => $self->cdsStart + 2,
1170 -strand => -1,
1171 -phase => 0,
1172 -primary_id => $transcript->primary_id . '.stop_codon',
1173 );
1174 0 ▶ $stop_codon->display_name( $transcript->display_name . '.stop_codon' )
Branch: 1 branch
BranchTrueFalseTotal
if $ucsc->do_name 0 0 0
1175 if $ucsc->do_name;
1176 }
1177  
1178 # start codon
1179 0 ▶ unless ($start_codon) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($start_codon) 0 0 0
1180 $start_codon = $ucsc->{sfclass}->new(
1181 0 -seq_id => $transcript->seq_id,
1182 -source => $transcript->source,
1183 -primary_tag => 'start_codon',
1184 -start => $self->cdsEnd - 2,
1185 -end => $self->cdsEnd,
1186 -strand => -1,
1187 -phase => 0,
1188 -primary_id => $transcript->primary_id . '.start_codon',
1189 -display_name => $transcript->primary_id . '.start_codon',
1190 );
1191 0 ▶ $start_codon->display_name( $transcript->display_name . '.start_codon' )
Branch: 1 branch
BranchTrueFalseTotal
if $ucsc->do_name 0 0 0
1192 if $ucsc->do_name;
1193 }
1194 }
1195  
1196 # associate with transcript
1197 0 $transcript->add_SeqFeature($start_codon);
1198 0 $transcript->add_SeqFeature($stop_codon);
1199 }
1200  
1201 303 ▶sub find_existing_subfeature {
Subroutine find_existing_subfeature: called CC=7 SCAR=19.5
Pod documented
1202 303 my ( $self, $gene, $type, $start, $stop ) = @_;
1203 303 ▶ return unless $gene;
Branch: 1 branch
BranchTrueFalseTotal
unless $gene 0 303 303
1204  
1205 # we will try to find a pre-existing subfeature at identical coordinates
1206 303 foreach my $transcript ( $gene->get_SeqFeatures() ) {
1207  
1208 # walk through transcripts
1209 988 foreach my $subfeature ( $transcript->get_SeqFeatures() ) {
1210  
1211 # walk through subfeatures of transcripts
1212 8284 ▶ if ( $subfeature->primary_tag eq $type
Branch: 1 branch
BranchTrueFalseTotal
if ($subfeature->primary_tag eq $type and $subfeature->start == $start and $subfeature->end == $stop) 163 8121 8284
Condition100%6/6
$subfeature->primary_tag eq $type and $subfeature->start == $start and $subfeature->end == $stop
!ll&&!rl&&r
805566163
$subfeature->primary_tag eq $type and $subfeature->start == $start
!ll&&!rl&&r
29325123229
MC/DC100%3/3
$subfeature->primary_tag eq $type and $subfeature->start == $start and $subfeature->end == $stop
$subfeature->primary_tag eq $type $subfeature->start == $start $subfeature->end == $stop
Truth table100%4/4
A and B and C
A= $subfeature->primary_tag eq $typeB= $subfeature->start == $startC= $subfeature->end == $stop
ABCresult
0XX0
10X0
1100
1111
1213 and $subfeature->start == $start
1214 and $subfeature->end == $stop )
1215 {
1216 # we found a match
1217 163 return $subfeature;
1218 }
1219 }
1220 }
1221 140 return;
1222 }
1223  
1224 2 1;
1225  
1226 __END__
« script/get_features.pl ↑ Summary lib/Bio/ToolBox/big_helper.pm »