Bio/SeqIO/tigrxml.pm

filter: Statementstmt 77.6% 202 / 260 Branchbran 62.5% 80 / 128 Conditioncond 60.0% 15 / 25 MC/DCmcdc 28.5% 4 / 14 Subroutinesub 100% 21 / 21 Podpod 85.7% 6 / 7 totaltotal 72.0% 328 / 455 CC 74 SCAR 38.5
CC
74
Cov
72%
start_element
106.7
characters
34.0
end_element
25.0
CRAP 47.1
« Bio/SearchIO/cross_match.pm ↑ Summary Bio/SeqFeature/Gene/Intron.pm »
1 #
2 # BioPerl module for Bio::SeqIO::tigrxml
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Jason Stajich <jason-at-bioperl-dot-org>
7 #
8 # Copyright Jason Stajich
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::tigrxml - Parse TIGR (new) XML
17  
18 =head1 SYNOPSIS
19  
20 use Bio::SeqIO;
21 my $in = Bio::SeqIO->new(-format => 'tigrcoordset',
22 -file => 'file.xml');
23  
24 while( my $seq = $in->next_seq ) {
25 # do something...
26 }
27  
28 =head1 DESCRIPTION
29  
30 This is a parser for TIGR Coordset XML for their in-progress
31 annotation dbs.
32  
33 =head1 FEEDBACK
34  
35 =head2 Mailing Lists
36  
37 User feedback is an integral part of the evolution of this and other
38 Bioperl modules. Send your comments and suggestions preferably to
39 the Bioperl mailing list. Your participation is much appreciated.
40  
41 bioperl-l@bioperl.org - General discussion
42 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
43  
44 =head2 Support
45  
46 Please direct usage questions or support issues to the mailing list:
47  
48 I<bioperl-l@bioperl.org>
49  
50 rather than to the module maintainer directly. Many experienced and
51 reponsive experts will be able look at the problem and quickly
52 address it. Please include a thorough description of the problem
53 with code and data examples if at all possible.
54  
55 =head2 Reporting Bugs
56  
57 Report bugs to the Bioperl bug tracking system to help us keep track
58 of the bugs and their resolution. Bug reports can be submitted via the
59 web:
60  
61 https://github.com/bioperl/bioperl-live/issues
62  
63 =head1 AUTHOR - Jason Stajich
64  
65 Email jason-at-bioperl-dot-org
66  
67 =head1 APPENDIX
68  
69 The rest of the documentation details each of the object methods.
70 Internal methods are usually preceded with a _
71  
72 =cut
73  
74  
75 # Let the code begin...
76  
77  
78 package Bio::SeqIO::tigrxml;
79 2 $Bio::SeqIO::tigrxml::VERSION = '1.7.8';
80 2 ▶use vars qw($Default_Source);
Subroutine BEGIN: called CC=1 SCAR=0.0
81 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
82 2 ▶use XML::SAX;
Subroutine BEGIN: called CC=1 SCAR=0.0
83 2 ▶use XML::SAX::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
85 2 ▶use Bio::Seq::SeqFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 2 ▶use Bio::Species;
Subroutine BEGIN: called CC=1 SCAR=0.0
87 2 ▶use Bio::SeqFeature::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
88 2 ▶use Bio::Annotation::Reference;
Subroutine BEGIN: called CC=1 SCAR=0.0
89 2 ▶use Bio::Annotation::Comment;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 2 ▶use Bio::Annotation::DBLink;
Subroutine BEGIN: called CC=1 SCAR=0.0
91 2 ▶use List::Util qw(min max);
Subroutine BEGIN: called CC=1 SCAR=0.0
92  
93 2 ▶use base qw(Bio::SeqIO XML::SAX::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
94  
95  
96 2 $Default_Source = 'TIGR';
97  
98 1 ▶sub _initialize {
Subroutine _initialize: called CC=2 SCAR=7.0
99 1 my ($self) = shift;
100 1 $self->SUPER::_initialize(@_);
101 1 $self->{'_parser'} = XML::SAX::ParserFactory->parser('Handler' => $self);
102 1 ▶ if( ! defined $self->sequence_factory ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->sequence_factory) 1 0 1
103 1 $self->sequence_factory(Bio::Seq::SeqFactory->new
104 (-verbose => $self->verbose(),
105 -type => 'Bio::Seq::RichSeq'));
106 }
107 1 return;
108 }
109  
110 1 ▶sub next_seq {
Subroutine next_seq: called CC=4 SCAR=16.1
Pod documented
111 1 my $self = shift;
112 1 ▶ if( @{$self->{'_seendata'}->{'_seqs'} || []} ||
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"_seendata"}{"_seqs"} or [];} or eof $self->_fh) 0 1 1
Condition40%2/5
@{$self->{"_seendata"}{"_seqs"} or [];} or eof $self->_fh
l!l&&r!l&&!r
001
$self->{'_seendata'}{'_seqs'} || []
l!l
01
MC/DC0%0/2
@{$self->{"_seendata"}{"_seqs"} or [];} or eof $self->_fh
@{$self->{"_seendata"}{"_seqs"} or [];} eof $self->_fh
MC/DC0%0/1
$self->{'_seendata'}{'_seqs'} || []
$self->{'_seendata'}{'_seqs'}
Truth table33%1/3
A or B
A= @{$self->{"_seendata"}{"_seqs"} or [];}B= eof $self->_fh
ABresult
1X1
011
000
Truth table50%1/2
A
A= $self->{'_seendata'}{'_seqs'}
Aresult
11
00
113 eof($self->_fh)) {
114 0 return shift @{$self->{'_seendata'}->{'_seqs'}};
115 }
116 1 $self->{'_parser'}->parse_file($self->_fh);
117 1 return shift @{$self->{'_seendata'}->{'_seqs'}};
118 }
119  
120 # XML::SAX::Base methods
121  
122 1 ▶sub start_document {
Subroutine start_document: called CC=1 SCAR=0.0
Pod documented
123 1 my ($self,$doc) = @_;
124 1 $self->{'_seendata'} = {'_seqs' => [],
125 '_authors' => [],
126 '_feats' => [] };
127 1 $self->SUPER::start_document($doc);
128 }
129  
130 1 ▶sub end_document {
Subroutine end_document: called CC=1 SCAR=0.0
Pod documented
131 1 my ($self,$doc) = @_;
132 1 $self->SUPER::end_document($doc);
133 }
134  
135 26 ▶sub start_element {
Subroutine start_element: called CC=30 SCAR=46.7
Pod documented
136 26 my ($self,$ele) = @_;
137 # attributes
138 26 my $name = uc $ele->{'LocalName'};
139 26 my $attr = $ele->{'Attributes'};
140 my $seqid = defined $self->{'_seendata'}->{'_seqs'}->[-1] ?
141 26 ▶ $self->{'_seendata'}->{'_seqs'}->[-1]->display_id : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_seendata'}{'_seqs'}[-1] ? : 25 1 26
142
143 # we're going to try and be SO-nice here
144 26 ▶ if( $name eq 'ASSEMBLY' ) { # New sequence
Branch: 19 branches
BranchTrueFalseTotal
if ($name eq 'ASSEMBLY') { } 1 25 26
elsif ($name eq 'HEADER') { } 1 24 25
elsif ($name eq 'CLONE_NAME') { } 1 23 24
elsif ($name eq 'ORGANISM') { } 1 22 23
elsif ($name eq 'AUTHOR_LIST') { } 1 21 22
elsif ($name eq 'TU') { } 2 19 21
elsif ($name eq 'MODEL') { } 2 17 19
elsif ($name eq 'EXON') { } 8 9 17
elsif ($name eq 'PROTEIN_SEQ') { } 2 7 9
elsif ($name eq 'CDS') { } 7 0 7
elsif ($name eq 'RNA-EXON') { } 0 0 0
elsif ($name eq 'PRE-TRNA') { } 0 0 0
elsif ($name eq 'TRNA') { } 0 0 0
elsif ($name eq 'REPEAT_LIST') { } 0 0 0
elsif ($name eq 'REPEAT') { } 0 0 0
elsif ($name eq 'AUTHOR') { } 0 0 0
elsif ($name eq 'GB_DESCRIPTION') { } 0 0 0
elsif ($name eq 'GB_COMMENT') { } 0 0 0
elsif ($name eq 'LINEAGE') { } 0 0 0
145 1 my ($len) = $attr->{'{}COORDS'}->{'Value'} =~ /\d+\-(\d+)/;
146 1 push @{$self->{'_seendata'}->{'_seqs'}},
147 $self->sequence_factory->create
148 (
149 1 -display_id => $attr->{'{}ASMBL_ID'}->{'Value'},
150 -length => $len,
151 );
152 } elsif( $name eq 'HEADER' ) {
153 } elsif( $name eq 'CLONE_NAME' ) {
154 } elsif( $name eq 'ORGANISM' ) {
155 } elsif( $name eq 'AUTHOR_LIST' ) {
156 1 $self->{'_seendata'}->{'_authors'} = [];
157 } elsif( $name eq 'TU' ) { # gene feature
158 2 my ($s,$e) = ($attr->{'{}COORDS'}->{'Value'} =~ /(\d+)\-(\d+)/);
159 2 my $strand = 1;
160 2 ▶ if( $s > $e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $e) 1 1 2
161 1 ($s,$e,$strand) = ( $e,$s,-1);
162 }
163 2 my $fname = $attr->{'{}FEAT_NAME'}->{'Value'};
164 my $f = Bio::SeqFeature::Generic->new
165 (-seq_id => $seqid,
166 -start => $s,
167 -end => $e,
168 -strand => $strand,
169 -primary_tag => 'gene', # what does this really map to?
170 -source_tag => $Default_Source,
171 -tag => {
172 'Note' => $attr->{'{}COM_NAME'}->{'Value'},
173 'ID' => $fname,
174 'locus' => $attr->{'{}LOCUS'}->{'Value'},
175 'pub_locus' => $attr->{'{}PUB_LOCUS'}->{'Value'},
176 'alt_locus' => $attr->{'{}ALT_LOCUS'}->{'Value'},
177 2 'pub_comment' => $attr->{'{}PUB_COMMENT'}->{'Value'},
178 }
179 );
180 2 push @{$self->{'_seendata'}->{'_feats'}}, $f;
181 # add this feature to the current sequence
182 2 $self->{'_seendata'}->{'_seqs'}->[-1]->add_SeqFeature($f);
183 } elsif( $name eq 'MODEL' ) { # mRNA/transcript
184 # reset the UTRs
185 2 $self->{'_seendata'}->{"five_prime_UTR"}= undef;
186 2 $self->{'_seendata'}->{"three_prime_UTR"} = undef;
187 2 my ($s,$e) = ($attr->{'{}COORDS'}->{'Value'} =~ /(\d+)\-(\d+)/);
188 2 my $strand = 1;
189 2 ▶ if( $s > $e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $e) 1 1 2
190 1 ($s,$e,$strand) = ( $e,$s,-1);
191 }
192 2 my $parent = $self->{'_seendata'}->{'_feats'}->[-1];
193 2 my ($parentid) = $parent->get_tag_values('ID');
194 my $f = Bio::SeqFeature::Generic->new
195 (-primary_tag => 'transcript',
196 -source_tag => $Default_Source,
197 -start => $s, # we use parent start/stop because 'MODEL' means CDS start/stop
198 -end => $e, # but we want to reflect
199 -strand => $strand,
200 -seq_id => $seqid,
201 -tag => {
202 'ID' => $attr->{'{}FEAT_NAME'}->{'Value'},
203 'Parent' => $parentid,
204 2 'Note' => $attr->{'{}COMMENT'}->{'Value'},
205 });
206 2 $parent->add_SeqFeature($f);
207 2 push @{$self->{'_seendata'}->{'_feats'}}, $f;
208 2 $self->{'_seendata'}->{'_seqs'}->[-1]->add_SeqFeature($f);
209 } elsif( $name eq 'EXON' ) { # exon feature
210 8 my ($s,$e) = ($attr->{'{}COORDS'}->{'Value'} =~ /(\d+)\-(\d+)/);
211 8 my $strand = 1;
212 8 ▶ if( $s > $e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $e) 6 2 8
213 6 ($s,$e,$strand) = ( $e,$s,-1);
214 }
215 8 my $parent = $self->{'_seendata'}->{'_feats'}->[-1];
216
217 8 my ($parentid) = $parent->get_tag_values('ID');
218  
219 my $f = Bio::SeqFeature::Generic->new
220 (-primary_tag => 'exon',
221 -source_tag => $Default_Source,
222 -seq_id => $seqid,
223 -start => $s,
224 -end => $e,
225 -strand => $strand,
226 -tag => {
227 8 'ID' => $attr->{'{}FEAT_NAME'}->{'Value'},
228 'Parent' => $parentid,
229 });
230 8 $parent->add_SeqFeature($f,'EXPAND');
231 8 $self->{'_seendata'}->{'_seqs'}->[-1]->add_SeqFeature($f);
232 # we'll still just add exons to the transcript
233 } elsif( $name eq 'PROTEIN_SEQ' ) {
234
235 } elsif( $name eq 'CDS' ) {
236 # CDS will be the translation of the transcript
237 7 my ($s,$e) = ($attr->{'{}COORDS'}->{'Value'} =~ /(\d+)\-(\d+)/);
238 7 my $strand = 1;
239 7 ▶ if( $s > $e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $e) 6 1 7
240 6 ($s,$e,$strand) = ( $e,$s,-1);
241 }
242 7 my $parent = $self->{'_seendata'}->{'_feats'}->[-1];
243 7 my ($parentid) = $parent->get_tag_values('ID');
244 7 $self->assert($parent->primary_tag eq 'transcript', 'Testing for primary tag equivalent to mRNA');
245 7 ▶ $self->assert($parent->strand == $strand || abs($s-$e) == 0, 'Testing that parent feature and current feature strand are equal '. $parentid. ' '.$attr->{'{}FEAT_NAME'}->{'Value'});
Condition33%1/3
$parent->strand == $strand || abs $s - $e == 0
l!l&&r!l&&!r
700
MC/DC0%0/2
$parent->strand == $strand || abs $s - $e == 0
$parent->strand == $strand abs $s - $e == 0
Truth table33%1/3
A || B
A= $parent->strand == $strandB= abs $s - $e == 0
ABresult
1X1
011
000
246 my $f = Bio::SeqFeature::Generic->new
247 (-primary_tag => 'CDS',
248 -source_tag => $Default_Source,
249 -seq_id => $seqid,
250 -start => $s,
251 -end => $e,
252 -strand => $parent->strand,
253 -tag => {
254 7 'ID' => $attr->{'{}FEAT_NAME'}->{'Value'},
255 'Parent' => $parentid, # should be the mRNA
256 });
257 7 $parent->add_SeqFeature($f);
258 7 $self->{'_seendata'}->{'_seqs'}->[-1]->add_SeqFeature($f);
259 } elsif( $name eq 'RNA-EXON' ) {
260  
261 0 my ($s,$e) = ($attr->{'{}COORDS'}->{'Value'} =~ /(\d+)\-(\d+)/);
262 0 my $strand = 1;
263 0 ▶ if( $s > $e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $e) 0 0 0
264 0 ($s,$e,$strand) = ( $e,$s,-1);
265 }
266 0 my $parent = $self->{'_seendata'}->{'_feats'}->[-1];
267 0 my ($parentid) = $parent->get_tag_values('ID');
268 my $f = Bio::SeqFeature::Generic->new
269 (-primary_tag => 'tRNA_exon', # tRNA_exon?
270 -source_tag => $Default_Source,
271 -seq_id => $seqid,
272 -start => $s,
273 -end => $e,
274 -strand => $strand,
275 -tag => {
276 0 'ID' => $attr->{'{}FEAT_NAME'}->{'Value'},
277 'Parent' => $parentid,
278 }
279 );
280 0 $parent->add_SeqFeature($f);
281 0 $self->{'_seendata'}->{'_seqs'}->[-1]->add_SeqFeature($f);
282 } elsif( $name eq 'PRE-TRNA' ) { # tRNA gene
283 0 my ($s,$e) = ( $attr->{'{}COORDS'}->{'Value'} =~/(\d+)\-(\d+)/);
284 0 my $strand = 1;
285 0 ▶ if( $s > $e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $e) 0 0 0
286 0 ($s,$e,$strand) = ( $e,$s,-1);
287 }
288 my $f = Bio::SeqFeature::Generic->new
289 ( -primary_tag => 'tRNA_coding_gene',
290 -source_tag => $Default_Source,
291 -seq_id => $seqid,
292 -start => $s,
293 -end => $e,
294 -strand => $strand,
295 0 -tag => {'ID' => $attr->{'{}FEAT_NAME'}->{'Value'},
296 }
297 );
298 0 push @{$self->{'_seendata'}->{'_feats'}}, $f;
299 0 $self->{'_seendata'}->{'_seqs'}->[-1]->add_SeqFeature($f);
300 } elsif( $name eq 'TRNA' ) { # tRNA transcript
301 0 my ($s,$e) = ($attr->{'{}COORDS'}->{'Value'} =~ /(\d+)\-(\d+)/);
302 0 my $strand = 1;
303 0 ▶ if( $s > $e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $e) 0 0 0
304 0 ($s,$e,$strand) = ( $e,$s,-1);
305 }
306 0 my $parent = $self->{'_seendata'}->{'_feats'}->[-1];
307 0 my ($parentid) = $parent->get_tag_values('ID');
308 my $f = Bio::SeqFeature::Generic->new
309 (-primary_tag => 'tRNA_primary_transcript',
310 -source_tag => $Default_Source,
311 -start => $s,
312 -end => $e,
313 -strand => $strand,
314 -seq_id => $seqid,
315 -tag => {
316 'ID' => $attr->{'{}FEAT_NAME'}->{'Value'},
317 'Parent' => $parentid,
318 'Note' => $attr->{'{}COM_NAME'}->{'Value'},
319 'anticodon' => $attr->{'{}ANTICODON'}->{'Value'},
320 0 'pub_locus' => $attr->{'{}PUB_LOCUS'}->{'Value'},
321  
322 });
323 0 $parent->add_SeqFeature($f);
324 0 push @{$self->{'_seendata'}->{'_feats'}}, $f;
325 0 $self->{'_seendata'}->{'_seqs'}->[-1]->add_SeqFeature($f);
326 } elsif( $name eq 'REPEAT_LIST' ) {
327 } elsif( $name eq 'REPEAT' ) {
328 0 my ($s,$e) = ($attr->{'{}COORDS'}->{'Value'} =~ /(\d+)\-(\d+)/);
329 0 my $strand = 1;
330 0 ▶ if( $s > $e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $e) 0 0 0
331 0 ($s,$e,$strand) = ( $e,$s,-1);
332 }
333 my $f = Bio::SeqFeature::Generic->new
334 (-primary_tag => 'simple_repeat',
335 -source_tag => $Default_Source,
336 -seq_id => $seqid,
337 -start => $s,
338 -end => $e,
339 -stand => $strand,
340 -tag => {
341 0 'ID' => $attr->{'{}FEAT_NAME'}->{'Value'},
342 });
343  
344 0 push @{$self->{'_seendata'}->{'_feats'}}, $f;
345 0 $self->{'_seendata'}->{'_seqs'}->[-1]->add_SeqFeature($f);
346 } elsif ( $name eq 'AUTHOR' ) {
347 } elsif( $name eq 'GB_DESCRIPTION' ) {
348
349 } elsif( $name eq 'GB_COMMENT' ) {
350 } elsif( $name eq 'LINEAGE' ) {
351
352 } else {
353 0 $self->warn("Unknown element $name, ignored\n");
354 }
355 26 push @{$self->{'_state'}}, $name;
356 26 $self->SUPER::start_element($ele);
357 }
358  
359 26 ▶sub end_element {
Subroutine end_element: called CC=23 SCAR=32.2
Pod documented
360 26 my ($self,$ele) = @_;
361 26 pop @{$self->{'_state'}};
362 26 my $name = $ele->{'LocalName'};
363 26 my $curseq = $self->{'_seendata'}->{'_seqs'}->[-1];
364 26 ▶ if( $name eq 'AUTHOR_LIST' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($name eq 'AUTHOR_LIST') { } 1 25 26
elsif ($name eq 'ASSEMBLY') { } 1 24 25
elsif ($name eq 'TU' or $name eq 'TRNA' or $name eq 'PRE-TRNA' or $name eq 'REPEAT') { } 2 22 24
elsif ($name eq 'MODEL') { } 2 20 22
365 1 ▶ if( $curseq->can('annotation') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($curseq->can("annotation")) 1 0 1
366 $curseq->annotation->add_Annotation
367 ('reference',Bio::Annotation::Reference->new
368 1 (-authors => join(',',@{$self->{'_seendata'}->{'_authors'}}))
369 );
370 }
371 1 $self->{'_seendata'}->{'_authors'} = [];
372 } elsif( $name eq 'ASSEMBLY' ) {
373 1 ▶ if( @{$self->{'_seendata'}->{'_feats'} || []} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"_seendata"}{"_feats"} or [];}) 0 1 1
Condition50%1/2
$self->{'_seendata'}{'_feats'} || []
l!l
10
MC/DC0%0/1
$self->{'_seendata'}{'_feats'} || []
$self->{'_seendata'}{'_feats'}
Truth table50%1/2
A
A= $self->{'_seendata'}{'_feats'}
Aresult
11
00
374 0 $self->warn("Leftover features which were not finished!");
375 }
376 1 $self->debug("end element for ASSEMBLY ". $curseq->display_id. "\n");
377 ▶ } elsif( $name eq 'TU' ||
Condition66%6/9
$name eq "TU" or $name eq "TRNA" or $name eq "PRE-TRNA" or $name eq "REPEAT"
l!l&&r!l&&!r
2022
$name eq "TU" or $name eq "TRNA" or $name eq "PRE-TRNA"
l!l&&r!l&&!r
2022
$name eq "TU" or $name eq "TRNA"
l!l&&r!l&&!r
2022
MC/DC25%1/4
$name eq "TU" or $name eq "TRNA" or $name eq "PRE-TRNA" or $name eq "REPEAT"
$name eq "TU" $name eq "TRNA" $name eq "PRE-TRNA" $name eq "REPEAT"
Truth table40%2/5
A or B or C or D
A= $name eq "TU"B= $name eq "TRNA"C= $name eq "PRE-TRNA"D= $name eq "REPEAT"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
378 $name eq 'TRNA' || $name eq 'PRE-TRNA' ||
379 $name eq 'REPEAT' ) {
380 2 pop @{$self->{'_seendata'}->{'_feats'}};
381 } elsif( $name eq 'MODEL' ) {
382 # This is all to for adding UTRs
383  
384 2 my $model = pop @{$self->{'_seendata'}->{'_feats'}};
385 2 my $curseq = $self->{'_seendata'}->{'_seqs'}->[-1];
386 # sort smallest to largest, don't forget about
387 # strandedness
388 2 my ($parentid) = $model->get_tag_values('Parent');
389  
390 2 my @features = $model->get_SeqFeatures();
391 8 my @exons = sort { $a->start <=> $b->start }
392 2 grep { $_->primary_tag eq 'exon' } @features;
393
394 7 my @cdsexons = sort { $a->start <=> $b->start }
395 2 grep { $_->primary_tag eq 'CDS' } @features;
396
397 # look at the exons, find those which come after the model start
398 2 my $cdsexon = shift @cdsexons;
399 2 my $exon = shift @exons; # first exon
400 2 ▶ if( ! defined $cdsexon ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $cdsexon) { } 0 2 2
elsif (not defined $exon) { } 0 2 2
401 0 $self->warn( "no CDS exons $parentid!");
402 0 return;
403 } elsif( ! defined $exon ) {
404 0 $self->warn("no exons $parentid!" );
405 0 return;
406 }
407 2 my $utrct = 1;
408 2 ▶ while( defined $exon && $exon->start < $cdsexon->start ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $exon and $exon->start < $cdsexon->start) 3 2 5
Condition100%3/3
defined $exon and $exon->start < $cdsexon->start
!ll&&!rl&&r
113
MC/DC100%2/2
defined $exon and $exon->start < $cdsexon->start
defined $exon $exon->start < $cdsexon->start
Truth table100%3/3
A and B
A= defined $exonB= $exon->start < $cdsexon->start
ABresult
0X0
100
111
409 3 my ($pid) = $exon->get_tag_values('Parent');
410 3 $self->debug("LeftPhase: tu-id $parentid mrna-id $pid exon is ".
411 $exon->location->to_FTstring.
412 " CDSexon is ".$cdsexon->location->to_FTstring."\n");
413
414 3 ▶ my $utr = Bio::SeqFeature::Generic->new
Branch: 1 branch
BranchTrueFalseTotal
$exon->strand > 0 ? : 2 1 3
415 (-seq_id => $exon->seq_id,
416 -strand => $exon->strand,
417 -primary_tag => $exon->strand > 0 ? "five_prime_UTR" : "three_prime_UTR",
418 -source_tag => $Default_Source,
419 -tag => {
420 'ID' => "$pid.UTR".$utrct++,
421 'Parent' => $pid },
422 );
423 3 my ($ns,$ne);
424 3 ▶ if( $utr->primary_tag eq 'five_prime_UTR' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utr->primary_tag eq 'five_prime_UTR') { } 2 1 3
425 2 $ns = $exon->start;
426 2 $ne = min ( $exon->end, $cdsexon->start - 1);
427 } else {
428 1 $ne = min( $exon->end, $cdsexon->start - 1);
429 1 $ns = $exon->start;
430 }
431 3 $utr->start($ns); $utr->end($ne);
432 3 $model->add_SeqFeature($utr);
433 3 $curseq->add_SeqFeature($utr);
434 3 $exon = shift @exons;
435 }
436 8 @exons = sort { $a->start <=> $b->start }
437 2 grep {$_->primary_tag eq 'exon' } @features;
438 7 @cdsexons = sort { $a->start <=> $b->start }
439 2 grep { $_->primary_tag eq 'CDS' } @features;
440
441 2 $cdsexon = pop @cdsexons;
442 2 $exon = pop @exons;
443 2 ▶ if( ! defined $cdsexon ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $cdsexon) { } 0 2 2
elsif (not defined $exon) { } 0 2 2
444 0 $self->warn( "no CDS exons $parentid!");
445 0 return;
446 } elsif( ! defined $exon ) {
447 0 $self->warn("no exons $parentid!" );
448 0 return;
449 }
450 2 $utrct = 1;
451 2 ▶ while( defined $exon &&$exon->end > $cdsexon->end ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $exon and $exon->end > $cdsexon->end) 2 2 4
Condition66%2/3
defined $exon and $exon->end > $cdsexon->end
!ll&&!rl&&r
022
MC/DC50%1/2
defined $exon and $exon->end > $cdsexon->end
defined $exon $exon->end > $cdsexon->end
Truth table66%2/3
A and B
A= defined $exonB= $exon->end > $cdsexon->end
ABresult
0X0
100
111
452 2 my ($pid) = $exon->get_tag_values('Parent');
453 2 $self->debug("RightPhase: tu-id $parentid mrna-id $pid exon is ".
454 $exon->location->to_FTstring.
455 " CDSexon is ".$cdsexon->location->to_FTstring."\n");
456
457 2 ▶ my $utr = Bio::SeqFeature::Generic->new
Branch: 1 branch
BranchTrueFalseTotal
$exon->strand < 0 ? : 1 1 2
458 (-seq_id => $exon->seq_id,
459 -strand => $exon->strand,
460 -primary_tag => $exon->strand < 0 ? "five_prime_UTR" : "three_prime_UTR",
461 -source_tag => $Default_Source,
462 -tag => {
463 'Parent' => $pid,
464 'ID' => "$pid.UTR".$utrct++,
465 }
466 );
467 2 my ($ns,$ne);
468 2 ▶ if( $utr->primary_tag eq 'three_prime_UTR' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utr->primary_tag eq 'three_prime_UTR') { } 1 1 2
469 1 $ns = max ( $exon->start, $cdsexon->end + 1);
470 1 $ne = $exon->end;
471 } else {
472 1 $ns = $cdsexon->end+1;
473 1 $ne = max ( $exon->end, $cdsexon->start + 1);
474 }
475 2 $utr->start($ns); $utr->end($ne);
476
477 2 $model->add_SeqFeature($utr);
478 2 $curseq->add_SeqFeature($utr);
479 2 $exon = pop @exons;
480 }
481 }
482 26 $self->SUPER::end_element($ele);
483 }
484  
485 44 ▶sub characters {
Subroutine characters: called CC=18 SCAR=35.3
Pod documented
486 44 my ($self,$data) = @_;
487 44 ▶ if( ! @{$self->{'_state'}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @{$self->{'_state'};}) { } 0 44 44
488 0 $self->warn("Calling characters with no previous start_element call. Ignoring data");
489 } else {
490 44 my $curseq = $self->{'_seendata'}->{'_seqs'}->[-1];
491 44 my $curfeat = $self->{'_seendata'}->{'_feats'}->[-1];
492 44 my $name = $self->{'_state'}->[-1];
493 44 ▶ if( defined $curseq ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $curseq) 44 0 44
494 44 ▶ if( $name eq 'CLONE_NAME' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($name eq 'CLONE_NAME') { } 1 43 44
elsif ($name eq 'ORGANISM') { } 1 42 43
elsif ($name eq 'LINEAGE') { } 0 42 42
elsif ($name eq 'AUTHOR') { } 0 42 42
495 1 $self->debug("Clone name is ",$data->{'Data'}, "\n");
496 1 $curseq->display_id($data->{'Data'});
497 } elsif( $name eq 'ORGANISM' ) {
498 1 my ($genus,$species,$subspec) = split(/\s+/,$data->{Data},3);
499 1 $curseq->species(Bio::Species->new(
500 -classification =>
501 [$species,$genus],
502 -sub_species => $species));
503 } elsif( $name eq 'LINEAGE' ) {
504 $curseq->species->classification(
505 [
506 $curseq->species->species,
507 $curseq->species->genus,
508 0 reverse (map { s/^\s+//;
509 0 s/\s+$//; $_; }
510 0 split /[;\.]+/,$data->{'Data'} ),
511 ]
512 );
513 } elsif( $name eq 'AUTHOR' ) {
514 0 push @{$self->{'_seendata'}->{'_authors'}}, $data->{'Data'};
515 }
516 }
517 44 ▶ if( defined $curfeat ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $curfeat) 33 11 44
518 33 ▶ if( $name eq 'EXON' ) { # exon feature
Branch: 10 branches
BranchTrueFalseTotal
if ($name eq 'EXON') { } 15 18 33
elsif ($name eq 'RNA-EXON') { } 0 18 18
elsif ($name eq 'PROTEIN_SEQ') { } 2 16 18
elsif ($name eq 'CDS') { } 0 16 16
elsif ($name eq 'PRE-TRNA') { } 0 16 16
elsif ($name eq 'TRNA') { } 0 16 16
elsif ($name eq 'REPEAT_LIST') { } 0 16 16
elsif ($name eq 'REPEAT') { } 0 16 16
elsif ($name eq 'GB_COMMENT') { } 0 16 16
elsif ($name eq 'GB_DESCRIPTION') { } 0 16 16
519 } elsif( $name eq 'RNA-EXON' ) {
520
521 } elsif( $name eq 'PROTEIN_SEQ' ) {
522 2 $curfeat->add_tag_value('translation',$data->{'Data'});
523 } elsif( $name eq 'CDS' ) {
524 } elsif( $name eq 'PRE-TRNA' ) { # tRNA gene
525 } elsif( $name eq 'TRNA' ) { # tRNA transcript
526 } elsif( $name eq 'REPEAT_LIST' ) {
527 } elsif( $name eq 'REPEAT' ) {
528 0 $curfeat->add_tag_value('Note',$data->{'Data'});
529 } elsif( $name eq 'GB_COMMENT' ) {
530 $curseq->annotation->add_Annotation
531 ('comment',
532 0 Bio::Annotation::Comment->new(-text => $data->{'Data'}));
533 } elsif( $name eq 'GB_DESCRIPTION' ) {
534 0 $curseq->description($data->{'Data'});
535 }
536 }
537 }
538 44 $self->SUPER::characters($data);
539 }
540  
541  
542 14 ▶sub assert {
Subroutine assert: called CC=2 SCAR=7.2
Pod undocumented
543 14 my ($self,$test,$msg) = @_;
544 14 ▶ $self->throw($msg) unless $test;
Branch: 1 branch
BranchTrueFalseTotal
unless $test 0 14 14
545 }
546 2 1;
« Bio/SearchIO/cross_match.pm ↑ Summary Bio/SeqFeature/Gene/Intron.pm »