Variation/IO/flat.pm

filter: Statementstmt 95.9% 356 / 371 Branchbran 78.0% 167 / 214 Conditioncond 80.9% 34 / 42 MC/DCmcdc 67.8% 19 / 28 Subroutinesub 100% 12 / 12 Podpod 100% 3 / 3 totaltotal 88.2% 591 / 670 CC 134 SCAR 43.5
CC
134
Cov
89%
write
102.9
next
56.6
_initialize
2.1
CRAP 77.3
« Variation/AAChange.pm ↑ Summary Variation/RNAChange.pm »
1 # BioPerl module for Bio::Variation::IO::flat
2 #
3 # Please direct questions and support issues to <bioperl-l@bioperl.org>
4 #
5 # Cared for by Heikki Lehvaslaiho <heikki-at-bioperl-dot-org>
6 #
7 # Copyright Heikki Lehvaslaiho
8 #
9 # You may distribute this module under the same terms as perl itself
10 #
11  
12 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::Variation::IO::flat - flat file sequence variation input/output stream
17  
18 =head1 SYNOPSIS
19  
20 Do not use this module directly. Use it via the Bio::Variation::IO class.
21  
22 =head1 DESCRIPTION
23  
24 This object can transform Bio::Variation::SeqDiff objects to and from
25 flat file databases.
26  
27 =head1 FEEDBACK
28  
29 =head2 Mailing Lists
30  
31 User feedback is an integral part of the evolution of this and other
32 Bioperl modules. Send your comments and suggestions preferably to the
33 Bioperl mailing lists Your participation is much appreciated.
34  
35 bioperl-l@bioperl.org - General discussion
36 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
37  
38 =head2 Support
39  
40 Please direct usage questions or support issues to the mailing list:
41  
42 I<bioperl-l@bioperl.org>
43  
44 rather than to the module maintainer directly. Many experienced and
45 reponsive experts will be able look at the problem and quickly
46 address it. Please include a thorough description of the problem
47 with code and data examples if at all possible.
48  
49 =head2 Reporting Bugs
50  
51 report bugs to the Bioperl bug tracking system to help us keep track
52 the bugs and their resolution. Bug reports can be submitted via the
53 web:
54  
55 https://github.com/bioperl/bioperl-live/issues
56  
57 =head1 AUTHOR - Heikki Lehvaslaiho
58  
59 Email: heikki-at-bioperl-dot-org
60  
61 =head1 APPENDIX
62  
63 The rest of the documentation details each of the object
64 methods. Internal methods are usually preceded with a _
65  
66 =cut
67  
68 # Let the code begin...
69  
70 package Bio::Variation::IO::flat;
71 2 $Bio::Variation::IO::flat::VERSION = '1.7.5';
72 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
73  
74 2 ▶use Text::Wrap;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 2 ▶use Bio::Variation::SeqDiff;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 2 ▶use Bio::Variation::DNAMutation;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 2 ▶use Bio::Variation::RNAChange;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 2 ▶use Bio::Variation::AAChange;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 2 ▶use Bio::Variation::Allele;
Subroutine BEGIN: called CC=1 SCAR=0.0
80  
81  
82 2 ▶use base qw(Bio::Variation::IO);
Subroutine BEGIN: called CC=1 SCAR=0.0
83  
84 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
85 4 my($class, @args) = @_;
86 4 my $self = bless {}, $class;
87 4 $self->_initialize(@args);
88 4 return $self;
89 }
90  
91 4 ▶sub _initialize {
Subroutine _initialize: called CC=2 SCAR=7.2
92 4 my($self,@args) = @_;
93 4 ▶ return unless $self->SUPER::_initialize(@args);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->SUPER::_initialize(@args) 0 4 4
94 }
95  
96 =head2 next
97  
98  
99 Title : next
100 Usage : $haplo = $stream->next()
101 Function: returns the next seqDiff in the stream
102 Returns : Bio::Variation::SeqDiff object
103 Args : NONE
104  
105 =cut
106  
107 17 ▶sub next {
Subroutine next: called CC=56 SCAR=40.4
Pod documented
108 17 my( $self ) = @_;
109 17 local $/ = '//';
110 17 ▶ return unless my $entry = $self->_readline;
Branch: 1 branch
BranchTrueFalseTotal
unless my $entry = $self->_readline 0 17 17
111
112 17 ▶ return if $entry =~ /^\s+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $entry =~ /^\s+$/ 2 15 17
113  
114 15 ▶ $entry =~ /\s*ID\s+\S+/ || $self->throw("We do need an ID!");
Branch: 1 branch
BranchTrueFalseTotal
$entry =~ /\s*ID\s+\S+/ or $self->throw("We do need an ID!") 15 0 15
115  
116 15 ▶ my ($id, $offset, $alphabet) = $entry =~ /\s*ID +([^:]+)..(\d+)[^\)]*.\[?([cg])?/
Branch: 1 branch
BranchTrueFalseTotal
() = $entry =~ /\s*ID +([^:]+)..(\d+)[^\)]*.\[?([cg])?/ or $self->throw("Can't parse ID line") 15 0 15
117 or $self->throw("Can't parse ID line");
118 # $self->throw("$1|$2|$3");
119 15 my $h =Bio::Variation::SeqDiff->new(-id => $id,
120 -offset => $offset,
121 );
122 15 ▶ if ($alphabet) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alphabet) 15 0 15
123 15 ▶ if ($alphabet eq 'g') {
Branch: 2 branches
BranchTrueFalseTotal
if ($alphabet eq 'g') { } 4 11 15
elsif ($alphabet eq 'c') { } 11 0 11
124 4 $alphabet = 'dna';
125 }
126 elsif ($alphabet eq 'c') {
127 11 $alphabet = 'rna';
128 }
129 15 $h->alphabet($alphabet);
130 }
131 #
132 # DNA
133 #
134 15 my @dna = split ( / DNA;/, $entry );
135 15 shift @dna;
136 15 my $prevdnaobj;
137 15 foreach my $dna (@dna) {
138 17 $dna =~ s/Feature[ \t]+//g;
139 17 ($dna) = split "RNA; ", $dna;
140 #$self->warn("|$dna|") ;
141 #exit;
142 17 my ($mut_number, $proof, $location, $upflank, $change, $dnflank) =
143 $dna =~ m|\W+([\d\.]+).+/proof: (\w+).+/location: ([^ \n]+).+/upflank: ([ \n\w]+).+/change: ([^ /]+).+/dnflank: ([ \n\w]+)|s;
144 17 $change =~ s/[ \n]//g;
145 17 my ($ori, $mut) = split /[>\|]/, $change;
146 17 my ($variation_number, $change_number) = split /\./, $mut_number;
147 #$self->warn("|$mut_number|>|$variation_number|$change_number|");
148 17 my $dnamut;
149 17 ▶ if ($change_number and $change_number > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($change_number and $change_number > 1) { } 1 16 17
Condition100%3/3
$change_number and $change_number > 1
!ll&&!rl&&r
1511
MC/DC100%2/2
$change_number and $change_number > 1
$change_number $change_number > 1
Truth table100%3/3
A and B
A= $change_numberB= $change_number > 1
ABresult
0X0
100
111
150 1 my $a3 = Bio::Variation::Allele->new;
151 1 ▶ $a3->seq($mut) if $mut;
Branch: 1 branch
BranchTrueFalseTotal
if $mut 1 0 1
152 #$dnamut->add_Allele($a3);
153 1 $prevdnaobj->add_Allele($a3);
154 } else {
155 16 $upflank =~ s/[ \n]//g;
156 16 $dnflank =~ s/[ \n]//g;
157 16 my ($region, $junk, $region_value, $junk2, $region_dist) =
158 $dna =~ m|.+/region: ([\w\']+)(; )?(\w+)?( ?\(\+?)?(-?\d+)?|s;
159 #my $s = join ("|", $mut_number, $proof, $location, $upflank,
160 # $change, $dnflank, $region, $region_value, $region_dist, $1,$2,$3,$4,$5);
161 #$self->warn($s);
162 #exit;
163 16 my ($start, $sep, $end) = $location =~ /(-?\d+)(.)?\D?(-?\d+)?/;
164 16 ▶ $end = $start if not defined $end ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $end 12 4 16
165 16 my ($len) = $end - $start +1;
166 16 ▶ $len = 0, $start = $end if defined $sep and $sep eq '^';
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep and $sep eq "^" 2 14 16
Condition100%3/3
defined $sep and $sep eq "^"
!ll&&!rl&&r
1222
MC/DC100%2/2
defined $sep and $sep eq "^"
defined $sep $sep eq "^"
Truth table100%3/3
A and B
A= defined $sepB= $sep eq "^"
ABresult
0X0
100
111
167 16 my $ismut = 0;
168 16 ▶ $ismut = 1 if $change =~ m/>/;
Branch: 1 branch
BranchTrueFalseTotal
if $change =~ />/ 14 2 16
169
170 16 $dnamut = Bio::Variation::DNAMutation->new
171 ('-start' => $start,
172 '-end' => $end,
173 '-length' => $len,
174 '-upStreamSeq' => $upflank,
175 '-dnStreamSeq' => $dnflank,
176 '-proof' => $proof,
177 '-mut_number' => $mut_number
178 );
179 16 $prevdnaobj = $dnamut;
180 16 my $a1 = Bio::Variation::Allele->new;
181 16 ▶ $a1->seq($ori) if $ori;
Branch: 1 branch
BranchTrueFalseTotal
if $ori 14 2 16
182 16 $dnamut->allele_ori($a1);
183 16 my $a2 = Bio::Variation::Allele->new;
184 16 ▶ $a2->seq($mut) if $mut;
Branch: 1 branch
BranchTrueFalseTotal
if $mut 14 2 16
185 16 $dnamut->add_Allele($a2);
186 16 ▶ if ($ismut) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ismut) 14 2 16
187 14 $dnamut->isMutation(1);
188 14 $dnamut->allele_mut($a2);
189 }
190 16 ▶ $dnamut->region($region) if defined $region;
Branch: 1 branch
BranchTrueFalseTotal
if defined $region 4 12 16
191 16 ▶ $dnamut->region_value($region_value) if defined $region_value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $region_value 2 14 16
192 16 ▶ $dnamut->region_dist($region_dist) if defined $region_dist;
Branch: 1 branch
BranchTrueFalseTotal
if defined $region_dist 4 12 16
193  
194 16 $h->add_Variant($dnamut);
195 16 $dnamut->SeqDiff($h);
196 }
197 }
198  
199 #
200 # RNA
201 #
202 15 my @rna = split ( / RNA;/, $entry );
203 15 shift @rna;
204 15 my $prevrnaobj;
205 15 foreach my $rna (@rna) {
206 17 $rna = substr ($rna, 0, index($rna, 'Feature AA'));
207 17 $rna =~ s/Feature[ \t]+//g;
208 17 ($rna) = split "DNA; ", $rna;
209 #$self->warn("|$rna|") ;
210 17 my ($mut_number, $proof, $location, $upflank, $change, $dnflank) =
211 $rna =~ m|\W+([\d\.]+).+/proof: (\w+).+/location: ([^ \n]+).+/upflank: (\w+).+/change: ([^/]+).+/dnflank: (\w+)|s ;#'
212 17 my ($region, $junk, $region_value, $junk2, $region_dist) =
213 $rna =~ m|.+/region: ([\w\']+)(; )?(\w+)?( ?\(\+?)?(-?\d+)?|s;
214 #my $s = join ("|", $mut_number, $proof, $location, $upflank,
215 # $change, $dnflank, $region, $region_value, $region_dist, $1,$2,$3,$4,$5);
216 #$self->warn($s);
217 #exit;
218 17 $change =~ s/[ \n]//g;
219 17 my ($ori, $mut) = split /[>\|]/, $change;
220 17 my $rnamut;
221 17 my ($variation_number, $change_number) = split /\./, $mut_number;
222 17 ▶ if ($change_number and $change_number > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($change_number and $change_number > 1) { } 1 16 17
Condition100%3/3
$change_number and $change_number > 1
!ll&&!rl&&r
1511
MC/DC100%2/2
$change_number and $change_number > 1
$change_number $change_number > 1
Truth table100%3/3
A and B
A= $change_numberB= $change_number > 1
ABresult
0X0
100
111
223 1 my $a3 = Bio::Variation::Allele->new;
224 1 ▶ $a3->seq($mut) if $mut;
Branch: 1 branch
BranchTrueFalseTotal
if $mut 1 0 1
225 #$rnamut->add_Allele($a3);
226 1 $prevrnaobj->add_Allele($a3);
227 } else {
228 16 my ($start, $sep, $end) = $location =~ /(-?\d+)(.)?\D?(-?\d+)?/;
229 16 ▶ $end = $start if not defined $end ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $end 12 4 16
230 16 my ($len) = $end - $start + 1;
231 16 ▶ $len = 0, $start = $end if defined $sep and $sep eq '^';
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep and $sep eq "^" 2 14 16
Condition100%3/3
defined $sep and $sep eq "^"
!ll&&!rl&&r
1222
MC/DC100%2/2
defined $sep and $sep eq "^"
defined $sep $sep eq "^"
Truth table100%3/3
A and B
A= defined $sepB= $sep eq "^"
ABresult
0X0
100
111
232 16 my $ismut;
233 16 ▶ $ismut = 1 if $change =~ m/>/;
Branch: 1 branch
BranchTrueFalseTotal
if $change =~ />/ 14 2 16
234 16 my ($codon_table) = $rna =~ m|.+/codon_table: (\d+)|s;
235 16 my ($codon_pos) = $rna =~ m|.+/codon:[^;]+; ([123])|s;
236  
237 16 $rnamut = Bio::Variation::RNAChange->new
238 ('-start' => $start,
239 '-end' => $end,
240 '-length' => $len,
241 '-upStreamSeq' => $upflank,
242 '-dnStreamSeq' => $dnflank,
243 '-proof' => $proof,
244 '-mut_number' => $mut_number
245
246 );
247 16 $prevrnaobj = $rnamut;
248 16 my $a1 = Bio::Variation::Allele->new;
249 16 ▶ $a1->seq($ori) if $ori;
Branch: 1 branch
BranchTrueFalseTotal
if $ori 14 2 16
250 16 $rnamut->allele_ori($a1);
251 16 my $a2 = Bio::Variation::Allele->new;
252 16 ▶ $a2->seq($mut) if $mut;
Branch: 1 branch
BranchTrueFalseTotal
if $mut 14 2 16
253 16 $rnamut->add_Allele($a2);
254 16 ▶ if ($ismut) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ismut) 14 2 16
255 14 $rnamut->isMutation(1);
256 14 $rnamut->allele_mut($a2);
257 }
258 16 ▶ $rnamut->region($region) if defined $region;
Branch: 1 branch
BranchTrueFalseTotal
if defined $region 16 0 16
259 16 ▶ $rnamut->region_value($region_value) if defined $region_value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $region_value 0 16 16
260 16 ▶ $rnamut->region_dist($region_dist) if defined $region_dist;
Branch: 1 branch
BranchTrueFalseTotal
if defined $region_dist 2 14 16
261  
262 16 ▶ $rnamut->codon_table($codon_table) if $codon_table;
Branch: 1 branch
BranchTrueFalseTotal
if $codon_table 12 4 16
263 16 ▶ $rnamut->codon_pos($codon_pos) if $codon_pos;
Branch: 1 branch
BranchTrueFalseTotal
if $codon_pos 12 4 16
264 16 $h->add_Variant($rnamut);
265 16 foreach my $mut ($h->each_Variant) {
266 35 ▶ if ($mut->isa('Bio::Variation::DNAMutation') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->isa("Bio::Variation::DNAMutation")) 18 17 35
267 18 ▶ if ($mut->mut_number == $rnamut->mut_number) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->mut_number == $rnamut->mut_number) 16 2 18
268 16 $rnamut->DNAMutation($mut);
269 16 $mut->RNAChange($rnamut);
270 }
271 }
272 }
273 }
274 }
275 #
276 # AA
277 #
278 15 my @aa = split ( / AA;/, $entry );
279 15 shift @aa;
280 15 my $prevaaobj;
281 15 foreach my $aa (@aa) {
282 13 $aa = substr ($aa, 0, index($aa, 'Feature AA'));
283 13 $aa =~ s/Feature[ \t]+//g;
284 13 ($aa) = split "DNA; ", $aa;
285 #$self->warn("|$aa|") ;
286 13 my ($mut_number, $proof, $location, $change) =
287 $aa =~ m|\W+([\d\.]+).+/proof: (\w+).+/location: ([^ \n]+)./change: ([^/;]+)|s;
288 13 $change =~ s/[ \n]//g;
289 #my $s = join ("|", $mut_number, $proof, $location, $change);
290 #$self->warn($s);
291 #exit;
292 13 $change =~ s/[ \n]//g;
293 13 $change =~ s/DNA$//;
294 13 my ($ori, $mut) = split /[>\|]/, $change;
295 #print "------$location----$ori-$mut-------------\n";
296 13 my ($variation_number, $change_number) = split /\./, $mut_number;
297 13 my $aamut;
298 13 ▶ if ($change_number and $change_number > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($change_number and $change_number > 1) { } 1 12 13
Condition100%3/3
$change_number and $change_number > 1
!ll&&!rl&&r
1111
MC/DC100%2/2
$change_number and $change_number > 1
$change_number $change_number > 1
Truth table100%3/3
A and B
A= $change_numberB= $change_number > 1
ABresult
0X0
100
111
299 1 my $a3 = Bio::Variation::Allele->new;
300 1 ▶ $a3->seq($mut) if $mut;
Branch: 1 branch
BranchTrueFalseTotal
if $mut 1 0 1
301 1 $prevaaobj->add_Allele($a3);
302 } else {
303 12 my ($start, $sep, $end) = $location =~ /(-?\d+)(.)?\D?(-?\d+)?/;
304 12 ▶ $end = $start if not defined $end ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $end 11 1 12
305 12 my ($len) = $end - $start + 1;
306 12 ▶ $len = 0, $start = $end if defined $sep and $sep eq '^';
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep and $sep eq "^" 0 12 12
Condition66%2/3
defined $sep and $sep eq "^"
!ll&&!rl&&r
1110
MC/DC0%0/2
defined $sep and $sep eq "^"
defined $sep $sep eq "^"
Truth table66%2/3
A and B
A= defined $sepB= $sep eq "^"
ABresult
0X0
100
111
307 12 my $ismut;
308 12 ▶ $ismut = 1 if $change =~ m/>/;
Branch: 1 branch
BranchTrueFalseTotal
if $change =~ />/ 10 2 12
309 12 my ($region) = $aa =~ m|.+/region: (\w+)|s ;
310 12 $aamut = Bio::Variation::AAChange->new
311 ('-start' => $start,
312 '-end' => $end,
313 '-length' => $len,
314 '-proof' => $proof,
315 '-mut_number' => $mut_number
316 );
317 12 $prevaaobj = $aamut;
318 12 my $a1 = Bio::Variation::Allele->new;
319 12 ▶ $a1->seq($ori) if $ori;
Branch: 1 branch
BranchTrueFalseTotal
if $ori 12 0 12
320 12 $aamut->allele_ori($a1);
321 12 my $a2 = Bio::Variation::Allele->new;
322 12 ▶ $a2->seq($mut) if $mut;
Branch: 1 branch
BranchTrueFalseTotal
if $mut 11 1 12
323 12 $aamut->add_Allele($a2);
324 12 ▶ if ($ismut) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ismut) 10 2 12
325 10 $aamut->isMutation(1);
326 10 $aamut->allele_mut($a2);
327 }
328 12 ▶ $region && $aamut->region($region);
Branch: 1 branch
BranchTrueFalseTotal
$region and $aamut->region($region) 0 12 12
329 12 $h->add_Variant($aamut);
330 12 foreach my $mut ($h->each_Variant) {
331 41 ▶ if ($mut->isa('Bio::Variation::RNAChange') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->isa("Bio::Variation::RNAChange")) 14 27 41
332 14 ▶ if ($mut->mut_number == $aamut->mut_number) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->mut_number == $aamut->mut_number) 12 2 14
333 12 $aamut->RNAChange($mut);
334 12 $mut->AAChange($aamut);
335 }
336 }
337 }
338  
339 }
340 }
341 15 return $h;
342 }
343  
344 =head2 write
345  
346 Title : write
347 Usage : $stream->write(@seqDiffs)
348 Function: writes the $seqDiff object into the stream
349 Returns : 1 for success and 0 for error
350 Args : Bio::Variation::SeqDiff object
351  
352  
353 =cut
354  
355 15 ▶sub write {
Subroutine write: called CC=78 SCAR=46.3
Pod documented
356 15 my ($self,@h) = @_;
357  
358 #$columns = 75; #default for Text::Wrap
359 15 my %tag =
360 (
361 'ID' => 'ID ',
362 'Description' => 'Description ',
363 'FeatureKey' => 'Feature ',
364 'FeatureQual' => "Feature ",
365 'FeatureWrap' => "Feature ",
366 'ErrorComment' => 'Comment '
367 #'Comment' => 'Comment -!-',
368 #'CommentLine' => 'Comment ',
369 );
370
371 15 ▶ if( !defined $h[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $h[0]) 0 15 15
372 0 $self->throw("Attempting to write with no information!");
373 }
374  
375 15 foreach my $h (@h) {
376
377 15 my @entry =();
378
379 15 my ($text, $tmp, $tmp2, $sep);
380 15 my ($count) = 0;
381  
382
383 15 $text = $tag{ID};
384
385 15 $text .= $h->id;
386 15 $text .= ":(". $h->offset;
387 15 ▶ $text .= "+1" if $h->sysname =~ /-/;
Branch: 1 branch
BranchTrueFalseTotal
if $h->sysname =~ /-/ 2 13 15
388 15 $text .= ")". $h->sysname;
389 15 ▶ $text .= "; ". $h->trivname if $h->trivname;
Branch: 1 branch
BranchTrueFalseTotal
if $h->trivname 11 4 15
390 15 push (@entry, $text);
391  
392 #Variants need to be ordered accoding to mutation_number attribute
393 #put them into a hash of arrays holding the Variant objects
394 #This is necessary for cases like several distict mutations present
395 # in the same sequence.
396 15 my @allvariants = $h->each_Variant;
397 15 my %variants = ();
398 15 foreach my $mut ($h->each_Variant) {
399 44 push @{$variants{$mut->mut_number} }, $mut;
400 }
401 #my ($variation_number, $change_number) = split /\./, $mut_number;
402 15 foreach my $var (sort keys %variants) {
403 #print $var, ": ", join (" ", @{$variants{$var}}), "\n";
404
405 16 foreach my $mut (@{$variants{$var}}) {
406 #
407 # DNA
408 #
409 44 ▶ if ( $mut->isa('Bio::Variation::DNAMutation') ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($mut->isa('Bio::Variation::DNAMutation')) { } 16 28 44
elsif ($mut->isa('Bio::Variation::RNAChange')) { } 16 12 28
elsif ($mut->isa('Bio::Variation::AAChange')) { } 12 0 12
410 #collect all non-reference alleles
411 16 ▶ $self->throw("allele_ori needs to be defined in [$mut]")
Branch: 1 branch
BranchTrueFalseTotal
unless $mut->allele_ori 0 16 16
412 if not $mut->allele_ori;
413 16 ▶ if ($mut->isMutation) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->isMutation) { } 14 2 16
414 14 $sep = '>';
415 } else {
416 2 $sep = '|';
417 }
418 16 my @alleles = $mut->each_Allele;
419 #push @alleles, $mut->allele_mut if $mut->allele_mut;
420 16 my $count = 0; # two alleles
421 16 foreach my $allele (@alleles) {
422 17 $count++;
423 17 my ($variation_number, $change_number) = split /\./, $mut->mut_number;
424 17 ▶ if ($change_number and $change_number != $count){
Branch: 1 branch
BranchTrueFalseTotal
if ($change_number and $change_number != $count) 1 16 17
Condition100%3/3
$change_number and $change_number != $count
!ll&&!rl&&r
1511
MC/DC100%2/2
$change_number and $change_number != $count
$change_number $change_number != $count
Truth table100%3/3
A and B
A= $change_numberB= $change_number != $count
ABresult
0X0
100
111
425 1 $mut->mut_number("$change_number.$count");
426 }
427 17 $mut->allele_mut($allele);
428 push (@entry,
429 17 $tag{FeatureKey}. 'DNA'. "; ". $mut->mut_number
430 );
431 #label
432 17 $text=$tag{FeatureQual}. '/label: '. $mut->label;
433 17 push (@entry, $text);
434
435 #proof
436 17 ▶ if ($mut->proof) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->proof) 17 0 17
437 17 $text = $tag{FeatureQual}. '/proof: '. $mut->proof;
438 17 push (@entry, $text) ;
439 }
440 #location
441 17 $text = $tag{FeatureQual}. '/location: ';
442 #$mut->id. '; '. $mut->start;
443 17 ▶ if ($mut->length > 1 ) {# if ($mut->end - $mut->start ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($mut->length > 1) { } 2 15 17
elsif ($mut->length == 0) { } 2 13 15
444 2 my $l = $mut->start + $mut->length -1;
445 2 $text .= $mut->start. '..'. $l;
446 }
447 elsif ($mut->length == 0) {
448 2 my $tmp_start = $mut->start - 1;
449 2 ▶ $tmp_start-- if $tmp_start == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $tmp_start == 0 0 2 2
450 2 $text .= $tmp_start. '^'. $mut->end;
451 } else {
452 13 $text .= $mut->start;
453 }
454  
455 17 ▶ if ($h->alphabet && $h->alphabet eq 'dna') {
Branch: 1 branch
BranchTrueFalseTotal
if ($h->alphabet and $h->alphabet eq "dna") 4 13 17
Condition66%2/3
$h->alphabet and $h->alphabet eq "dna"
!ll&&!rl&&r
0134
MC/DC50%1/2
$h->alphabet and $h->alphabet eq "dna"
$h->alphabet $h->alphabet eq "dna"
Truth table66%2/3
A and B
A= $h->alphabetB= $h->alphabet eq "dna"
ABresult
0X0
100
111
456 4 $tmp = $mut->start + $h->offset;
457 4 ▶ $tmp-- if $tmp <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $tmp <= 0 0 4 4
458 4 ▶ $mut->start < 1 && $tmp++;
Branch: 1 branch
BranchTrueFalseTotal
$mut->start < 1 and ++$tmp 1 3 4
459 #$text.= ' ('. $h->id. '::'. $tmp;
460 4 $tmp2 = $mut->end + $h->offset;
461 4 ▶ if ( $mut->length > 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($mut->length > 1) { } 0 4 4
elsif ($mut->length == 0) { } 0 4 4
462 0 ▶ $mut->end < 1 && $tmp2++;
Branch: 1 branch
BranchTrueFalseTotal
$mut->end < 1 and ++$tmp2 0 0 0
463 0 $text.= ' ('. $h->id. '::'. $tmp. "..". $tmp2;
464 }
465 elsif ($mut->length == 0) {
466 0 $tmp--;
467 0 ▶ $tmp-- if $tmp == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $tmp == 0 0 0 0
468 0 $text .= ' ('. $h->id. '::'. $tmp. '^'. $tmp2;
469 } else {
470 4 $text.= ' ('. $h->id. '::'. $tmp;
471 }
472 4 $text .= ')';
473 }
474 17 push (@entry, $text);
475 #sequence
476 push (@entry,
477 17 $tag{FeatureQual}. '/upflank: '. $mut->upStreamSeq
478 );
479 17 $text = '';
480 17 ▶ $text = $mut->allele_ori->seq if $mut->allele_ori->seq;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->allele_ori->seq 15 2 17
481 17 $text .= $sep;
482 17 ▶ $text .= $mut->allele_mut->seq if $mut->allele_mut->seq;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->allele_mut->seq 15 2 17
483 push (@entry,
484 wrap($tag{FeatureQual}. '/change: ', $tag{FeatureWrap},
485 17 $text)
486 );
487
488 push (@entry,
489 17 $tag{FeatureQual}. '/dnflank: '. $mut->dnStreamSeq
490 );
491 #restriction enzyme
492 17 ▶ if ($mut->restriction_changes ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->restriction_changes ne "") 16 1 17
493 16 $text = $mut->restriction_changes;
494 16 $text = wrap($tag{FeatureQual}. '/re_site: ', $tag{FeatureWrap}, $text);
495 16 push (@entry,
496 $text
497 );
498 }
499 #region
500 17 ▶ if ($mut->region ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->region) 4 13 17
501 4 $text = $tag{FeatureQual}. '/region: '. $mut->region;
502 4 ▶ $text .= ';' if $mut->region_value or $mut->region_dist;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->region_value or $mut->region_dist 4 0 4
Condition66%2/3
$mut->region_value or $mut->region_dist
l!l&&r!l&&!r
220
MC/DC0%0/2
$mut->region_value or $mut->region_dist
$mut->region_value $mut->region_dist
Truth table66%2/3
A or B
A= $mut->region_valueB= $mut->region_dist
ABresult
1X1
011
000
503 4 ▶ $text .= ' '. $mut->region_value if $mut->region_value;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->region_value 2 2 4
504 4 ▶ if ($mut->region_dist ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->region_dist) 4 0 4
505 4 $tmp = '';
506 4 ▶ $tmp = '+' if $mut->region_dist > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->region_dist > 1 2 2 4
507 4 $text .= " (". $tmp. $mut->region_dist. ')';
508 }
509 4 push (@entry, $text);
510 }
511 #CpG
512 17 ▶ if ($mut->CpG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->CpG) 0 17 17
513 push (@entry,
514 0 $tag{FeatureQual}. "/CpG"
515 );
516 }
517 }
518 }
519 #
520 # RNA
521 #
522 elsif ($mut->isa('Bio::Variation::RNAChange') ) {
523 #collect all non-reference alleles
524 16 ▶ $self->throw("allele_ori needs to be defined in [$mut]")
Branch: 1 branch
BranchTrueFalseTotal
unless $mut->allele_ori 0 16 16
525 if not $mut->allele_ori;
526 16 my @alleles = $mut->each_Allele;
527 #push @alleles, $mut->allele_mut if $mut->allele_mut;
528 16 ▶ if ($mut->isMutation) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->isMutation) { } 14 2 16
529 14 $sep = '>';
530 } else {
531 2 $sep = '|';
532 }
533  
534 16 my $count = 0; # two alleles
535 16 foreach my $allele (@alleles) {
536 17 $count++;
537 17 my ($variation_number, $change_number) = split /\./, $mut->mut_number;
538 17 ▶ if ($change_number and $change_number != $count){
Branch: 1 branch
BranchTrueFalseTotal
if ($change_number and $change_number != $count) 1 16 17
Condition100%3/3
$change_number and $change_number != $count
!ll&&!rl&&r
1511
MC/DC100%2/2
$change_number and $change_number != $count
$change_number $change_number != $count
Truth table100%3/3
A and B
A= $change_numberB= $change_number != $count
ABresult
0X0
100
111
539 1 $mut->mut_number("$change_number.$count");
540 }
541 17 $mut->allele_mut($allele);
542 push (@entry,
543 17 $tag{FeatureKey}. 'RNA'. "; ". $mut->mut_number
544 );
545 #label
546 17 $text=$tag{FeatureQual}. '/label: '. $mut->label;
547 17 push (@entry, $text);
548 #proof
549 17 ▶ if ($mut->proof) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->proof) 17 0 17
550 17 $text = $tag{FeatureQual}. '/proof: '. $mut->proof;
551 17 push (@entry, $text) ;
552 }
553 #location
554 17 $text = $tag{FeatureQual}. '/location: ' ;
555 17 ▶ if ($mut->length > 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($mut->length > 1) { } 2 15 17
elsif ($mut->length == 0) { } 2 13 15
556 2 $text .= $mut->start. '..'. $mut->end;
557 2 $tmp2 = $mut->end + $h->offset;
558 }
559 elsif ($mut->length == 0) {
560 2 my $tmp_start = $mut->start;
561 2 $tmp_start--;
562 2 ▶ $tmp_start-- if $tmp_start == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $tmp_start == 0 0 2 2
563 2 $text .= $tmp_start. '^'. $mut->end;
564 } else {
565 13 $text .= $mut->start;
566 }
567  
568 17 ▶ if ($h->alphabet && $h->alphabet eq 'rna') {
Branch: 1 branch
BranchTrueFalseTotal
if ($h->alphabet and $h->alphabet eq "rna") 13 4 17
Condition66%2/3
$h->alphabet and $h->alphabet eq "rna"
!ll&&!rl&&r
0413
MC/DC50%1/2
$h->alphabet and $h->alphabet eq "rna"
$h->alphabet $h->alphabet eq "rna"
Truth table66%2/3
A and B
A= $h->alphabetB= $h->alphabet eq "rna"
ABresult
0X0
100
111
569 13 $tmp = $mut->start + $h->offset;
570 13 ▶ $tmp-- if $tmp <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $tmp <= 0 0 13 13
571 #$mut->start < 1 && $tmp++;
572 #$text.= ' ('. $h->id. '::'. $tmp;
573 13 $tmp2 = $mut->end + $h->offset;
574 #$mut->end < 1 && $tmp2++;
575 13 ▶ if ( $mut->length > 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($mut->length > 1) { } 2 11 13
elsif ($mut->length == 0) { } 2 9 11
576 2 $text.= ' ('. $h->id. '::'. $tmp. "..". $tmp2;
577 }
578 elsif ($mut->length == 0) {
579 2 $tmp--;
580 2 $text .= ' ('. $h->id. '::'. $tmp. '^'. $tmp2;
581 } else {
582 9 $text.= ' ('. $h->id. '::'. $tmp;
583 }
584  
585 13 $text .= ')';
586 }
587 17 push (@entry, $text);
588  
589 #sequence
590 push (@entry,
591 17 $tag{FeatureQual}. '/upflank: '. $mut->upStreamSeq
592 );
593 17 $text = '';
594 17 ▶ $text = $mut->allele_ori->seq if $mut->allele_ori->seq;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->allele_ori->seq 15 2 17
595 17 $text .= $sep;
596 17 ▶ $text .= $mut->allele_mut->seq if $mut->allele_mut->seq;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->allele_mut->seq 15 2 17
597 push (@entry,
598 wrap($tag{FeatureQual}. '/change: ', $tag{FeatureWrap},
599 17 $text)
600 );
601 push (@entry,
602 17 $tag{FeatureQual}. '/dnflank: '. $mut->dnStreamSeq
603 );
604 #restriction
605 17 ▶ if ($mut->restriction_changes ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->restriction_changes ne "") 16 1 17
606 16 $text = $mut->restriction_changes;
607 16 $text = wrap($tag{FeatureQual}. '/re_site: ', $tag{FeatureWrap}, $text);
608 16 push (@entry,
609 $text
610 );
611 }
612 #coding
613 17 ▶ if ($mut->region eq 'coding') {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->region eq "coding") 13 4 17
614 #codon table
615 13 $text = $tag{FeatureQual}. '/codon_table: ';
616 13 $text .= $mut->codon_table;
617 13 push (@entry, $text);
618 #codon
619  
620 13 $text = $tag{FeatureQual}. '/codon: '. $mut->codon_ori. $sep;
621 13 ▶ if ($mut->DNAMutation->label =~ /.*point/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->DNAMutation->label =~ /.*point/) { } 8 5 13
622 8 $text .= $mut->codon_mut;
623 }
624 else {
625 5 $text .= '-';
626 }
627 13 $text .= "; ". $mut->codon_pos;
628 13 push (@entry, $text);
629 }
630 #region
631 17 ▶ if ($mut->region ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->region) 17 0 17
632 17 $text = $tag{FeatureQual}. '/region: '. $mut->region;
633 17 ▶ $text .= ';' if $mut->region_value or $mut->region_dist;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->region_value or $mut->region_dist 2 15 17
Condition66%2/3
$mut->region_value or $mut->region_dist
l!l&&r!l&&!r
0215
MC/DC50%1/2
$mut->region_value or $mut->region_dist
$mut->region_value $mut->region_dist
Truth table66%2/3
A or B
A= $mut->region_valueB= $mut->region_dist
ABresult
1X1
011
000
634 17 ▶ $text .= ' '. $mut->region_value if $mut->region_value;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->region_value 0 17 17
635 17 ▶ if ($mut->region_dist ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->region_dist) 2 15 17
636 2 $tmp = '';
637 2 ▶ $tmp = '+' if $mut->region_dist > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->region_dist > 1 1 1 2
638 2 $text .= " (". $tmp. $mut->region_dist. ')';
639 }
640 17 push (@entry, $text);
641 }
642 }
643 }
644 #
645 # AA
646 #
647 elsif ($mut->isa('Bio::Variation::AAChange')) {
648 #collect all non-reference alleles
649 12 ▶ $self->throw("allele_ori needs to be defined in [$mut]")
Branch: 1 branch
BranchTrueFalseTotal
unless $mut->allele_ori 0 12 12
650 if not $mut->allele_ori;
651 12 ▶ if ($mut->isMutation) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->isMutation) { } 10 2 12
652 10 $sep = '>';
653 } else {
654 2 $sep = '|';
655 }
656 12 my @alleles = $mut->each_Allele;
657 #push @alleles, $mut->allele_mut if $mut->allele_mut;
658 12 my $count = 0; # two alleles
659 12 foreach my $allele (@alleles) {
660 13 $count++;
661 13 my ($variation_number, $change_number) = split /\./, $mut->mut_number;
662 13 ▶ if ($change_number and $change_number != $count){
Branch: 1 branch
BranchTrueFalseTotal
if ($change_number and $change_number != $count) 1 12 13
Condition100%3/3
$change_number and $change_number != $count
!ll&&!rl&&r
1111
MC/DC100%2/2
$change_number and $change_number != $count
$change_number $change_number != $count
Truth table100%3/3
A and B
A= $change_numberB= $change_number != $count
ABresult
0X0
100
111
663 1 $mut->mut_number("$change_number.$count");
664 }
665 13 $mut->allele_mut($allele);
666 push (@entry,
667 13 $tag{FeatureKey}. 'AA'. "; ". $mut->mut_number
668 );
669 #label
670 13 $text=$tag{FeatureQual}. '/label: '. $mut->label;
671 13 push (@entry, $text) ;
672 #proof
673 13 ▶ if ($mut->proof) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->proof) 13 0 13
674 13 $text = $tag{FeatureQual}. '/proof: '. $mut->proof;
675 13 push (@entry, $text) ;
676 }
677 #location
678 13 $text = $tag{FeatureQual}. '/location: '.
679 #$mut->id. '; '. $mut->start;
680 $mut->start;
681 13 ▶ if ($mut->length > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->length > 1) 1 12 13
682 1 $tmp = $mut->start + $mut->length -1;
683 1 $text .= '..'. $tmp;
684 }
685 13 push (@entry, $text);
686 #sequence
687 13 $text = '';
688 13 ▶ $text = $mut->allele_ori->seq if $mut->allele_ori->seq;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->allele_ori->seq 13 0 13
689 13 $text .= $sep;
690 13 ▶ $text .= $mut->allele_mut->seq if $mut->allele_mut->seq;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->allele_mut->seq 12 1 13
691 push (@entry,
692 wrap($tag{FeatureQual}. '/change: ', $tag{FeatureWrap},
693 13 $text)
694 );
695 #region
696 13 ▶ if ($mut->region ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->region) 0 13 13
697 0 $text = $tag{FeatureQual}. '/region: '. $mut->region;
698 0 ▶ $text .= ';' if $mut->region_value or $mut->region_dist;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->region_value or $mut->region_dist 0 0 0
Condition0%0/3
$mut->region_value or $mut->region_dist
l!l&&r!l&&!r
000
MC/DC0%0/2
$mut->region_value or $mut->region_dist
$mut->region_value $mut->region_dist
Truth table0%0/3
A or B
A= $mut->region_valueB= $mut->region_dist
ABresult
1X1
011
000
699 0 ▶ $text .= ' '. $mut->region_value if $mut->region_value;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->region_value 0 0 0
700 0 ▶ if ($mut->region_dist ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mut->region_dist) 0 0 0
701 0 $tmp = '';
702 0 ▶ $tmp = '+' if $mut->region_dist > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $mut->region_dist > 1 0 0 0
703 0 $text .= " (". $tmp. $mut->region_dist. ')';
704 }
705 0 push (@entry, $text);
706 }
707 }
708 }
709 }
710 }
711 15 push (@entry,
712 "//"
713 );
714 15 my $str = join ("\n", @entry). "\n";
715 15 $str =~ s/\t/ /g;
716 15 $self->_print($str);
717 }
718 15 return 1;
719 }
720  
721 2 1;
« Variation/AAChange.pm ↑ Summary Variation/RNAChange.pm »