| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::Seq::Meta::Array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Cared for by Heikki Lehvaslaiho | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # Copyright Heikki Lehvaslaiho | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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::Seq::Meta::Array - array-based generic implementation of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | sequence class with residue-based meta information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | use Bio::LocatableSeq; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | use Bio::Seq::Meta::Array; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | my $seq = Bio::Seq::Meta::Array->new(-id=>'test', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | -seq=>'ACTGCTAGCT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | -start=>2434, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | -start=>2443, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | -strand=>1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | -verbose=>1, # to see warnings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # to test this is a meta seq object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | $seq->isa("Bio::Seq::Meta::Array") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | || $seq->throw("$seq is not a Bio::Seq::Meta::Array"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | $seq->meta('1 2 3 4 5 6 7 8 9 10'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # or you could create the Meta object directly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | $seq = Bio::Seq::Meta::Array->new(-id=>'test', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | -seq=>'ACTGCTAGCT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | -start=>2434, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | -start=>2443, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | -strand=>1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | -meta=>'1 2 3 4 5 6 7 8 9 10', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | -verbose=>1, # to see warnings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # accessors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | $arrayref = $seq->meta(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | $string = $seq->meta_text(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | $substring = $seq->submeta_text(2,5); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $unique_key = $seq->accession_number(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | This class implements generic methods for sequences with residue-based | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | meta information. Meta sequences with meta data are Bio::LocatableSeq | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | objects with additional methods to store that meta information. See | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | L<Bio::LocatableSeq> and L<Bio::Seq::MetaI>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | The meta information in this class can be a string of variable length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | and can be a complex structure. Blank values are undef or zero. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | Application specific implementations should inherit from this class to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | override and add to these methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | This class can be used for storing sequence quality values but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | Bio::Seq::Quality has named methods that make it easier. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | L<Bio::LocatableSeq>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | L<Bio::Seq::MetaI>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | L<Bio::Seq::Meta>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | L<Bio::Seq::Quality> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | =head1 NOTE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | This Bio::Seq::MetaI implementation inherits from Bio::LocatableSeq, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | itself inherits from Bio::PrimarySeq. It is not a Bio::SeqI, so bless-ing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | objects of this class into a Bio::SeqI or vice versa and will not work as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | expected (see bug 2262). This may be addressed in a future refactor of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | Bio::LocatableSeq. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | =head2 Support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | web: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | =head1 AUTHOR - Heikki Lehvaslaiho | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | Email heikki-at-bioperl-dot-org | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | =head1 CONTRIBUTORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | Chad Matsalla, bioinformatics@dieselwurks.com | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | Aaron Mackey, amackey@virginia.edu | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # Let the code begin... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | package Bio::Seq::Meta::Array; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 13 | $Bio::Seq::Meta::Array::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 13 | ▶ | use base qw(Bio::LocatableSeq Bio::Seq Bio::Seq::MetaI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 13 | our $DEFAULT_NAME = 'DEFAULT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 13 | our $GAP = '-'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 13 | our $META_GAP = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | Title : new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | Usage : $metaseq = Bio::Seq::Meta::Array->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ( -meta => 'aaaaaaaabbbbbbbb', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | -seq => 'TKLMILVSHIVILSRM' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | -id => 'human_id', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | -accession_number => 'S000012', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | Function: Constructor for Bio::Seq::Meta::Array class, meta data being in a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | string. Note that you can provide an empty quality string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | Returns : a new Bio::Seq::Meta::Array object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 370 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 370 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # run-time modification of @ISA is extremely evil (you should't pick your | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # interface on the fly); this has no obvious effect on any tests so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # commenting out - cjfields 2011-4-6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | #defined inheritance according to stated baseclass, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | #if undefined then will be PrimarySeq | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | #if (defined($args{'-baseclass'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # @ISA = ($args{'-baseclass'},"Bio::Seq::MetaI"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | #else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # @ISA = qw( Bio::LocatableSeq Bio::Seq Bio::Seq::MetaI ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 370 | my $self = $class->SUPER::new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 370 | my($meta, $forceflush) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | $self->_rearrange([qw(META | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | FORCE_FLUSH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | %args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 370 | $self->{'_meta'}->{$DEFAULT_NAME} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 370 | ▶ | $meta && $self->meta($meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 370 | ▶ | $forceflush && $self->force_flush($forceflush); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 370 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | =head2 meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | Title : meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | Usage : $meta_values = $obj->meta($values_string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | Function: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | Get and set method for the meta data starting from residue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | position one. Since it is dependent on the length of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | sequence, it needs to be manipulated after the sequence. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | The length of the returned value always matches the length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | of the sequence. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | Returns : reference to an array of meta data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | Args : new value, string or array ref, optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 33 | ▶ | sub meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
meta: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 33 | shift->named_meta($DEFAULT_NAME, shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | =head2 meta_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | Title : meta_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | Usage : $meta_values = $obj->meta_text($values_arrayref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | Function: Variant of meta() guarantied to return a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | representation of meta data. For details, see L<meta>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | Returns : a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | Args : new value, string or array ref, optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 19 | ▶ | sub meta_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
meta_text: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 19 | ▶ | return join ' ', map {0 unless $_} @{shift->meta(shift)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | =head2 named_meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | Title : named_meta() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | Usage : $meta_values = $obj->named_meta($name, $values_arrayref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | Function: A more general version of meta(). Each meta data set needs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | to be named. See also L<meta_names>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | Returns : reference to an array of meta data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | Args : scalar, name of the meta data set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | new value, string or array ref, optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 457 | ▶ | sub named_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
named_meta: called CC=9 SCAR=22.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 457 | my ($self, $name, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 457 | ▶ | $name ||= $DEFAULT_NAME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$name ||= $Bio::Seq::Meta::Array::DEFAULT_NAME
MC/DC0%0/2
$name ||= $Bio::Seq::Meta::Array::DEFAULT_NAME
$name
$Bio::Seq::Meta::Array::DEFAULT_NAME
Truth table33%1/3
A ||= B
A= $nameB= $Bio::Seq::Meta::Array::DEFAULT_NAME
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 457 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 367 | my ($arrayref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 367 | ▶ | if (ref $value eq 'ARRAY' ) { # array ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 358 | $arrayref = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | elsif (not ref($value)) { # scalar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 9 | $arrayref = [split /\s+/, $value]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $self->throw("I need a scalar or array ref, not [". ref($value). "]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # test for length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 367 | my $diff = $self->length - @{$arrayref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 367 | ▶ | if ($diff > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | foreach (1..$diff) { push @{$arrayref}, 0;} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 367 | $self->{'_meta'}->{$name} = $arrayref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | #$self->_test_gap_positions($name) if $self->verbose > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 457 | ▶ | $self->_do_flush if $self->force_flush; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 457 | ▶ | return $self->{'_meta'}->{$name} || (" " x $self->length); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'_meta'}{$name} || ' ' x $self->length
MC/DC0%0/2
$self->{'_meta'}{$name} || ' ' x $self->length
$self->{'_meta'}{$name}
' ' x $self->length
Truth table33%1/3
A || B
A= $self->{'_meta'}{$name}B= ' ' x $self->length
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | =head2 _test_gap_positions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | Title : _test_gap_positions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | Usage : $meta_values = $obj->_test_gap_positions($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | Function: Internal test for correct position of gap characters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | Gap being only '-' this time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | This method is called from named_meta() when setting meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | data but only if verbose is positive as this can be an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | expensive process on very long sequences. Set verbose(1) to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | see warnings when gaps do not align in sequence and meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | data and turn them into errors by setting verbose(2). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | Returns : true on success, prints warnings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | Args : none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | sub _test_gap_positions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_test_gap_positions: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $success = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | $self->seq || return $success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my $len = CORE::length($self->seq); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | for (my $i=0; $i < $len; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $s = substr $self->{seq}, $i, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $m = substr $self->{_meta}->{$name}, $i, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | $self->warn("Gap mismatch in column [". ($i+1). "] of [$name] meta data in seq [". $self->id. "]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$m eq '-' && $s ne $m && ($self->warn('Gap mismatch in column [' . ($i + 1) . "] of [$name] meta data in seq [" . $self->id . ']') && ($success = 0))
$m eq "-" and $s ne $m
$self->warn('Gap mismatch in column [' . ($i + 1) . "] of [$name] meta data in seq [" . $self->id . ']') and $success = 0
MC/DC0%0/4
$m eq '-' && $s ne $m && ($self->warn('Gap mismatch in column [' . ($i + 1) . "] of [$name] meta data in seq [" . $self->id . ']') && ($success = 0))
$m eq "-"
$s ne $m
$self->warn('Gap mismatch in column [' . ($i + 1) . "] of [$name] meta data in seq [" . $self->id . ']')
$success = 0
Truth table0%0/5
A and B && C and D
A= $m eq "-"B= $s ne $mC= $self->warn('Gap mismatch in column [' . ($i + 1) . "] of [$name] meta data in seq [" . $self->id . ']')D= $success = 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | and $success = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | if ($m eq '-') && $s ne $m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return $success; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | =head2 named_meta_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | Title : named_meta_text() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | Usage : $meta_values = $obj->named_meta_text($name, $values_arrayref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | Function: Variant of named_meta() guarantied to return a textual | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | representation of the named meta data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | For details, see L<meta>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | Returns : a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | Args : scalar, name of the meta data set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | new value, string or array ref, optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 3 | ▶ | sub named_meta_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
named_meta_text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 3 | return join ' ', @{shift->named_meta(@_)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | =head2 submeta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | Title : submeta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | Usage : $subset_of_meta_values = $obj->submeta(10, 20, $value_string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | $subset_of_meta_values = $obj->submeta(10, undef, $value_string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | Function: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | Get and set method for meta data for subsequences. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | Numbering starts from 1 and the number is inclusive, ie 1-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | are the first two residue of the sequence. Start cannot be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | larger than end but can be equal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | If the second argument is missing the returned values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | should extend to the end of the sequence. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | The return value may be a string or an array reference, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | depending on the implementation. If in doubt, use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | submeta_text() which is a variant guarantied to return a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | string. See L<submeta_text>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | Returns : A reference to an array or a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | Args : integer, start position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | integer, end position, optional when a third argument present | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | new value, string or array ref, optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 1032 | ▶ | sub submeta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submeta: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 1032 | shift->named_submeta($DEFAULT_NAME, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | =head2 submeta_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | Title : submeta_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | Usage : $meta_values = $obj->submeta_text(20, $value_string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | Function: Variant of submeta() guarantied to return a textual | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | representation of meta data. For details, see L<meta>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | Returns : a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | Args : new value, string or array ref, optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 4 | ▶ | sub submeta_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submeta_text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 4 | return join ' ', @{shift->named_submeta($DEFAULT_NAME, @_)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | =head2 named_submeta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | Title : named_submeta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | Usage : $subset_of_meta_values = $obj->named_submeta($name, 10, 20, $value_string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | $subset_of_meta_values = $obj->named_submeta($name, 10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | Function: Variant of submeta() guarantied to return a textual | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | representation of meta data. For details, see L<meta>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | Returns : A reference to an array or a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | Args : scalar, name of the meta data set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | integer, start position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | integer, end position, optional when a third argument present (can be undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | new value, string or array ref, optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1811 | ▶ | sub named_submeta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
named_submeta: called CC=16 SCAR=30.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1811 | my ($self, $name, $start, $end, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 1811 | ▶ | $name ||= $DEFAULT_NAME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$name ||= $Bio::Seq::Meta::Array::DEFAULT_NAME
MC/DC0%0/2
$name ||= $Bio::Seq::Meta::Array::DEFAULT_NAME
$name
$Bio::Seq::Meta::Array::DEFAULT_NAME
Truth table33%1/3
A ||= B
A= $nameB= $Bio::Seq::Meta::Array::DEFAULT_NAME
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1811 | ▶ | $start ||=1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$start ||= 1
MC/DC100%1/1
$start ||= 1
$start
Truth table100%2/2
A
A= $start
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 1811 | ▶ | $start =~ /^[+]?\d+$/ and $start > 0 or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$start =~ /^[+]?\d+$/ and $start > 0
MC/DC0%0/2
$start =~ /^[+]?\d+$/ and $start > 0
$start =~ /^[+]?\d+$/
$start > 0
Truth table33%1/3
A and B
A= $start =~ /^[+]?\d+$/B= $start > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | $self->throw("Need at least a positive integer start value"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1811 | $start--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 1811 | my $meta_len = scalar(@{$self->{_meta}->{$name}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 1811 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 4 | my $arrayref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 4 | ▶ | if (ref $value eq 'ARRAY' ) { # array ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $arrayref = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | elsif (not ref($value)) { # scalar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 4 | $arrayref = [split /\s+/, $value]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $self->throw("I need a space separated scalar or array ref, not [". ref($value). "]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | $self->warn("You are setting meta values beyond the length of the sequence\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | "[$start > ". length($self->seq)."] in sequence ". $self->id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 4 | ▶ | if $start + scalar @{$arrayref} -1 > $self->length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 4 | ▶ | $end or $end = @{$arrayref} + $start; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 4 | $end--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # test for length; pad if needed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 4 | my $diff = $end - $start - scalar @{$arrayref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 4 | ▶ | if ($diff > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | foreach (1..$diff) { push @{$arrayref}, $META_GAP} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 4 | @{$self->{_meta}->{$name}}[$start..$end] = @{$arrayref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 4 | ▶ | $self->_do_flush if $self->force_flush; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 4 | return $arrayref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # don't set by seq length; use meta array length instead; bug 2478 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1807 | ▶ | $end ||= $meta_len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$end ||= $meta_len
MC/DC0%0/2
$end ||= $meta_len
$end
$meta_len
Truth table66%2/3
A ||= B
A= $endB= $meta_len
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1807 | ▶ | if ($end > $meta_len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $self->warn("End is longer than meta sequence $name length; resetting to $meta_len"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $end = $meta_len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # warn but don't reset (push use of trunc() instead) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1807 | ▶ | $self->warn("End is longer than sequence length; use trunc() \n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | "if you want a fully truncated object") if $end > $self->length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 1807 | $end--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 1807 | return [@{$self->{_meta}->{$name}}[$start..$end]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | =head2 named_submeta_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | Title : named_submeta_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | Usage : $meta_values = $obj->named_submeta_text($name, 20, $value_string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | Function: Variant of submeta() guarantied to return a textual | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | representation of meta data. For details, see L<meta>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | Returns : a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | Args : scalar, name of the meta data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | Args : integer, start position, optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | integer, end position, optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | new value, string or array ref, optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 3 | ▶ | sub named_submeta_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
named_submeta_text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 3 | return join ' ', @{shift->named_submeta(@_)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | =head2 meta_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | Title : meta_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | Usage : @meta_names = $obj->meta_names() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | Function: Retrieves an array of meta data set names. The default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | (unnamed) set name is guarantied to be the first name if it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | contains any data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | Returns : an array of names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | Args : none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 35 | ▶ | sub meta_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
meta_names: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 35 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 35 | my @r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 35 | foreach ( sort keys %{$self->{'_meta'}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 53 | ▶ | push (@r, $_) unless $_ eq $DEFAULT_NAME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 35 | ▶ | unshift @r, $DEFAULT_NAME if $self->{'_meta'}->{$DEFAULT_NAME}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 35 | return @r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | =head2 meta_length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | Title : meta_length() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | Usage : $meta_len = $obj->meta_length(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | Function: return the number of elements in the meta set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | Returns : integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | Args : - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 4 | ▶ | sub meta_length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
meta_length: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 4 | return $self->named_meta_length($DEFAULT_NAME); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | =head2 named_meta_length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | Title : named_meta_length() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | Usage : $meeta_len = $obj->named_meta_length($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | Function: return the number of elements in the named meta set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | Returns : integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | Args : - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 100 | ▶ | sub named_meta_length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
named_meta_length: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 100 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 100 | ▶ | $name ||= $DEFAULT_NAME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$name ||= $Bio::Seq::Meta::Array::DEFAULT_NAME
MC/DC0%0/2
$name ||= $Bio::Seq::Meta::Array::DEFAULT_NAME
$name
$Bio::Seq::Meta::Array::DEFAULT_NAME
Truth table33%1/3
A ||= B
A= $nameB= $Bio::Seq::Meta::Array::DEFAULT_NAME
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 100 | return scalar @{$self->{'_meta'}->{$name}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | =head2 force_flush | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | Title : force_flush() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | Usage : $force_flush = $obj->force_flush(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | Function: Automatically pad with empty values or truncate meta values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | to sequence length. Not done by default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | Returns : boolean 1 or 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | Args : optional boolean value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | Note that if you turn this forced padding off, the previously padded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | values are not changed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 481 | ▶ | sub force_flush { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
force_flush: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 481 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 481 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 7 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 5 | $self->{force_flush} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 5 | $self->_do_flush; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | $self->{force_flush} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 481 | return $self->{force_flush}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | =head2 _do_flush | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | Title : _do_flush | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | Function: internal method to do the force that meta values are same | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | length as sequence . Called from L<force_flush> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | Returns : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | Args : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 26 | ▶ | sub _do_flush { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_do_flush: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 26 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 26 | foreach my $name ($self->meta_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | #print "seq: ", $self->length , " ", $name, ": ", $self->named_meta_length($name), "======\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # elongnation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 36 | ▶ | if ($self->length > $self->named_meta_length($name)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 10 | my $diff = $self->length - $self->named_meta_length($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 10 | foreach (1..$diff) { push @{$self->{'_meta'}->{$name}}, $META_GAP} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | # truncation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | elsif ( $self->length < $self->named_meta_length($name) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 4 | $self->{_meta}->{$name} = [@{$self->{_meta}->{$name}}[0..($self->length-1)]] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | =head2 is_flush | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | Title : is_flush | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | Usage : $is_flush = $obj->is_flush() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | or $is_flush = $obj->is_flush($my_meta_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | Function: Boolean to tell if all meta values are in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | flush with the sequence length. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | Returns true if force_flush() is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | Set verbosity to a positive value to see failed meta sets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | Returns : boolean 1 or 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | Args : optional name of the meta set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 13 | ▶ | sub is_flush { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_flush: called CC=9 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 13 | my ($self, $name) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 13 | ▶ | return 1 if $self->force_flush; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 8 | my $sticky = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 8 | ▶ | if ($name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | $sticky .= "$name " if $self->length != $self->named_meta_length($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 8 | foreach my $m ($self->meta_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 14 | ▶ | $sticky .= "$m " if ($self->named_meta_length($m) > 0) && ($self->length != $self->named_meta_length($m)) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->named_meta_length($m) > 0 and $self->length != $self->named_meta_length($m)
MC/DC0%0/2
$self->named_meta_length($m) > 0 and $self->length != $self->named_meta_length($m)
$self->named_meta_length($m) > 0
$self->length != $self->named_meta_length($m)
Truth table66%2/3
A and B
A= $self->named_meta_length($m) > 0B= $self->length != $self->named_meta_length($m)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 8 | ▶ | if ($sticky) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | print "These meta set are not flush: $sticky\n" if $self->verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 8 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | =head1 Bio::PrimarySeqI methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | =head2 revcom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | Title : revcom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | Usage : $newseq = $seq->revcom(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | Function: Produces a new Bio::Seq::MetaI implementing object where | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | the order of residues and their meta information is reversed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | Returns : A new (fresh) Bio::Seq::Meta object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | Args : none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | Throws : if the object returns false on is_flush() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | Note: The method does nothing to meta values, it reorders them, only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 8 | ▶ | sub revcom { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
revcom: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 8 | ▶ | $self->throw("Can not get a reverse complement. The object is not flush.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | unless $self->is_flush; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 8 | my $new = $self->SUPER::revcom; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 8 | my $end = $self->length - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 14 | $new->{_meta}->{$_} = [ reverse @{$self->{_meta}->{$_}}[0..$end]] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 8 | } keys %{$self->{_meta}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 8 | return $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | =head2 trunc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | Title : trunc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | Usage : $subseq = $seq->trunc(10,100); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | Function: Provides a truncation of a sequence together with meta data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | Returns : a fresh Bio::Seq::Meta implementing object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | Args : Two integers denoting first and last residue of the sub-sequence. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 37 | ▶ | sub trunc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trunc: called CC=7 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 37 | my ($self, $start, $end) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | # test arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 37 | ▶ | $start =~ /^[+]?\d+$/ and $start > 0 or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$start =~ /^[+]?\d+$/ and $start > 0
MC/DC0%0/2
$start =~ /^[+]?\d+$/ and $start > 0
$start =~ /^[+]?\d+$/
$start > 0
Truth table33%1/3
A and B
A= $start =~ /^[+]?\d+$/B= $start > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | $self->throw("Need at least a positive integer start value as start; got [$start]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 37 | ▶ | $end =~ /^[+]?\d+$/ and $end > 0 or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$end =~ /^[+]?\d+$/ and $end > 0
MC/DC0%0/2
$end =~ /^[+]?\d+$/ and $end > 0
$end =~ /^[+]?\d+$/
$end > 0
Truth table33%1/3
A and B
A= $end =~ /^[+]?\d+$/B= $end > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | $self->throw("Need at least a positive integer start value as end; got [$end]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 37 | ▶ | $end >= $start or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | $self->throw("End position has to be larger or equal to start; got [$start..$end]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 37 | ▶ | $end <= $self->length or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | $self->throw("End position can not be larger than sequence length; got [$end]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 37 | my $new = $self->SUPER::trunc($start, $end); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 37 | $start--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 37 | $end--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 73 | $new->{_meta}->{$_} = [@{$self->{_meta}->{$_}}[$start..$end]] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 37 | } keys %{$self->{_meta}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 37 | return $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||