Bio/SeqIO/embl.pm

filter: Statementstmt 83.6% 547 / 654 Branchbran 61.5% 294 / 478 Conditioncond 70.2% 92 / 131 MC/DCmcdc 42.8% 33 / 77 Subroutinesub 90.9% 30 / 33 Podpod 100% 2 / 2 totaltotal 72.5% 998 / 1375 CC 306 SCAR 52.8
CC
306
Cov
74%
write_seq
541.1
next_seq
94.1
_read_FTHelper_EMBL
56.1
CRAP 196.6
« Bio/SearchIO/Writer/TextResultWriter.pm ↑ Summary Bio/SearchIO/Writer/HTMLResultWriter.pm »
1 #
2 # BioPerl module for Bio::SeqIO::EMBL
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Ewan Birney <birney@ebi.ac.uk>
7 #
8 # Copyright Ewan Birney
9 #
10 # You may distribute this module under the same terms as perl itself
11  
12 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::SeqIO::embl - EMBL sequence input/output stream
17  
18 =head1 SYNOPSIS
19  
20 It is probably best not to use this object directly, but
21 rather go through the SeqIO handler system. Go:
22  
23 $stream = Bio::SeqIO->new(-file => $filename, -format => 'EMBL');
24  
25 while ( (my $seq = $stream->next_seq()) ) {
26 # do something with $seq
27 }
28  
29 =head1 DESCRIPTION
30  
31 This object can transform Bio::Seq objects to and from EMBL flat
32 file databases.
33  
34 There is a lot of flexibility here about how to dump things which
35 should be documented more fully.
36  
37 There should be a common object that this and Genbank share (probably
38 with Swissprot). Too much of the magic is identical.
39  
40 =head2 Optional functions
41  
42 =over 3
43  
44 =item _show_dna()
45  
46 (output only) shows the dna or not
47  
48 =item _post_sort()
49  
50 (output only) provides a sorting func which is applied to the FTHelpers
51 before printing
52  
53 =item _id_generation_func()
54  
55 This is function which is called as
56  
57 print "ID ", $func($annseq), "\n";
58  
59 To generate the ID line. If it is not there, it generates a sensible ID
60 line using a number of tools.
61  
62 If you want to output annotations in EMBL format they need to be
63 stored in a Bio::Annotation::Collection object which is accessible
64 through the Bio::SeqI interface method L<annotation()|annotation>.
65  
66 The following are the names of the keys which are polled from a
67 L<Bio::Annotation::Collection> object.
68  
69 reference - Should contain Bio::Annotation::Reference objects
70 comment - Should contain Bio::Annotation::Comment objects
71 dblink - Should contain Bio::Annotation::DBLink objects
72  
73 =back
74  
75 =head1 FEEDBACK
76  
77 =head2 Mailing Lists
78  
79 User feedback is an integral part of the evolution of this and other
80 Bioperl modules. Send your comments and suggestions preferably to one
81 of the Bioperl mailing lists. Your participation is much appreciated.
82  
83 bioperl-l@bioperl.org - General discussion
84 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
85  
86 =head2 Support
87  
88 Please direct usage questions or support issues to the mailing list:
89  
90 I<bioperl-l@bioperl.org>
91  
92 rather than to the module maintainer directly. Many experienced and
93 reponsive experts will be able look at the problem and quickly
94 address it. Please include a thorough description of the problem
95 with code and data examples if at all possible.
96  
97 =head2 Reporting Bugs
98  
99 Report bugs to the Bioperl bug tracking system to help us keep track
100 the bugs and their resolution. Bug reports can be submitted via
101 the web:
102  
103 https://github.com/bioperl/bioperl-live/issues
104  
105 =head1 AUTHOR - Ewan Birney
106  
107 Email birney@ebi.ac.uk
108  
109 =head1 APPENDIX
110  
111 The rest of the documentation details each of the object
112 methods. Internal methods are usually preceded with a _
113  
114 =cut
115  
116  
117 # Let the code begin...
118  
119  
120 package Bio::SeqIO::embl;
121 5 $Bio::SeqIO::embl::VERSION = '1.7.8';
122 5 ▶use vars qw(%FTQUAL_NO_QUOTE);
Subroutine BEGIN: called CC=1 SCAR=0.0
123 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
124 5 ▶use Bio::SeqIO::FTHelper;
Subroutine BEGIN: called CC=1 SCAR=0.0
125 5 ▶use Bio::SeqFeature::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
126 5 ▶use Bio::Species;
Subroutine BEGIN: called CC=1 SCAR=0.0
127 5 ▶use Bio::Seq::SeqFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
128 5 ▶use Bio::Annotation::Collection;
Subroutine BEGIN: called CC=1 SCAR=0.0
129 5 ▶use Bio::Annotation::Comment;
Subroutine BEGIN: called CC=1 SCAR=0.0
130 5 ▶use Bio::Annotation::Reference;
Subroutine BEGIN: called CC=1 SCAR=0.0
131 5 ▶use Bio::Annotation::DBLink;
Subroutine BEGIN: called CC=1 SCAR=0.0
132  
133 5 ▶use base qw(Bio::SeqIO);
Subroutine BEGIN: called CC=1 SCAR=0.0
134  
135 # Note that a qualifier that exceeds one line (i.e. a long label) will
136 # automatically be quoted regardless:
137 5 %FTQUAL_NO_QUOTE=(
138 'anticodon'=>1,
139 'citation'=>1,
140 'codon'=>1,
141 'codon_start'=>1,
142 'compare'=>1,
143 'cons_splice'=>1,
144 'direction'=>1,
145 'estimated_length'=>1,
146 'evidence'=>1,
147 'label'=>1,
148 'mod_base'=> 1,
149 'number'=> 1,
150 'rpt_type'=> 1,
151 'rpt_unit'=> 1,
152 'rpt_unit_range'=>1,
153 'tag_peptide'=>1,
154 'transl_except'=> 1,
155 'transl_table'=> 1,
156 'usedin'=> 1,
157 );
158  
159 27 ▶sub _initialize {
Subroutine _initialize: called CC=2 SCAR=7.0
160 27 my($self,@args) = @_;
161  
162 27 $self->SUPER::_initialize(@args);
163 # hash for functions for decoding keys.
164 27 $self->{'_func_ftunit_hash'} = {};
165 # sets this to one by default. People can change it
166 27 $self->_show_dna(1);
167 27 ▶ if ( ! defined $self->sequence_factory ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->sequence_factory) 27 0 27
168 27 $self->sequence_factory(Bio::Seq::SeqFactory->new
169 (-verbose => $self->verbose(),
170 -type => 'Bio::Seq::RichSeq'));
171 }
172 }
173  
174 =head2 next_seq
175  
176 Title : next_seq
177 Usage : $seq = $stream->next_seq()
178 Function: returns the next sequence in the stream
179 Returns : Bio::Seq object
180 Args :
181  
182 =cut
183  
184 21 ▶sub next_seq {
Subroutine next_seq: called CC=82 SCAR=45.4
Pod documented
185 21 my ($self,@args) = @_;
186 21 my ($pseq,$c,$line,$name,$desc,$acc,$seqc,$mol,$div,
187 $date, $comment, @date_arr);
188  
189 21 my ($annotation, %params, @features) =
190 Bio::Annotation::Collection->new();
191  
192 21 $line = $self->_readline;
193 # This needs to be before the first eof() test
194  
195 21 ▶ if ( !defined $line ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $line) 1 20 21
196 1 return; # no throws - end of file
197 }
198  
199 20 ▶ if ( $line =~ /^\s+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s+$/) 1 19 20
200 1 ▶ while ( defined ($line = $self->_readline) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = $self->_readline)) 1 0 1
201 1 ▶ $line =~/^\S/ && last;
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /^\S/ and last 1 0 1
202 }
203 # return without error if the whole next sequence was just a single
204 # blank line and then eof
205 1 ▶ return unless $line;
Branch: 1 branch
BranchTrueFalseTotal
unless $line 0 1 1
206 }
207  
208 # no ID as 1st non-blank line, need short circuit and exit routine
209 20 ▶ $self->throw("EMBL stream with no ID. Not embl in my book")
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /^ID\s+\S+/ 0 20 20
210 unless $line =~ /^ID\s+\S+/;
211  
212 # At this point we are sure that $line contains an ID header line
213 20 my $alphabet;
214 20 ▶ if ( $line =~ tr/;/;/ == 6) { # New style headers contain exactly six semicolons.
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ tr/;// == 6) { } 10 10 20
215  
216 # New style header (EMBL Release >= 87, after June 2006)
217 10 my $topology;
218 my $sv;
219  
220 # ID DQ299383; SV 1; linear; mRNA; STD; MAM; 431 BP.
221 # This regexp comes from the new2old.pl conversion script, from EBI
222 10 ▶ if ($line =~ m/^ID (\S+);\s+SV (\d+); (\w+); ([^;]+); (\w{3}); (\w{3}); (\d+) BP./) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^ID (\S+);\s+SV (\d+); (\w+); ([^;]+); (\w{3}); (\w{3}); (\d+) BP./) 7 3 10
223 7 ($name, $sv, $topology, $mol, $div) = ($1, $2, $3, $4, $6);
224 }
225 10 ▶ if (defined $sv) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sv) 7 3 10
226 7 $params{'-seq_version'} = $sv;
227 7 $params{'-version'} = $sv;
228 }
229  
230 10 ▶ if (defined $topology && $topology eq 'circular') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $topology and $topology eq "circular") 0 10 10
Condition66%2/3
defined $topology and $topology eq "circular"
!ll&&!rl&&r
370
MC/DC0%0/2
defined $topology and $topology eq "circular"
defined $topology $topology eq "circular"
Truth table66%2/3
A and B
A= defined $topologyB= $topology eq "circular"
ABresult
0X0
100
111
231 0 $params{'-is_circular'} = 1;
232 }
233
234 10 ▶ if (defined $mol ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mol) 7 3 10
235 7 ▶ if ($mol =~ /DNA/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($mol =~ /DNA/) { } 6 1 7
elsif ($mol =~ /RNA/) { } 1 0 1
elsif ($mol =~ /AA/) { } 0 0 0
236 6 $alphabet = 'dna';
237 } elsif ($mol =~ /RNA/) {
238 1 $alphabet = 'rna';
239 } elsif ($mol =~ /AA/) {
240 0 $alphabet = 'protein';
241 }
242 }
243 } else {
244
245 # Old style header (EMBL Release < 87, before June 2006)
246 10 ▶ if ($line =~ /^ID\s+(\S+)[^;]*;\s+(\S+)[^;]*;\s+(\S+)[^;]*;/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^ID\s+(\S+)[^;]*;\s+(\S+)[^;]*;\s+(\S+)[^;]*;/) 8 2 10
247 8 ($name, $mol, $div) = ($1, $2, $3);
248 }
249
250 10 ▶ if ($mol) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mol) 8 2 10
251 8 ▶ if ( $mol =~ /circular/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mol =~ /circular/) 0 8 8
252 0 $params{'-is_circular'} = 1;
253 0 $mol =~ s|circular ||;
254 }
255 8 ▶ if (defined $mol ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mol) 8 0 8
256 8 ▶ if ($mol =~ /DNA/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($mol =~ /DNA/) { } 7 1 8
elsif ($mol =~ /RNA/) { } 1 0 1
elsif ($mol =~ /AA/) { } 0 0 0
257 7 $alphabet='dna';
258 } elsif ($mol =~ /RNA/) {
259 1 $alphabet='rna';
260 } elsif ($mol =~ /AA/) {
261 0 $alphabet='protein';
262 }
263 }
264 }
265 }
266  
267 20 ▶ unless( defined $name && length($name) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name and length $name) 5 15 20
Condition66%2/3
defined $name and length $name
!ll&&!rl&&r
5015
MC/DC50%1/2
defined $name and length $name
defined $name length $name
Truth table66%2/3
A and B
A= defined $nameB= length $name
ABresult
0X0
100
111
268 5 $name = "unknown_id";
269 }
270  
271 # $self->warn("not parsing upper annotation in EMBL file yet!");
272 20 my $buffer = $line;
273 20 local $_;
274 20 BEFORE_FEATURE_TABLE :
275 my $ncbi_taxid;
276 20 ▶ until ( !defined $buffer ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (not defined $buffer) 424 0 424
277 424 $_ = $buffer;
278 # Exit at start of Feature table
279 424 ▶ if ( /^(F[HT]|SQ)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^(F[HT]|SQ)/) 20 404 424
280 20 ▶ $self->_pushback($_) if( $1 eq 'SQ' || $1 eq 'FT');
Branch: 1 branch
BranchTrueFalseTotal
if $1 eq "SQ" or $1 eq "FT" 2 18 20
Condition100%3/3
$1 eq "SQ" or $1 eq "FT"
l!l&&r!l&&!r
1118
MC/DC100%2/2
$1 eq "SQ" or $1 eq "FT"
$1 eq "SQ" $1 eq "FT"
Truth table100%3/3
A or B
A= $1 eq "SQ"B= $1 eq "FT"
ABresult
1X1
011
000
281 20 last;
282 }
283 # Description line(s)
284 404 ▶ if (/^DE\s+(\S.*\S)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^DE\s+(\S.*\S)/) 17 387 404
285 17 ▶ $desc .= $desc ? " $1" : $1;
Branch: 1 branch
BranchTrueFalseTotal
$desc ? : 1 16 17
286 }
287  
288 #accession number
289 404 ▶ if ( /^AC\s+(.*)?/ || /^PA\s+(.*)?/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^AC\s+(.*)?/ or /^PA\s+(.*)?/) 20 384 404
Condition100%3/3
/^AC\s+(.*)?/ or /^PA\s+(.*)?/
l!l&&r!l&&!r
191384
MC/DC100%2/2
/^AC\s+(.*)?/ or /^PA\s+(.*)?/
/^AC\s+(.*)?/ /^PA\s+(.*)?/
Truth table100%3/3
A or B
A= /^AC\s+(.*)?/B= /^PA\s+(.*)?/
ABresult
1X1
011
000
290 20 my @accs = split(/[; ]+/, $1); # allow space in addition
291 $params{'-accession_number'} = shift @accs
292 20 ▶ unless defined $params{'-accession_number'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $params{"-accession_number"} 19 1 20
293 20 push @{$params{'-secondary_accessions'}}, @accs;
294 }
295  
296 #version number
297 404 ▶ if ( /^SV\s+\S+\.(\d+);?/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^SV\s+\S+\.(\d+);?/) 3 401 404
298 3 my $sv = $1;
299 #$sv =~ s/\;//;
300 3 $params{'-seq_version'} = $sv;
301 3 $params{'-version'} = $sv;
302 }
303  
304 #date (NOTE: takes last date line)
305 404 ▶ if ( /^DT\s+(.+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^DT\s+(.+)$/) 20 384 404
306 20 my $line = $1;
307 20 my ($date, $version) = split(' ', $line, 2);
308 20 $date =~ tr/,//d; # remove comma if new version
309 20 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 18 2 20
310 18 ▶ if ($version =~ /\(Rel\. (\d+), Created\)/ms ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($version =~ /\(Rel\. (\d+), Created\)/ms) { } 8 10 18
elsif ($version =~ /\(Rel\. (\d+), Last updated, Version (\d+)\)/ms) { } 8 2 10
311 8 my $release = Bio::Annotation::SimpleValue->new(
312 -tagname => 'creation_release',
313 -value => $1
314 );
315 8 $annotation->add_Annotation($release);
316 } elsif ($version =~ /\(Rel\. (\d+), Last updated, Version (\d+)\)/ms ) {
317 8 my $release = Bio::Annotation::SimpleValue->new(
318 -tagname => 'update_release',
319 -value => $1
320 );
321 8 $annotation->add_Annotation($release);
322  
323 8 my $update = Bio::Annotation::SimpleValue->new(
324 -tagname => 'update_version',
325 -value => $2
326 );
327 8 $annotation->add_Annotation($update);
328 }
329 }
330 20 push @{$params{'-dates'}}, $date;
331 }
332  
333 #keywords
334 404 ▶ if ( /^KW (.*)\S*$/ ) {
Branch: 6 branches
BranchTrueFalseTotal
if (/^KW (.*)\S*$/) { } 25 379 404
elsif (/^O[SC]/) { } 17 362 379
elsif (/^OX/) { } 3 359 362
elsif (/^R/) { } 90 269 359
elsif (/^DR/) { } 3 266 269
elsif (/^CC\s+(.*)/) { } 11 255 266
335 25 my @kw = split(/\s*\;\s*/,$1);
336 25 push @{$params{'-keywords'}}, @kw;
337 }
338  
339 # Organism name and phylogenetic information
340 elsif (/^O[SC]/) {
341 # pass the accession number so we can give an informative throw message if necessary
342 17 my $species = $self->_read_EMBL_Species(\$buffer, $params{'-accession_number'});
343 17 $params{'-species'}= $species;
344 }
345  
346 # NCBI TaxID Xref
347 elsif (/^OX/) {
348 3 ▶ if (/NCBI_TaxID=(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/NCBI_TaxID=(\d+)/) 3 0 3
349 3 $ncbi_taxid=$1;
350 }
351  
352 3 my @links = $self->_read_EMBL_TaxID_DBLink(\$buffer);
353 3 foreach my $dblink ( @links ) {
354 1 $annotation->add_Annotation('dblink',$dblink);
355 }
356 }
357  
358 # References
359 elsif (/^R/) {
360 90 my @refs = $self->_read_EMBL_References(\$buffer);
361 90 foreach my $ref ( @refs ) {
362 90 $annotation->add_Annotation('reference',$ref);
363 }
364 }
365  
366 # DB Xrefs
367 elsif (/^DR/) {
368 3 my @links = $self->_read_EMBL_DBLink(\$buffer);
369 3 foreach my $dblink ( @links ) {
370 20 $annotation->add_Annotation('dblink',$dblink);
371 }
372 }
373  
374 # Comments
375 elsif (/^CC\s+(.*)/) {
376 11 $comment .= $1;
377 11 $comment .= " ";
378 11 ▶ while (defined ($_ = $self->_readline) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 210 0 210
379 210 ▶ if (/^CC\s+(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^CC\s+(.*)/) { } 199 11 210
380 199 $comment .= $1;
381 199 $comment .= " ";
382 } else {
383 11 last;
384 }
385 }
386 11 my $commobj = Bio::Annotation::Comment->new();
387 11 $commobj->text($comment);
388 11 $annotation->add_Annotation('comment',$commobj);
389 11 $comment = "";
390 }
391  
392 # Get next line.
393 404 $buffer = $self->_readline;
394 }
395  
396 20 ▶ while ( defined ($_ = $self->_readline) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 38 0 38
397 38 ▶ /^FT\s{3}\w/ && last;
Branch: 1 branch
BranchTrueFalseTotal
/^FT\s{3}\w/ and last 18 20 38
398 20 ▶ /^SQ / && last;
Branch: 1 branch
BranchTrueFalseTotal
/^SQ / and last 2 18 20
399 18 ▶ /^CO / && last;
Branch: 1 branch
BranchTrueFalseTotal
/^CO / and last 0 18 18
400 }
401 20 $buffer = $_;
402  
403 20 ▶ if (defined($buffer) && $buffer =~ /^FT /) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $buffer and $buffer =~ /^FT /) 18 2 20
Condition66%2/3
defined $buffer and $buffer =~ /^FT /
!ll&&!rl&&r
0218
MC/DC50%1/2
defined $buffer and $buffer =~ /^FT /
defined $buffer $buffer =~ /^FT /
Truth table66%2/3
A and B
A= defined $bufferB= $buffer =~ /^FT /
ABresult
0X0
100
111
404 18 ▶ until ( !defined ($buffer) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (not defined $buffer) 205 0 205
405 205 my $ftunit = $self->_read_FTHelper_EMBL(\$buffer);
406  
407 # process ftunit
408 205 my $feat =
409 $ftunit->_generic_seqfeature($self->location_factory(), $name);
410  
411 # add taxon_id from source if available
412 # Notice, this will override what is found in the OX line.
413 # this is by design as this seems to be the official way
414 # of specifying a TaxID
415 205 ▶ if ($params{'-species'} && ($feat->primary_tag eq 'source')
Branch: 1 branch
BranchTrueFalseTotal
if ($params{"-species"} and $feat->primary_tag eq "source" and $feat->has_tag("db_xref") and not $params{"-species"}->ncbi_taxid) 9 196 205
Condition88%8/9
$params{"-species"} and $feat->primary_tag eq "source" and $feat->has_tag("db_xref") and not $params{"-species"}->ncbi_taxid
!ll&&!rl&&r
19609
$params{"-species"} and $feat->primary_tag eq "source" and $feat->has_tag("db_xref")
!ll&&!rl&&r
19159
$params{"-species"} and $feat->primary_tag eq "source"
!ll&&!rl&&r
618514
MC/DC75%3/4
$params{"-species"} and $feat->primary_tag eq "source" and $feat->has_tag("db_xref") and not $params{"-species"}->ncbi_taxid
$params{"-species"} $feat->primary_tag eq "source" $feat->has_tag("db_xref") not $params{"-species"}->ncbi_taxid
Truth table80%4/5
A and B and C and not(D)
A= $params{"-species"}B= $feat->primary_tag eq "source"C= $feat->has_tag("db_xref")D= not $params{"-species"}->ncbi_taxid
ABCDresult
0XXX0
10XX0
110X0
11100
11111
416 && $feat->has_tag('db_xref')
417 && (! $params{'-species'}->ncbi_taxid())) {
418 9 foreach my $tagval ($feat->get_tag_values('db_xref')) {
419 9 ▶ if (index($tagval,"taxon:") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($tagval, "taxon:") == 0) 9 0 9
420 9 $params{'-species'}->ncbi_taxid(substr($tagval,6));
421 9 last;
422 }
423 }
424 }
425  
426 # add feature to list of features
427 205 push(@features, $feat);
428  
429 205 ▶ if ( $buffer !~ /^FT/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($buffer =~ /^FT/) 18 187 205
430 18 last;
431 }
432 }
433 }
434 # Set taxid found in OX line
435 20 ▶ if ($params{'-species'} && defined $ncbi_taxid
Branch: 1 branch
BranchTrueFalseTotal
if ($params{"-species"} and defined $ncbi_taxid and not $params{"-species"}->ncbi_taxid) 2 18 20
Condition100%6/6
$params{"-species"} and defined $ncbi_taxid and not $params{"-species"}->ncbi_taxid
!ll&&!rl&&r
1712
$params{"-species"} and defined $ncbi_taxid
!ll&&!rl&&r
3143
MC/DC100%3/3
$params{"-species"} and defined $ncbi_taxid and not $params{"-species"}->ncbi_taxid
$params{"-species"} defined $ncbi_taxid not $params{"-species"}->ncbi_taxid
Truth table100%4/4
A and B and not(C)
A= $params{"-species"}B= defined $ncbi_taxidC= not $params{"-species"}->ncbi_taxid
ABCresult
0XX0
10X0
1100
1111
436 && (! $params{'-species'}->ncbi_taxid())) {
437 2 $params{'-species'}->ncbi_taxid($ncbi_taxid);
438 }
439  
440 # skip comments
441 20 ▶ while ( defined ($buffer) && $buffer =~ /^XX/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $buffer and $buffer =~ /^XX/) 16 20 36
Condition66%2/3
defined $buffer and $buffer =~ /^XX/
!ll&&!rl&&r
02016
MC/DC50%1/2
defined $buffer and $buffer =~ /^XX/
defined $buffer $buffer =~ /^XX/
Truth table66%2/3
A and B
A= defined $bufferB= $buffer =~ /^XX/
ABresult
0X0
100
111
442 16 $buffer = $self->_readline();
443 }
444
445 20 ▶ if ( $buffer =~ /^CO/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer =~ /^CO/) 4 16 20
446 # bug#2982
447 # special : create contig as annotation
448 4 ▶ while ( defined ($buffer) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $buffer) 4 0 4
449 4 $annotation->add_Annotation($_) for $self->_read_EMBL_Contig(\$buffer);
450 4 ▶ if ( !$buffer || $buffer !~ /^CO/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($buffer and $buffer =~ /^CO/) 4 0 4
Condition66%2/3
$buffer and $buffer =~ /^CO/
!ll&&!rl&&r
130
MC/DC0%0/2
$buffer and $buffer =~ /^CO/
$buffer $buffer =~ /^CO/
Truth table66%2/3
A and B
A= $bufferB= $buffer =~ /^CO/
ABresult
0X0
100
111
451 4 last;
452 }
453 }
454 4 ▶ $buffer ||= '';
Condition100%2/2
$buffer ||= ""
l!l
31
MC/DC100%1/1
$buffer ||= ""
$buffer
Truth table100%2/2
A
A= $buffer
Aresult
11
00
455 }
456 20 ▶ if ($buffer !~ /^\/\//) { # if no SQ lines following CO (bug#2958)
Branch: 1 branch
BranchTrueFalseTotal
unless ($buffer =~ m[^//]) 16 4 20
457 16 ▶ if ( $buffer !~ /^SQ/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($buffer =~ /^SQ/) 1 15 16
458 1 ▶ while ( defined ($_ = $self->_readline) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 0 1 1
459 0 ▶ /^SQ/ && last;
Branch: 1 branch
BranchTrueFalseTotal
/^SQ/ and last 0 0 0
460 }
461 }
462 16 $seqc = "";
463 16 ▶ while ( defined ($_ = $self->_readline) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 2501 2 2503
464 2501 ▶ m{^//} && last;
Branch: 1 branch
BranchTrueFalseTotal
m[^//] and last 14 2487 2501
465 2487 $_ = uc($_);
466 2487 s/[^A-Za-z]//g;
467 2487 $seqc .= $_;
468 }
469 }
470 20 my $seq = $self->sequence_factory->create
471 (-verbose => $self->verbose(),
472 -division => $div,
473 -seq => $seqc,
474 -desc => $desc,
475 -display_id => $name,
476 -annotation => $annotation,
477 -molecule => $mol,
478 -alphabet => $alphabet,
479 -features => \@features,
480 %params);
481 20 return $seq;
482 }
483  
484  
485  
486 =head2 _write_ID_line
487  
488 Title : _write_ID_line
489 Usage : $self->_write_ID_line($seq);
490 Function: Writes the EMBL Release 87 format ID line to the stream, unless
491 : there is a user-supplied ID line generation function in which
492 : case that is used instead.
493 : ( See Bio::SeqIO::embl::_id_generation_function(). )
494 Returns : nothing
495 Args : Bio::Seq object
496  
497 =cut
498  
499 11 ▶sub _write_ID_line {
Subroutine _write_ID_line: called CC=21 SCAR=34.1
500  
501 11 my ($self, $seq) = @_;
502  
503 11 my $id_line;
504 # If there is a user-supplied ID generation function, use it.
505 11 ▶ if ( $self->_id_generation_func ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_id_generation_func) { } 0 11 11
506 0 $id_line = "ID " . &{$self->_id_generation_func}($seq) . "\nXX\n";
507 }
508 # Otherwise, generate a standard EMBL release 87 (June 2006) ID line.
509 else {
510  
511 # The sequence name is supposed to be the primary accession number,
512 11 my $name = $seq->accession_number();
513 11 ▶ if ( not(defined $name) || $name eq 'unknown') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $name or $name eq "unknown") 5 6 11
Condition66%2/3
not defined $name or $name eq "unknown"
l!l&&r!l&&!r
056
MC/DC50%1/2
not defined $name or $name eq "unknown"
not defined $name $name eq "unknown"
Truth table66%2/3
not(A) or B
A= not defined $nameB= $name eq "unknown"
ABresult
1X1
011
000
514 # but if it is not present, use the sequence ID or the empty string
515 5 ▶ $name = $seq->id() || '';
Condition100%2/2
$seq->id || ''
l!l
14
MC/DC100%1/1
$seq->id || ''
$seq->id
Truth table100%2/2
A
A= $seq->id
Aresult
11
00
516 }
517
518 11 ▶ $self->warn("No whitespace allowed in EMBL id [". $name. "]") if $name =~ /\s/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\s/ 0 11 11
519  
520 # Use the sequence version, or default to 1.
521 11 ▶ my $version = $seq->version() || 1;
Condition50%1/2
$seq->version || 1
l!l
011
MC/DC0%0/1
$seq->version || 1
$seq->version
Truth table50%1/2
A
A= $seq->version
Aresult
11
00
522  
523 11 my $len = $seq->length();
524  
525 # Taxonomic division.
526 11 my $div;
527 11 ▶ if ( $seq->can('division') && defined($seq->division) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($seq->can('division') and defined $seq->division and $self->_is_valid_division($seq->division)) { } 2 9 11
Condition83%5/6
$seq->can("division") and defined $seq->division and $self->_is_valid_division($seq->division)
!ll&&!rl&&r
902
$seq->can("division") and defined $seq->division
!ll&&!rl&&r
722
MC/DC66%2/3
$seq->can("division") and defined $seq->division and $self->_is_valid_division($seq->division)
$seq->can("division") defined $seq->division $self->_is_valid_division($seq->division)
Truth table75%3/4
A and B and C
A= $seq->can("division")B= defined $seq->divisionC= $self->_is_valid_division($seq->division)
ABCresult
0XX0
10X0
1100
1111
528 $self->_is_valid_division($seq->division) ) {
529 2 $div = $seq->division();
530 } else {
531 9 ▶ $div ||= 'UNC'; # 'UNC' is the EMBL division code for 'unclassified'.
Condition50%1/2
$div ||= "UNC"
l!l
09
MC/DC0%0/1
$div ||= "UNC"
$div
Truth table50%1/2
A
A= $div
Aresult
11
00
532 }
533  
534 11 my $mol;
535 # If the molecule type is a valid EMBL type, use it.
536 11 ▶ if ( $seq->can('molecule')
Branch: 2 branches
BranchTrueFalseTotal
if ($seq->can('molecule') and defined $seq->molecule and $self->_is_valid_molecule_type($seq->molecule)) { } 0 11 11
elsif ($seq->can('primary_seq') and defined $seq->primary_seq->alphabet) { } 6 7 13
Condition83%5/6
$seq->can("molecule") and defined $seq->molecule and $self->_is_valid_molecule_type($seq->molecule)
!ll&&!rl&&r
920
$seq->can("molecule") and defined $seq->molecule
!ll&&!rl&&r
722
MC/DC0%0/3
$seq->can("molecule") and defined $seq->molecule and $self->_is_valid_molecule_type($seq->molecule)
$seq->can("molecule") defined $seq->molecule $self->_is_valid_molecule_type($seq->molecule)
Truth table75%3/4
A and B and C
A= $seq->can("molecule")B= defined $seq->moleculeC= $self->_is_valid_molecule_type($seq->molecule)
ABCresult
0XX0
10X0
1100
1111
537 && defined($seq->molecule)
538 && $self->_is_valid_molecule_type($seq->molecule)
539 ) {
540 0 $mol = $seq->molecule();
541 }
542 # Otherwise, choose unassigned DNA or RNA based on the alphabet.
543 ▶ elsif ($seq->can('primary_seq') && defined $seq->primary_seq->alphabet) {
Condition100%3/3
$seq->can("primary_seq") and defined $seq->primary_seq->alphabet
!ll&&!rl&&r
236
MC/DC100%2/2
$seq->can("primary_seq") and defined $seq->primary_seq->alphabet
$seq->can("primary_seq") defined $seq->primary_seq->alphabet
Truth table100%3/3
A and B
A= $seq->can("primary_seq")B= defined $seq->primary_seq->alphabet
ABresult
0X0
100
111
544 6 my $alphabet =$seq->primary_seq->alphabet;
545 6 ▶ if ($alphabet eq 'dna') {
Branch: 3 branches
BranchTrueFalseTotal
if ($alphabet eq 'dna') { } 6 0 6
elsif ($alphabet eq 'rna') { } 0 0 0
elsif ($alphabet eq 'protein') { } 0 0 0
546 6 $mol ='unassigned DNA';
547 } elsif ($alphabet eq 'rna') {
548 0 $mol='unassigned RNA';
549 } elsif ($alphabet eq 'protein') {
550 0 $self->warn("Protein sequence found; EMBL is a nucleotide format.");
551 0 $mol='AA'; # AA is not a valid EMBL molecule type.
552 }
553 }
554  
555 11 my $topology = 'linear';
556 11 ▶ if ($seq->is_circular) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq->is_circular) 0 11 11
557 0 $topology = 'circular';
558 }
559  
560 11 ▶ $mol ||= ''; # 'unassigned'; ?
Condition100%2/2
$mol ||= ""
l!l
65
MC/DC100%1/1
$mol ||= ""
$mol
Truth table100%2/2
A
A= $mol
Aresult
11
00
561 11 $id_line = "ID $name; SV $version; $topology; $mol; STD; $div; $len BP.\nXX\n";
562 }
563 11 $self->_print($id_line);
564 }
565  
566 =head2 _is_valid_division
567  
568 Title : _is_valid_division
569 Usage : $self->_is_valid_division($div)
570 Function: tests division code for validity
571 Returns : true if $div is a valid EMBL release 87 taxonomic division.
572 Args : taxonomic division code string
573  
574 =cut
575  
576 2 ▶sub _is_valid_division {
Subroutine _is_valid_division: called CC=1 SCAR=0.0
577 2 my ($self, $division) = @_;
578  
579 2 my %EMBL_divisions = (
580 "PHG" => 1, # Bacteriophage
581 "ENV" => 1, # Environmental Sample
582 "FUN" => 1, # Fungal
583 "HUM" => 1, # Human
584 "INV" => 1, # Invertebrate
585 "MAM" => 1, # Other Mammal
586 "VRT" => 1, # Other Vertebrate
587 "MUS" => 1, # Mus musculus
588 "PLN" => 1, # Plant
589 "PRO" => 1, # Prokaryote
590 "ROD" => 1, # Other Rodent
591 "SYN" => 1, # Synthetic
592 "UNC" => 1, # Unclassified
593 "VRL" => 1 # Viral
594 );
595  
596 2 return exists($EMBL_divisions{$division});
597 }
598  
599 =head2 _is_valid_molecule_type
600  
601 Title : _is_valid_molecule_type
602 Usage : $self->_is_valid_molecule_type($mol)
603 Function: tests molecule type for validity
604 Returns : true if $mol is a valid EMBL release 87 molecule type.
605 Args : molecule type string
606  
607 =cut
608  
609 2 ▶sub _is_valid_molecule_type {
Subroutine _is_valid_molecule_type: called CC=1 SCAR=0.0
610 2 my ($self, $moltype) = @_;
611  
612 2 my %EMBL_molecule_types = (
613 "genomic DNA" => 1,
614 "genomic RNA" => 1,
615 "mRNA" => 1,
616 "tRNA" => 1,
617 "rRNA" => 1,
618 "snoRNA" => 1,
619 "snRNA" => 1,
620 "scRNA" => 1,
621 "pre-RNA" => 1,
622 "other RNA" => 1,
623 "other DNA" => 1,
624 "unassigned DNA" => 1,
625 "unassigned RNA" => 1
626 );
627  
628 2 return exists($EMBL_molecule_types{$moltype});
629 }
630  
631 =head2 write_seq
632  
633 Title : write_seq
634 Usage : $stream->write_seq($seq)
635 Function: writes the $seq object (must be seq) to the stream
636 Returns : 1 for success and undef for error
637 Args : array of 1 to n Bio::SeqI objects
638  
639  
640 =cut
641  
642 13 ▶sub write_seq {
Subroutine write_seq: called CC=101 SCAR=62.9
Pod documented
643 13 my ($self,@seqs) = @_;
644  
645 13 foreach my $seq ( @seqs ) {
646 13 ▶ $self->throw("Attempting to write with no seq!") unless defined $seq;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $seq 0 13 13
647 13 ▶ unless ( ref $seq && $seq->isa('Bio::SeqI' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $seq and $seq->isa("Bio::SeqI")) 4 9 13
Condition100%3/3
ref $seq and $seq->isa("Bio::SeqI")
!ll&&!rl&&r
229
MC/DC100%2/2
ref $seq and $seq->isa("Bio::SeqI")
ref $seq $seq->isa("Bio::SeqI")
Truth table100%3/3
A and B
A= ref $seqB= $seq->isa("Bio::SeqI")
ABresult
0X0
100
111
648 4 ▶ $self->warn("$seq is not a SeqI compliant sequence object!")
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose >= 0 0 4 4
649 if $self->verbose >= 0;
650 4 ▶ unless ( ref $seq && $seq->isa('Bio::PrimarySeqI' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $seq and $seq->isa("Bio::PrimarySeqI")) 2 2 4
Condition66%2/3
ref $seq and $seq->isa("Bio::PrimarySeqI")
!ll&&!rl&&r
202
MC/DC50%1/2
ref $seq and $seq->isa("Bio::PrimarySeqI")
ref $seq $seq->isa("Bio::PrimarySeqI")
Truth table66%2/3
A and B
A= ref $seqB= $seq->isa("Bio::PrimarySeqI")
ABresult
0X0
100
111
651 2 $self->throw("$seq is not a PrimarySeqI compliant sequence object!");
652 }
653 }
654 11 ▶ my $str = $seq->seq || '';
Condition100%2/2
$seq->seq || ''
l!l
83
MC/DC100%1/1
$seq->seq || ''
$seq->seq
Truth table100%2/2
A
A= $seq->seq
Aresult
11
00
655  
656 # Write the ID line.
657 11 $self->_write_ID_line($seq);
658  
659  
660 # Write the accession line if present
661 11 my( $acc );
662 {
663 11 ▶ if ( my $func = $self->_ac_generation_func ) {
Branch: 3 branches
BranchTrueFalseTotal
if (my $func = $self->_ac_generation_func) { } 0 11 11
elsif ($seq->isa('Bio::Seq::RichSeqI') and defined $seq->accession_number) { } 4 7 11
elsif ($seq->can('accession_number')) { } 7 0 7
664 0 $acc = &{$func}($seq);
665 ▶ } elsif ( $seq->isa('Bio::Seq::RichSeqI') &&
Condition66%2/3
$seq->isa("Bio::Seq::RichSeqI") and defined $seq->accession_number
!ll&&!rl&&r
704
MC/DC50%1/2
$seq->isa("Bio::Seq::RichSeqI") and defined $seq->accession_number
$seq->isa("Bio::Seq::RichSeqI") defined $seq->accession_number
Truth table66%2/3
A and B
A= $seq->isa("Bio::Seq::RichSeqI")B= defined $seq->accession_number
ABresult
0X0
100
111
666 defined($seq->accession_number) ) {
667 4 $acc = $seq->accession_number;
668 4 $acc = join("; ", $acc, $seq->get_secondary_accessions);
669 } elsif ( $seq->can('accession_number') ) {
670 7 $acc = $seq->accession_number;
671 }
672  
673 11 ▶ if (defined $acc) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $acc) 11 0 11
674 11 ▶ $self->_print("AC $acc;\n",
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("AC $acc;\n", "XX\n") or return 11 0 11
675 "XX\n") || return;
676 }
677 }
678  
679 # Date lines
680 11 my $switch=0;
681 11 ▶ if ( $seq->can('get_dates') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq->can("get_dates")) 4 7 11
682 4 my @dates = $seq->get_dates();
683 4 my $ct = 1;
684 4 my $date_flag = 0;
685 4 my ($cr) = $seq->annotation->get_Annotations("creation_release");
686 4 my ($ur) = $seq->annotation->get_Annotations("update_release");
687 4 my ($uv) = $seq->annotation->get_Annotations("update_version");
688  
689 4 ▶ unless ($cr && $ur && $ur) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cr and $ur and $ur) 4 0 4
Condition33%2/6
$cr and $ur and $ur
!ll&&!rl&&r
400
$cr and $ur
!ll&&!rl&&r
400
MC/DC0%0/3
$cr and $ur and $ur
$cr $ur $ur
Truth table25%1/4
A and B and C
A= $crB= $urC= $ur
ABCresult
0XX0
10X0
1100
1111
690 4 $date_flag = 1;
691 }
692  
693 4 foreach my $dt (@dates) {
694 0 ▶ if (!$date_flag) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $date_flag) { } 0 0 0
695 0 ▶ $self->_write_line_EMBL_regex("DT ","DT ",
Branch: 1 branch
BranchTrueFalseTotal
if $ct == 1 0 0 0
696 $dt." (Rel. ".($cr->value()).", Created)",
697 '\s+|$',80) if $ct == 1;
698 0 ▶ $self->_write_line_EMBL_regex("DT ","DT ",
Branch: 1 branch
BranchTrueFalseTotal
if $ct == 2 0 0 0
699 $dt." (Rel. ".($ur->value()).", Last updated, Version ".($uv->value()).")",
700 '\s+|$',80) if $ct == 2;
701 } else { # other formats?
702 0 $self->_write_line_EMBL_regex("DT ","DT ",
703 $dt,'\s+|$',80);
704 }
705 0 $switch =1;
706 0 $ct++;
707 }
708 4 ▶ if ($switch == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($switch == 1) 0 4 4
709 0 ▶ $self->_print("XX\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("XX\n") or return 0 0 0
710 }
711 }
712  
713 # Description lines
714 11 ▶ $self->_write_line_EMBL_regex("DE ","DE ",$seq->desc(),'\s+|$',80) || return; #'
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("DE ", "DE ", $seq->desc, "\\s+|\$", 80) or return 11 0 11
715 11 ▶ $self->_print( "XX\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("XX\n") or return 11 0 11
716  
717 # if there, write the kw line
718 {
719 11 my( $kw );
720 11 ▶ if ( my $func = $self->_kw_generation_func ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $func = $self->_kw_generation_func) { } 0 11 11
elsif ($seq->can('keywords')) { } 4 7 11
721 0 $kw = &{$func}($seq);
722 } elsif ( $seq->can('keywords') ) {
723 4 $kw = $seq->keywords;
724 }
725 11 ▶ if (defined $kw) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $kw) 4 7 11
726 4 ▶ $self->_write_line_EMBL_regex("KW ", "KW ", $kw, '\s+|$', 80) || return; #'
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("KW ", "KW ", $kw, "\\s+|\$", 80) or return 4 0 4
727 4 ▶ $self->_print( "XX\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("XX\n") or return 4 0 4
728 }
729 }
730  
731 # Organism lines
732  
733 11 ▶ if ($seq->can('species') && (my $spec = $seq->species)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq->can("species") and my $spec = $seq->species) 6 5 11
Condition100%3/3
$seq->can("species") and my $spec = $seq->species
!ll&&!rl&&r
236
MC/DC100%2/2
$seq->can("species") and my $spec = $seq->species
$seq->can("species") my $spec = $seq->species
Truth table100%3/3
A and B
A= $seq->can("species")B= my $spec = $seq->species
ABresult
0X0
100
111
734 6 my @class = $spec->classification();
735 6 shift @class; # get rid of species name. Some embl files include
736 # the species name in the OC lines, but this seems
737 # more like an error than something we need to
738 # emulate
739 6 my $OS = $spec->scientific_name;
740 6 ▶ if ($spec->common_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec->common_name) 0 6 6
741 0 $OS .= ' ('.$spec->common_name.')';
742 }
743 6 ▶ $self->_print("OS $OS\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("OS $OS\n") or return 6 0 6
744 6 my $OC = join('; ', reverse(@class)) .'.';
745 6 ▶ $self->_write_line_EMBL_regex("OC ","OC ",$OC,'; |$',80) || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("OC ", "OC ", $OC, "; |\$", 80) or return 6 0 6
746 6 ▶ if ($spec->organelle) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec->organelle) 0 6 6
747 0 ▶ $self->_write_line_EMBL_regex("OG ","OG ",$spec->organelle,'; |$',80) || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("OG ", "OG ", $spec->organelle, "; |\$", 80) or return 0 0 0
748 }
749 6 my $ncbi_taxid = $spec->ncbi_taxid;
750 6 ▶ if ($ncbi_taxid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ncbi_taxid) 2 4 6
751 2 ▶ $self->_print("OX NCBI_TaxID=$ncbi_taxid\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("OX NCBI_TaxID=$ncbi_taxid\n") or return 2 0 2
752 }
753 6 ▶ $self->_print("XX\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("XX\n") or return 6 0 6
754 }
755 # Reference lines
756 11 my $t = 1;
757 11 ▶ if ( $seq->can('annotation') && defined $seq->annotation ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq->can("annotation") and defined $seq->annotation) 9 2 11
Condition66%2/3
$seq->can("annotation") and defined $seq->annotation
!ll&&!rl&&r
209
MC/DC50%1/2
$seq->can("annotation") and defined $seq->annotation
$seq->can("annotation") defined $seq->annotation
Truth table66%2/3
A and B
A= $seq->can("annotation")B= defined $seq->annotation
ABresult
0X0
100
111
758 9 foreach my $ref ( $seq->annotation->get_Annotations('reference') ) {
759 6 ▶ $self->_print( "RN [$t]\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("RN [$t]\n") or return 6 0 6
760  
761 # Having no RP line is legal, but we need both
762 # start and end for a valid location.
763 6 ▶ if ($ref->comment) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->comment) 0 6 6
764 0 ▶ $self->_write_line_EMBL_regex("RC ", "RC ", $ref->comment, '\s+|$', 80) || return; #'
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("RC ", "RC ", $ref->comment, "\\s+|\$", 80) or return 0 0 0
765 }
766 6 my $start = $ref->start;
767 6 my $end = $ref->end;
768 6 ▶ if ($start and $end) {
Branch: 2 branches
BranchTrueFalseTotal
if ($start and $end) { } 6 0 6
elsif ($start or $end) { } 0 0 0
Condition33%1/3
$start and $end
!ll&&!rl&&r
006
MC/DC0%0/2
$start and $end
$start $end
Truth table33%1/3
A and B
A= $startB= $end
ABresult
0X0
100
111
769 6 ▶ $self->_print( "RP $start-$end\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("RP $start-$end\n") or return 6 0 6
770 ▶ } elsif ($start or $end) {
Condition0%0/3
$start or $end
l!l&&r!l&&!r
000
MC/DC0%0/2
$start or $end
$start $end
Truth table0%0/3
A or B
A= $startB= $end
ABresult
1X1
011
000
771 0 $self->throw("Both start and end are needed for a valid RP line.".
772 " Got: start='$start' end='$end'");
773 }
774  
775 6 ▶ if (my $med = $ref->medline) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $med = $ref->medline) 0 6 6
776 0 ▶ $self->_print( "RX MEDLINE; $med.\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("RX MEDLINE; $med.\n") or return 0 0 0
777 }
778 6 ▶ if (my $pm = $ref->pubmed) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pm = $ref->pubmed) 0 6 6
779 0 ▶ $self->_print( "RX PUBMED; $pm.\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("RX PUBMED; $pm.\n") or return 0 0 0
780 }
781 6 my $authors = $ref->authors;
782 6 $authors =~ s/([\w\.]) (\w)/$1#$2/g; # add word wrap protection char '#'
783  
784 6 ▶ $self->_write_line_EMBL_regex("RA ", "RA ",
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("RA ", "RA ", $authors . ';', "\\s+|\$", 80) or return 6 0 6
785 $authors . ";",
786 '\s+|$', 80) || return; #'
787  
788 # If there is no title to the reference, it appears
789 # as a single semi-colon. All titles must end in
790 # a semi-colon.
791 6 ▶ my $ref_title = $ref->title || '';
Condition100%2/2
$ref->title || ''
l!l
24
MC/DC100%1/1
$ref->title || ''
$ref->title
Truth table100%2/2
A
A= $ref->title
Aresult
11
00
792 6 $ref_title =~ s/[\s;]*$/;/;
793 6 ▶ $self->_write_line_EMBL_regex("RT ", "RT ", $ref_title, '\s+|$', 80) || return; #'
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("RT ", "RT ", $ref_title, "\\s+|\$", 80) or return 6 0 6
794 6 ▶ $self->_write_line_EMBL_regex("RL ", "RL ", $ref->location, '\s+|$', 80) || return; #'
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("RL ", "RL ", $ref->location, "\\s+|\$", 80) or return 6 0 6
795 6 ▶ $self->_print("XX\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("XX\n") or return 6 0 6
796 6 $t++;
797 }
798  
799 # DB Xref lines
800 9 ▶ if (my @db_xref = $seq->annotation->get_Annotations('dblink') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@db_xref) = $seq->annotation->get_Annotations("dblink")) 2 7 9
801 2 for my $dr (@db_xref) {
802 43 my $db_name = $dr->database;
803 43 my $prim = $dr->primary_id;
804  
805 43 ▶ my $opt = $dr->optional_id || '';
Condition50%1/2
$dr->optional_id || ''
l!l
043
MC/DC0%0/1
$dr->optional_id || ''
$dr->optional_id
Truth table50%1/2
A
A= $dr->optional_id
Aresult
11
00
806 43 ▶ my $line = $opt ? "$db_name; $prim; $opt." : "$db_name; $prim.";
Branch: 1 branch
BranchTrueFalseTotal
$opt ? : 0 43 43
807 43 ▶ $self->_write_line_EMBL_regex("DR ", "DR ", $line, '\s+|$', 80) || return; #'
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("DR ", "DR ", $line, "\\s+|\$", 80) or return 43 0 43
808 }
809 2 ▶ $self->_print("XX\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("XX\n") or return 2 0 2
810 }
811
812 # Comment lines
813 9 foreach my $comment ( $seq->annotation->get_Annotations('comment') ) {
814 4 ▶ $self->_write_line_EMBL_regex("CC ", "CC ", $comment->text, '\s+|$', 80) || return; #'
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("CC ", "CC ", $comment->text, "\\s+|\$", 80) or return 4 0 4
815 4 ▶ $self->_print("XX\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("XX\n") or return 4 0 4
816 }
817 }
818 # "\\s\+\|\$"
819  
820 ## FEATURE TABLE
821  
822 11 ▶ $self->_print("FH Key Location/Qualifiers\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("FH Key Location/Qualifiers\n") or return 11 0 11
823 11 ▶ $self->_print("FH\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("FH\n") or return 11 0 11
824  
825 11 ▶ my @feats = $seq->can('top_SeqFeatures') ? $seq->top_SeqFeatures : ();
Branch: 1 branch
BranchTrueFalseTotal
$seq->can('top_SeqFeatures') ? : 9 2 11
826 11 ▶ if ($feats[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($feats[0]) 6 5 11
827 6 ▶ if ( defined $self->_post_sort ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_post_sort) { } 0 6 6
828 # we need to read things into an array.
829 # Process. Sort them. Print 'em
830  
831 0 my $post_sort_func = $self->_post_sort();
832 0 my @fth;
833  
834 0 foreach my $sf ( @feats ) {
835 0 push(@fth,Bio::SeqIO::FTHelper::from_SeqFeature($sf,$seq));
836 }
837  
838 0 @fth = sort { &$post_sort_func($a,$b) } @fth;
839  
840 0 foreach my $fth ( @fth ) {
841 0 ▶ $self->_print_EMBL_FTHelper($fth) || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print_EMBL_FTHelper($fth) or return 0 0 0
842 }
843 } else {
844 # not post sorted. And so we can print as we get them.
845 # lower memory load...
846  
847 6 foreach my $sf ( @feats ) {
848 38 my @fth = Bio::SeqIO::FTHelper::from_SeqFeature($sf,$seq);
849 38 foreach my $fth ( @fth ) {
850 38 ▶ if ( $fth->key eq 'CONTIG') {
Branch: 1 branch
BranchTrueFalseTotal
if ($fth->key eq "CONTIG") 0 38 38
851 0 $self->_show_dna(0);
852 }
853 38 ▶ $self->_print_EMBL_FTHelper($fth) || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print_EMBL_FTHelper($fth) or return 38 0 38
854 }
855 }
856 }
857 }
858  
859 11 ▶ if ( $self->_show_dna() == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_show_dna == 0) 0 11 11
860 0 ▶ $self->_print( "//\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("//\n") or return 0 0 0
861 0 return;
862 }
863 11 ▶ $self->_print( "XX\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("XX\n") or return 11 0 11
864  
865 # finished printing features.
866  
867 # print contig if present : bug#2982
868 11 ▶ if ( $seq->can('annotation') && defined $seq->annotation) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq->can("annotation") and defined $seq->annotation) 9 2 11
Condition66%2/3
$seq->can("annotation") and defined $seq->annotation
!ll&&!rl&&r
209
MC/DC50%1/2
$seq->can("annotation") and defined $seq->annotation
$seq->can("annotation") defined $seq->annotation
Truth table66%2/3
A and B
A= $seq->can("annotation")B= defined $seq->annotation
ABresult
0X0
100
111
869 9 foreach my $ctg ( $seq->annotation->get_Annotations('contig') ) {
870 0 ▶ if ($ctg->value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ctg->value) 0 0 0
871 0 ▶ $self->_write_line_EMBL_regex("CO ","CO ", $ctg->value,
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("CO ", "CO ", $ctg->value, "[,]|\$", 80) or return 0 0 0
872 '[,]|$', 80) || return;
873 }
874 }
875 }
876 # print sequence lines only if sequence is present! bug#2982
877 11 ▶ if (length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $str) 8 3 11
878 8 $str =~ tr/A-Z/a-z/;
879  
880 # Count each nucleotide
881 8 my $alen = $str =~ tr/a/a/;
882 8 my $clen = $str =~ tr/c/c/;
883 8 my $glen = $str =~ tr/g/g/;
884 8 my $tlen = $str =~ tr/t/t/;
885
886 8 my $len = $seq->length();
887 8 my $olen = $seq->length() - ($alen + $tlen + $clen + $glen);
888 8 ▶ if ( $olen < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($olen < 0) 0 8 8
889 0 $self->warn("Weird. More atgc than bases. Problem!");
890 }
891
892 8 ▶ $self->_print("SQ Sequence $len BP; $alen A; $clen C; $glen G; $tlen T; $olen other;\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("SQ Sequence $len BP; $alen A; $clen C; $glen G; $tlen T; $olen other;\n") or return 8 0 8
893  
894 8 my $nuc = 60; # Number of nucleotides per line
895 8 my $whole_pat = 'a10' x 6; # Pattern for unpacking a whole line
896 8 my $out_pat = 'A11' x 6; # Pattern for packing a line
897 8 my $length = length($str);
898
899 # Calculate the number of nucleotides which fit on whole lines
900 8 my $whole = int($length / $nuc) * $nuc;
901  
902 # Print the whole lines
903 8 my( $i );
904 8 ▶ for ($i = 0; $i < $whole; $i += $nuc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $whole) 162 8 170
905 162 my $blocks = pack $out_pat,
906 unpack $whole_pat,
907 substr($str, $i, $nuc);
908 162 ▶ $self->_print(sprintf(" $blocks%9d\n", $i + $nuc)) || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print(sprintf(" $blocks%9d\n", $i + $nuc)) or return 162 0 162
909 }
910  
911 # Print the last line
912 8 ▶ if (my $last = substr($str, $i)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $last = substr($str, $i)) 8 0 8
913 8 my $last_len = length($last);
914 8 my $last_pat = 'a10' x int($last_len / 10) .'a'. $last_len % 10;
915 8 my $blocks = pack $out_pat,
916 unpack($last_pat, $last);
917 8 ▶ $self->_print(sprintf(" $blocks%9d\n", $length)) ||
Branch: 1 branch
BranchTrueFalseTotal
$self->_print(sprintf(" $blocks%9d\n", $length)) or return 8 0 8
918 return; # Add the length to the end
919 }
920 }
921
922 11 ▶ $self->_print( "//\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("//\n") or return 11 0 11
923
924 11 ▶ $self->flush if $self->_flush_on_write && defined $self->_fh;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_flush_on_write and defined $self->_fh 11 0 11
Condition33%1/3
$self->_flush_on_write and defined $self->_fh
!ll&&!rl&&r
0011
MC/DC0%0/2
$self->_flush_on_write and defined $self->_fh
$self->_flush_on_write defined $self->_fh
Truth table33%1/3
A and B
A= $self->_flush_on_writeB= defined $self->_fh
ABresult
0X0
100
111
925 }
926 11 return 1;
927 }
928  
929 =head2 _print_EMBL_FTHelper
930  
931 Title : _print_EMBL_FTHelper
932 Usage :
933 Function: Internal function
934 Returns : 1 if writing succeeded, otherwise undef
935 Args :
936  
937  
938 =cut
939  
940 38 ▶sub _print_EMBL_FTHelper {
Subroutine _print_EMBL_FTHelper: called CC=17 SCAR=39.3
941 38 my ($self,$fth) = @_;
942  
943 38 ▶ if ( ! ref $fth || ! $fth->isa('Bio::SeqIO::FTHelper') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $fth and $fth->isa("Bio::SeqIO::FTHelper")) 0 38 38
Condition33%1/3
ref $fth and $fth->isa("Bio::SeqIO::FTHelper")
!ll&&!rl&&r
0038
MC/DC0%0/2
ref $fth and $fth->isa("Bio::SeqIO::FTHelper")
ref $fth $fth->isa("Bio::SeqIO::FTHelper")
Truth table33%1/3
A and B
A= ref $fthB= $fth->isa("Bio::SeqIO::FTHelper")
ABresult
0X0
100
111
944 0 $fth->warn("$fth is not a FTHelper class. Attempting to print, but there could be tears!");
945 }
946  
947  
948 #$self->_print( "FH Key Location/Qualifiers\n");
949 #$self->_print( sprintf("FT %-15s %s\n",$fth->key,$fth->loc));
950 # let
951 38 ▶ if ( $fth->key eq 'CONTIG' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fth->key eq "CONTIG") 0 38 38
952 0 ▶ $self->_print("XX\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("XX\n") or return 0 0 0
953 0 ▶ $self->_write_line_EMBL_regex("CO ",
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("CO ", "CO ", $fth->loc, "\\,|\$", 80) or return 0 0 0
954 "CO ",$fth->loc,
955 '\,|$',80) || return; #'
956 0 return 1;
957 }
958 38 ▶ $self->_write_line_EMBL_regex(sprintf("FT %-15s ",$fth->key),
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex(sprintf("FT %-15s ", $fth->key), "FT ", $fth->loc, "\\,|\$", 80) or return 38 0 38
959 "FT ",$fth->loc,
960 '\,|$',80) || return; #'
961 38 foreach my $tag (sort keys %{$fth->field} ) {
962 108 ▶ if ( ! defined $fth->field->{$tag} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fth->field->{$tag}) 0 108 108
963 0 next;
964 }
965 108 foreach my $value ( @{$fth->field->{$tag}} ) {
966 139 $value =~ s/\"/\"\"/g;
967 139 ▶ if ($value eq "_no_value") {
Branch: 2 branches
BranchTrueFalseTotal
if ($value eq '_no_value') { } 0 139 139
elsif (not $Bio::SeqIO::embl::FTQUAL_NO_QUOTE{$tag} or length "/$tag=$value" >= 60) { } 139 0 139
968 0 ▶ $self->_write_line_EMBL_regex("FT ",
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("FT ", "FT ", "/$tag", ".|\$", 80) or return 0 0 0
969 "FT ",
970 "/$tag",'.|$',80) || return; #'
971 }
972 # there are almost 3x more quoted qualifier values and they
973 # are more common too so we take quoted ones first
974 #
975 # Long qualifiers, that will be line wrapped, are always quoted
976 ▶ elsif (!$FTQUAL_NO_QUOTE{$tag} or length("/$tag=$value")>=60) {
Condition66%2/3
not $Bio::SeqIO::embl::FTQUAL_NO_QUOTE{$tag} or length "/$tag=$value" >= 60
l!l&&r!l&&!r
13810
MC/DC0%0/2
not $Bio::SeqIO::embl::FTQUAL_NO_QUOTE{$tag} or length "/$tag=$value" >= 60
not $Bio::SeqIO::embl::FTQUAL_NO_QUOTE{$tag} length "/$tag=$value" >= 60
Truth table66%2/3
not(A) or B
A= not $Bio::SeqIO::embl::FTQUAL_NO_QUOTE{$tag}B= length "/$tag=$value" >= 60
ABresult
1X1
011
000
977 139 ▶ my $pat = $value =~ /\s+/ ? '\s+|\-|$' : '.|\-|$';
Branch: 1 branch
BranchTrueFalseTotal
$value =~ /\s+/ ? : 80 59 139
978 139 ▶ $self->_write_line_EMBL_regex("FT ",
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("FT ", "FT ", qq[/$tag="$value"], $pat, 80) or return 139 0 139
979 "FT ",
980 "/$tag=\"$value\"",$pat,80) || return;
981 } else {
982 0 ▶ $self->_write_line_EMBL_regex("FT ",
Branch: 1 branch
BranchTrueFalseTotal
$self->_write_line_EMBL_regex("FT ", "FT ", "/$tag=$value", ".|\$", 80) or return 0 0 0
983 "FT ",
984 "/$tag=$value",'.|$',80) || return; #'
985 }
986 }
987 }
988  
989 38 return 1;
990 }
991  
992  
993  
994 =head2 _read_EMBL_Contig()
995  
996 Title : _read_EMBL_Contig
997 Usage :
998 Function: convert CO lines into annotations
999 Returns :
1000 Args :
1001  
1002 =cut
1003  
1004 4 ▶sub _read_EMBL_Contig {
Subroutine _read_EMBL_Contig: called CC=5 SCAR=16.3
1005 4 my ($self, $buffer) = @_;
1006 4 my @ret;
1007 4 ▶ if ( $$buffer !~ /^CO/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$buffer =~ /^CO/) 0 4 4
1008 0 warn("Not parsing line '$$buffer' which maybe important");
1009 }
1010 4 $self->_pushback($$buffer);
1011 4 ▶ while ( defined ($_ = $self->_readline) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 356 1 357
1012 356 ▶ /^C/ || last;
Branch: 1 branch
BranchTrueFalseTotal
/^C/ or last 353 3 356
1013 353 ▶ /^CO\s+(.*)/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/^CO\s+(.*)/ and do { push @ret, "Bio::Annotation::SimpleValue"->new("-tagname", "contig", "-value", $1) } 353 0 353
1014 353 push @ret, Bio::Annotation::SimpleValue->new( -tagname => 'contig',
1015 -value => $1);
1016 };
1017 }
1018 4 $$buffer = $_;
1019 4 return @ret;
1020  
1021 }
1022 #'
1023 =head2 _read_EMBL_References
1024  
1025 Title : _read_EMBL_References
1026 Usage :
1027 Function: Reads references from EMBL format. Internal function really
1028 Example :
1029 Returns :
1030 Args :
1031  
1032  
1033 =cut
1034  
1035 90 ▶sub _read_EMBL_References {
Subroutine _read_EMBL_References: called CC=11 SCAR=24.0
1036 90 my ($self,$buffer) = @_;
1037 90 my (@refs);
1038  
1039 # assume things are starting with RN
1040  
1041 90 ▶ if ( $$buffer !~ /^RN/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$buffer =~ /^RN/) 0 90 90
1042 0 warn("Not parsing line '$$buffer' which maybe important");
1043 }
1044 90 my $b1;
1045 my $b2;
1046 90 my $title;
1047 90 my $loc;
1048 90 my $au;
1049 90 my $med;
1050 90 my $pm;
1051 90 my $com;
1052  
1053 90 ▶ while ( defined ($_ = $self->_readline) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 658 0 658
1054 658 ▶ /^R/ || last;
Branch: 1 branch
BranchTrueFalseTotal
/^R/ or last 568 90 658
1055 568 ▶ /^RP (\d+)-(\d+)/ && do {$b1=$1;$b2=$2;};
Branch: 1 branch
BranchTrueFalseTotal
/^RP (\d+)-(\d+)/ and do { $b1 = $1; $b2 = $2 } 31 537 568
1056 568 ▶ /^RX MEDLINE;\s+(\d+)/ && do {$med=$1};
Branch: 1 branch
BranchTrueFalseTotal
/^RX MEDLINE;\s+(\d+)/ and do { $med = $1 } 50 518 568
1057 568 ▶ /^RX PUBMED;\s+(\d+)/ && do {$pm=$1};
Branch: 1 branch
BranchTrueFalseTotal
/^RX PUBMED;\s+(\d+)/ and do { $pm = $1 } 8 560 568
1058 568 ▶ /^RA (.*)/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/^RA (.*)/ and do { $au = $self->_concatenate_lines($au, $1); next } 181 387 568
1059 181 $au = $self->_concatenate_lines($au,$1); next;
1060 };
1061 387 ▶ /^RT (.*)/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/^RT (.*)/ and do { $title = $self->_concatenate_lines($title, $1); next } 149 238 387
1062 149 $title = $self->_concatenate_lines($title,$1); next;
1063 };
1064 238 ▶ /^RL (.*)/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/^RL (.*)/ and do { $loc = $self->_concatenate_lines($loc, $1); next } 139 99 238
1065 139 $loc = $self->_concatenate_lines($loc,$1); next;
1066 };
1067 99 ▶ /^RC (.*)/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/^RC (.*)/ and do { $com = $self->_concatenate_lines($com, $1); next } 3 96 99
1068 3 $com = $self->_concatenate_lines($com,$1); next;
1069 };
1070 }
1071  
1072 90 my $ref = Bio::Annotation::Reference->new();
1073 90 $au =~ s/;\s*$//g;
1074 90 $title =~ s/;\s*$//g;
1075  
1076 90 $ref->start($b1);
1077 90 $ref->end($b2);
1078 90 $ref->authors($au);
1079 90 $ref->title($title);
1080 90 $ref->location($loc);
1081 90 $ref->medline($med);
1082 90 $ref->comment($com);
1083 90 $ref->pubmed($pm);
1084  
1085 90 push(@refs,$ref);
1086 90 $$buffer = $_;
1087  
1088 90 return @refs;
1089 }
1090  
1091 =head2 _read_EMBL_Species
1092  
1093 Title : _read_EMBL_Species
1094 Usage :
1095 Function: Reads the EMBL Organism species and classification
1096 lines.
1097 Example :
1098 Returns : A Bio::Species object
1099 Args : a reference to the current line buffer, accession number
1100  
1101 =cut
1102  
1103 17 ▶sub _read_EMBL_Species {
Subroutine _read_EMBL_Species: called CC=24 SCAR=33.8
1104 17 my( $self, $buffer, $acc ) = @_;
1105 17 my $org;
1106  
1107 17 $_ = $$buffer;
1108 17 my( $sub_species, $species, $genus, $common, $sci_name, $class_lines );
1109 17 ▶ while (defined( $_ ||= $self->_readline )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ ||= $self->_readline)) 75 0 75
Condition66%2/3
$_ ||= $self->_readline
l!l&&r!l&&!r
17580
MC/DC0%0/2
$_ ||= $self->_readline
$_ $self->_readline
Truth table66%2/3
A ||= B
A= $_B= $self->_readline
ABresult
1X1
011
000
1110 75 ▶ if (/^OS\s+(.+)/) {
Branch: 3 branches
BranchTrueFalseTotal
if (/^OS\s+(.+)/) { } 17 58 75
elsif (s/^OC\s+(.+)$//) { } 41 17 58
elsif (/^OG\s+(.*)/) { } 0 17 17
1111 17 ▶ $sci_name .= ($sci_name) ? ' '.$1 : $1;
Branch: 1 branch
BranchTrueFalseTotal
$sci_name ? : 0 17 17
1112 } elsif (s/^OC\s+(.+)$//) {
1113 41 $class_lines .= $1;
1114 } elsif (/^OG\s+(.*)/) {
1115 0 $org = $1;
1116 } else {
1117 17 last;
1118 }
1119  
1120 58 $_ = undef; # Empty $_ to trigger read of next line
1121 }
1122  
1123 # $$buffer = $_;
1124 17 $self->_pushback($_);
1125
1126 17 $sci_name =~ s{\.$}{};
1127 17 ▶ $sci_name || return;
Branch: 1 branch
BranchTrueFalseTotal
$sci_name or return 17 0 17
1128  
1129 # Convert data in classification lines into classification array.
1130 # only split on ';' or '.' so that classification that is 2 or more words
1131 # will still get matched, use map() to remove trailing/leading/intervening
1132 # spaces
1133 17 my @class = map { s/^\s+//; s/\s+$//; s/\s{2,}/ /g; $_; } split /(?<!subgen)[;\.]+/, $class_lines;
1134  
1135 # do we have a genus?
1136 17 my $possible_genus = $class[-1];
1137 17 ▶ $possible_genus .= "|$class[-2]" if $class[-2];
Branch: 1 branch
BranchTrueFalseTotal
if $class[-2] 17 0 17
1138 17 ▶ if ($sci_name =~ /^($possible_genus)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sci_name =~ /^($possible_genus)/) { } 17 0 17
1139 17 $genus = $1;
1140 17 ($species) = $sci_name =~ /^$genus\s+(.+)/;
1141 } else {
1142 0 $species = $sci_name;
1143 }
1144  
1145 # Don't make a species object if it is "Unknown" or "None"
1146 17 ▶ if ($genus) {
Branch: 1 branch
BranchTrueFalseTotal
if ($genus) 17 0 17
1147 17 ▶ return if $genus =~ /^(Unknown|None)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $genus =~ /^(Unknown|None)$/i 0 17 17
1148 }
1149  
1150 # is this organism of rank species or is it lower?
1151 # (doesn't catch everything, but at least the guess isn't dangerous)
1152 17 ▶ if ($species =~ /subsp\.|var\./) {
Branch: 1 branch
BranchTrueFalseTotal
if ($species =~ /subsp\.|var\./) 0 17 17
1153 0 ($species, $sub_species) = $species =~ /(.+)\s+((?:subsp\.|var\.).+)/;
1154 }
1155  
1156 # sometimes things have common name in brackets, like
1157 # Schizosaccharomyces pombe (fission yeast), so get rid of the common
1158 # name bit. Probably dangerous if real scientific species name ends in
1159 # bracketed bit.
1160 17 ▶ unless ($class[-1] eq 'Viruses') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class[-1] eq "Viruses") 17 0 17
1161 17 ($species, $common) = $species =~ /^(.+)\s+\((.+)\)$/;
1162 17 ▶ $sci_name =~ s/\s+\(.+\)$// if $common;
Branch: 1 branch
BranchTrueFalseTotal
if $common 9 8 17
1163 }
1164  
1165 # Bio::Species array needs array in Species -> Kingdom direction
1166 17 ▶ unless ($class[-1] eq $sci_name) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class[-1] eq $sci_name) 17 0 17
1167 17 push(@class, $sci_name);
1168 }
1169 17 @class = reverse @class;
1170  
1171 # do minimal sanity checks before we hand off to Bio::Species which won't
1172 # be able to give informative throw messages if it has to throw because
1173 # of problems here
1174 17 ▶ $self->throw("$acc seems to be missing its OS line: invalid.") unless $sci_name;
Branch: 1 branch
BranchTrueFalseTotal
unless $sci_name 0 17 17
1175 17 my %names;
1176 17 foreach my $i (0..$#class) {
1177 199 my $name = $class[$i];
1178 199 $names{$name}++;
1179 # this code breaks examples like: Xenopus (Silurana) tropicalis
1180 # commenting out, see bug 3158
1181
1182 #if ($names{$name} > 1 && ($name ne $class[$i - 1])) {
1183 # $self->warn("$acc seems to have an invalid species classification:$name ne $class[$i - 1]");
1184 #}
1185 }
1186 17 my $make = Bio::Species->new();
1187 17 $make->scientific_name($sci_name);
1188 17 $make->classification(@class);
1189 17 ▶ unless ($class[-1] eq 'Viruses') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class[-1] eq "Viruses") 17 0 17
1190 17 ▶ $make->genus($genus) if $genus;
Branch: 1 branch
BranchTrueFalseTotal
if $genus 17 0 17
1191 17 ▶ $make->species($species) if $species;
Branch: 1 branch
BranchTrueFalseTotal
if $species 9 8 17
1192 17 ▶ $make->sub_species($sub_species) if $sub_species;
Branch: 1 branch
BranchTrueFalseTotal
if $sub_species 0 17 17
1193 17 ▶ $make->common_name($common) if $common;
Branch: 1 branch
BranchTrueFalseTotal
if $common 9 8 17
1194 }
1195 17 ▶ $make->organelle($org) if $org;
Branch: 1 branch
BranchTrueFalseTotal
if $org 0 17 17
1196 17 return $make;
1197 }
1198  
1199 =head2 _read_EMBL_DBLink
1200  
1201 Title : _read_EMBL_DBLink
1202 Usage :
1203 Function: Reads the EMBL database cross reference ("DR") lines
1204 Example :
1205 Returns : A list of Bio::Annotation::DBLink objects
1206 Args :
1207  
1208 =cut
1209  
1210 3 ▶sub _read_EMBL_DBLink {
Subroutine _read_EMBL_DBLink: called CC=4 SCAR=13.9
1211 3 my( $self,$buffer ) = @_;
1212 3 my( @db_link );
1213  
1214 3 $_ = $$buffer;
1215 3 ▶ while (defined( $_ ||= $self->_readline )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ ||= $self->_readline)) 23 0 23
Condition66%2/3
$_ ||= $self->_readline
l!l&&r!l&&!r
3200
MC/DC0%0/2
$_ ||= $self->_readline
$_ $self->_readline
Truth table66%2/3
A ||= B
A= $_B= $self->_readline
ABresult
1X1
011
000
1216 23 ▶ if ( /^DR ([^\s;]+);\s*([^\s;]+);?\s*([^\s;]+)?\.$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^DR ([^\s;]+);\s*([^\s;]+);?\s*([^\s;]+)?\.$/) { } 20 3 23
1217 20 my ($databse, $prim_id, $sec_id) = ($1,$2,$3);
1218 20 my $link = Bio::Annotation::DBLink->new(-database => $databse,
1219 -primary_id => $prim_id,
1220 -optional_id => $sec_id);
1221  
1222 20 push(@db_link, $link);
1223 } else {
1224 3 last;
1225 }
1226 20 $_ = undef; # Empty $_ to trigger read of next line
1227 }
1228  
1229 3 $$buffer = $_;
1230 3 return @db_link;
1231 }
1232  
1233 =head2 _read_EMBL_TaxID_DBLink
1234  
1235 Title : _read_EMBL_TaxID_DBLink
1236 Usage :
1237 Function: Reads the EMBL database cross reference to NCBI TaxID ("OX") lines
1238 Example :
1239 Returns : A list of Bio::Annotation::DBLink objects
1240 Args :
1241  
1242 =cut
1243  
1244 3 ▶sub _read_EMBL_TaxID_DBLink {
Subroutine _read_EMBL_TaxID_DBLink: called CC=4 SCAR=13.9
1245 3 my( $self,$buffer ) = @_;
1246 3 my( @db_link );
1247  
1248 3 $_ = $$buffer;
1249 3 ▶ while (defined( $_ ||= $self->_readline )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ ||= $self->_readline)) 4 0 4
Condition66%2/3
$_ ||= $self->_readline
l!l&&r!l&&!r
310
MC/DC0%0/2
$_ ||= $self->_readline
$_ $self->_readline
Truth table66%2/3
A ||= B
A= $_B= $self->_readline
ABresult
1X1
011
000
1250 4 ▶ if ( /^OX (\S+)=(\d+);$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^OX (\S+)=(\d+);$/) { } 1 3 4
1251 1 my ($databse, $prim_id) = ($1,$2);
1252 1 my $link = Bio::Annotation::DBLink->new(-database => $databse,
1253 -primary_id => $prim_id,);
1254 1 push(@db_link, $link);
1255 } else {
1256 3 last;
1257 }
1258 1 $_ = undef; # Empty $_ to trigger read of next line
1259 }
1260  
1261 3 $$buffer = $_;
1262 3 return @db_link;
1263 }
1264  
1265 =head2 _filehandle
1266  
1267 Title : _filehandle
1268 Usage : $obj->_filehandle($newval)
1269 Function:
1270 Example :
1271 Returns : value of _filehandle
1272 Args : newvalue (optional)
1273  
1274  
1275 =cut
1276  
1277 0 ▶sub _filehandle{
Subroutine _filehandle: not called CC=2 SCAR=17.9
1278 0 my ($obj,$value) = @_;
1279 0 ▶ if ( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
1280 0 $obj->{'_filehandle'} = $value;
1281 }
1282 0 return $obj->{'_filehandle'};
1283  
1284 }
1285  
1286 =head2 _read_FTHelper_EMBL
1287  
1288 Title : _read_FTHelper_EMBL
1289 Usage : _read_FTHelper_EMBL($buffer)
1290 Function: reads the next FT key line
1291 Example :
1292 Returns : Bio::SeqIO::FTHelper object
1293 Args : filehandle and reference to a scalar
1294  
1295  
1296 =cut
1297  
1298 205 ▶sub _read_FTHelper_EMBL {
Subroutine _read_FTHelper_EMBL: called CC=24 SCAR=40.3
1299 205 my ($self,$buffer) = @_;
1300  
1301 205 my ($key, # The key of the feature
1302 $loc, # The location line from the feature
1303 @qual, # An arrray of lines making up the qualifiers
1304 );
1305  
1306 205 ▶ if ($$buffer =~ /^FT\s{3}(\S+)\s+(\S+)/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($$buffer =~ /^FT\s{3}(\S+)\s+(\S+)/) { } 205 0 205
elsif ($$buffer =~ /^CO\s+(\S+)/) { } 0 0 0
1307 205 $key = $1;
1308 205 $loc = $2;
1309 # Read all the lines up to the next feature
1310 205 ▶ while ( defined($_ = $self->_readline) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 1836 0 1836
1311 1836 ▶ if (/^FT(\s+)(.+?)\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^FT(\s+)(.+?)\s*$/) { } 1818 18 1836
1312 # Lines inside features are preceeded by 19 spaces
1313 # A new feature is preceeded by 3 spaces
1314 1818 ▶ if (length($1) > 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $1 > 4) { } 1631 187 1818
1315 # Add to qualifiers if we're in the qualifiers
1316 1631 ▶ if (@qual) {
Branch: 2 branches
BranchTrueFalseTotal
if (@qual) { } 1426 205 1631
elsif (substr($2, 0, 1) eq '/') { } 203 2 205
1317 1426 push(@qual, $2);
1318 }
1319 # Start the qualifier list if it's the first qualifier
1320 elsif (substr($2, 0, 1) eq '/') {
1321 203 @qual = ($2);
1322 }
1323 # We're still in the location line, so append to location
1324 else {
1325 2 $loc .= $2;
1326 }
1327 } else {
1328 # We've reached the start of the next feature
1329 187 last;
1330 }
1331 } else {
1332 # We're at the end of the feature table
1333 18 last;
1334 }
1335 }
1336 } elsif ( $$buffer =~ /^CO\s+(\S+)/) {
1337 0 $key = 'CONTIG';
1338 0 $loc = $1;
1339 # Read all the lines up to the next feature
1340 0 ▶ while ( defined($_ = $self->_readline) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 0 0 0
1341 0 ▶ if (/^CO\s+(\S+)\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^CO\s+(\S+)\s*$/) { } 0 0 0
1342 0 $loc .= $1;
1343 } else {
1344 # We've reached the start of the next feature
1345 0 last;
1346 }
1347 }
1348 } else {
1349 # No feature key
1350 0 return;
1351 }
1352  
1353 # Put the first line of the next feature into the buffer
1354 205 $$buffer = $_;
1355  
1356 # Make the new FTHelper object
1357 205 my $out = Bio::SeqIO::FTHelper->new();
1358 205 $out->verbose($self->verbose());
1359 205 $out->key($key);
1360 205 $out->loc($loc);
1361  
1362 # Now parse and add any qualifiers. (@qual is kept
1363 # intact to provide informative error messages.)
1364 205 my $last_unquoted_qualifier;
1365 QUAL:
1366 205 ▶ for (my $i = 0; $i < @qual; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @qual) 992 205 1197
1367 992 my $data = $qual[$i];
1368 992 my ( $qualifier, $value );
1369
1370 992 ▶ unless (( $qualifier, $value ) = ($data =~ m{^/([^=]+)(?:=\s*(.*))?})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (() = $data =~ m[^/([^=]+)(?:=\s*(.*))?]) 0 992 992
1371 0 ▶ if ( defined $last_unquoted_qualifier ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $last_unquoted_qualifier) { } 0 0 0
1372 # handle case of unquoted multiline - read up everything until the next qualifier
1373 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
defined($data = $qual[++$i]) and not $data =~ m[^/] and do { do { $value .= ' ' if $qualifier ne "translation"; $value .= $data } } 0 0 0
Condition0%0/3
defined($data = $qual[++$i]) and not $data =~ m[^/]
!ll&&!rl&&r
000
MC/DC0%0/2
defined($data = $qual[++$i]) and not $data =~ m[^/]
defined($data = $qual[++$i]) not $data =~ m[^/]
Truth table0%0/3
A and not(B)
A= defined($data = $qual[++$i])B= not $data =~ m[^/]
ABresult
0X0
100
111
1374 # Protein sequence translations need to be joined without spaces,
1375 # other qualifiers need those.
1376 0 ▶ $value .= ' ' if $qualifier ne "translation";
Branch: 1 branch
BranchTrueFalseTotal
if $qualifier ne "translation" 0 0 0
1377 0 $value .= $data;
1378 } while defined($data = $qual[++$i]) && $data !~ m[^/];
1379 0 $i--;
1380 0 $out->field->{$last_unquoted_qualifier}->[-1] .= $value;
1381 0 $last_unquoted_qualifier = undef;
1382 0 next QUAL;
1383 } else {
1384 0 $self->throw("Can't see new qualifier in: $_\nfrom:\n"
1385 . join('', map "$_\n", @qual));
1386 }
1387 }
1388 992 ▶ $qualifier = '' if not defined $qualifier;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $qualifier 0 992 992
1389  
1390 992 $last_unquoted_qualifier = undef;
1391 992 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 992 0 992
1392 # Do we have a quoted value?
1393 992 ▶ if (substr($value, 0, 1) eq '"') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($value, 0, 1) eq '"') { } 881 111 992
1394 # Keep adding to value until we find the trailing quote
1395 # and the quotes are balanced
1396 QUOTES:
1397 881 ▶ while ($value !~ /"$/ or $value =~ tr/"/"/ % 2) { #"
Branch: 1 branch
BranchTrueFalseTotal
if (not $value =~ /"$/ or $value =~ tr/"// % 2) 637 881 1518
Condition66%2/3
not $value =~ /"$/ or $value =~ tr/"// % 2
l!l&&r!l&&!r
6370881
MC/DC50%1/2
not $value =~ /"$/ or $value =~ tr/"// % 2
not $value =~ /"$/ $value =~ tr/"// % 2
Truth table66%2/3
not(A) or B
A= not $value =~ /"$/B= $value =~ tr/"// % 2
ABresult
1X1
011
000
1398 637 $i++;
1399 637 my $next = $qual[$i];
1400 637 ▶ if (!defined($next)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $next) 0 637 637
1401 0 $self->warn("Unbalanced quote in:\n".join("\n", @qual).
1402 "\nAdding quote to close...".
1403 "Check sequence quality!");
1404 0 $value .= '"';
1405 0 last QUOTES;
1406 }
1407  
1408 # Protein sequence translations need to be joined without spaces,
1409 # other qualifiers need those.
1410 637 ▶ if ($qualifier eq "translation") {
Branch: 1 branch
BranchTrueFalseTotal
if ($qualifier eq 'translation') { } 534 103 637
1411 534 $value .= $next;
1412 } else {
1413 103 $value .= " $next";
1414 }
1415 }
1416 # Trim leading and trailing quotes
1417 881 $value =~ s/^"|"$//g;
1418 # Undouble internal quotes
1419 881 $value =~ s/""/"/g; #"
1420 } else {
1421 111 $last_unquoted_qualifier = $qualifier;
1422 }
1423 } else {
1424 0 $value = '_no_value';
1425 }
1426  
1427 # Store the qualifier
1428 992 ▶ $out->field->{$qualifier} ||= [];
Condition100%2/2
$out->field->{$qualifier} ||= []
l!l
152840
MC/DC100%1/1
$out->field->{$qualifier} ||= []
$out->field->{$qualifier}
Truth table100%2/2
A
A= $out->field->{$qualifier}
Aresult
11
00
1429 992 push(@{$out->field->{$qualifier}},$value);
1430 }
1431  
1432 205 return $out;
1433 }
1434  
1435 =head2 _write_line_EMBL
1436  
1437 Title : _write_line_EMBL
1438 Usage :
1439 Function: internal function
1440 Example :
1441 Returns : 1 if writing succeeded, else undef
1442 Args :
1443  
1444  
1445 =cut
1446  
1447 0 ▶sub _write_line_EMBL {
Subroutine _write_line_EMBL: not called CC=5 SCAR=34.0
1448 0 my ($self,$pre1,$pre2,$line,$length) = @_;
1449  
1450 0 ▶ $length || $self->throw("Miscalled write_line_EMBL without length. Programming error!");
Branch: 1 branch
BranchTrueFalseTotal
$length or $self->throw("Miscalled write_line_EMBL without length. Programming error!") 0 0 0
1451 0 my $subl = $length - length $pre2;
1452 0 my $linel = length $line;
1453 0 my $i;
1454  
1455 0 my $sub = substr($line,0,$length - length $pre1);
1456  
1457 0 ▶ $self->_print( "$pre1$sub\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("$pre1$sub\n") or return 0 0 0
1458  
1459 0 ▶ for ($i= ($length - length $pre1);$i < $linel;) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $linel) 0 0 0
1460 0 $sub = substr($line,$i,($subl));
1461 0 ▶ $self->_print( "$pre2$sub\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("$pre2$sub\n") or return 0 0 0
1462 0 $i += $subl;
1463 }
1464  
1465 0 return 1;
1466 }
1467  
1468 =head2 _write_line_EMBL_regex
1469  
1470 Title : _write_line_EMBL_regex
1471 Usage :
1472 Function: internal function for writing lines of specified
1473 length, with different first and the next line
1474 left hand headers and split at specific points in the
1475 text
1476 Example :
1477 Returns : nothing
1478 Args : file handle, first header, second header, text-line, regex for line breaks, total line length
1479  
1480  
1481 =cut
1482  
1483 263 ▶sub _write_line_EMBL_regex {
Subroutine _write_line_EMBL_regex: called CC=11 SCAR=24.8
1484 263 my ($self,$pre1,$pre2,$line,$regex,$length) = @_;
1485  
1486 #print STDOUT "Going to print with $line!\n";
1487  
1488 263 ▶ $length || $self->throw("Programming error - called write_line_EMBL_regex without length.");
Branch: 1 branch
BranchTrueFalseTotal
$length or $self->throw("Programming error - called write_line_EMBL_regex without length.") 263 0 263
1489  
1490 263 my $subl = $length - (length $pre1) -1 ;
1491 263 my( @lines );
1492  
1493 263 ▶ CHUNK: while($line) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line) 401 263 664
1494 401 foreach my $pat ($regex, '[,;\.\/-]\s|'.$regex, '[,;\.\/-]|'.$regex) {
1495 401 ▶ if ($line =~ m/^(.{1,$subl})($pat)(.*)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(.{1,$subl})($pat)(.*)/) 401 0 401
1496 401 my $l = $1.$2;
1497 401 ▶ $l =~ s/#/ /g # remove word wrap protection char '#'
Branch: 1 branch
BranchTrueFalseTotal
if $pre1 eq "RA " 8 393 401
1498 if $pre1 eq "RA ";
1499 401 my $newl = $3;
1500 401 $line = substr($line,length($l));
1501 # be strict about not padding spaces according to
1502 # genbank format
1503 401 $l =~ s/\s+$//;
1504 401 ▶ next CHUNK if ($l eq '');
Branch: 1 branch
BranchTrueFalseTotal
if $l eq "" 0 401 401
1505 401 push(@lines, $l);
1506 401 next CHUNK;
1507 }
1508 }
1509 # if we get here none of the patterns matched $subl or less chars
1510 0 $self->warn("trouble dissecting \"$line\"\n into chunks ".
1511 "of $subl chars or less - this tag won't print right");
1512 # insert a space char to prevent infinite loops
1513 0 $line = substr($line,0,$subl) . " " . substr($line,$subl);
1514 }
1515 263 my $s = shift @lines;
1516 263 ▶ ($self->_print("$pre1$s\n") || return) if $s;
Branch: 1 branch
BranchTrueFalseTotal
if $s 256 7 263
Condition60%3/5
$s && ($self->_print("$pre1$s\n") || (return))
!ll&&!rl&&r
72560
$self->_print("$pre1$s\n") or return
l!l
2560
MC/DC0%0/2
$s && ($self->_print("$pre1$s\n") || (return))
$s $self->_print("$pre1$s\n")
Truth table33%1/3
A && B
A= $sB= $self->_print("$pre1$s\n")
ABresult
0X0
100
111
1517 263 foreach my $s ( @lines ) {
1518 145 ▶ $self->_print("$pre2$s\n") || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_print("$pre2$s\n") or return 145 0 145
1519 }
1520  
1521 263 return 1;
1522 }
1523  
1524 =head2 _post_sort
1525  
1526 Title : _post_sort
1527 Usage : $obj->_post_sort($newval)
1528 Function:
1529 Returns : value of _post_sort
1530 Args : newvalue (optional)
1531  
1532  
1533 =cut
1534  
1535 6 ▶sub _post_sort{
Subroutine _post_sort: called CC=2 SCAR=8.4
1536 6 my $obj = shift;
1537 6 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 6 6
1538 0 my $value = shift;
1539 0 $obj->{'_post_sort'} = $value;
1540 }
1541 6 return $obj->{'_post_sort'};
1542  
1543 }
1544  
1545 =head2 _show_dna
1546  
1547 Title : _show_dna
1548 Usage : $obj->_show_dna($newval)
1549 Function:
1550 Returns : value of _show_dna
1551 Args : newvalue (optional)
1552  
1553  
1554 =cut
1555  
1556 38 ▶sub _show_dna{
Subroutine _show_dna: called CC=2 SCAR=6.9
1557 38 my $obj = shift;
1558 38 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 27 11 38
1559 27 my $value = shift;
1560 27 $obj->{'_show_dna'} = $value;
1561 }
1562 38 return $obj->{'_show_dna'};
1563  
1564 }
1565  
1566 =head2 _id_generation_func
1567  
1568 Title : _id_generation_func
1569 Usage : $obj->_id_generation_func($newval)
1570 Function:
1571 Returns : value of _id_generation_func
1572 Args : newvalue (optional)
1573  
1574  
1575 =cut
1576  
1577 11 ▶sub _id_generation_func{
Subroutine _id_generation_func: called CC=2 SCAR=8.4
1578 11 my $obj = shift;
1579 11 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 11 11
1580 0 my $value = shift;
1581 0 $obj->{'_id_generation_func'} = $value;
1582 }
1583 11 return $obj->{'_id_generation_func'};
1584  
1585 }
1586  
1587 =head2 _ac_generation_func
1588  
1589 Title : _ac_generation_func
1590 Usage : $obj->_ac_generation_func($newval)
1591 Function:
1592 Returns : value of _ac_generation_func
1593 Args : newvalue (optional)
1594  
1595  
1596 =cut
1597  
1598 11 ▶sub _ac_generation_func{
Subroutine _ac_generation_func: called CC=2 SCAR=8.4
1599 11 my $obj = shift;
1600 11 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 11 11
1601 0 my $value = shift;
1602 0 $obj->{'_ac_generation_func'} = $value;
1603 }
1604 11 return $obj->{'_ac_generation_func'};
1605  
1606 }
1607  
1608 =head2 _sv_generation_func
1609  
1610 Title : _sv_generation_func
1611 Usage : $obj->_sv_generation_func($newval)
1612 Function:
1613 Returns : value of _sv_generation_func
1614 Args : newvalue (optional)
1615  
1616  
1617 =cut
1618  
1619 0 ▶sub _sv_generation_func{
Subroutine _sv_generation_func: not called CC=2 SCAR=17.9
1620 0 my $obj = shift;
1621 0 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
1622 0 my $value = shift;
1623 0 $obj->{'_sv_generation_func'} = $value;
1624 }
1625 0 return $obj->{'_sv_generation_func'};
1626  
1627 }
1628  
1629 =head2 _kw_generation_func
1630  
1631 Title : _kw_generation_func
1632 Usage : $obj->_kw_generation_func($newval)
1633 Function:
1634 Returns : value of _kw_generation_func
1635 Args : newvalue (optional)
1636  
1637  
1638 =cut
1639  
1640 11 ▶sub _kw_generation_func{
Subroutine _kw_generation_func: called CC=2 SCAR=8.4
1641 11 my $obj = shift;
1642 11 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 11 11
1643 0 my $value = shift;
1644 0 $obj->{'_kw_generation_func'} = $value;
1645 }
1646 11 return $obj->{'_kw_generation_func'};
1647  
1648 }
1649  
1650 5 1;
« Bio/SearchIO/Writer/TextResultWriter.pm ↑ Summary Bio/SearchIO/Writer/HTMLResultWriter.pm »