Bio/Tools/Genemark.pm

filter: Statementstmt 89.2% 158 / 177 Branchbran 79.7% 59 / 74 Conditioncond 60.0% 9 / 15 MC/DCmcdc 30.0% 3 / 10 Subroutinesub 90.0% 18 / 20 Podpod 100% 4 / 4 totaltotal 83.6% 251 / 300 CC 46 SCAR 27.6
CC
46
Cov
85%
_parse_predictions
31.1
_has_cds
12.0
_read_fasta_seq
5.0
CRAP 15.7
« Bio/SearchIO/blasttable.pm ↑ Summary Bio/Seq/BaseSeqProcessor.pm »
1 #
2 # BioPerl module for Bio::Tools::Genemark
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Mark Fiers <hlapp@gmx.net>
7 #
8 # Copyright Hilmar Lapp, Mark Fiers
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::Tools::Genemark - Results of one Genemark run
17  
18 =head1 SYNOPSIS
19  
20 $Genemark = Bio::Tools::Genemark->new(-file => 'result.Genemark');
21 # filehandle:
22 $Genemark = Bio::Tools::Genemark->new( -fh => \*INPUT );
23  
24 # parse the results
25 # note: this class is-a Bio::Tools::AnalysisResult which implements
26 # Bio::SeqAnalysisParserI, i.e., $Genemark->next_feature() is the same
27 while($gene = $Genemark->next_prediction()) {
28 # $gene is an instance of Bio::Tools::Prediction::Gene, which inherits
29 # off Bio::SeqFeature::Gene::Transcript.
30 #
31 # $gene->exons() returns an array of
32 # Bio::Tools::Prediction::Exon objects
33 # all exons:
34 @exon_arr = $gene->exons();
35  
36 # initial exons only
37 @init_exons = $gene->exons('Initial');
38 # internal exons only
39 @intrl_exons = $gene->exons('Internal');
40 # terminal exons only
41 @term_exons = $gene->exons('Terminal');
42 # singleton exons:
43 ($single_exon) = $gene->exons();
44 }
45  
46 # essential if you gave a filename at initialization (otherwise the file
47 # will stay open)
48 $Genemark->close();
49  
50 =head1 DESCRIPTION
51  
52 The Genemark module provides a parser for Genemark gene structure
53 prediction output. It parses one gene prediction into a
54 Bio::SeqFeature::Gene::Transcript- derived object.
55  
56 This module has been developed around genemark.hmm for eukaryots v2.2a
57 and will probably not work with other versions.
58  
59  
60 This module also implements the Bio::SeqAnalysisParserI interface, and
61 thus can be used wherever such an object fits. See
62 L<Bio::SeqAnalysisParserI>.
63  
64 =head1 FEEDBACK
65  
66 =head2 Mailing Lists
67  
68 User feedback is an integral part of the evolution of this and other
69 Bioperl modules. Send your comments and suggestions preferably to one
70 of the Bioperl mailing lists. Your participation is much appreciated.
71  
72 bioperl-l@bioperl.org - General discussion
73 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
74  
75 =head2 Support
76  
77 Please direct usage questions or support issues to the mailing list:
78  
79 I<bioperl-l@bioperl.org>
80  
81 rather than to the module maintainer directly. Many experienced and
82 reponsive experts will be able look at the problem and quickly
83 address it. Please include a thorough description of the problem
84 with code and data examples if at all possible.
85  
86 =head2 Reporting Bugs
87  
88 Report bugs to the Bioperl bug tracking system to help us keep track
89 the bugs and their resolution. Bug reports can be submitted via the
90 web:
91  
92 https://github.com/bioperl/bioperl-live/issues
93  
94 =head1 AUTHOR - Hilmar Lapp, Mark Fiers
95  
96 Email hlapp@gmx.net
97 m.w.e.j.fiers@plant.wag-ur.nl
98  
99 =head1 APPENDIX
100  
101 The rest of the documentation details each of the object
102 methods. Internal methods are usually preceded with a _
103  
104 =cut
105  
106  
107 # Let the code begin...
108  
109  
110 package Bio::Tools::Genemark;
111 2 $Bio::Tools::Genemark::VERSION = '1.7.8';
112 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
113 2 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
114  
115 2 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
116 2 ▶use Bio::Tools::Prediction::Gene;
Subroutine BEGIN: called CC=1 SCAR=0.0
117 2 ▶use Bio::Tools::Prediction::Exon;
Subroutine BEGIN: called CC=1 SCAR=0.0
118 2 ▶use Bio::Seq;
Subroutine BEGIN: called CC=1 SCAR=0.0
119 2 ▶use Bio::Factory::FTLocationFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
120  
121 2 ▶use base qw(Bio::Tools::AnalysisResult);
Subroutine BEGIN: called CC=1 SCAR=0.0
122  
123 =head2 new
124  
125 Title : new
126 Usage : my $obj = Bio::Tools::Genemark->new();
127 Function: Builds a new Bio::Tools::Genemark object
128 Returns : an instance of Bio::Tools::Genemark
129 Args : seqname
130  
131  
132 =cut
133  
134 2 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
135 2 my($class,@args) = @_;
136  
137 2 my $self = $class->SUPER::new(@args);
138  
139 2 my ($seqname) = $self->_rearrange([qw(SEQNAME)], @args);
140  
141 # hardwire seq_id when creating gene and exon objects
142 2 ▶ $self->_seqname($seqname) if defined($seqname);
Branch: 1 branch
BranchTrueFalseTotal
if defined $seqname 1 1 2
143  
144 2 return $self;
145 }
146  
147 2 ▶sub _initialize_state {
Subroutine _initialize_state: called CC=1 SCAR=0.0
148 2 my ($self,@args) = @_;
149  
150 # first call the inherited method!
151 2 $self->SUPER::_initialize_state(@args);
152  
153 # our private state variables
154 2 $self->{'_preds_parsed'} = 0;
155 2 $self->{'_has_cds'} = 0;
156 # array of pre-parsed predictions
157 2 $self->{'_preds'} = [];
158 # seq stack
159 2 $self->{'_seqstack'} = [];
160 }
161  
162 =head2 analysis_method
163  
164 Usage : $Genemark->analysis_method();
165 Purpose : Inherited method. Overridden to ensure that the name matches
166 /GeneMark.hmm/i.
167 Returns : String
168 Argument : n/a
169  
170 =cut
171  
172 #-------------
173 47 ▶sub analysis_method {
Subroutine analysis_method: called CC=3 SCAR=12.0
Pod documented
174 #-------------
175 47 my ($self, $method) = @_;
176 47 ▶ if($method && ($method !~ /Genemark\.hmm/i)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method and not $method =~ /Genemark\.hmm/i) 0 47 47
Condition66%2/3
$method and not $method =~ /Genemark\.hmm/i
!ll&&!rl&&r
4520
MC/DC0%0/2
$method and not $method =~ /Genemark\.hmm/i
$method not $method =~ /Genemark\.hmm/i
Truth table66%2/3
A and not(B)
A= $methodB= not $method =~ /Genemark\.hmm/i
ABresult
0X0
100
111
177 0 $self->throw("method $method not supported in " . ref($self));
178 }
179 47 return $self->SUPER::analysis_method($method);
180 }
181  
182 =head2 next_feature
183  
184 Title : next_feature
185 Usage : while($gene = $Genemark->next_feature()) {
186 # do something
187 }
188 Function: Returns the next gene structure prediction of the Genemark result
189 file. Call this method repeatedly until FALSE is returned.
190  
191 The returned object is actually a SeqFeatureI implementing object.
192 This method is required for classes implementing the
193 SeqAnalysisParserI interface, and is merely an alias for
194 next_prediction() at present.
195  
196 Example :
197 Returns : A Bio::Tools::Prediction::Gene object.
198 Args :
199  
200 =cut
201  
202 0 ▶sub next_feature {
Subroutine next_feature: not called CC=1 SCAR=6.9
Pod documented
203 0 my ($self,@args) = @_;
204 # even though next_prediction doesn't expect any args (and this method
205 # does neither), we pass on args in order to be prepared if this changes
206 # ever
207 0 return $self->next_prediction(@args);
208 }
209  
210 =head2 next_prediction
211  
212 Title : next_prediction
213 Usage : while($gene = $Genemark->next_prediction()) {
214 # do something
215 }
216 Function: Returns the next gene structure prediction of the Genemark result
217 file. Call this method repeatedly until FALSE is returned.
218  
219 Example :
220 Returns : A Bio::Tools::Prediction::Gene object.
221 Args :
222  
223 =cut
224  
225 16 ▶sub next_prediction {
Subroutine next_prediction: called CC=2 SCAR=6.9
Pod documented
226 16 my ($self) = @_;
227 16 my $gene;
228  
229 # if the prediction section hasn't been parsed yet, we do this now
230 16 ▶ $self->_parse_predictions() unless $self->_predictions_parsed();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_predictions_parsed 2 14 16
231  
232 # get next gene structure
233 16 $gene = $self->_prediction();
234  
235 16 return $gene;
236 }
237  
238 =head2 _parse_predictions
239  
240 Title : _parse_predictions()
241 Usage : $obj->_parse_predictions()
242 Function: Parses the prediction section. Automatically called by
243 next_prediction() if not yet done.
244 Example :
245 Returns :
246  
247 =cut
248  
249 2 ▶sub _parse_predictions {
Subroutine _parse_predictions: called CC=29 SCAR=34.4
250 2 my ($self) = @_;
251 2 my %exontags = ('Initial' => 'Initial',
252 'Internal' => 'Internal',
253 'Terminal' => 'Terminal',
254 'Single' => '',
255 '_na_' => '');
256 2 my $exontag;
257 my $gene;
258 2 my $exontype;
259 2 my $current_gene_no = -1;
260  
261 # The prediction report does not contain a sequence identifier
262 # (at least the prokaryotic version doesn't)
263 2 my $seqname = $self->_seqname();
264
265 2 ▶ while(defined($_ = $self->_readline())) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 77 1 78
266  
267 77 ▶ if( (/^\s*(\d+)\s+(\d+)/) || (/^\s*(\d+)\s+[\+\-]/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s*(\d+)\s+(\d+)/ or /^\s*(\d+)\s+[\+\-]/) 45 32 77
Condition100%3/3
/^\s*(\d+)\s+(\d+)/ or /^\s*(\d+)\s+[\+\-]/
l!l&&r!l&&!r
43232
MC/DC100%2/2
/^\s*(\d+)\s+(\d+)/ or /^\s*(\d+)\s+[\+\-]/
/^\s*(\d+)\s+(\d+)/ /^\s*(\d+)\s+[\+\-]/
Truth table100%3/3
A or B
A= /^\s*(\d+)\s+(\d+)/B= /^\s*(\d+)\s+[\+\-]/
ABresult
1X1
011
000
268  
269 # this is an exon, Genemark doesn't predict anything else
270 # $prednr corresponds to geneno.
271 45 my $prednr = $1;
272  
273 #exon no:
274 45 my $signalnr = 0;
275 45 ▶ if ($2) { my $signalnr = $2; } # used in tag: exon_no
Branch: 1 branch
BranchTrueFalseTotal
if ($2) 43 2 45
276
277 # split into fields
278 45 chomp();
279 45 my @flds = split(' ', $_);
280  
281 # create the feature (an exon) object
282 45 my $predobj = Bio::Tools::Prediction::Exon->new();
283  
284
285 # define info depending on it being eu- or prokaryot
286 45 my ($start, $end, $orientation, $prediction_source);
287  
288 45 ▶ if ($self->analysis_method() =~ /PROKARYOTIC/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->analysis_method =~ /PROKARYOTIC/i) { } 2 43 45
289 2 $prediction_source = "Genemark.hmm.pro";
290 2 ▶ $orientation = ($flds[1] eq '+') ? 1 : -1;
Branch: 1 branch
BranchTrueFalseTotal
$flds[1] eq '+' ? : 2 0 2
291 2 ($start, $end) = @flds[(2,3)];
292 2 $exontag = "_na_";
293  
294 } else {
295 43 $prediction_source = "Genemark.hmm.eu";
296 43 ▶ $orientation = ($flds[2] eq '+') ? 1 : -1;
Branch: 1 branch
BranchTrueFalseTotal
$flds[2] eq '+' ? : 14 29 43
297 43 ($start, $end) = @flds[(4,5)];
298 43 $exontag = $flds[3];
299 }
300  
301 # instatiate a location object via
302 # Bio::Factory::FTLocationFactory (to handle
303 # inexact coordinates)
304 45 my $location_string = join('..', $start, $end);
305 45 my $location_factory = Bio::Factory::FTLocationFactory->new();
306 45 my $location_obj = $location_factory->from_string($location_string);
307 45 $predobj->location($location_obj);
308  
309 #store the data in the exon object
310 45 $predobj->source_tag($prediction_source);
311 45 $predobj->strand($orientation);
312  
313 45 $predobj->primary_tag($exontags{$exontag} . "Exon");
314  
315 45 ▶ $predobj->add_tag_value('exon_no',"$signalnr") if ($signalnr);
Branch: 1 branch
BranchTrueFalseTotal
if $signalnr 0 45 45
316  
317 45 $predobj->is_coding(1);
318  
319 45 ▶ $predobj->seq_id($seqname) if (defined($seqname) && ($seqname ne 'unknown'));
Branch: 1 branch
BranchTrueFalseTotal
if defined $seqname and $seqname ne "unknown" 45 0 45
Condition33%1/3
defined $seqname and $seqname ne "unknown"
!ll&&!rl&&r
0045
MC/DC0%0/2
defined $seqname and $seqname ne "unknown"
defined $seqname $seqname ne "unknown"
Truth table33%1/3
A and B
A= defined $seqnameB= $seqname ne "unknown"
ABresult
0X0
100
111
320
321 # frame calculation as in the genscan module
322 # is to be implemented...
323
324 #If the $prednr is not equal to the current gene, we
325 #need to make a new gene and close the old one
326 45 ▶ if($prednr != $current_gene_no) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prednr != $current_gene_no) 15 30 45
327 # a new gene, store the old one if it exists
328 15 ▶ if (defined ($gene)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $gene) 13 2 15
329 13 $gene->seq_id($seqname);
330 13 $gene = undef ;
331 }
332 #and make a new one
333 15 $gene = Bio::Tools::Prediction::Gene->new
334 (
335 '-primary' => "GenePrediction$prednr",
336 '-source' => $prediction_source);
337 15 $self->_add_prediction($gene);
338 15 $current_gene_no = $prednr;
339 15 ▶ $gene->seq_id($seqname) if (defined($seqname) && ($seqname ne 'unknown'));
Branch: 1 branch
BranchTrueFalseTotal
if defined $seqname and $seqname ne "unknown" 15 0 15
Condition33%1/3
defined $seqname and $seqname ne "unknown"
!ll&&!rl&&r
0015
MC/DC0%0/2
defined $seqname and $seqname ne "unknown"
defined $seqname $seqname ne "unknown"
Truth table33%1/3
A and B
A= defined $seqnameB= $seqname ne "unknown"
ABresult
0X0
100
111
340 }
341
342 # Add the exon to the gene
343 $gene->add_exon($predobj, ($exontag eq "_na_" ?
344 45 ▶ undef : $exontags{$exontag}));
Branch: 1 branch
BranchTrueFalseTotal
$exontag eq '_na_' ? : 2 43 45
345  
346 }
347  
348 77 ▶ if(/^(Genemark\.hmm\s*[PROKARYOTIC]*)\s+\(Version (.*)\)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^(Genemark\.hmm\s*[PROKARYOTIC]*)\s+\(Version (.*)\)$/i) 2 75 77
349 2 $self->analysis_method($1);
350  
351 2 my $gm_version = $2;
352  
353 2 $self->analysis_method_version($gm_version);
354 2 next;
355 }
356  
357 #Matrix file for eukaryot version
358 75 ▶ if (/^Matrices file:\s+(\S+)?/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^Matrices file:\s+(\S+)?/i) 1 74 75
359 1 $self->analysis_subject($1);
360 # since the line after the matrix file is always the date
361 # (in the output file's I have seen!) extract and store this
362 # here
363 1 ▶ if (defined(my $_date = $self->_readline())) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $_date = $self->_readline)) 1 0 1
364 1 chomp ($_date);
365 1 $self->analysis_date($_date);
366 }
367 }
368
369 #Matrix file for prokaryot version
370 75 ▶ if (/^Model file name:\s+(\S+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^Model file name:\s+(\S+)/) 1 74 75
371 1 $self->analysis_subject($1);
372 # since the line after the matrix file is always the date
373 # (in the output file's I have seen!) extract and store this
374 # here
375 1 my $_date = $self->_readline() ;
376 1 ▶ if (defined($_date = $self->_readline())) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_date = $self->_readline)) 1 0 1
377 1 chomp ($_date);
378 1 $self->analysis_date($_date);
379 }
380 }
381
382 75 ▶ if(/^Sequence[ file]? name:\s+(.+)\s*$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^Sequence[ file]? name:\s+(.+)\s*$/i) 1 74 75
383 1 $seqname = $1;
384 # $self->analysis_subject($seqname);
385 1 next;
386 }
387
388  
389 74 ▶ /^>/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/^>/ and do { $self->_pushback($_); while (1) { () = $self->_read_fasta_seq; last unless $aa_id; FINDPRED: foreach my $gene (@{$$self{"_preds"};}) { $gene->primary_tag =~ /[^0-9]([0-9]+)$/; my $geneno = $1; if ($aa_id =~ /\|gene.$geneno\|/) { my $seqobj = "Bio::Seq"->new("-seq", $seq, "-display_id", $aa_id, "-alphabet", "protein"); $gene->predicted_protein($seqobj); last FINDPRED; } ; } ; } ; last } 1 73 74
390 1 $self->_pushback($_);
391  
392 # section of predicted aa sequences on recognition
393 # of a fasta start, read all sequences and find the
394 # appropriate gene
395 1 while (1) {
396 14 my ($aa_id, $seq) = $self->_read_fasta_seq();
397 14 ▶ last unless ($aa_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $aa_id 1 13 14
398  
399 #now parse through the predictions to add the pred. protein
400 13 FINDPRED: foreach my $gene (@{$self->{'_preds'}}) {
401 91 $gene->primary_tag() =~ /[^0-9]([0-9]+)$/;
402 91 my $geneno = $1;
403 91 ▶ if ($aa_id =~ /\|gene.$geneno\|/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aa_id =~ /\|gene.$geneno\|/) 13 78 91
404 #print "x SEQ : \n $seq \nXXXX\n";
405 13 my $seqobj = Bio::Seq->new('-seq' => $seq,
406 '-display_id' => $aa_id,
407 '-alphabet' => "protein");
408 13 $gene->predicted_protein($seqobj);
409 13 last FINDPRED;
410 }
411  
412 }
413 }
414  
415 1 last;
416 };
417 }
418  
419 # if the analysis query object contains a ref to a Seq of PrimarySeq
420 # object, then extract the predicted sequences and add it to the gene
421 # object.
422 2 ▶ if (defined $self->analysis_query()) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->analysis_query) 0 2 2
423 0 my $orig_seq = $self->analysis_query();
424 0 FINDPREDSEQ: foreach my $gene (@{$self->{'_preds'}}) {
425 0 my $predseq = "";
426 0 foreach my $exon ($gene->exons()) {
427 #print $exon->start() . " " . $exon->end () . "\n";
428 0 $predseq .= $orig_seq->subseq($exon->start(), $exon->end());
429 }
430  
431 0 my $seqobj = Bio::PrimarySeq->new('-seq' => $predseq,
432 '-display_id' => "transl");
433 0 $gene->predicted_cds($seqobj);
434 }
435 }
436  
437  
438 2 $self->_predictions_parsed(1);
439 }
440  
441 =head2 _prediction
442  
443 Title : _prediction()
444 Usage : $gene = $obj->_prediction()
445 Function: internal
446 Example :
447 Returns :
448  
449 =cut
450  
451 16 ▶sub _prediction {
Subroutine _prediction: called CC=3 SCAR=11.0
452 16 my ($self) = @_;
453  
454 16 ▶ return unless(exists($self->{'_preds'}) && @{$self->{'_preds'}});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_preds"} and @{$self->{"_preds"};} 1 15 16
Condition66%2/3
exists $self->{"_preds"} and @{$self->{"_preds"};}
!ll&&!rl&&r
0115
MC/DC50%1/2
exists $self->{"_preds"} and @{$self->{"_preds"};}
exists $self->{"_preds"} @{$self->{"_preds"};}
Truth table66%2/3
A and B
A= exists $self->{"_preds"}B= @{$self->{"_preds"};}
ABresult
0X0
100
111
455 15 return shift(@{$self->{'_preds'}});
456 }
457  
458 =head2 _add_prediction
459  
460 Title : _add_prediction()
461 Usage : $obj->_add_prediction($gene)
462 Function: internal
463 Example :
464 Returns :
465  
466 =cut
467  
468 15 ▶sub _add_prediction {
Subroutine _add_prediction: called CC=2 SCAR=7.4
469 15 my ($self, $gene) = @_;
470  
471 15 ▶ if(! exists($self->{'_preds'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_preds"}) 0 15 15
472 0 $self->{'_preds'} = [];
473 }
474 15 push(@{$self->{'_preds'}}, $gene);
475 }
476  
477 =head2 _predictions_parsed
478  
479 Title : _predictions_parsed
480 Usage : $obj->_predictions_parsed
481 Function: internal
482 Example :
483 Returns : TRUE or FALSE
484  
485 =cut
486  
487 18 ▶sub _predictions_parsed {
Subroutine _predictions_parsed: called CC=3 SCAR=11.3
488 18 my ($self, $val) = @_;
489  
490 18 ▶ $self->{'_preds_parsed'} = $val if $val;
Branch: 1 branch
BranchTrueFalseTotal
if $val 2 16 18
491 18 ▶ if(! exists($self->{'_preds_parsed'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_preds_parsed"}) 0 18 18
492 0 $self->{'_preds_parsed'} = 0;
493 }
494 18 return $self->{'_preds_parsed'};
495 }
496  
497 =head2 _has_cds
498  
499 Title : _has_cds()
500 Usage : $obj->_has_cds()
501 Function: Whether or not the result contains the predicted CDSs, too.
502 Example :
503 Returns : TRUE or FALSE
504  
505 =cut
506  
507 0 ▶sub _has_cds {
Subroutine _has_cds: not called CC=3 SCAR=24.8
508 0 my ($self, $val) = @_;
509  
510 0 ▶ $self->{'_has_cds'} = $val if $val;
Branch: 1 branch
BranchTrueFalseTotal
if $val 0 0 0
511 0 ▶ if(! exists($self->{'_has_cds'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_has_cds"}) 0 0 0
512 0 $self->{'_has_cds'} = 0;
513 }
514 0 return $self->{'_has_cds'};
515 }
516  
517 =head2 _read_fasta_seq
518  
519 Title : _read_fasta_seq()
520 Usage : ($id,$seqstr) = $obj->_read_fasta_seq();
521 Function: Simple but specialised FASTA format sequence reader. Uses
522 $self->_readline() to retrieve input, and is able to strip off
523 the traling description lines.
524 Example :
525 Returns : An array of two elements.
526  
527 =cut
528  
529 14 ▶sub _read_fasta_seq {
Subroutine _read_fasta_seq: called CC=5 SCAR=16.1
530 14 my ($self) = @_;
531 14 my ($id, $seq);
532 14 local $/ = ">";
533  
534 14 ▶ return 0 unless (my $entry = $self->_readline());
Branch: 1 branch
BranchTrueFalseTotal
unless my $entry = $self->_readline 1 13 14
535  
536 13 $entry =~ s/^>//;
537 # complete the entry if the first line came from a pushback buffer
538 13 ▶ while(! ($entry =~ />$/)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($entry =~ />$/) 2 12 14
539 2 ▶ last unless ($_ = $self->_readline());
Branch: 1 branch
BranchTrueFalseTotal
unless $_ = $self->_readline 1 1 2
540 1 $entry .= $_;
541 }
542  
543 # delete everything onwards from an new fasta start (>)
544 13 $entry =~ s/\n>.*$//s;
545 # id and sequence
546  
547 13 ▶ if($entry =~ s/^(.+)\n//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry =~ s/^(.+)\n//) { } 13 0 13
548 13 $id = $1;
549 13 $id =~ s/ /_/g;
550 13 $seq = $entry;
551 13 $seq =~ s/\s//g;
552 #print "\n@@ $id \n@@ $seq \n##\n";
553 } else {
554 0 $self->throw("Can't parse Genemark predicted sequence entry");
555 }
556 13 $seq =~ s/\s//g; # Remove whitespace
557 13 return ($id, $seq);
558 }
559  
560 =head2 _seqname
561  
562 Title : _seqname
563 Usage : $obj->_seqname($seqname)
564 Function: internal
565 Example :
566 Returns : String
567  
568 =cut
569  
570 3 ▶sub _seqname {
Subroutine _seqname: called CC=3 SCAR=11.0
571 3 my ($self, $val) = @_;
572  
573 3 ▶ $self->{'_seqname'} = $val if $val;
Branch: 1 branch
BranchTrueFalseTotal
if $val 1 2 3
574 3 ▶ if(! exists($self->{'_seqname'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_seqname"}) 1 2 3
575 1 $self->{'_seqname'} = 'unknown';
576 }
577 3 return $self->{'_seqname'};
578 }
579  
580 2 1;
581  
« Bio/SearchIO/blasttable.pm ↑ Summary Bio/Seq/BaseSeqProcessor.pm »