Sequence.pm

filter: Statementstmt 88.1% 119 / 135 Branchbran 72.6% 61 / 84 Conditioncond 51.8% 28 / 54 MC/DCmcdc 25.0% 8 / 32 Subroutinesub 92.3% 12 / 13 Podpod 100% 8 / 8 totaltotal 72.3% 236 / 326 CC 63 SCAR 31.7
CC
63
Cov
76%
_parse
45.5
trimdata
17.4
parse
9.2
CRAP 23.9
↑ Summary EntrezGene.pm »
1 package Bio::ASN1::Sequence;
2 4 our $AUTHORITY = 'cpan:BIOPERLML';
3 4 $Bio::ASN1::Sequence::VERSION = '1.72';
4 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Carp qw(carp croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Regular expression-based Perl Parser for ASN.1-formatted NCBI Sequences.
10 # AUTHOR: Dr. Mingyi Liu <mingyiliu@gmail.com>
11 # OWNER: 2005 Mingyi Liu
12 # OWNER: 2005 GPC Biotech AG
13 # OWNER: 2005 Altana Research Institute
14 # LICENSE: Perl_5
15  
16  
17  
18 sub new
19 {
20 2 ▶ my $class = shift;
Subroutine new: called CC=4 SCAR=13.9
Pod documented
21 2 ▶ $class = ref($class) if(ref($class));
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 2 2
22 2 my $self = { maxerrstr => 20, @_ };
23 2 bless $self, $class;
24 2 ▶ map { $self->input_file($self->{$_}) if($self->{$_}) } qw(file -file);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$_} 1 3 4
25 2 ▶ map { $self->fh($self->{$_}) if($self->{$_}) } qw(fh -fh);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$_} 2 2 4
26 2 return $self;
27 }
28  
29  
30 sub maxerrstr
31 {
32 0 ▶ my ($self, $value) = @_;
Subroutine maxerrstr: not called CC=2 SCAR=17.9
Pod documented
33 0 ▶ $self->{maxerrstr} = $value if $value > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $value > 0 0 0 0
34 0 return $self->{maxerrstr};
35 }
36  
37  
38  
39 sub parse
40 {
41 2 ▶ my ($self, $input, $compact, $noreset) = @_;
Subroutine parse: called CC=7 SCAR=22.2
Pod documented
42 2 ▶ $input || croak "must have input!\n";
Branch: 1 branch
BranchTrueFalseTotal
$input or croak("must have input!\n") 0 2 2
43 2 $self->{input} = $input;
44 2 ▶ $self->{filename} = "input" unless $self->{filename};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"filename"} 1 1 2
45 2 ▶ $self->{linenumber} = 1 unless $self->{linenumber} && $noreset;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"linenumber"} and $noreset 2 0 2
Condition33%1/3
$self->{"linenumber"} and $noreset
!ll&&!rl&&r
200
MC/DC0%0/2
$self->{"linenumber"} and $noreset
$self->{"linenumber"} $noreset
Truth table33%1/3
A and B
A= $self->{"linenumber"}B= $noreset
ABresult
0X0
100
111
46 2 $self->{depth} = 0;
47 2 my $result;
48 eval
49 2 {
50 2 $result = $self->_parse(); # no need to reset $self->{depth} or linenumber
51 };
52 2 ▶ if($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 2 2
53 {
54 0 ▶ if($@ !~ /^Data Error:/)
Branch: 1 branch
BranchTrueFalseTotal
if (not $@ =~ /^Data Error:/) { } 0 0 0
55 {
56 croak "non-conforming data broke parser on line $self->{linenumber} in $self->{filename}\n".
57 "possible cause includes randomly inserted brackets in input file before line $self->{linenumber}\n".
58 "first $self->{maxerrstr} (or till end of input) characters including the non-conforming data:\n" .
59 0 substr($self->{input}, pos($self->{input}), $self->{maxerrstr}) . "\nRaw error mesg: $@\n";
60 }
61 0 else { die $@ }
62 }
63 2 trimdata($result, $compact);
64 2 return $result;
65 }
66  
67  
68 sub input_file
69 {
70 1 ▶ my ($self, $filename) = @_;
Subroutine input_file: called CC=4 SCAR=16.6
Pod documented
71 # in case user's Perl system can't handle large file. Assuming Unix, otherwise raise error
72 1 local *IN; # older styled code to enable module to work with perl 5.005_03
73 1 ▶ open(*IN, $filename) ||
Branch: 1 branch
BranchTrueFalseTotal
open *IN, $filename or $! =~ /too large/i and open *IN, "cat $filename |" or croak("can't open $filename! -- $!\n") 0 1 1
Condition16%1/6
open *IN, $filename or $! =~ /too large/i and open *IN, "cat $filename |"
l!l&&r!l&&!r
100
$! =~ /too large/i and open *IN, "cat $filename |"
!ll&&!rl&&r
000
MC/DC0%0/3
open *IN, $filename or $! =~ /too large/i and open *IN, "cat $filename |"
open *IN, $filename $! =~ /too large/i open *IN, "cat $filename |"
Truth table25%1/4
A or B and C
A= open *IN, $filenameB= $! =~ /too large/iC= open *IN, "cat $filename |"
ABCresult
1XX1
0111
00X0
0100
74 ($! =~ /too large/i && open(*IN, "cat $filename |")) ||
75 croak "can't open $filename! -- $!\n";
76 1 $self->{fh} = *IN;
77 1 $self->{filename} = $filename;
78 1 $self->{linenumber} = 0; # reset line number
79 }
80  
81  
82 sub next_seq
83 {
84 2 ▶ my ($self, $compact) = @_;
Subroutine next_seq: called CC=5 SCAR=16.4
Pod documented
85 2 ▶ $self->{fh} || croak "you must pass in a file name or handle through new() or input_file() first before calling next_seq!\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"fh"} or croak("you must pass in a file name or handle through new() or input_file() first before calling next_seq!\n") 0 2 2
86 2 local $/ = "Seq-entry ::= set {"; # set record separator
87 2 ▶ while($_ = readline($self->{fh}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $self->{"fh"})) 4 0 4
88 {
89 4 chomp;
90 4 ▶ next unless /\S/;
Branch: 1 branch
BranchTrueFalseTotal
unless /\S/ 2 2 4
91 2 ▶ my $tmp = (/^\s*Seq-entry ::= set ({.*)/si)? $1 : "{" . $_; # get rid of the 'Seq-entry ::= set ' at the beginning of Sequence record
Branch: 1 branch
BranchTrueFalseTotal
/^\s*Seq-entry ::= set ({.*)/is ? : 0 2 2
92 2 return $self->parse($tmp, $compact, 1); # 1 species no resetting line number
93 }
94 }
95  
96  
97 sub _parse
98 {
99 294 ▶ my ($self, $flag) = @_;
Subroutine _parse: called CC=30 SCAR=38.2
100 294 my $data;
101 294 while(1)
102 {
103 # changing orders of regex if/elsif statements made little difference. current order is close to optimal
104 1244 ▶ if($self->{input} =~ /\G[ \t]*,?[ \t]*\n/cg) # cleanup leftover
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"input"} =~ /\G[ \t]*,?[ \t]*\n/cg) 476 768 1244
105 {
106 476 $self->{linenumber}++;
107 476 next;
108 }
109 768 ▶ if($self->{input} =~ /\G[ \t]*}/cg)
Branch: 4 branches
BranchTrueFalseTotal
if ($self->{'input'} =~ /\G[ \t]*}/cg) { } 208 560 768
elsif ($self->{'input'} =~ /\G[ \t]*{/cg) { } 40 520 560
elsif ($self->{'input'} =~ /\G[ \t]*([\w-]+)(\s*)/cg) { } 516 4 520
elsif ($self->{'input'} =~ /\G[ \t]*"((?:[^"]+|"")*)"(?=\s*[,}])/cg) { } 2 2 4
110 {
111 208 ▶ if(!($self->{depth}--) && $self->{input} =~ /\S/)
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"depth"}-- and $self->{"input"} =~ /\S/) 0 208 208
Condition33%1/3
not $self->{"depth"}-- and $self->{"input"} =~ /\S/
!ll&&!rl&&r
20800
MC/DC0%0/2
not $self->{"depth"}-- and $self->{"input"} =~ /\S/
not $self->{"depth"}-- $self->{"input"} =~ /\S/
Truth table33%1/3
not(A) and B
A= not $self->{"depth"}--B= $self->{"input"} =~ /\S/
ABresult
0X0
100
111
112 {
113 0 croak "Data Error: extra (mismatched) '}' found on line $self->{linenumber} in $self->{filename}!\n";
114 }
115 208 return $data
116 }
117 elsif($self->{input} =~ /\G[ \t]*{/cg)
118 {
119 40 $self->{depth}++;
120 40 push(@$data, $self->_parse())
121 }
122 elsif($self->{input} =~ /\G[ \t]*([\w-]+)(\s*)/cg)
123 {
124 516 my ($id, $lines) = ($1, $2);
125 # we're prepared for NCBI to make the format even worse:
126 # note: to count line numbers right for text files on different OS, I'm sacrificing much speed (maybe I shouldn't worry so much)
127 516 ▶ $self->{linenumber} += $lines =~ s/\n//g || $lines =~ s/\r//g; # count by *NIX/Win or Mac
Condition66%2/3
$lines =~ s/\n//g || $lines =~ s/\r//g
l!l&&r!l&&!r
840432
MC/DC50%1/2
$lines =~ s/\n//g || $lines =~ s/\r//g
$lines =~ s/\n//g $lines =~ s/\r//g
Truth table66%2/3
A || B
A= $lines =~ s/\n//gB= $lines =~ s/\r//g
ABresult
1X1
011
000
128 516 my ($tmp, $tmp1);
129 # we put \s* in lookahead for linenumber counting purpose (which slows things down)
130 516 ▶ if(($self->{input} =~ /\G"((?:[^"]+|"")*)"(?=\s*[,}])/cg && ++$tmp) ||
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'input'} =~ /\G"((?:[^"]+|"")*)"(?=\s*[,}])/cg and ++$tmp or $self->{'input'} =~ /\G'([^']+)'\s*H/cig and ++$tmp1 or $self->{'input'} =~ /\G([\w-]+)(?=\s*[,}])/cg) { } 264 252 516
elsif ($self->{'input'} =~ /\G\{/cg) { } 168 84 252
elsif ($self->{'input'} =~ /\G(?=[,}])/cg) { } 0 84 84
Condition83%10/12
$self->{"input"} =~ /\G"((?:[^"]+|"")*)"(?=\s*[,}])/cg and ++$tmp or $self->{"input"} =~ /\G'([^']+)'\s*H/cig and ++$tmp1 or $self->{"input"} =~ /\G([\w-]+)(?=\s*[,}])/cg
l!l&&r!l&&!r
134130252
$self->{"input"} =~ /\G"((?:[^"]+|"")*)"(?=\s*[,}])/cg and ++$tmp or $self->{"input"} =~ /\G'([^']+)'\s*H/cig and ++$tmp1
l!l&&r!l&&!r
1322382
$self->{"input"} =~ /\G"((?:[^"]+|"")*)"(?=\s*[,}])/cg and ++$tmp
!ll&&!rl&&r
3840132
$self->{"input"} =~ /\G'([^']+)'\s*H/cig and ++$tmp1
!ll&&!rl&&r
38202
MC/DC60%3/5
$self->{"input"} =~ /\G"((?:[^"]+|"")*)"(?=\s*[,}])/cg and ++$tmp or $self->{"input"} =~ /\G'([^']+)'\s*H/cig and ++$tmp1 or $self->{"input"} =~ /\G([\w-]+)(?=\s*[,}])/cg
$self->{"input"} =~ /\G"((?:[^"]+|"")*)"(?=\s*[,}])/cg ++$tmp $self->{"input"} =~ /\G'([^']+)'\s*H/cig ++$tmp1 $self->{"input"} =~ /\G([\w-]+)(?=\s*[,}])/cg
Truth table36%4/11
A and B or C and D or E
A= $self->{"input"} =~ /\G"((?:[^"]+|"")*)"(?=\s*[,}])/cgB= ++$tmpC= $self->{"input"} =~ /\G'([^']+)'\s*H/cigD= ++$tmp1E= $self->{"input"} =~ /\G([\w-]+)(?=\s*[,}])/cg
ABCDEresult
11XXX1
0X11X1
1011X1
0X0X11
0X1011
100X11
101011
0X0X00
0X1000
100X00
101000
131 ($self->{input} =~ /\G'([^']+)'\s*H/icg && ++$tmp1) || # this is the only difference b/w sequence and entrez gene formats so far
132 $self->{input} =~ /\G([\w-]+)(?=\s*[,}])/cg)
133 {
134 264 my $value = $1;
135 264 ▶ if($tmp) # slight speed optimization, not really necessary since regex is fast enough
Branch: 2 branches
BranchTrueFalseTotal
if ($tmp) { } 132 132 264
elsif ($tmp1) { } 2 130 132
136 {
137 132 $value =~ s/""/"/g;
138 132 ▶ $self->{linenumber} += $value =~ s/\n//g || $value =~ s/\r//g; # count by *NIX/Win or Mac
Condition66%2/3
$value =~ s/\n//g || $value =~ s/\r//g
l!l&&r!l&&!r
120120
MC/DC50%1/2
$value =~ s/\n//g || $value =~ s/\r//g
$value =~ s/\n//g $value =~ s/\r//g
Truth table66%2/3
A || B
A= $value =~ s/\n//gB= $value =~ s/\r//g
ABresult
1X1
011
000
139 132 $value =~ s/[\r\n]+//g; # in case it's Win format
140 }
141 elsif($tmp1) # slight speed optimization, not really necessary since regex is fast enough
142 {
143 2 $value =~ tr/fF8421/NNTGCA/; # good for NCBI4na. But if NCBI8na was used, then more needs to be transliterated
144 2 ▶ $self->{linenumber} += $value =~ s/\n//g || $value =~ s/\r//g; # count by *NIX/Win or Mac
Condition33%1/3
$value =~ s/\n//g || $value =~ s/\r//g
l!l&&r!l&&!r
200
MC/DC0%0/2
$value =~ s/\n//g || $value =~ s/\r//g
$value =~ s/\n//g $value =~ s/\r//g
Truth table33%1/3
A || B
A= $value =~ s/\n//gB= $value =~ s/\r//g
ABresult
1X1
011
000
145 2 $value =~ s/[\r\n0]+//g; # in case it's Win format (get rid of '0' at end of seq too)
146 }
147 264 ▶ if(ref($data->{$id})) { push(@{$data->{$id}}, $value) } # hash value is not a terminal (or have multiple values), create array to avoid multiple same-keyed hash overwrite each other
Branch: 2 branches
BranchTrueFalseTotal
if (ref $data->{$id}) { } 0 264 264
elsif ($data->{$id}) { } 0 264 264
148 0 elsif($data->{$id}) { $data->{$id} = [$data->{$id}, $value] } # hash value has a second terminal value now!
149 264 else { $data->{$id} = $value } # the first terminal value
150 }
151 elsif($self->{input} =~ /\G\{/cg)
152 {
153 168 $self->{depth}++;
154 168 push(@{$data->{$id}}, $self->_parse());
155 }
156 0 elsif($self->{input} =~ /\G(?=[,}])/cg) { push(@$data, $id) }
157 else # must be "id value value" format
158 {
159 84 $self->{depth}++;
160 84 push(@{$data->{$id}}, $self->_parse(1))
161 }
162 516 ▶ if($flag)
Branch: 1 branch
BranchTrueFalseTotal
if ($flag) 84 432 516
163 {
164 84 ▶ if(!($self->{depth}--) && $self->{input} =~ /\S/)
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"depth"}-- and $self->{"input"} =~ /\S/) 0 84 84
Condition33%1/3
not $self->{"depth"}-- and $self->{"input"} =~ /\S/
!ll&&!rl&&r
8400
MC/DC0%0/2
not $self->{"depth"}-- and $self->{"input"} =~ /\S/
not $self->{"depth"}-- $self->{"input"} =~ /\S/
Truth table33%1/3
not(A) and B
A= not $self->{"depth"}--B= $self->{"input"} =~ /\S/
ABresult
0X0
100
111
165 {
166 0 croak "Data Error: extra (mismatched) '}' found on line $self->{linenumber} in $self->{filename}!\n";
167 }
168 84 return $data;
169 }
170 }
171 elsif($self->{input} =~ /\G[ \t]*"((?:[^"]+|"")*)"(?=\s*[,}])/cg)
172 {
173 2 my $value = $1;
174 2 $value =~ s/""/"/g;
175 2 ▶ $self->{linenumber} += $value =~ s/\n//g || $value =~ s/\r//g; # count by *NIX/Win or Mac
Condition33%1/3
$value =~ s/\n//g || $value =~ s/\r//g
l!l&&r!l&&!r
002
MC/DC0%0/2
$value =~ s/\n//g || $value =~ s/\r//g
$value =~ s/\n//g $value =~ s/\r//g
Truth table33%1/3
A || B
A= $value =~ s/\n//gB= $value =~ s/\r//g
ABresult
1X1
011
000
176 2 $value =~ s/[\r\n]+//g; # in case it's Win format
177 2 push(@$data, $value)
178 }
179 else # end of input
180 {
181 2 my ($pos, $len) = (pos($self->{input}), length($self->{input}));
182 2 ▶ if($pos != $len && $self->{input} =~ /\G\s*\S/cg) # problem with parsing, must be non-conforming data
Branch: 3 branches
BranchTrueFalseTotal
if ($pos != $len and $self->{'input'} =~ /\G\s*\S/cg) { } 0 2 2
elsif ($self->{'depth'} > 0) { } 0 2 2
elsif ($self->{'depth'} < 0) { } 0 2 2
Condition33%1/3
$pos != $len and $self->{"input"} =~ /\G\s*\S/cg
!ll&&!rl&&r
200
MC/DC0%0/2
$pos != $len and $self->{"input"} =~ /\G\s*\S/cg
$pos != $len $self->{"input"} =~ /\G\s*\S/cg
Truth table33%1/3
A and B
A= $pos != $lenB= $self->{"input"} =~ /\G\s*\S/cg
ABresult
0X0
100
111
183 {
184 croak "Data Error: none conforming data found on line $self->{linenumber} in $self->{filename}!\n" .
185 "first $self->{maxerrstr} (or till end of input) characters including the non-conforming data:\n" .
186 0 substr($self->{input}, $pos, $self->{maxerrstr}) . "\n";
187 }
188 elsif($self->{depth} > 0)
189 {
190 0 croak "Data Error: missing '}' found at end of input in $self->{filename}!";
191 }
192 elsif($self->{depth} < 0)
193 {
194 0 croak "Data Error: extra (mismatched) '}' found at end of input in $self->{filename}!";
195 }
196 2 return $data;
197 }
198 }
199 }
200  
201 # following copied directly from my Pipeline::Util::util just to make this module
202 # more self-sufficient. Changes should be made over in that module though.
203  
204 # trims arrayrefs that points to one-element array to slims the
205 # data structure down (calls Pipeline::Util::util::trimdata)
206 # something like
207 # 'comments' => ARRAY(0x898be94)
208 # 0 ARRAY(0x883fc54)
209 # 0 ARRAY(0x886aef4)
210 # 0 HASH(0x884d554)
211 # 'heading' => 'LocusTagLink'
212 # 'source' => ARRAY(0x8810714)
213 # 0 ARRAY(0x8a7df18)
214 # 0 ARRAY(0x889f940)
215 # 0 HASH(0x886ada4)
216 # 'src' => ARRAY(0x88454fc)
217 # 0 ARRAY(0x8845598)
218 # 0 HASH(0x898c0ec)
219 # 'db' => 'HGNC'
220 # 'tag' => ARRAY(0x898bfb4)
221 # 0 HASH(0x898c164)
222 # 'id' => 5
223 # becomes this if $flag == 1:
224 # 'comments' => ARRAY(0x8840014)
225 # 0 HASH(0x884d8a4)
226 # 'heading' => 'LocusTagLink'
227 # 'source' => HASH(0x8a9869c)
228 # 'src' => HASH(0x884534c)
229 # 'db' => 'HGNC'
230 # 'tag' => HASH(0x88453c4)
231 # 'id' => 5
232 # so now $hash->{comments}->[0]->[0]->[0]->{source}->[0]->[0]->[0]->{src}->[0]->[0]->{tag}->[0]->{id}
233 # becomes $hash->{comments}->[0]->{source}->{src}->{tag}->{id}
234 # this may create problem as array might suddenly change to hash depending on whether it
235 # has multiple elements or not. So set $flag to 2 or 0/undef would disallow trimming that
236 # would lead to data type change, thus resulting in data structure like:
237 # 'comments' => ARRAY(0x88617e8)
238 # 0 HASH(0x889d578)
239 # 'heading' => 'LocusTagLink'
240 # 'source' => ARRAY(0x8912244)
241 # 0 HASH(0x8a5d648)
242 # 'src' => ARRAY(0x8a2203c)
243 # 0 HASH(0x8a1af10)
244 # 'db' => 'HGNC'
245 # 'tag' => ARRAY(0x8a1add8)
246 # 0 HASH(0x8a1af88)
247 # 'id' => 5
248 # still not the safest, but saves some hassle writing code
249  
250  
251 sub trimdata
252 {
253 510 ▶ my ($ref, $flag) = @_;
Subroutine trimdata: called CC=16 SCAR=28.6
Pod documented
254 510 ▶ $flag = 2 unless $flag;
Branch: 1 branch
BranchTrueFalseTotal
unless $flag 2 508 510
255 510 ▶ return if $flag == 3 || !ref($ref);
Branch: 1 branch
BranchTrueFalseTotal
if $flag == 3 or not ref $ref 0 510 510
Condition33%1/3
$flag == 3 or not ref $ref
l!l&&r!l&&!r
00510
MC/DC0%0/2
$flag == 3 or not ref $ref
$flag == 3 not ref $ref
Truth table33%1/3
A or not(B)
A= $flag == 3B= not ref $ref
ABresult
1X1
011
000
256 510 ▶ if(ref($ref) ne 'ARRAY') # allows for object refs
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref ne 'ARRAY') { } 264 246 510
257 {
258 264 my @keys;
259 264 eval { @keys = keys %$ref }; # let's be careful and check if it can work as a hash
260 264 ▶ return if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 264 264
261 264 foreach my $key (@keys)
262 {
263 508 my $tmp = $ref->{$key};
264 508 ▶ while(ref($tmp) eq 'ARRAY' && @$tmp == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $tmp eq "ARRAY" and @$tmp == 1) 258 278 536
Condition100%3/3
ref $tmp eq "ARRAY" and @$tmp == 1
!ll&&!rl&&r
26414258
MC/DC100%2/2
ref $tmp eq "ARRAY" and @$tmp == 1
ref $tmp eq "ARRAY" @$tmp == 1
Truth table100%3/3
A and B
A= ref $tmp eq "ARRAY"B= @$tmp == 1
ABresult
0X0
100
111
265 {
266 258 ▶ last if($flag == 2 && ref($tmp->[0]) ne 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
if $flag == 2 and ref $tmp->[0] ne "ARRAY" 230 28 258
Condition66%2/3
$flag == 2 and ref $tmp->[0] ne "ARRAY"
!ll&&!rl&&r
028230
MC/DC50%1/2
$flag == 2 and ref $tmp->[0] ne "ARRAY"
$flag == 2 ref $tmp->[0] ne "ARRAY"
Truth table66%2/3
A and B
A= $flag == 2B= ref $tmp->[0] ne "ARRAY"
ABresult
0X0
100
111
267 28 $tmp = $tmp->[0]
268 }
269 508 $ref->{$key} = $tmp;
270 508 ▶ trimdata($ref->{$key}, $flag) if(ref($ref->{$key}))
Branch: 1 branch
BranchTrueFalseTotal
if ref $ref->{$key} 244 264 508
271 }
272 }
273 else
274 {
275 # since the only situations where we would get an array of array is
276 # when ASN file has a bracket of brackets (otherwise we'd get at least
277 # a hash), it makes sense to reduce the arrayrefs to one level
278 246 foreach my $item (@$ref)
279 {
280 266 my $tmp = $item;
281 266 ▶ while(ref($tmp) eq 'ARRAY' && @$tmp == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $tmp eq "ARRAY" and @$tmp == 1) 0 266 266
Condition33%1/3
ref $tmp eq "ARRAY" and @$tmp == 1
!ll&&!rl&&r
26600
MC/DC0%0/2
ref $tmp eq "ARRAY" and @$tmp == 1
ref $tmp eq "ARRAY" @$tmp == 1
Truth table33%1/3
A and B
A= ref $tmp eq "ARRAY"B= @$tmp == 1
ABresult
0X0
100
111
282 {
283 0 $tmp = $tmp->[0];
284 }
285 266 $item = $tmp;
286 266 ▶ trimdata($item, $flag) if(ref($item))
Branch: 1 branch
BranchTrueFalseTotal
if ref $item 264 2 266
287 }
288 }
289 }
290  
291  
292 sub fh
293 {
294 3 ▶ my ($self, $filehandle) = @_;
Subroutine fh: called CC=2 SCAR=6.9
Pod documented
295 3 ▶ if($filehandle)
Branch: 1 branch
BranchTrueFalseTotal
if ($filehandle) 2 1 3
296 {
297 2 $self->{fh} = $filehandle;
298 2 $self->{linenumber} = 0; # reset line number
299 }
300 3 return $self->{fh};
301 }
302  
303  
304 sub rawdata
305 {
306 1 ▶ my $self = shift;
Subroutine rawdata: called CC=1 SCAR=0.0
Pod documented
307 1 return "Seq-entry ::= set $self->{input}";
308 }
309  
310 4 1;
311  
312 __END__
↑ Summary EntrezGene.pm »