| 1 | package Bio::ToolBox::Data::Iterator; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Bio::ToolBox::Data::Feature; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | our $VERSION = '2.02'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 11 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | 11 | my ( $class, $data ) = @_; | |||||||||||||||||||||||||||
| 12 | 11 | my %iterator = ( | |||||||||||||||||||||||||||
| 13 | 'index' => 1, | ||||||||||||||||||||||||||||
| 14 | 'data' => $data, | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | 11 | return bless \%iterator, $class; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 165 | ▶ | sub next_row { | ||||||||||||||||||||||||||
|
Subroutine
next_row: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | 165 | my $self = shift; | |||||||||||||||||||||||||||
| 21 | 165 | ▶ | return if $self->{'index'} > $self->{data}->{last_row}; # no more | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 157 | my $i = $self->{'index'}; | |||||||||||||||||||||||||||
| 23 | 157 | $self->{'index'}++; | |||||||||||||||||||||||||||
| 24 | my @options = ( | ||||||||||||||||||||||||||||
| 25 | 'data' => $self->{data}, | ||||||||||||||||||||||||||||
| 26 | 157 | 'index' => $i, | |||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | 157 | ▶ | if ( exists $self->{data}->{SeqFeatureObjects} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $self->{"data"}{"SeqFeatureObjects"} and defined $self->{"data"}{"SeqFeatureObjects"}[$i]
MC/DC0%0/2
exists $self->{"data"}{"SeqFeatureObjects"} and defined $self->{"data"}{"SeqFeatureObjects"}[$i]
exists $self->{"data"}{"SeqFeatureObjects"}
defined $self->{"data"}{"SeqFeatureObjects"}[$i]
Truth table66%2/3
A and B
A= exists $self->{"data"}{"SeqFeatureObjects"}B= defined $self->{"data"}{"SeqFeatureObjects"}[$i]
| |||||||||||||||||||||||||||||
| 29 | and defined $self->{data}->{SeqFeatureObjects}->[$i] ) | ||||||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||||||
| 31 | 0 | push @options, 'feature', $self->{data}->{SeqFeatureObjects}->[$i]; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 157 | return Bio::ToolBox::Data::Feature->new(@options); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub row_index { | ||||||||||||||||||||||||||
|
Subroutine
row_index: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | carp 'ERROR: row_index is a read only method' if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | return $self->{'index'}; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 4 | 1; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head1 NAME | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | Bio::ToolBox::Data::Iterator - Class for iterating through Data tables | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # open a Bio::ToolBox::Data object | ||||||||||||||||||||||||||||
| 51 | # initiate an iterator stream | ||||||||||||||||||||||||||||
| 52 | my $stream = $Data->row_stream; | ||||||||||||||||||||||||||||
| 53 | while (my $row = $stream->next_row) { | ||||||||||||||||||||||||||||
| 54 | # each $row is a Bio::ToolBox::Data::Feature object | ||||||||||||||||||||||||||||
| 55 | # representing the row in the data table | ||||||||||||||||||||||||||||
| 56 | my $value = $row->value($index); | ||||||||||||||||||||||||||||
| 57 | # do something with $value | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | This is an iteration object for iterating through the rows of a | ||||||||||||||||||||||||||||
| 63 | L<Bio::ToolBox::Data> object table. | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | This should not be created directly by end-users. Rather, see | ||||||||||||||||||||||||||||
| 66 | L<Bio::ToolBox::Data\row_stream> for details. | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head1 METHODS | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | There is essentially only one method for end-users, C<next_row>. | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =over 4 | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =item new | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | Pass a valid L<Bio::ToolBox::Data> object. | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =item next_row | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | This returns the next row in a Data table as a | ||||||||||||||||||||||||||||
| 81 | L<Bio::ToolBox::Data::Feature> row object. If SeqFeature objects are | ||||||||||||||||||||||||||||
| 82 | associated with the row, perhaps from a parsed input annotation file, | ||||||||||||||||||||||||||||
| 83 | then they are automatically associated with the row object. (Previous | ||||||||||||||||||||||||||||
| 84 | versions required separately calling the seqfeature() row method to | ||||||||||||||||||||||||||||
| 85 | perform this.) | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =item row_index | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | Returns the index position of the current data row within the data | ||||||||||||||||||||||||||||
| 90 | table. Useful for knowing where you are at within the data table. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =back | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Timothy J. Parnell, PhD | ||||||||||||||||||||||||||||
| 97 | Dept of Oncological Sciences | ||||||||||||||||||||||||||||
| 98 | Huntsman Cancer Institute | ||||||||||||||||||||||||||||
| 99 | University of Utah | ||||||||||||||||||||||||||||
| 100 | Salt Lake City, UT, 84112 | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | This package is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 103 | it under the terms of the Artistic License 2.0. | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||