| 1 | # BioPerl module for Bio::Seq::LargeLocatableSeq | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Cared for by Albert Vilella | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # based on the Bio::LargePrimarySeq module | ||||||||||||||||||||||||||||
| 8 | # by Ewan Birney <birney@sanger.ac.uk> | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # and the Bio::LocatableSeq module | ||||||||||||||||||||||||||||
| 11 | # by Ewan Birney <birney@sanger.ac.uk> | ||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||
| 13 | # Copyright Albert Vilella | ||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||
| 15 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 NAME | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | Bio::Seq::LargeLocatableSeq - LocatableSeq object that stores sequence as | ||||||||||||||||||||||||||||
| 22 | files in the tempdir | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # normal primary seq usage | ||||||||||||||||||||||||||||
| 27 | use Bio::Seq::LargeLocatableSeq; | ||||||||||||||||||||||||||||
| 28 | my $seq = Bio::Seq::LargeLocatableSeq->new(-seq => "CAGT-GGT", | ||||||||||||||||||||||||||||
| 29 | -id => "seq1", | ||||||||||||||||||||||||||||
| 30 | -start => 1, | ||||||||||||||||||||||||||||
| 31 | -end => 7); | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | Bio::Seq::LargeLocatableSeq - object with start/end points on it that | ||||||||||||||||||||||||||||
| 36 | can be projected into a MSA or have coordinates relative to another | ||||||||||||||||||||||||||||
| 37 | seq. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | This object, unlike Bio::LocatableSeq, stores a sequence as a series | ||||||||||||||||||||||||||||
| 40 | of files in a temporary directory. The aim is to allow someone the | ||||||||||||||||||||||||||||
| 41 | ability to store very large sequences (eg, E<gt> 100MBases) in a file | ||||||||||||||||||||||||||||
| 42 | system without running out of memory (eg, on a 64 MB real memory | ||||||||||||||||||||||||||||
| 43 | machine!). | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | Of course, to actually make use of this functionality, the programs | ||||||||||||||||||||||||||||
| 46 | which use this object B<must> not call $primary_seq-E<gt>seq otherwise | ||||||||||||||||||||||||||||
| 47 | the entire sequence will come out into memory and probably crash your | ||||||||||||||||||||||||||||
| 48 | machine. However, calls like $primary_seq-E<gt>subseq(10,100) will cause | ||||||||||||||||||||||||||||
| 49 | only 90 characters to be brought into real memory. | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head1 FEEDBACK | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =head2 Mailing Lists | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||
| 56 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||
| 57 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||
| 60 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head2 Support | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||
| 69 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||
| 70 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||
| 71 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||
| 76 | of the bugs and their resolution. Bug reports can be submitted via | ||||||||||||||||||||||||||||
| 77 | the web: | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head1 AUTHOR - Albert Vilella | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Email avilella-AT-gmail-DOT-com | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =head1 APPENDIX | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||
| 88 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | # Let the code begin... | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | package Bio::Seq::LargeLocatableSeq; | ||||||||||||||||||||||||||||
| 96 | 4 | $Bio::Seq::LargeLocatableSeq::VERSION = '1.7.8'; | |||||||||||||||||||||||||||
| 97 | 4 | ▶ | use vars qw($AUTOLOAD); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 98 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 4 | ▶ | use base qw(Bio::Seq::LargePrimarySeq Bio::LocatableSeq Bio::Root::IO); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head2 new | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | Title : new | ||||||||||||||||||||||||||||
| 107 | Usage : my $obj = Bio::Seq::LargeLocatableSeq->new(); | ||||||||||||||||||||||||||||
| 108 | Function: Builds a new Bio::Seq::LargeLocatableSeq object | ||||||||||||||||||||||||||||
| 109 | Returns : an instance of Bio::Seq::LargeLocatableSeq | ||||||||||||||||||||||||||||
| 110 | Args : | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||
| 116 | 8 | my ($class, %params) = @_; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | # don't let PrimarySeq set seq until we have | ||||||||||||||||||||||||||||
| 119 | # opened filehandle | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 8 | ▶ | my $seq = $params{'-seq'} || $params{'-SEQ'}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$params{'-seq'} || $params{'-SEQ'}
MC/DC50%1/2
$params{'-seq'} || $params{'-SEQ'}
$params{'-seq'}
$params{'-SEQ'}
Truth table66%2/3
A || B
A= $params{'-seq'}B= $params{'-SEQ'}
| |||||||||||||||||||||||||||||
| 122 | 8 | ▶ | if($seq ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 1 | delete $params{'-seq'}; | |||||||||||||||||||||||||||
| 124 | 1 | delete $params{'-SEQ'}; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | 8 | my $self = $class->SUPER::new(%params); | |||||||||||||||||||||||||||
| 127 | 8 | ▶ | my $mapping = exists $params{'-mapping'} ? $params{'-mapping'} : [1,1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 8 | $self->mapping($mapping); | |||||||||||||||||||||||||||
| 129 | 8 | $self->_initialize_io(%params); | |||||||||||||||||||||||||||
| 130 | 8 | my $tempdir = $self->tempdir( CLEANUP => 1); | |||||||||||||||||||||||||||
| 131 | 8 | my ($tfh,$file) = $self->tempfile( DIR => $tempdir ); | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 8 | ▶ | $tfh && $self->_fh($tfh); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 8 | ▶ | $file && $self->_filename($file); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 8 | $self->length(0); | |||||||||||||||||||||||||||
| 136 | 8 | ▶ | $seq && $self->seq($seq); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 8 | return $self; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =head2 length | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | Title : length | ||||||||||||||||||||||||||||
| 145 | Usage : | ||||||||||||||||||||||||||||
| 146 | Function: | ||||||||||||||||||||||||||||
| 147 | Example : | ||||||||||||||||||||||||||||
| 148 | Returns : | ||||||||||||||||||||||||||||
| 149 | Args : | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =cut | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 146 | ▶ | sub length { | ||||||||||||||||||||||||||
|
Subroutine
length: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 155 | 146 | my ($obj,$value) = @_; | |||||||||||||||||||||||||||
| 156 | 146 | ▶ | if( defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 24 | $obj->{'length'} = $value; | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 146 | ▶ | return (defined $obj->{'length'}) ? $obj->{'length'} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | =head2 seq | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | Title : seq | ||||||||||||||||||||||||||||
| 166 | Usage : | ||||||||||||||||||||||||||||
| 167 | Function: | ||||||||||||||||||||||||||||
| 168 | Example : | ||||||||||||||||||||||||||||
| 169 | Returns : | ||||||||||||||||||||||||||||
| 170 | Args : | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =cut | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 50 | ▶ | sub seq { | ||||||||||||||||||||||||||
|
Subroutine
seq: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 176 | 50 | my ($self, $data) = @_; | |||||||||||||||||||||||||||
| 177 | 50 | ▶ | if( defined $data ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 1 | ▶ | if( $self->length() == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 1 | $self->add_sequence_as_string($data); | |||||||||||||||||||||||||||
| 180 | } else { | ||||||||||||||||||||||||||||
| 181 | 0 | $self->warn("Trying to reset the seq string, cannot do this with a LargeLocatableSeq - must allocate a new object"); | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | 50 | return $self->subseq(1,$self->length); | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | =head2 subseq | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | Title : subseq | ||||||||||||||||||||||||||||
| 191 | Usage : | ||||||||||||||||||||||||||||
| 192 | Function: | ||||||||||||||||||||||||||||
| 193 | Example : | ||||||||||||||||||||||||||||
| 194 | Returns : | ||||||||||||||||||||||||||||
| 195 | Args : | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | =cut | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 50 | ▶ | sub subseq{ | ||||||||||||||||||||||||||
|
Subroutine
subseq: called CC=19 SCAR=52.4
Pod
documented
| |||||||||||||||||||||||||||||
| 201 | 50 | my ($self,$start,$end) = @_; | |||||||||||||||||||||||||||
| 202 | 50 | my $string; | |||||||||||||||||||||||||||
| 203 | 50 | my $fh = $self->_fh(); | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 50 | ▶ | if( ref($start) && $start->isa('Bio::LocationI') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $start and $start->isa("Bio::LocationI")
MC/DC0%0/2
ref $start and $start->isa("Bio::LocationI")
ref $start
$start->isa("Bio::LocationI")
Truth table33%1/3
A and B
A= ref $startB= $start->isa("Bio::LocationI")
| |||||||||||||||||||||||||||||
| 206 | 0 | my $loc = $start; | |||||||||||||||||||||||||||
| 207 | 0 | ▶ | if( $loc->length == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 208 | 0 | $self->warn("Expect location lengths to be > 0"); | |||||||||||||||||||||||||||
| 209 | 0 | return ''; | |||||||||||||||||||||||||||
| 210 | } elsif( $loc->end < $loc->start ) { | ||||||||||||||||||||||||||||
| 211 | # what about circular seqs | ||||||||||||||||||||||||||||
| 212 | 0 | $self->warn("Expect location start to come before location end"); | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | 0 | my $seq = ''; | |||||||||||||||||||||||||||
| 215 | 0 | ▶ | if( $loc->isa('Bio::Location::SplitLocationI') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 0 | foreach my $subloc ( $loc->sub_Location ) { | |||||||||||||||||||||||||||
| 217 | 0 | ▶ | if(! seek($fh,$subloc->start() - 1,0)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 0 | $self->throw("Unable to seek on file $start:$end $!"); | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | 0 | my $ret = read($fh, $string, $subloc->length()); | |||||||||||||||||||||||||||
| 221 | 0 | ▶ | if( !defined $ret ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | 0 | $self->throw("Unable to read $start:$end $!"); | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if( $subloc->strand < 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | # $string = Bio::PrimarySeq->new(-seq => $string)->revcom()->seq(); | ||||||||||||||||||||||||||||
| 226 | 0 | $string = Bio::Seq::LargePrimarySeq->new(-seq => $string)->revcom()->seq(); | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | 0 | $seq .= $string; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | } else { | ||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if(! seek($fh,$loc->start()-1,0)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 0 | $self->throw("Unable to seek on file ".$loc->start.":". | |||||||||||||||||||||||||||
| 233 | $loc->end ." $!"); | ||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | 0 | my $ret = read($fh, $string, $loc->length()); | |||||||||||||||||||||||||||
| 236 | 0 | ▶ | if( !defined $ret ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 0 | $self->throw("Unable to read ".$loc->start.":". | |||||||||||||||||||||||||||
| 238 | $loc->end ." $!"); | ||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | 0 | $seq = $string; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if( defined $loc->strand && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $loc->strand and $loc->strand < 0
MC/DC0%0/2
defined $loc->strand and $loc->strand < 0
defined $loc->strand
$loc->strand < 0
Truth table0%0/3
A and B
A= defined $loc->strandB= $loc->strand < 0
| |||||||||||||||||||||||||||||
| 243 | $loc->strand < 0 ) { | ||||||||||||||||||||||||||||
| 244 | # $seq = Bio::PrimarySeq->new(-seq => $string)->revcom()->seq(); | ||||||||||||||||||||||||||||
| 245 | 0 | $seq = Bio::Seq::LargePrimarySeq->new(-seq => $seq)->revcom()->seq(); | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | 0 | return $seq; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | 50 | ▶ | if( $start <= 0 || $end > $self->length ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$start <= 0 or $end > $self->length
MC/DC0%0/2
$start <= 0 or $end > $self->length
$start <= 0
$end > $self->length
Truth table33%1/3
A or B
A= $start <= 0B= $end > $self->length
| |||||||||||||||||||||||||||||
| 250 | 0 | $self->throw("Attempting to get a subseq out of range $start:$end vs ". | |||||||||||||||||||||||||||
| 251 | $self->length); | ||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | 50 | ▶ | if( $end < $start ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 0 | $self->throw("Attempting to subseq with end ($end) less than start ($start). To revcom use the revcom function with trunc"); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 50 | ▶ | if(! seek($fh,$start-1,0)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | 0 | $self->throw("Unable to seek on file $start:$end $!"); | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | 50 | my $ret = read($fh, $string, $end-$start+1); | |||||||||||||||||||||||||||
| 261 | 50 | ▶ | if( !defined $ret ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | 0 | $self->throw("Unable to read $start:$end $!"); | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | 50 | return $string; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | =head2 add_sequence_as_string | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | Title : add_sequence_as_string | ||||||||||||||||||||||||||||
| 271 | Usage : $seq->add_sequence_as_string("CATGAT"); | ||||||||||||||||||||||||||||
| 272 | Function: Appends additional residues to an existing LargeLocatableSeq object. | ||||||||||||||||||||||||||||
| 273 | This allows one to build up a large sequence without storing | ||||||||||||||||||||||||||||
| 274 | entire object in memory. | ||||||||||||||||||||||||||||
| 275 | Returns : Current length of sequence | ||||||||||||||||||||||||||||
| 276 | Args : string to append | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | =cut | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 8 | ▶ | sub add_sequence_as_string{ | ||||||||||||||||||||||||||
|
Subroutine
add_sequence_as_string: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 281 | 8 | my ($self,$str) = @_; | |||||||||||||||||||||||||||
| 282 | 8 | my $len = $self->length + CORE::length($str); | |||||||||||||||||||||||||||
| 283 | 8 | my $fh = $self->_fh(); | |||||||||||||||||||||||||||
| 284 | 8 | ▶ | if(! seek($fh,0,2)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | 0 | $self->throw("Unable to seek end of file: $!"); | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | 8 | $self->_print($str); | |||||||||||||||||||||||||||
| 288 | 8 | $self->length($len); | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =head2 _filename | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | Title : _filename | ||||||||||||||||||||||||||||
| 295 | Usage : $obj->_filename($newval) | ||||||||||||||||||||||||||||
| 296 | Function: | ||||||||||||||||||||||||||||
| 297 | Example : | ||||||||||||||||||||||||||||
| 298 | Returns : value of _filename | ||||||||||||||||||||||||||||
| 299 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | =cut | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 60 | ▶ | sub _filename{ | ||||||||||||||||||||||||||
|
Subroutine
_filename: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 305 | 60 | my ($obj,$value) = @_; | |||||||||||||||||||||||||||
| 306 | 60 | ▶ | if( defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | 16 | $obj->{'_filename'} = $value; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | 60 | return $obj->{'_filename'}; | |||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | =head2 alphabet | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | Title : alphabet | ||||||||||||||||||||||||||||
| 317 | Usage : $obj->alphabet($newval) | ||||||||||||||||||||||||||||
| 318 | Function: | ||||||||||||||||||||||||||||
| 319 | Example : | ||||||||||||||||||||||||||||
| 320 | Returns : value of alphabet | ||||||||||||||||||||||||||||
| 321 | Args : newvalue (optional) | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | =cut | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 0 | ▶ | sub alphabet{ | ||||||||||||||||||||||||||
|
Subroutine
alphabet: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 327 | 0 | my ($self,$value) = @_; | |||||||||||||||||||||||||||
| 328 | 0 | ▶ | if( defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | 0 | $self->SUPER::alphabet($value); | |||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | 0 | ▶ | return $self->SUPER::alphabet() || 'dna'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->SUPER::alphabet || 'dna'
MC/DC0%0/1
$self->SUPER::alphabet || 'dna'
$self->SUPER::alphabet
Truth table0%0/2
A
A= $self->SUPER::alphabet
| |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 10 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 336 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 337 | 10 | my $fh = $self->_fh(); | |||||||||||||||||||||||||||
| 338 | 10 | ▶ | close($fh) if( defined $fh ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | # this should be handled by Tempfile removal, but we'll unlink anyways. | ||||||||||||||||||||||||||||
| 340 | 10 | ▶ | unlink $self->_filename() if defined $self->_filename() && -e $self->_filename; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->_filename and -e $self->_filename
MC/DC50%1/2
defined $self->_filename and -e $self->_filename
defined $self->_filename
-e $self->_filename
Truth table66%2/3
A and B
A= defined $self->_filenameB= -e $self->_filename
| |||||||||||||||||||||||||||||
| 341 | 10 | $self->SUPER::DESTROY(); | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | 4 | 1; | |||||||||||||||||||||||||||