Bio/SeqIO/embl.pm

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