| 1 | # | ||||||||||||||||||||||||||||||||
| 2 | # Copyright (c) 1997-2001 bioperl, Chad Matsalla. All Rights Reserved. | ||||||||||||||||||||||||||||||||
| 3 | # This module is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||
| 4 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||
| 6 | # Copyright Chad Matsalla | ||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||
| 8 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | Bio::SeqIO::scf - .scf file input/output stream | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | Do not use this module directly. Use it via the Bio::SeqIO class, see | ||||||||||||||||||||||||||||||||
| 19 | L<Bio::SeqIO> for more information. | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | This object can transform .scf files to and from Bio::Seq::SequenceTrace | ||||||||||||||||||||||||||||||||
| 24 | objects. Mechanisms are present to retrieve trace data from scf | ||||||||||||||||||||||||||||||||
| 25 | files. | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||
| 32 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||||||||||||||||||||||||
| 33 | of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||
| 36 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | =head2 Support | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||
| 45 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||
| 46 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||
| 47 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||
| 52 | the bugs and their resolution. Bug reports can be submitted via | ||||||||||||||||||||||||||||||||
| 53 | the web: | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | =head1 AUTHOR Chad Matsalla | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | Chad Matsalla | ||||||||||||||||||||||||||||||||
| 60 | bioinformatics@dieselwurks.com | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | =head1 CONTRIBUTORS | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | Jason Stajich, jason@bioperl.org | ||||||||||||||||||||||||||||||||
| 65 | Tony Cox, avc@sanger.ac.uk | ||||||||||||||||||||||||||||||||
| 66 | Heikki Lehvaslaiho, heikki-at-bioperl-dot-org | ||||||||||||||||||||||||||||||||
| 67 | Nancy Hansen, nhansen at mail.nih.gov | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | The rest of the documentation details each of the object | ||||||||||||||||||||||||||||||||
| 72 | methods. Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | # Let the code begin... | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | package Bio::SeqIO::scf; | ||||||||||||||||||||||||||||||||
| 79 | 2 | $Bio::SeqIO::scf::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | use vars qw($DEFAULT_QUALITY); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | use Bio::Seq::SeqFactory; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | use Bio::Seq::SequenceTrace; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | use Bio::Annotation::Comment; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 85 | 2 | ▶ | use Dumpvalue; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 2 | my $dumper = Dumpvalue->new(); | |||||||||||||||||||||||||||||||
| 88 | 2 | $dumper->veryCompact(1); | |||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 91 | 2 | $DEFAULT_QUALITY= 10; | |||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 2 | ▶ | use base qw(Bio::SeqIO); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | 25 | ▶ | sub _initialize { | ||||||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||
| 97 | 25 | my($self,@args) = @_; | |||||||||||||||||||||||||||||||
| 98 | 25 | $self->SUPER::_initialize(@args); | |||||||||||||||||||||||||||||||
| 99 | 25 | ▶ | if( ! defined $self->sequence_factory ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 100 | 25 | $self->sequence_factory(Bio::Seq::SeqFactory->new | |||||||||||||||||||||||||||||||
| 101 | (-verbose => $self->verbose(), | ||||||||||||||||||||||||||||||||
| 102 | -type => 'Bio::Seq::Quality')); | ||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||
| 104 | 25 | binmode $self->_fh; # for the Win32/Mac crowds | |||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | =head2 next_seq() | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | Title : next_seq() | ||||||||||||||||||||||||||||||||
| 110 | Usage : $scf = $stream->next_seq() | ||||||||||||||||||||||||||||||||
| 111 | Function: returns the next scf sequence in the stream | ||||||||||||||||||||||||||||||||
| 112 | Returns : a Bio::Seq::SequenceTrace object | ||||||||||||||||||||||||||||||||
| 113 | Args : NONE | ||||||||||||||||||||||||||||||||
| 114 | Notes : Fills the interface specification for SeqIO. | ||||||||||||||||||||||||||||||||
| 115 | The SCF specification does not provide for having more then | ||||||||||||||||||||||||||||||||
| 116 | one sequence in a given scf. So once the filehandle has been open | ||||||||||||||||||||||||||||||||
| 117 | and passed to SeqIO do not expect to run this function more then | ||||||||||||||||||||||||||||||||
| 118 | once on a given scf unless you embraced and extended the SCF | ||||||||||||||||||||||||||||||||
| 119 | standard. SCF comments are accessible through the Bio::SeqI | ||||||||||||||||||||||||||||||||
| 120 | interface method annotation(). | ||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | =cut | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | #' | ||||||||||||||||||||||||||||||||
| 125 | 15 | ▶ | sub next_seq { | ||||||||||||||||||||||||||||||
|
Subroutine
next_seq: called CC=17 SCAR=30.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 126 | 15 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 127 | 15 | my ($seq, $seqc, $fh, $buffer, $offset, $length, $read_bytes, @read, | |||||||||||||||||||||||||||||||
| 128 | %names); | ||||||||||||||||||||||||||||||||
| 129 | # set up a filehandle to read in the scf | ||||||||||||||||||||||||||||||||
| 130 | 15 | ▶ | return if $self->{_readfile}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 131 | 15 | $fh = $self->_fh(); | |||||||||||||||||||||||||||||||
| 132 | 15 | ▶ | unless ($fh) { # simulate the <> function | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ( !fileno(ARGV) or eof(ARGV) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not fileno ARGV or eof ARGV
MC/DC0%0/2
not fileno ARGV or eof ARGV
not fileno ARGV
eof ARGV
Truth table0%0/3
not(A) or B
A= not fileno ARGVB= eof ARGV
| |||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | return unless my $ARGV = shift; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | open(ARGV,$ARGV) or | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 136 | $self->throw("Could not open $ARGV for SCF stream reading $!"); | ||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||
| 138 | 0 | $fh = \*ARGV; | |||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||
| 140 | 15 | ▶ | return unless read $fh, $buffer, 128; # no exception; probably end of file | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 141 | # now, the master data structure will be the creator | ||||||||||||||||||||||||||||||||
| 142 | 15 | my $creator; | |||||||||||||||||||||||||||||||
| 143 | # he first thing to do is parse the header. This is common | ||||||||||||||||||||||||||||||||
| 144 | # among all versions of scf. | ||||||||||||||||||||||||||||||||
| 145 | # the rest of the the information is different between the | ||||||||||||||||||||||||||||||||
| 146 | # the different versions of scf. | ||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | 15 | $creator->{header} = $self->_get_header($buffer); | |||||||||||||||||||||||||||||||
| 149 | 15 | ▶ | if ($creator->{header}->{'version'} lt "3.00") { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 150 | 4 | $self->debug("scf.pm is working with a version 2 scf.\n"); | |||||||||||||||||||||||||||||||
| 151 | # first gather the trace information | ||||||||||||||||||||||||||||||||
| 152 | $length = $creator->{header}->{'samples'} * | ||||||||||||||||||||||||||||||||
| 153 | 4 | $creator->{header}->{sample_size}*4; | |||||||||||||||||||||||||||||||
| 154 | $buffer = $self->read_from_buffer($fh, $buffer, $length, | ||||||||||||||||||||||||||||||||
| 155 | 4 | $creator->{header}->{samples_offset}); | |||||||||||||||||||||||||||||||
| 156 | # @read = unpack "n$length",$buffer; | ||||||||||||||||||||||||||||||||
| 157 | # these traces need to be split | ||||||||||||||||||||||||||||||||
| 158 | # returns a reference to a hash | ||||||||||||||||||||||||||||||||
| 159 | $creator->{traces} = $self->_parse_v2_traces( | ||||||||||||||||||||||||||||||||
| 160 | 4 | $buffer,$creator->{header}->{sample_size}); | |||||||||||||||||||||||||||||||
| 161 | # now go and get the base information | ||||||||||||||||||||||||||||||||
| 162 | 4 | $offset = $creator->{header}->{bases_offset}; | |||||||||||||||||||||||||||||||
| 163 | 4 | $length = ($creator->{header}->{bases} * 12); | |||||||||||||||||||||||||||||||
| 164 | 4 | seek $fh,$offset,0; | |||||||||||||||||||||||||||||||
| 165 | 4 | $buffer = $self->read_from_buffer($fh,$buffer,$length,$creator->{header}->{bases_offset}); | |||||||||||||||||||||||||||||||
| 166 | # now distill the information into its fractions. | ||||||||||||||||||||||||||||||||
| 167 | # the old way : $self->_set_v2_bases($buffer); | ||||||||||||||||||||||||||||||||
| 168 | # ref to an array, ref to a hash, string | ||||||||||||||||||||||||||||||||
| 169 | ($creator->{peak_indices}, | ||||||||||||||||||||||||||||||||
| 170 | $creator->{qualities}, | ||||||||||||||||||||||||||||||||
| 171 | $creator->{sequence}, | ||||||||||||||||||||||||||||||||
| 172 | 4 | $creator->{accuracies}) = $self->_parse_v2_bases($buffer); | |||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | } else { | ||||||||||||||||||||||||||||||||
| 175 | 11 | $self->debug("scf.pm is working with a version 3+ scf.\n"); | |||||||||||||||||||||||||||||||
| 176 | 11 | my $transformed_read; | |||||||||||||||||||||||||||||||
| 177 | 11 | my $current_read_position = $creator->{header}->{sample_offset}; | |||||||||||||||||||||||||||||||
| 178 | $length = $creator->{header}->{'samples'}* | ||||||||||||||||||||||||||||||||
| 179 | 11 | $creator->{header}->{sample_size}; | |||||||||||||||||||||||||||||||
| 180 | # $dumper->dumpValue($creator->{header}); | ||||||||||||||||||||||||||||||||
| 181 | 11 | foreach (qw(a c g t)) { | |||||||||||||||||||||||||||||||
| 182 | 44 | $buffer = $self->read_from_buffer($fh,$buffer,$length,$current_read_position); | |||||||||||||||||||||||||||||||
| 183 | 44 | my $byte = "n"; | |||||||||||||||||||||||||||||||
| 184 | 44 | ▶ | if ($creator->{header}->{sample_size} == 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 185 | 0 | $byte = "c"; | |||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||
| 187 | 44 | @read = unpack "${byte}${length}",$buffer; | |||||||||||||||||||||||||||||||
| 188 | # this little spurt of nonsense is because | ||||||||||||||||||||||||||||||||
| 189 | # the trace values are given in the binary | ||||||||||||||||||||||||||||||||
| 190 | # file as unsigned shorts but they really | ||||||||||||||||||||||||||||||||
| 191 | # are signed deltas. 30000 is an arbitrary number | ||||||||||||||||||||||||||||||||
| 192 | # (will there be any traces with a given | ||||||||||||||||||||||||||||||||
| 193 | # point greater then 30000? I hope not. | ||||||||||||||||||||||||||||||||
| 194 | # once the read is read, it must be changed | ||||||||||||||||||||||||||||||||
| 195 | # from relative | ||||||||||||||||||||||||||||||||
| 196 | 44 | foreach (@read) { | |||||||||||||||||||||||||||||||
| 197 | 424924 | ▶ | if ($_ > 30000) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 198 | 142333 | $_ -= 65536; | |||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||
| 201 | 44 | $transformed_read = $self->_delta(\@read,"backward"); | |||||||||||||||||||||||||||||||
| 202 | # For 8-bit data we need to emulate a signed/unsigned | ||||||||||||||||||||||||||||||||
| 203 | # cast that is implicit in the C implementations..... | ||||||||||||||||||||||||||||||||
| 204 | 44 | ▶ | if ($creator->{header}->{sample_size} == 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 205 | 0 | foreach (@{$transformed_read}) { | |||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | $_ += 256 if ($_ < 0); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||
| 209 | 44 | $current_read_position += $length; | |||||||||||||||||||||||||||||||
| 210 | 44 | $creator->{'traces'}->{$_} = join(' ',@{$transformed_read}); | |||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||
| 213 | # now go and get the peak index information | ||||||||||||||||||||||||||||||||
| 214 | 11 | $offset = $creator->{header}->{bases_offset}; | |||||||||||||||||||||||||||||||
| 215 | 11 | $length = ($creator->{header}->{bases} * 4); | |||||||||||||||||||||||||||||||
| 216 | 11 | $buffer = $self->read_from_buffer($fh,$buffer,$length,$offset); | |||||||||||||||||||||||||||||||
| 217 | 11 | $creator->{peak_indices} = $self->_get_v3_peak_indices($buffer); | |||||||||||||||||||||||||||||||
| 218 | 11 | $offset += $length; | |||||||||||||||||||||||||||||||
| 219 | # now go and get the accuracy information | ||||||||||||||||||||||||||||||||
| 220 | 11 | $buffer = $self->read_from_buffer($fh,$buffer,$length,$offset); | |||||||||||||||||||||||||||||||
| 221 | 11 | $creator->{accuracies} = $self->_get_v3_base_accuracies($buffer); | |||||||||||||||||||||||||||||||
| 222 | # OK, now go and get the base information. | ||||||||||||||||||||||||||||||||
| 223 | 11 | $offset += $length; | |||||||||||||||||||||||||||||||
| 224 | 11 | $length = $creator->{header}->{bases}; | |||||||||||||||||||||||||||||||
| 225 | 11 | $buffer = $self->read_from_buffer($fh,$buffer,$length,$offset); | |||||||||||||||||||||||||||||||
| 226 | 11 | $creator->{'sequence'} = unpack("a$length",$buffer); | |||||||||||||||||||||||||||||||
| 227 | # now, finally, extract the calls from the accuracy information. | ||||||||||||||||||||||||||||||||
| 228 | $creator->{qualities} = $self->_get_v3_quality( | ||||||||||||||||||||||||||||||||
| 229 | 11 | $creator->{'sequence'},$creator->{accuracies}); | |||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||
| 231 | # now go and get the comment information | ||||||||||||||||||||||||||||||||
| 232 | 15 | $offset = $creator->{header}->{comments_offset}; | |||||||||||||||||||||||||||||||
| 233 | 15 | seek $fh,$offset,0; | |||||||||||||||||||||||||||||||
| 234 | 15 | $length = $creator->{header}->{comment_size}; | |||||||||||||||||||||||||||||||
| 235 | 15 | $buffer = $self->read_from_buffer($fh,$buffer,$length); | |||||||||||||||||||||||||||||||
| 236 | 15 | $creator->{comments} = $self->_get_comments($buffer); | |||||||||||||||||||||||||||||||
| 237 | 74 | my @name_comments = grep {$_->tagname() eq 'NAME'} | |||||||||||||||||||||||||||||||
| 238 | 15 | $creator->{comments}->get_Annotations('comment'); | |||||||||||||||||||||||||||||||
| 239 | 15 | my $name_comment; | |||||||||||||||||||||||||||||||
| 240 | 15 | ▶ | if (@name_comments){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 241 | 7 | $name_comment = $name_comments[0]->as_text(); | |||||||||||||||||||||||||||||||
| 242 | 7 | $name_comment =~ s/^Comment:\s+//; | |||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | my $swq = Bio::Seq::Quality->new( | ||||||||||||||||||||||||||||||||
| 246 | -seq => $creator->{'sequence'}, | ||||||||||||||||||||||||||||||||
| 247 | 15 | -qual => $creator->{'qualities'}, | |||||||||||||||||||||||||||||||
| 248 | -id => $name_comment | ||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||
| 250 | my $returner = Bio::Seq::SequenceTrace->new( | ||||||||||||||||||||||||||||||||
| 251 | -swq => $swq, | ||||||||||||||||||||||||||||||||
| 252 | -trace_a => $creator->{'traces'}->{'a'}, | ||||||||||||||||||||||||||||||||
| 253 | -trace_t => $creator->{'traces'}->{'t'}, | ||||||||||||||||||||||||||||||||
| 254 | -trace_g => $creator->{'traces'}->{'g'}, | ||||||||||||||||||||||||||||||||
| 255 | -trace_c => $creator->{'traces'}->{'c'}, | ||||||||||||||||||||||||||||||||
| 256 | -accuracy_a => $creator->{'accuracies'}->{'a'}, | ||||||||||||||||||||||||||||||||
| 257 | -accuracy_t => $creator->{'accuracies'}->{'t'}, | ||||||||||||||||||||||||||||||||
| 258 | -accuracy_g => $creator->{'accuracies'}->{'g'}, | ||||||||||||||||||||||||||||||||
| 259 | -accuracy_c => $creator->{'accuracies'}->{'c'}, | ||||||||||||||||||||||||||||||||
| 260 | 15 | -peak_indices => $creator->{'peak_indices'} | |||||||||||||||||||||||||||||||
| 261 | ); | ||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | 15 | $returner->annotation($creator->{'comments'}); # add SCF comments | |||||||||||||||||||||||||||||||
| 264 | 15 | $self->{'_readfile'} = 1; | |||||||||||||||||||||||||||||||
| 265 | 15 | return $returner; | |||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||
| 269 | =head2 _get_v3_quality() | ||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||
| 271 | Title : _get_v3_quality() | ||||||||||||||||||||||||||||||||
| 272 | Usage : $self->_get_v3_quality() | ||||||||||||||||||||||||||||||||
| 273 | Function: Set the base qualities from version3 scf | ||||||||||||||||||||||||||||||||
| 274 | Returns : Nothing. Alters $self. | ||||||||||||||||||||||||||||||||
| 275 | Args : None. | ||||||||||||||||||||||||||||||||
| 276 | Notes : | ||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||
| 278 | =cut | ||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||
| 280 | #' | ||||||||||||||||||||||||||||||||
| 281 | 11 | ▶ | sub _get_v3_quality { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_v3_quality: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||
| 282 | 11 | my ($self,$sequence,$accuracies) = @_; | |||||||||||||||||||||||||||||||
| 283 | 11 | my @bases = split//,$sequence; | |||||||||||||||||||||||||||||||
| 284 | 11 | my (@qualities,$currbase,$currqual,$counter); | |||||||||||||||||||||||||||||||
| 285 | 11 | ▶ | for ($counter=0; $counter <= $#bases ; $counter++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 286 | 7639 | $currbase = lc($bases[$counter]); | |||||||||||||||||||||||||||||||
| 287 | 7639 | ▶ | if ($currbase eq "a") { $currqual = $accuracies->{'a'}->[$counter]; } | ||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||
| 288 | 2691 | elsif ($currbase eq "c") { $currqual = $accuracies->{'c'}->[$counter]; } | |||||||||||||||||||||||||||||||
| 289 | 1227 | elsif ($currbase eq "g") { $currqual = $accuracies->{'g'}->[$counter]; } | |||||||||||||||||||||||||||||||
| 290 | 1988 | elsif ($currbase eq "t") { $currqual = $accuracies->{'t'}->[$counter]; } | |||||||||||||||||||||||||||||||
| 291 | 0 | else { $currqual = "unknown"; } | |||||||||||||||||||||||||||||||
| 292 | 7639 | push @qualities,$currqual; | |||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||
| 294 | 11 | return \@qualities; | |||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||
| 297 | =head2 _get_v3_peak_indices($buffer) | ||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||
| 299 | Title : _get_v3_peak_indices($buffer) | ||||||||||||||||||||||||||||||||
| 300 | Usage : $self->_get_v3_peak_indices($buffer); | ||||||||||||||||||||||||||||||||
| 301 | Function: Unpacks the base accuracies for version3 scf | ||||||||||||||||||||||||||||||||
| 302 | Returns : Nothing. Alters $self | ||||||||||||||||||||||||||||||||
| 303 | Args : A scalar containing binary data. | ||||||||||||||||||||||||||||||||
| 304 | Notes : | ||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||
| 306 | =cut | ||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||
| 308 | 11 | ▶ | sub _get_v3_peak_indices { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_v3_peak_indices: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 309 | 11 | my ($self,$buffer) = @_; | |||||||||||||||||||||||||||||||
| 310 | 11 | my $length = length($buffer); | |||||||||||||||||||||||||||||||
| 311 | 11 | my @read = unpack "N$length",$buffer; | |||||||||||||||||||||||||||||||
| 312 | 11 | return join(' ',@read); | |||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | =head2 _get_v3_base_accuracies($buffer) | ||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||
| 317 | Title : _get_v3_base_accuracies($buffer) | ||||||||||||||||||||||||||||||||
| 318 | Usage : $self->_get_v3_base_accuracies($buffer) | ||||||||||||||||||||||||||||||||
| 319 | Function: Set the base accuracies for version 3 scf's | ||||||||||||||||||||||||||||||||
| 320 | Returns : Nothing. Alters $self. | ||||||||||||||||||||||||||||||||
| 321 | Args : A scalar containing binary data. | ||||||||||||||||||||||||||||||||
| 322 | Notes : | ||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||
| 324 | =cut | ||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||
| 326 | #' | ||||||||||||||||||||||||||||||||
| 327 | 11 | ▶ | sub _get_v3_base_accuracies { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_v3_base_accuracies: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 328 | 11 | my ($self,$buffer) = @_; | |||||||||||||||||||||||||||||||
| 329 | 11 | my $length = length($buffer); | |||||||||||||||||||||||||||||||
| 330 | 11 | my $qlength = $length/4; | |||||||||||||||||||||||||||||||
| 331 | 11 | my $offset = 0; | |||||||||||||||||||||||||||||||
| 332 | 11 | my (@qualities,@sorter,$counter,$round,$last_base,$accuracies,$currbase); | |||||||||||||||||||||||||||||||
| 333 | 11 | foreach $currbase (qw(a c g t)) { | |||||||||||||||||||||||||||||||
| 334 | 44 | my @read; | |||||||||||||||||||||||||||||||
| 335 | 44 | $last_base = $offset + $qlength; | |||||||||||||||||||||||||||||||
| 336 | 44 | ▶ | for (;$offset < $last_base; $offset += $qlength) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 337 | # a bioperler (perhaps me?) changed the unpack string to include 'n' rather than 'C' | ||||||||||||||||||||||||||||||||
| 338 | # on 040322 I think that 'C' is correct. please email chad if you would like to accuse me of being incorrect | ||||||||||||||||||||||||||||||||
| 339 | 44 | @read = unpack "C$qlength", substr($buffer,$offset,$qlength); | |||||||||||||||||||||||||||||||
| 340 | 44 | $accuracies->{$currbase} = \@read; | |||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||
| 343 | 11 | return $accuracies; | |||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||
| 347 | =head2 _get_comments($buffer) | ||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||
| 349 | Title : _get_comments($buffer) | ||||||||||||||||||||||||||||||||
| 350 | Usage : $self->_get_comments($buffer); | ||||||||||||||||||||||||||||||||
| 351 | Function: Gather the comments section from the scf and parse it into its | ||||||||||||||||||||||||||||||||
| 352 | components. | ||||||||||||||||||||||||||||||||
| 353 | Returns : a Bio::Annotation::Collection object | ||||||||||||||||||||||||||||||||
| 354 | Args : The buffer. It is expected that the buffer contains a binary | ||||||||||||||||||||||||||||||||
| 355 | string for the comments section of an scf file according to | ||||||||||||||||||||||||||||||||
| 356 | the scf file specifications. | ||||||||||||||||||||||||||||||||
| 357 | Notes : | ||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||
| 359 | =cut | ||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||
| 361 | 15 | ▶ | sub _get_comments { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_comments: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 362 | 15 | my ($self,$buffer) = @_; | |||||||||||||||||||||||||||||||
| 363 | 15 | my $comments = Bio::Annotation::Collection->new(); | |||||||||||||||||||||||||||||||
| 364 | 15 | my $size = length($buffer); | |||||||||||||||||||||||||||||||
| 365 | 15 | my $comments_retrieved = unpack "a$size",$buffer; | |||||||||||||||||||||||||||||||
| 366 | 15 | $comments_retrieved =~ s/\0//; | |||||||||||||||||||||||||||||||
| 367 | 15 | my @comments_split = split/\n/,$comments_retrieved; | |||||||||||||||||||||||||||||||
| 368 | 15 | ▶ | if (@comments_split) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 369 | 13 | foreach (@comments_split) { | |||||||||||||||||||||||||||||||
| 370 | 100 | /(\w+)=(.*)/; | |||||||||||||||||||||||||||||||
| 371 | 100 | ▶ | if ($1 && $2) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$1 and $2
MC/DC50%1/2
$1 and $2
$1
$2
Truth table66%2/3
A and B
A= $1B= $2
| |||||||||||||||||||||||||||||||||
| 372 | 74 | my ($tagname, $text) = ($1, $2); | |||||||||||||||||||||||||||||||
| 373 | 74 | my $comment_obj = Bio::Annotation::Comment->new( | |||||||||||||||||||||||||||||||
| 374 | -text => $text, | ||||||||||||||||||||||||||||||||
| 375 | -tagname => $tagname); | ||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||
| 377 | 74 | $comments->add_Annotation('comment', $comment_obj); | |||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||
| 381 | 15 | $self->{'comments'} = $comments; | |||||||||||||||||||||||||||||||
| 382 | 15 | return $comments; | |||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||
| 385 | =head2 _get_header() | ||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||
| 387 | Title : _get_header($buffer) | ||||||||||||||||||||||||||||||||
| 388 | Usage : $self->_get_header($buffer); | ||||||||||||||||||||||||||||||||
| 389 | Function: Gather the header section from the scf and parse it into its | ||||||||||||||||||||||||||||||||
| 390 | components. | ||||||||||||||||||||||||||||||||
| 391 | Returns : Reference to a hash containing the header components. | ||||||||||||||||||||||||||||||||
| 392 | Args : The buffer. It is expected that the buffer contains a binary | ||||||||||||||||||||||||||||||||
| 393 | string for the header section of an scf file according to the | ||||||||||||||||||||||||||||||||
| 394 | scf file specifications. | ||||||||||||||||||||||||||||||||
| 395 | Notes : None. | ||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||
| 397 | =cut | ||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||
| 399 | 15 | ▶ | sub _get_header { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_header: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 400 | 15 | my ($self,$buffer) = @_; | |||||||||||||||||||||||||||||||
| 401 | 15 | my $header; | |||||||||||||||||||||||||||||||
| 402 | ($header->{'scf'}, | ||||||||||||||||||||||||||||||||
| 403 | $header->{'samples'}, | ||||||||||||||||||||||||||||||||
| 404 | $header->{'sample_offset'}, | ||||||||||||||||||||||||||||||||
| 405 | $header->{'bases'}, | ||||||||||||||||||||||||||||||||
| 406 | $header->{'bases_left_clip'}, | ||||||||||||||||||||||||||||||||
| 407 | $header->{'bases_right_clip'}, | ||||||||||||||||||||||||||||||||
| 408 | $header->{'bases_offset'}, | ||||||||||||||||||||||||||||||||
| 409 | $header->{'comment_size'}, | ||||||||||||||||||||||||||||||||
| 410 | $header->{'comments_offset'}, | ||||||||||||||||||||||||||||||||
| 411 | $header->{'version'}, | ||||||||||||||||||||||||||||||||
| 412 | $header->{'sample_size'}, | ||||||||||||||||||||||||||||||||
| 413 | $header->{'code_set'}, | ||||||||||||||||||||||||||||||||
| 414 | 15 | @{$header->{'header_spare'}} ) = unpack "a4 NNNNNNNN a4 NN N20", $buffer; | |||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||
| 416 | 15 | $self->{'header'} = $header; | |||||||||||||||||||||||||||||||
| 417 | 15 | return $header; | |||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||
| 420 | =head2 _parse_v2_bases($buffer) | ||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||
| 422 | Title : _parse_v2_bases($buffer) | ||||||||||||||||||||||||||||||||
| 423 | Usage : $self->_parse_v2_bases($buffer); | ||||||||||||||||||||||||||||||||
| 424 | Function: Gather the bases section from the scf and parse it into its | ||||||||||||||||||||||||||||||||
| 425 | components. | ||||||||||||||||||||||||||||||||
| 426 | Returns : | ||||||||||||||||||||||||||||||||
| 427 | Args : The buffer. It is expected that the buffer contains a binary | ||||||||||||||||||||||||||||||||
| 428 | string for the bases section of an scf file according to the | ||||||||||||||||||||||||||||||||
| 429 | scf file specifications. | ||||||||||||||||||||||||||||||||
| 430 | Notes : None. | ||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||
| 432 | =cut | ||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | 4 | ▶ | sub _parse_v2_bases { | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_v2_bases: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 435 | 4 | my ($self,$buffer) = @_; | |||||||||||||||||||||||||||||||
| 436 | 4 | my $length = length($buffer); | |||||||||||||||||||||||||||||||
| 437 | 4 | my ($offset2,$currbuff,$currbase,$currqual,$sequence,@qualities,@indices); | |||||||||||||||||||||||||||||||
| 438 | 4 | my (@read,$harvester,$accuracies); | |||||||||||||||||||||||||||||||
| 439 | 4 | ▶ | for ($offset2=0;$offset2<$length;$offset2+=12) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 440 | 3734 | @read = unpack "N C C C C a C3", substr($buffer,$offset2,$length); | |||||||||||||||||||||||||||||||
| 441 | 3734 | push @indices,$read[0]; | |||||||||||||||||||||||||||||||
| 442 | 3734 | $currbase = lc($read[5]); | |||||||||||||||||||||||||||||||
| 443 | 3734 | ▶ | if ($currbase eq "a") { $currqual = $read[1]; } | ||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||
| 444 | 1238 | elsif ($currbase eq "c") { $currqual = $read[2]; } | |||||||||||||||||||||||||||||||
| 445 | 710 | elsif ($currbase eq "g") { $currqual = $read[3]; } | |||||||||||||||||||||||||||||||
| 446 | 958 | elsif ($currbase eq "t") { $currqual = $read[4]; } | |||||||||||||||||||||||||||||||
| 447 | 0 | else { $currqual = "UNKNOWN"; } | |||||||||||||||||||||||||||||||
| 448 | 3734 | push @{$accuracies->{"a"}},$read[1]; | |||||||||||||||||||||||||||||||
| 449 | 3734 | push @{$accuracies->{"c"}},$read[2]; | |||||||||||||||||||||||||||||||
| 450 | 3734 | push @{$accuracies->{"g"}},$read[3]; | |||||||||||||||||||||||||||||||
| 451 | 3734 | push @{$accuracies->{"t"}},$read[4]; | |||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||
| 453 | 3734 | $sequence .= $currbase; | |||||||||||||||||||||||||||||||
| 454 | 3734 | push @qualities,$currqual; | |||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||
| 456 | 4 | return (\@indices,\@qualities,$sequence,$accuracies) | |||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||
| 459 | =head2 _parse_v2_traces(\@traces_array) | ||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||
| 461 | Title : _pares_v2_traces(\@traces_array) | ||||||||||||||||||||||||||||||||
| 462 | Usage : $self->_parse_v2_traces(\@traces_array); | ||||||||||||||||||||||||||||||||
| 463 | Function: Parses an scf Version2 trace array into its base components. | ||||||||||||||||||||||||||||||||
| 464 | Returns : Nothing. Modifies $self. | ||||||||||||||||||||||||||||||||
| 465 | Args : A reference to an array of the unpacked traces section of an | ||||||||||||||||||||||||||||||||
| 466 | scf version2 file. | ||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||
| 468 | =cut | ||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||
| 470 | 4 | ▶ | sub _parse_v2_traces { | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_v2_traces: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 471 | 4 | my ($self,$buffer,$sample_size) = @_; | |||||||||||||||||||||||||||||||
| 472 | 4 | my $byte; | |||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | if ($sample_size == 1) { $byte = "c"; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 474 | 4 | else { $byte = "n"; } | |||||||||||||||||||||||||||||||
| 475 | 4 | my $length = CORE::length($buffer); | |||||||||||||||||||||||||||||||
| 476 | 4 | my @read = unpack "${byte}${length}",$buffer; | |||||||||||||||||||||||||||||||
| 477 | # this will be an array to the reference holding the array | ||||||||||||||||||||||||||||||||
| 478 | 4 | my $traces; | |||||||||||||||||||||||||||||||
| 479 | 4 | my $array = 0; | |||||||||||||||||||||||||||||||
| 480 | 4 | ▶ | for (my $offset2 = 0; $offset2< scalar(@read); $offset2+=4) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 481 | 46000 | push @{$traces->{'a'}},$read[$offset2]; | |||||||||||||||||||||||||||||||
| 482 | 46000 | push @{$traces->{'c'}},$read[$offset2+1]; | |||||||||||||||||||||||||||||||
| 483 | 46000 | push @{$traces->{'g'}},$read[$offset2+3]; | |||||||||||||||||||||||||||||||
| 484 | 46000 | push @{$traces->{'t'}},$read[$offset2+2]; | |||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||
| 486 | 4 | return $traces; | |||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | sub get_trace_deprecated_use_the_sequencetrace_object_instead { | ||||||||||||||||||||||||||||||
|
Subroutine
get_trace_deprecated_use_the_sequencetrace_object_instead: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 491 | # my ($self,$base_channel,$traces) = @_; | ||||||||||||||||||||||||||||||||
| 492 | # $base_channel =~ tr/a-z/A-Z/; | ||||||||||||||||||||||||||||||||
| 493 | # if ($base_channel !~ /A|T|G|C/) { | ||||||||||||||||||||||||||||||||
| 494 | # $self->throw("You tried to ask for a base channel that wasn't A,T,G, or C. Ask for one of those next time."); | ||||||||||||||||||||||||||||||||
| 495 | ##} elsif ($base_channel) { | ||||||||||||||||||||||||||||||||
| 496 | # my @temp = split(' ',$self->{'traces'}->{$base_channel}); | ||||||||||||||||||||||||||||||||
| 497 | #return \@temp; | ||||||||||||||||||||||||||||||||
| 498 | #} | ||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | sub _deprecated_get_peak_indices_deprecated_use_the_sequencetrace_object_instead { | ||||||||||||||||||||||||||||||
|
Subroutine
_deprecated_get_peak_indices_deprecated_use_the_sequencetrace_object_instead: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 502 | 0 | my ($self) = shift; | |||||||||||||||||||||||||||||||
| 503 | 0 | my @temp = split(' ',$self->{'parsed'}->{'peak_indices'}); | |||||||||||||||||||||||||||||||
| 504 | 0 | return \@temp; | |||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||
| 508 | =head2 get_header() | ||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||
| 510 | Title : get_header() | ||||||||||||||||||||||||||||||||
| 511 | Usage : %header = %{$obj->get_header()}; | ||||||||||||||||||||||||||||||||
| 512 | Function: Return the header for this scf. | ||||||||||||||||||||||||||||||||
| 513 | Returns : A reference to a hash containing the header for this scf. | ||||||||||||||||||||||||||||||||
| 514 | Args : None. | ||||||||||||||||||||||||||||||||
| 515 | Notes : | ||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||
| 517 | =cut | ||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||
| 519 | 1 | ▶ | sub get_header { | ||||||||||||||||||||||||||||||
|
Subroutine
get_header: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 520 | 1 | my ($self) = shift; | |||||||||||||||||||||||||||||||
| 521 | 1 | return $self->{'header'}; | |||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||
| 524 | =head2 get_comments() | ||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||
| 526 | Title : get_comments() | ||||||||||||||||||||||||||||||||
| 527 | Usage : %comments = %{$obj->get_comments()}; | ||||||||||||||||||||||||||||||||
| 528 | Function: Return the comments for this scf. | ||||||||||||||||||||||||||||||||
| 529 | Returns : A Bio::Annotation::Collection object | ||||||||||||||||||||||||||||||||
| 530 | Args : None. | ||||||||||||||||||||||||||||||||
| 531 | Notes : | ||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||
| 533 | =cut | ||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||
| 535 | 1 | ▶ | sub get_comments { | ||||||||||||||||||||||||||||||
|
Subroutine
get_comments: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 536 | 1 | my ($self) = shift; | |||||||||||||||||||||||||||||||
| 537 | 1 | return $self->{'comments'}; | |||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | sub _dump_traces_outgoing_deprecated_use_the_sequencetrace_object { | ||||||||||||||||||||||||||||||
|
Subroutine
_dump_traces_outgoing_deprecated_use_the_sequencetrace_object: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 541 | 0 | my ($self,$transformed) = @_; | |||||||||||||||||||||||||||||||
| 542 | 0 | my (@sA,@sT,@sG,@sC); | |||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | if ($transformed) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 544 | 0 | @sA = @{$self->{'text'}->{'t_samples_a'}}; | |||||||||||||||||||||||||||||||
| 545 | 0 | @sC = @{$self->{'text'}->{'t_samples_c'}}; | |||||||||||||||||||||||||||||||
| 546 | 0 | @sG = @{$self->{'text'}->{'t_samples_g'}}; | |||||||||||||||||||||||||||||||
| 547 | 0 | @sT = @{$self->{'text'}->{'t_samples_t'}}; | |||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||
| 549 | else { | ||||||||||||||||||||||||||||||||
| 550 | 0 | @sA = @{$self->{'text'}->{'samples_a'}}; | |||||||||||||||||||||||||||||||
| 551 | 0 | @sC = @{$self->{'text'}->{'samples_c'}}; | |||||||||||||||||||||||||||||||
| 552 | 0 | @sG = @{$self->{'text'}->{'samples_g'}}; | |||||||||||||||||||||||||||||||
| 553 | 0 | @sT = @{$self->{'text'}->{'samples_t'}}; | |||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||
| 555 | 0 | print ("Count\ta\tc\tg\tt\n"); | |||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | for (my $curr=0; $curr < scalar(@sG); $curr++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 557 | 0 | print("$curr\t$sA[$curr]\t$sC[$curr]\t$sG[$curr]\t$sT[$curr]\n"); | |||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||
| 559 | 0 | return; | |||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | sub _dump_traces_incoming_deprecated_use_the_sequencetrace_object { | ||||||||||||||||||||||||||||||
|
Subroutine
_dump_traces_incoming_deprecated_use_the_sequencetrace_object: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 563 | # my ($self) = @_; | ||||||||||||||||||||||||||||||||
| 564 | # my (@sA,@sT,@sG,@sC); | ||||||||||||||||||||||||||||||||
| 565 | # @sA = @{$self->{'traces'}->{'A'}}; | ||||||||||||||||||||||||||||||||
| 566 | # @sC = @{$self->{'traces'}->{'C'}}; | ||||||||||||||||||||||||||||||||
| 567 | # @sG = @{$self->{'traces'}->{'G'}}; | ||||||||||||||||||||||||||||||||
| 568 | # @sT = @{$self->{'traces'}->{'T'}}; | ||||||||||||||||||||||||||||||||
| 569 | # @sA = @{$self->get_trace('A')}; | ||||||||||||||||||||||||||||||||
| 570 | # @sC = @{$self->get_trace('C')}; | ||||||||||||||||||||||||||||||||
| 571 | # @sG = @{$self->get_trace('G')}; | ||||||||||||||||||||||||||||||||
| 572 | # @sT = @{$self->get_trace('t')}; | ||||||||||||||||||||||||||||||||
| 573 | # print ("Count\ta\tc\tg\tt\n"); | ||||||||||||||||||||||||||||||||
| 574 | # for (my $curr=0; $curr < scalar(@sG); $curr++) { | ||||||||||||||||||||||||||||||||
| 575 | # print("$curr\t$sA[$curr]\t$sC[$curr]\t$sG[$curr]\t$sT[$curr]\n"); | ||||||||||||||||||||||||||||||||
| 576 | #} | ||||||||||||||||||||||||||||||||
| 577 | #return; | ||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||
| 580 | =head2 write_seq | ||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||
| 582 | Title : write_seq(-target => $swq, <comments>) | ||||||||||||||||||||||||||||||||
| 583 | Usage : $obj->write_seq( | ||||||||||||||||||||||||||||||||
| 584 | -target => $swq, | ||||||||||||||||||||||||||||||||
| 585 | -version => 2, | ||||||||||||||||||||||||||||||||
| 586 | -CONV => "Bioperl-Chads Mighty SCF writer."); | ||||||||||||||||||||||||||||||||
| 587 | Function: Write out an scf. | ||||||||||||||||||||||||||||||||
| 588 | Returns : Nothing. | ||||||||||||||||||||||||||||||||
| 589 | Args : Requires: a reference to a Bio::Seq::Quality object to form the | ||||||||||||||||||||||||||||||||
| 590 | basis for the scf. | ||||||||||||||||||||||||||||||||
| 591 | if -version is provided, it should be "2" or "3". A SCF of that | ||||||||||||||||||||||||||||||||
| 592 | version will be written. | ||||||||||||||||||||||||||||||||
| 593 | Any other arguments are assumed to be comments and are put into | ||||||||||||||||||||||||||||||||
| 594 | the comments section of the scf. Read the specifications for scf | ||||||||||||||||||||||||||||||||
| 595 | to decide what might be good to put in here. | ||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||
| 597 | Notes : | ||||||||||||||||||||||||||||||||
| 598 | For best results, use a SequenceTrace object. | ||||||||||||||||||||||||||||||||
| 599 | The things that you need to write an scf: | ||||||||||||||||||||||||||||||||
| 600 | a) sequence | ||||||||||||||||||||||||||||||||
| 601 | b) quality | ||||||||||||||||||||||||||||||||
| 602 | c) peak indices | ||||||||||||||||||||||||||||||||
| 603 | d) traces | ||||||||||||||||||||||||||||||||
| 604 | - You _can_ write an scf with just a and b by passing in a | ||||||||||||||||||||||||||||||||
| 605 | Bio::Seq::Quality object- false traces will be synthesized | ||||||||||||||||||||||||||||||||
| 606 | for you. | ||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||
| 608 | =cut | ||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||
| 610 | 10 | ▶ | sub write_seq { | ||||||||||||||||||||||||||||||
|
Subroutine
write_seq: called CC=26 SCAR=34.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 611 | 10 | my ($self,%args) = @_; | |||||||||||||||||||||||||||||||
| 612 | 10 | my %comments; | |||||||||||||||||||||||||||||||
| 613 | 10 | my ($label,$arg); | |||||||||||||||||||||||||||||||
| 614 | 10 | my ($swq) = $self->_rearrange([qw(TARGET)], %args); | |||||||||||||||||||||||||||||||
| 615 | 10 | my $writer_fodder; | |||||||||||||||||||||||||||||||
| 616 | 10 | ▶ | if (ref($swq) =~ /Bio::Seq::SequenceTrace|Bio::Seq::Quality/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 617 | 10 | ▶ | if (ref($swq) eq "Bio::Seq::Quality") { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 618 | # this means that the object *has no trace data* | ||||||||||||||||||||||||||||||||
| 619 | # we might as well synthesize some now, ok? | ||||||||||||||||||||||||||||||||
| 620 | 2 | $swq = Bio::Seq::SequenceTrace->new( | |||||||||||||||||||||||||||||||
| 621 | -swq => $swq | ||||||||||||||||||||||||||||||||
| 622 | ); | ||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||
| 625 | else { | ||||||||||||||||||||||||||||||||
| 626 | 0 | $self->throw("You must pass a Bio::Seq::Quality or a Bio::Seq::SequenceTrace object to write_seq as a parameter named \"target\""); | |||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||
| 628 | # all of the rest of the arguments are comments for the scf | ||||||||||||||||||||||||||||||||
| 629 | 10 | foreach $arg (sort keys %args) { | |||||||||||||||||||||||||||||||
| 630 | 23 | ▶ | next if ($arg =~ /target/i); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 631 | 13 | ($label = $arg) =~ s/^\-//; | |||||||||||||||||||||||||||||||
| 632 | 13 | $writer_fodder->{comments}->{$label} = $args{$arg}; | |||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||
| 634 | 10 | ▶ | if (!$comments{'NAME'}) { $comments{'NAME'} = $swq->id(); } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 635 | # HA! Bwahahahaha. | ||||||||||||||||||||||||||||||||
| 636 | 10 | ▶ | $writer_fodder->{comments}->{'CONV'} = "Bioperl-Chads Mighty SCF writer." unless defined $comments{'CONV'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 637 | # now deal with the version of scf they want to write | ||||||||||||||||||||||||||||||||
| 638 | 10 | ▶ | if ($writer_fodder->{comments}->{version}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 639 | 1 | ▶ | if ($writer_fodder->{comments}->{version} != 2 && $writer_fodder->{comments}->{version} != 3) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$writer_fodder->{"comments"}{"version"} != 2 and $writer_fodder->{"comments"}{"version"} != 3
MC/DC0%0/2
$writer_fodder->{"comments"}{"version"} != 2 and $writer_fodder->{"comments"}{"version"} != 3
$writer_fodder->{"comments"}{"version"} != 2
$writer_fodder->{"comments"}{"version"} != 3
Truth table33%1/3
A and B
A= $writer_fodder->{"comments"}{"version"} != 2B= $writer_fodder->{"comments"}{"version"} != 3
| |||||||||||||||||||||||||||||||||
| 640 | 0 | $self->warn("This module can only write version 2.0 or 3.0 scf's. Writing a version 2.0 scf by default."); | |||||||||||||||||||||||||||||||
| 641 | 0 | $writer_fodder->{header}->{version} = "2.00"; | |||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||
| 643 | elsif ($writer_fodder->{comments}->{'version'} > 2) { | ||||||||||||||||||||||||||||||||
| 644 | 0 | $writer_fodder->{header}->{'version'} = "3.00"; | |||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||
| 646 | else { | ||||||||||||||||||||||||||||||||
| 647 | 1 | $writer_fodder->{header}->{version} = "2"; | |||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||
| 650 | else { | ||||||||||||||||||||||||||||||||
| 651 | 9 | $writer_fodder->{header}->{'version'} = "3.00"; | |||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||
| 653 | # set a few things in the header | ||||||||||||||||||||||||||||||||
| 654 | 10 | $writer_fodder->{'header'}->{'magic'} = ".scf"; | |||||||||||||||||||||||||||||||
| 655 | 10 | $writer_fodder->{'header'}->{'sample_size'} = "2"; | |||||||||||||||||||||||||||||||
| 656 | 10 | $writer_fodder->{'header'}->{'bases'} = length($swq->seq()); | |||||||||||||||||||||||||||||||
| 657 | 10 | $writer_fodder->{'header'}->{'bases_left_clip'} = "0"; | |||||||||||||||||||||||||||||||
| 658 | 10 | $writer_fodder->{'header'}->{'bases_right_clip'} = "0"; | |||||||||||||||||||||||||||||||
| 659 | 10 | $writer_fodder->{'header'}->{'sample_size'} = "2"; | |||||||||||||||||||||||||||||||
| 660 | 10 | $writer_fodder->{'header'}->{'code_set'} = "9"; | |||||||||||||||||||||||||||||||
| 661 | 10 | @{$writer_fodder->{'header'}->{'spare'}} = qw(0 0 0 0 0 0 0 0 0 0 | |||||||||||||||||||||||||||||||
| 662 | 0 0 0 0 0 0 0 0 0 0); | ||||||||||||||||||||||||||||||||
| 663 | 10 | $writer_fodder->{'header'}->{'samples_offset'} = "128"; | |||||||||||||||||||||||||||||||
| 664 | 10 | $writer_fodder->{'header'}->{'samples'} = $swq->trace_length(); | |||||||||||||||||||||||||||||||
| 665 | # create the binary for the comments and file it in writer_fodder | ||||||||||||||||||||||||||||||||
| 666 | $writer_fodder->{comments} = $self->_get_binary_comments( | ||||||||||||||||||||||||||||||||
| 667 | 10 | $writer_fodder->{comments}); | |||||||||||||||||||||||||||||||
| 668 | # create the binary and the strings for the traces, bases, | ||||||||||||||||||||||||||||||||
| 669 | # offsets (if necessary), and accuracies (if necessary) | ||||||||||||||||||||||||||||||||
| 670 | $writer_fodder->{traces} = $self->_get_binary_traces( | ||||||||||||||||||||||||||||||||
| 671 | $writer_fodder->{'header'}->{'version'}, | ||||||||||||||||||||||||||||||||
| 672 | 10 | $swq,$writer_fodder->{'header'}->{'sample_size'}); | |||||||||||||||||||||||||||||||
| 673 | 10 | my ($b_base_offsets,$b_base_accuracies,$samples_size,$bases_size); | |||||||||||||||||||||||||||||||
| 674 | # | ||||||||||||||||||||||||||||||||
| 675 | # version 2 | ||||||||||||||||||||||||||||||||
| 676 | # | ||||||||||||||||||||||||||||||||
| 677 | 10 | ▶ | if ($writer_fodder->{'header'}->{'version'} == 2) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 678 | $writer_fodder->{bases} = $self->_get_binary_bases( | ||||||||||||||||||||||||||||||||
| 679 | 2, | ||||||||||||||||||||||||||||||||
| 680 | $swq, | ||||||||||||||||||||||||||||||||
| 681 | 1 | $writer_fodder->{'header'}->{'sample_size'}); | |||||||||||||||||||||||||||||||
| 682 | 1 | $samples_size = CORE::length($writer_fodder->{traces}->{'binary'}); | |||||||||||||||||||||||||||||||
| 683 | 1 | $bases_size = CORE::length($writer_fodder->{bases}->{binary}); | |||||||||||||||||||||||||||||||
| 684 | 1 | $writer_fodder->{'header'}->{'bases_offset'} = 128 + $samples_size; | |||||||||||||||||||||||||||||||
| 685 | 1 | $writer_fodder->{'header'}->{'comments_offset'} = 128 + | |||||||||||||||||||||||||||||||
| 686 | $samples_size + $bases_size; | ||||||||||||||||||||||||||||||||
| 687 | $writer_fodder->{'header'}->{'comments_size'} = | ||||||||||||||||||||||||||||||||
| 688 | 1 | length($writer_fodder->{'comments'}->{binary}); | |||||||||||||||||||||||||||||||
| 689 | 1 | $writer_fodder->{'header'}->{'private_size'} = "0"; | |||||||||||||||||||||||||||||||
| 690 | $writer_fodder->{'header'}->{'private_offset'} = 128 + | ||||||||||||||||||||||||||||||||
| 691 | $samples_size + $bases_size + | ||||||||||||||||||||||||||||||||
| 692 | 1 | $writer_fodder->{'header'}->{'comments_size'}; | |||||||||||||||||||||||||||||||
| 693 | $writer_fodder->{'header'}->{'binary'} = | ||||||||||||||||||||||||||||||||
| 694 | 1 | $self->_get_binary_header($writer_fodder->{header}); | |||||||||||||||||||||||||||||||
| 695 | 1 | ▶ | $dumper->dumpValue($writer_fodder) if $self->verbose > 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 696 | 1 | ▶ | $self->_print ($writer_fodder->{'header'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 697 | or print("Could not write binary header...\n"); | ||||||||||||||||||||||||||||||||
| 698 | 1 | ▶ | $self->_print ($writer_fodder->{'traces'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 699 | or print("Could not write binary traces...\n"); | ||||||||||||||||||||||||||||||||
| 700 | 1 | ▶ | $self->_print ($writer_fodder->{'bases'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 701 | or print("Could not write binary base structures...\n"); | ||||||||||||||||||||||||||||||||
| 702 | 1 | ▶ | $self->_print ($writer_fodder->{'comments'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 703 | or print("Could not write binary comments...\n"); | ||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||
| 705 | else { | ||||||||||||||||||||||||||||||||
| 706 | ($writer_fodder->{peak_indices}, | ||||||||||||||||||||||||||||||||
| 707 | $writer_fodder->{accuracies}, | ||||||||||||||||||||||||||||||||
| 708 | $writer_fodder->{bases}, | ||||||||||||||||||||||||||||||||
| 709 | $writer_fodder->{reserved} ) = | ||||||||||||||||||||||||||||||||
| 710 | $self->_get_binary_bases( | ||||||||||||||||||||||||||||||||
| 711 | 3, | ||||||||||||||||||||||||||||||||
| 712 | $swq, | ||||||||||||||||||||||||||||||||
| 713 | 9 | $writer_fodder->{'header'}->{'sample_size'} | |||||||||||||||||||||||||||||||
| 714 | ); | ||||||||||||||||||||||||||||||||
| 715 | $writer_fodder->{'header'}->{'bases_offset'} = 128 + | ||||||||||||||||||||||||||||||||
| 716 | 9 | length($writer_fodder->{'traces'}->{'binary'}); | |||||||||||||||||||||||||||||||
| 717 | $writer_fodder->{'header'}->{'comments_size'} = | ||||||||||||||||||||||||||||||||
| 718 | 9 | length($writer_fodder->{'comments'}->{'binary'}); | |||||||||||||||||||||||||||||||
| 719 | # this is: | ||||||||||||||||||||||||||||||||
| 720 | # bases_offset + base_offsets + accuracies + called_bases + | ||||||||||||||||||||||||||||||||
| 721 | # reserved | ||||||||||||||||||||||||||||||||
| 722 | 9 | $writer_fodder->{'header'}->{'private_size'} = "0"; | |||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||
| 724 | $writer_fodder->{'header'}->{'comments_offset'} = | ||||||||||||||||||||||||||||||||
| 725 | 128+length($writer_fodder->{'traces'}->{'binary'})+ | ||||||||||||||||||||||||||||||||
| 726 | length($writer_fodder->{'peak_indices'}->{'binary'})+ | ||||||||||||||||||||||||||||||||
| 727 | length($writer_fodder->{'accuracies'}->{'binary'})+ | ||||||||||||||||||||||||||||||||
| 728 | length($writer_fodder->{'bases'}->{'binary'})+ | ||||||||||||||||||||||||||||||||
| 729 | 9 | length($writer_fodder->{'reserved'}->{'binary'}); | |||||||||||||||||||||||||||||||
| 730 | $writer_fodder->{'header'}->{'private_offset'} = | ||||||||||||||||||||||||||||||||
| 731 | $writer_fodder->{'header'}->{'comments_offset'} + | ||||||||||||||||||||||||||||||||
| 732 | 9 | $writer_fodder->{'header'}->{'comments_size'}; | |||||||||||||||||||||||||||||||
| 733 | $writer_fodder->{'header'}->{'spare'}->[1] = | ||||||||||||||||||||||||||||||||
| 734 | $writer_fodder->{'header'}->{'comments_offset'} + | ||||||||||||||||||||||||||||||||
| 735 | 9 | length($writer_fodder->{'comments'}->{'binary'}); | |||||||||||||||||||||||||||||||
| 736 | $writer_fodder->{header}->{binary} = | ||||||||||||||||||||||||||||||||
| 737 | 9 | $self->_get_binary_header($writer_fodder->{header}); | |||||||||||||||||||||||||||||||
| 738 | 9 | ▶ | $self->_print ($writer_fodder->{'header'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 739 | or print("Couldn't write header\n"); | ||||||||||||||||||||||||||||||||
| 740 | 9 | ▶ | $self->_print ($writer_fodder->{'traces'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 741 | or print("Couldn't write samples\n"); | ||||||||||||||||||||||||||||||||
| 742 | 9 | ▶ | $self->_print ($writer_fodder->{'peak_indices'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 743 | or print("Couldn't write peak offsets\n"); | ||||||||||||||||||||||||||||||||
| 744 | 9 | ▶ | $self->_print ($writer_fodder->{'accuracies'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 745 | or print("Couldn't write accuracies\n"); | ||||||||||||||||||||||||||||||||
| 746 | 9 | ▶ | $self->_print ($writer_fodder->{'bases'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 747 | or print("Couldn't write called_bases\n"); | ||||||||||||||||||||||||||||||||
| 748 | 9 | ▶ | $self->_print ($writer_fodder->{'reserved'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 749 | or print("Couldn't write reserved\n"); | ||||||||||||||||||||||||||||||||
| 750 | 9 | ▶ | $self->_print ($writer_fodder->{'comments'}->{'binary'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 751 | or print ("Couldn't write comments\n"); | ||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||
| 754 | # kinda unnecessary, given the close() below, but maybe that'll go | ||||||||||||||||||||||||||||||||
| 755 | # away someday. | ||||||||||||||||||||||||||||||||
| 756 | 10 | ▶ | $self->flush if $self->_flush_on_write && defined $self->_fh; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_flush_on_write and defined $self->_fh
MC/DC0%0/2
$self->_flush_on_write and defined $self->_fh
$self->_flush_on_write
defined $self->_fh
Truth table33%1/3
A and B
A= $self->_flush_on_writeB= defined $self->_fh
| |||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||
| 758 | 10 | $self->close(); | |||||||||||||||||||||||||||||||
| 759 | 10 | return 1; | |||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||
| 766 | =head2 _get_binary_header() | ||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||
| 768 | Title : _get_binary_header(); | ||||||||||||||||||||||||||||||||
| 769 | Usage : $self->_get_binary_header(); | ||||||||||||||||||||||||||||||||
| 770 | Function: Provide the binary string that will be used as the header for | ||||||||||||||||||||||||||||||||
| 771 | a scfv2 document. | ||||||||||||||||||||||||||||||||
| 772 | Returns : A binary string. | ||||||||||||||||||||||||||||||||
| 773 | Args : None. Uses the entries in the $self->{'header'} hash. These | ||||||||||||||||||||||||||||||||
| 774 | are set on construction of the object (hopefully correctly!). | ||||||||||||||||||||||||||||||||
| 775 | Notes : | ||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||
| 777 | =cut | ||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||
| 779 | 10 | ▶ | sub _get_binary_header { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_binary_header: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 780 | 10 | my ($self,$header) = @_; | |||||||||||||||||||||||||||||||
| 781 | my $binary = pack "a4 NNNNNNNN a4 NN N20", | ||||||||||||||||||||||||||||||||
| 782 | ( | ||||||||||||||||||||||||||||||||
| 783 | $header->{'magic'}, | ||||||||||||||||||||||||||||||||
| 784 | $header->{'samples'}, | ||||||||||||||||||||||||||||||||
| 785 | $header->{'samples_offset'}, | ||||||||||||||||||||||||||||||||
| 786 | $header->{'bases'}, | ||||||||||||||||||||||||||||||||
| 787 | $header->{'bases_left_clip'}, | ||||||||||||||||||||||||||||||||
| 788 | $header->{'bases_right_clip'}, | ||||||||||||||||||||||||||||||||
| 789 | $header->{'bases_offset'}, | ||||||||||||||||||||||||||||||||
| 790 | $header->{'comments_size'}, | ||||||||||||||||||||||||||||||||
| 791 | $header->{'comments_offset'}, | ||||||||||||||||||||||||||||||||
| 792 | $header->{'version'}, | ||||||||||||||||||||||||||||||||
| 793 | $header->{'sample_size'}, | ||||||||||||||||||||||||||||||||
| 794 | $header->{'code_set'}, | ||||||||||||||||||||||||||||||||
| 795 | 10 | @{$header->{'spare'}} | |||||||||||||||||||||||||||||||
| 796 | ); | ||||||||||||||||||||||||||||||||
| 797 | 10 | return $binary; | |||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||
| 800 | =head2 _get_binary_traces($version,$ref) | ||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||
| 802 | Title : _set_binary_tracesbases($version,$ref) | ||||||||||||||||||||||||||||||||
| 803 | Usage : $self->_set_binary_tracesbases($version,$ref); | ||||||||||||||||||||||||||||||||
| 804 | Function: Constructs the trace and base strings for all scfs | ||||||||||||||||||||||||||||||||
| 805 | Returns : Nothing. Alters self. | ||||||||||||||||||||||||||||||||
| 806 | Args : $version - "2" or "3" | ||||||||||||||||||||||||||||||||
| 807 | $sequence - a scalar containing arbitrary sequence data | ||||||||||||||||||||||||||||||||
| 808 | $ref - a reference to either a SequenceTraces or a | ||||||||||||||||||||||||||||||||
| 809 | SequenceWithQuality object. | ||||||||||||||||||||||||||||||||
| 810 | Notes : This is a really complicated thing. | ||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||
| 812 | =cut | ||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||
| 814 | 10 | ▶ | sub _get_binary_traces { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_binary_traces: called CC=13 SCAR=27.8
| |||||||||||||||||||||||||||||||||
| 815 | 10 | my ($self,$version,$ref,$sample_size) = @_; | |||||||||||||||||||||||||||||||
| 816 | # ref _should_ be a Bio::Seq::SequenceTrace, but might be a | ||||||||||||||||||||||||||||||||
| 817 | # Bio::Seq::Quality | ||||||||||||||||||||||||||||||||
| 818 | 10 | my $returner; | |||||||||||||||||||||||||||||||
| 819 | 10 | my $sequence = $ref->seq(); | |||||||||||||||||||||||||||||||
| 820 | 10 | my $sequence_length = length($sequence); | |||||||||||||||||||||||||||||||
| 821 | # first of all, do we need to synthesize the trace? | ||||||||||||||||||||||||||||||||
| 822 | # if so, call synthesize_base | ||||||||||||||||||||||||||||||||
| 823 | 10 | my ($traceobj,@traces,$current); | |||||||||||||||||||||||||||||||
| 824 | 10 | ▶ | if ( ref($ref) eq "Bio::Seq::Quality" ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 825 | 0 | $traceobj = Bio::Seq::Quality->new( | |||||||||||||||||||||||||||||||
| 826 | -target => $ref | ||||||||||||||||||||||||||||||||
| 827 | ); | ||||||||||||||||||||||||||||||||
| 828 | 0 | $traceobj->_synthesize_traces(); | |||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||
| 830 | else { | ||||||||||||||||||||||||||||||||
| 831 | 10 | $traceobj = $ref; | |||||||||||||||||||||||||||||||
| 832 | 10 | ▶ | if ($version eq "2") { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 833 | 1 | my $trace_length = $traceobj->trace_length(); | |||||||||||||||||||||||||||||||
| 834 | 1 | ▶ | for ($current = 1; $current <= $trace_length; $current++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 835 | 14107 | foreach (qw(a c g t)) { | |||||||||||||||||||||||||||||||
| 836 | 56428 | push @traces,$traceobj->trace_value_at($_,$current); | |||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||
| 840 | elsif ($version == 3) { | ||||||||||||||||||||||||||||||||
| 841 | 9 | foreach my $current_trace (qw(a c g t)) { | |||||||||||||||||||||||||||||||
| 842 | 36 | my @trace = @{$traceobj->trace($current_trace)}; | |||||||||||||||||||||||||||||||
| 843 | 36 | foreach (@trace) { | |||||||||||||||||||||||||||||||
| 844 | 245300 | ▶ | if ($_ > 30000) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 845 | 0 | $_ -= 65536; | |||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||
| 848 | 36 | my $transformed = $self->_delta(\@trace,"forward"); | |||||||||||||||||||||||||||||||
| 849 | 36 | ▶ | if($sample_size == 1){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 850 | 0 | foreach (@{$transformed}) { | |||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | $_ += 256 if ($_ < 0); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||
| 854 | 36 | push @traces,@{$transformed}; | |||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||
| 858 | 10 | $returner->{version} = $version; | |||||||||||||||||||||||||||||||
| 859 | 10 | $returner->{string} = \@traces; | |||||||||||||||||||||||||||||||
| 860 | 10 | my $length_of_traces = scalar(@traces); | |||||||||||||||||||||||||||||||
| 861 | 10 | my $byte; | |||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | if ($sample_size == 1) { $byte = "c"; } else { $byte = "n"; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 863 | # an unsigned integer should be I, but this is too long | ||||||||||||||||||||||||||||||||
| 864 | # | ||||||||||||||||||||||||||||||||
| 865 | 10 | $returner->{binary} = pack "n${length_of_traces}",@traces; | |||||||||||||||||||||||||||||||
| 866 | 10 | $returner->{length} = CORE::length($returner->{binary}); | |||||||||||||||||||||||||||||||
| 867 | 10 | return $returner; | |||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||
| 871 | 10 | ▶ | sub _get_binary_bases { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_binary_bases: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 872 | 10 | my ($self,$version,$trace,$sample_size) = @_; | |||||||||||||||||||||||||||||||
| 873 | 10 | my $byte; | |||||||||||||||||||||||||||||||
| 874 | 0 | ▶ | if ($sample_size == 1) { $byte = "c"; } else { $byte = "n"; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 875 | 10 | my ($returner,@current_row,$current_base,$string,$binary); | |||||||||||||||||||||||||||||||
| 876 | 10 | my $length = $trace->length(); | |||||||||||||||||||||||||||||||
| 877 | 10 | ▶ | if ($version == 2) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 878 | 1 | $returner->{'version'} = "2"; | |||||||||||||||||||||||||||||||
| 879 | 1 | ▶ | for (my $current_base =1; $current_base <= $length; $current_base++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 880 | 1106 | my @current_row; | |||||||||||||||||||||||||||||||
| 881 | 1106 | push @current_row,$trace->peak_index_at($current_base); | |||||||||||||||||||||||||||||||
| 882 | 1106 | push @current_row,$trace->accuracy_at("a",$current_base); | |||||||||||||||||||||||||||||||
| 883 | 1106 | push @current_row,$trace->accuracy_at("c",$current_base); | |||||||||||||||||||||||||||||||
| 884 | 1106 | push @current_row,$trace->accuracy_at("g",$current_base); | |||||||||||||||||||||||||||||||
| 885 | 1106 | push @current_row,$trace->accuracy_at("t",$current_base); | |||||||||||||||||||||||||||||||
| 886 | 1106 | push @current_row,$trace->baseat($current_base); | |||||||||||||||||||||||||||||||
| 887 | 1106 | push @current_row,0,0,0; | |||||||||||||||||||||||||||||||
| 888 | 1106 | push @{$returner->{string}},@current_row; | |||||||||||||||||||||||||||||||
| 889 | 1106 | $returner->{binary} .= pack "N C C C C a C3",@current_row; | |||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||
| 891 | 1 | return $returner; | |||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||
| 893 | else { | ||||||||||||||||||||||||||||||||
| 894 | 9 | $returner->{'version'} = "3.00"; | |||||||||||||||||||||||||||||||
| 895 | 9 | $returner->{peak_indices}->{string} = $trace->peak_indices(); | |||||||||||||||||||||||||||||||
| 896 | 9 | my $length = scalar(@{$returner->{peak_indices}->{string}}); | |||||||||||||||||||||||||||||||
| 897 | $returner->{peak_indices}->{binary} = | ||||||||||||||||||||||||||||||||
| 898 | 9 | pack "N$length",@{$returner->{peak_indices}->{string}}; | |||||||||||||||||||||||||||||||
| 899 | $returner->{peak_indices}->{length} = | ||||||||||||||||||||||||||||||||
| 900 | 9 | CORE::length($returner->{peak_indices}->{binary}); | |||||||||||||||||||||||||||||||
| 901 | 9 | my @accuracies; | |||||||||||||||||||||||||||||||
| 902 | 9 | foreach my $base (qw(a c g t)) { | |||||||||||||||||||||||||||||||
| 903 | 36 | $returner->{accuracies}->{$base} = $trace->accuracies($base); | |||||||||||||||||||||||||||||||
| 904 | 36 | push @accuracies,@{$trace->accuracies($base)}; | |||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||
| 906 | 9 | $returner->{sequence} = $trace->seq(); | |||||||||||||||||||||||||||||||
| 907 | 9 | $length = scalar(@accuracies); | |||||||||||||||||||||||||||||||
| 908 | # this really is "c" for samplesize == 2 | ||||||||||||||||||||||||||||||||
| 909 | 9 | $returner->{accuracies}->{binary} = pack "C${length}",@accuracies; | |||||||||||||||||||||||||||||||
| 910 | $returner->{accuracies}->{length} = | ||||||||||||||||||||||||||||||||
| 911 | 9 | CORE::length($returner->{accuracies}->{binary}); | |||||||||||||||||||||||||||||||
| 912 | 9 | $length = $trace->seq_obj()->length(); | |||||||||||||||||||||||||||||||
| 913 | 9 | ▶ | for (my $count=0; $count< $length; $count++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 914 | 4629 | push @{$returner->{reserved}->{string}},0,0,0; | |||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||
| 917 | 9 | $length = scalar(@{$returner->{reserved}->{string}}); | |||||||||||||||||||||||||||||||
| 918 | # this _must_ be "c" | ||||||||||||||||||||||||||||||||
| 919 | $returner->{'reserved'}->{'binary'} = | ||||||||||||||||||||||||||||||||
| 920 | 9 | pack "c$length",@{$returner->{reserved}->{string}}; | |||||||||||||||||||||||||||||||
| 921 | $returner->{'reserved'}->{'length'} = | ||||||||||||||||||||||||||||||||
| 922 | 9 | CORE::length($returner->{'reserved'}->{'binary'}); | |||||||||||||||||||||||||||||||
| 923 | # $returner->{'bases'}->{'string'} = $trace->seq(); | ||||||||||||||||||||||||||||||||
| 924 | 9 | my @bases = split('',$trace->seq()); | |||||||||||||||||||||||||||||||
| 925 | 9 | $length = $trace->length(); | |||||||||||||||||||||||||||||||
| 926 | 9 | $returner->{'bases'}->{'binary'} = $trace->seq(); | |||||||||||||||||||||||||||||||
| 927 | # print("Returning this:\n"); | ||||||||||||||||||||||||||||||||
| 928 | # $dumper->dumpValue($returner); | ||||||||||||||||||||||||||||||||
| 929 | return ($returner->{peak_indices}, | ||||||||||||||||||||||||||||||||
| 930 | $returner->{accuracies}, | ||||||||||||||||||||||||||||||||
| 931 | $returner->{bases}, | ||||||||||||||||||||||||||||||||
| 932 | 9 | $returner->{reserved}); | |||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||
| 937 | =head2 _make_trace_string($version) | ||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||
| 939 | Title : _make_trace_string($version) | ||||||||||||||||||||||||||||||||
| 940 | Usage : $self->_make_trace_string($version) | ||||||||||||||||||||||||||||||||
| 941 | Function: Merges trace data for the four bases to produce an scf | ||||||||||||||||||||||||||||||||
| 942 | trace string. _requires_ $version | ||||||||||||||||||||||||||||||||
| 943 | Returns : Nothing. Alters $self. | ||||||||||||||||||||||||||||||||
| 944 | Args : $version - a version number. "2" or "3" | ||||||||||||||||||||||||||||||||
| 945 | Notes : | ||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||
| 947 | =cut | ||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||
| 949 | 0 | ▶ | sub _make_trace_string { | ||||||||||||||||||||||||||||||
|
Subroutine
_make_trace_string: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||
| 950 | 0 | my ($self,$version) = @_; | |||||||||||||||||||||||||||||||
| 951 | 0 | my @traces; | |||||||||||||||||||||||||||||||
| 952 | my @traces_view; | ||||||||||||||||||||||||||||||||
| 953 | 0 | my @as = @{$self->{'text'}->{'samples_a'}}; | |||||||||||||||||||||||||||||||
| 954 | 0 | my @cs = @{$self->{'text'}->{'samples_c'}}; | |||||||||||||||||||||||||||||||
| 955 | 0 | my @gs = @{$self->{'text'}->{'samples_g'}}; | |||||||||||||||||||||||||||||||
| 956 | 0 | my @ts = @{$self->{'text'}->{'samples_t'}}; | |||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | if ($version == 2) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | for (my $curr=0; $curr < scalar(@as); $curr++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 959 | 0 | ▶ | $as[$curr] = $DEFAULT_QUALITY unless defined $as[$curr]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | $cs[$curr] = $DEFAULT_QUALITY unless defined $cs[$curr]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 961 | 0 | ▶ | $gs[$curr] = $DEFAULT_QUALITY unless defined $gs[$curr]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 962 | 0 | ▶ | $ts[$curr] = $DEFAULT_QUALITY unless defined $ts[$curr]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 963 | 0 | push @traces,($as[$curr],$cs[$curr],$gs[$curr],$ts[$curr]); | |||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||
| 965 | } | ||||||||||||||||||||||||||||||||
| 966 | elsif ($version == 3) { | ||||||||||||||||||||||||||||||||
| 967 | 0 | @traces = (@as,@cs,@gs,@ts); | |||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||
| 969 | else { | ||||||||||||||||||||||||||||||||
| 970 | 0 | $self->throw("No idea what version required to make traces here. You gave #$version# Bailing."); | |||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||
| 972 | 0 | my $length = scalar(@traces); | |||||||||||||||||||||||||||||||
| 973 | 0 | $self->{'text'}->{'samples_all'} = \@traces; | |||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||
| 977 | =head2 _get_binary_comments(\@comments) | ||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||
| 979 | Title : _get_binary_comments(\@comments) | ||||||||||||||||||||||||||||||||
| 980 | Usage : $self->_get_binary_comments(\@comments); | ||||||||||||||||||||||||||||||||
| 981 | Function: Provide a binary string that will be the comments section of | ||||||||||||||||||||||||||||||||
| 982 | the scf file. See the scf specifications for detailed | ||||||||||||||||||||||||||||||||
| 983 | specifications for the comments section of an scf file. Hint: | ||||||||||||||||||||||||||||||||
| 984 | CODE=something\nBODE=something\n\0 | ||||||||||||||||||||||||||||||||
| 985 | Returns : | ||||||||||||||||||||||||||||||||
| 986 | Args : A reference to an array containing comments. | ||||||||||||||||||||||||||||||||
| 987 | Notes : None. | ||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||
| 989 | =cut | ||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||
| 991 | 10 | ▶ | sub _get_binary_comments { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_binary_comments: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 992 | 10 | my ($self,$rcomments) = @_; | |||||||||||||||||||||||||||||||
| 993 | 10 | my $returner; | |||||||||||||||||||||||||||||||
| 994 | 10 | my $comments_string = ''; | |||||||||||||||||||||||||||||||
| 995 | 10 | my %comments = %$rcomments; | |||||||||||||||||||||||||||||||
| 996 | 10 | foreach my $key (sort keys %comments) { | |||||||||||||||||||||||||||||||
| 997 | 21 | ▶ | $comments{$key} ||= ''; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$comments{$key} ||= ""
MC/DC0%0/1
$comments{$key} ||= ""
$comments{$key}
Truth table50%1/2
A
A= $comments{$key}
| |||||||||||||||||||||||||||||||||
| 998 | 21 | $comments_string .= "$key=$comments{$key}\n"; | |||||||||||||||||||||||||||||||
| 999 | } | ||||||||||||||||||||||||||||||||
| 1000 | 10 | $comments_string .= "\n\0"; | |||||||||||||||||||||||||||||||
| 1001 | 10 | my $length = CORE::length($comments_string); | |||||||||||||||||||||||||||||||
| 1002 | 10 | $returner->{length} = $length; | |||||||||||||||||||||||||||||||
| 1003 | 10 | $returner->{string} = $comments_string; | |||||||||||||||||||||||||||||||
| 1004 | 10 | $returner->{binary} = pack "A$length",$comments_string; | |||||||||||||||||||||||||||||||
| 1005 | 10 | return $returner; | |||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||
| 1008 | #=head2 _fill_missing_data($swq) | ||||||||||||||||||||||||||||||||
| 1009 | # | ||||||||||||||||||||||||||||||||
| 1010 | # Title : _fill_missing_data($swq) | ||||||||||||||||||||||||||||||||
| 1011 | # Usage : $self->_fill_missing_data($swq); | ||||||||||||||||||||||||||||||||
| 1012 | # Function: If the $swq with quality has no qualities, set all qualities | ||||||||||||||||||||||||||||||||
| 1013 | # to 0. | ||||||||||||||||||||||||||||||||
| 1014 | # If the $swq has no sequence, set the sequence to N's. | ||||||||||||||||||||||||||||||||
| 1015 | # Returns : Nothing. Modifies the Bio::Seq::Quality that was passed as an | ||||||||||||||||||||||||||||||||
| 1016 | # argument. | ||||||||||||||||||||||||||||||||
| 1017 | # Args : A reference to a Bio::Seq::Quality | ||||||||||||||||||||||||||||||||
| 1018 | # Notes : None. | ||||||||||||||||||||||||||||||||
| 1019 | # | ||||||||||||||||||||||||||||||||
| 1020 | #=cut | ||||||||||||||||||||||||||||||||
| 1021 | # | ||||||||||||||||||||||||||||||||
| 1022 | ##' | ||||||||||||||||||||||||||||||||
| 1023 | #sub _fill_missing_data { | ||||||||||||||||||||||||||||||||
| 1024 | # my ($self,$swq) = @_; | ||||||||||||||||||||||||||||||||
| 1025 | # my $qual_obj = $swq->qual_obj(); | ||||||||||||||||||||||||||||||||
| 1026 | # my $seq_obj = $swq->seq_obj(); | ||||||||||||||||||||||||||||||||
| 1027 | # if ($qual_obj->length() == 0 && $seq_obj->length() != 0) { | ||||||||||||||||||||||||||||||||
| 1028 | # my $fake_qualities = ("$DEFAULT_QUALITY ")x$seq_obj->length(); | ||||||||||||||||||||||||||||||||
| 1029 | # $swq->qual($fake_qualities); | ||||||||||||||||||||||||||||||||
| 1030 | # } | ||||||||||||||||||||||||||||||||
| 1031 | # if ($seq_obj->length() == 0 && $qual_obj->length != 0) { | ||||||||||||||||||||||||||||||||
| 1032 | # my $sequence = ("N")x$qual_obj->length(); | ||||||||||||||||||||||||||||||||
| 1033 | # $swq->seq($sequence); | ||||||||||||||||||||||||||||||||
| 1034 | # } | ||||||||||||||||||||||||||||||||
| 1035 | #} | ||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||
| 1037 | =head2 _delta(\@trace_data,$direction) | ||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||
| 1039 | Title : _delta(\@trace_data,$direction) | ||||||||||||||||||||||||||||||||
| 1040 | Usage : $self->_delta(\@trace_data,$direction); | ||||||||||||||||||||||||||||||||
| 1041 | Function: | ||||||||||||||||||||||||||||||||
| 1042 | Returns : A reference to an array containing modified trace values. | ||||||||||||||||||||||||||||||||
| 1043 | Args : A reference to an array containing trace data and a string | ||||||||||||||||||||||||||||||||
| 1044 | indicating the direction of conversion. ("forward" or | ||||||||||||||||||||||||||||||||
| 1045 | "backward"). | ||||||||||||||||||||||||||||||||
| 1046 | Notes : This code is taken from the specification for SCF3.2. | ||||||||||||||||||||||||||||||||
| 1047 | http://www.mrc-lmb.cam.ac.uk/pubseq/manual/formats_unix_4.html | ||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||
| 1049 | =cut | ||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||
| 1052 | 80 | ▶ | sub _delta { | ||||||||||||||||||||||||||||||
|
Subroutine
_delta: called CC=11 SCAR=33.9
| |||||||||||||||||||||||||||||||||
| 1053 | 80 | my ($self,$rsamples,$direction) = @_; | |||||||||||||||||||||||||||||||
| 1054 | 80 | my @samples = @$rsamples; | |||||||||||||||||||||||||||||||
| 1055 | # /* If job == DELTA_IT: | ||||||||||||||||||||||||||||||||
| 1056 | # * change a series of sample points to a series of delta delta values: | ||||||||||||||||||||||||||||||||
| 1057 | # * ie change them in two steps: | ||||||||||||||||||||||||||||||||
| 1058 | # * first: delta = current_value - previous_value | ||||||||||||||||||||||||||||||||
| 1059 | # * then: delta_delta = delta - previous_delta | ||||||||||||||||||||||||||||||||
| 1060 | # * else | ||||||||||||||||||||||||||||||||
| 1061 | # * do the reverse | ||||||||||||||||||||||||||||||||
| 1062 | # */ | ||||||||||||||||||||||||||||||||
| 1063 | # int i; | ||||||||||||||||||||||||||||||||
| 1064 | # uint_2 p_delta, p_sample; | ||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||
| 1066 | 80 | my ($i,$num_samples,$p_delta,$p_sample,@samples_converted,$p_sample1,$p_sample2); | |||||||||||||||||||||||||||||||
| 1067 | 80 | my $SLOW_BUT_CLEAR = 0; | |||||||||||||||||||||||||||||||
| 1068 | 80 | $num_samples = scalar(@samples); | |||||||||||||||||||||||||||||||
| 1069 | # c-programmers are funny people with their single-letter variables | ||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||
| 1071 | 80 | ▶ | if ( $direction eq "forward" ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 1072 | 36 | ▶ | if($SLOW_BUT_CLEAR){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1073 | 0 | $p_delta = 0; | |||||||||||||||||||||||||||||||
| 1074 | 0 | ▶ | for ($i=0; $i < $num_samples; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1075 | 0 | $p_sample = $samples[$i]; | |||||||||||||||||||||||||||||||
| 1076 | 0 | $samples[$i] = $samples[$i] - $p_delta; | |||||||||||||||||||||||||||||||
| 1077 | 0 | $p_delta = $p_sample; | |||||||||||||||||||||||||||||||
| 1078 | } | ||||||||||||||||||||||||||||||||
| 1079 | 0 | $p_delta = 0; | |||||||||||||||||||||||||||||||
| 1080 | 0 | ▶ | for ($i=0; $i < $num_samples; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1081 | 0 | $p_sample = $samples[$i]; | |||||||||||||||||||||||||||||||
| 1082 | 0 | $samples[$i] = $samples[$i] - $p_delta; | |||||||||||||||||||||||||||||||
| 1083 | 0 | $p_delta = $p_sample; | |||||||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||||||
| 1085 | } else { | ||||||||||||||||||||||||||||||||
| 1086 | 36 | ▶ | for ($i = $num_samples-1; $i > 1; $i--){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1087 | 245228 | $samples[$i] = $samples[$i] - 2*$samples[$i-1] + $samples[$i-2]; | |||||||||||||||||||||||||||||||
| 1088 | } | ||||||||||||||||||||||||||||||||
| 1089 | 36 | $samples[1] = $samples[1] - 2*$samples[0]; | |||||||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||||||
| 1091 | } | ||||||||||||||||||||||||||||||||
| 1092 | elsif ($direction eq "backward") { | ||||||||||||||||||||||||||||||||
| 1093 | 44 | ▶ | if($SLOW_BUT_CLEAR){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1094 | 0 | $p_sample = 0; | |||||||||||||||||||||||||||||||
| 1095 | 0 | ▶ | for ($i=0; $i < $num_samples; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1096 | 0 | $samples[$i] = $samples[$i] + $p_sample; | |||||||||||||||||||||||||||||||
| 1097 | 0 | $p_sample = $samples[$i]; | |||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||
| 1099 | 0 | $p_sample = 0; | |||||||||||||||||||||||||||||||
| 1100 | 0 | ▶ | for ($i=0; $i < $num_samples; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1101 | 0 | $samples[$i] = $samples[$i] + $p_sample; | |||||||||||||||||||||||||||||||
| 1102 | 0 | $p_sample = $samples[$i]; | |||||||||||||||||||||||||||||||
| 1103 | } | ||||||||||||||||||||||||||||||||
| 1104 | } else { | ||||||||||||||||||||||||||||||||
| 1105 | 44 | $p_sample1 = $p_sample2 = 0; | |||||||||||||||||||||||||||||||
| 1106 | 44 | ▶ | for ($i = 0; $i < $num_samples; $i++){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1107 | 424924 | $p_sample1 = $p_sample1 + $samples[$i]; | |||||||||||||||||||||||||||||||
| 1108 | 424924 | $samples[$i] = $p_sample1 + $p_sample2; | |||||||||||||||||||||||||||||||
| 1109 | 424924 | $p_sample2 = $samples[$i]; | |||||||||||||||||||||||||||||||
| 1110 | } | ||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||
| 1112 | } | ||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||
| 1114 | else { | ||||||||||||||||||||||||||||||||
| 1115 | 0 | $self->warn("Bad direction. Use \"forward\" or \"backward\"."); | |||||||||||||||||||||||||||||||
| 1116 | } | ||||||||||||||||||||||||||||||||
| 1117 | 80 | return \@samples; | |||||||||||||||||||||||||||||||
| 1118 | } | ||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||
| 1120 | =head2 _unpack_magik($buffer) | ||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||
| 1122 | Title : _unpack_magik($buffer) | ||||||||||||||||||||||||||||||||
| 1123 | Usage : $self->_unpack_magik($buffer) | ||||||||||||||||||||||||||||||||
| 1124 | Function: What unpack specification should be used? Try them all. | ||||||||||||||||||||||||||||||||
| 1125 | Returns : Nothing. | ||||||||||||||||||||||||||||||||
| 1126 | Args : A buffer containing arbitrary binary data. | ||||||||||||||||||||||||||||||||
| 1127 | Notes : Eliminate the ambiguity and the guesswork. Used in the | ||||||||||||||||||||||||||||||||
| 1128 | adaptation of _delta(), mostly. | ||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||
| 1130 | =cut | ||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||
| 1132 | 0 | ▶ | sub _unpack_magik { | ||||||||||||||||||||||||||||||
|
Subroutine
_unpack_magik: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 1133 | 0 | my ($self,$buffer) = @_; | |||||||||||||||||||||||||||||||
| 1134 | 0 | my $length = length($buffer); | |||||||||||||||||||||||||||||||
| 1135 | 0 | my (@read,$counter); | |||||||||||||||||||||||||||||||
| 1136 | 0 | foreach (qw(c C s S i I l L n N v V)) { | |||||||||||||||||||||||||||||||
| 1137 | 0 | @read = unpack "$_$length", $buffer; | |||||||||||||||||||||||||||||||
| 1138 | 0 | ▶ | for ($counter=0; $counter < 20; $counter++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1139 | 0 | print("$read[$counter]\n"); | |||||||||||||||||||||||||||||||
| 1140 | } | ||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||
| 1142 | } | ||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||
| 1144 | =head2 read_from_buffer($filehandle,$buffer,$length) | ||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||
| 1146 | Title : read_from_buffer($filehandle,$buffer,$length) | ||||||||||||||||||||||||||||||||
| 1147 | Usage : $self->read_from_buffer($filehandle,$buffer,$length); | ||||||||||||||||||||||||||||||||
| 1148 | Function: Read from the buffer. | ||||||||||||||||||||||||||||||||
| 1149 | Returns : $buffer, containing a read of $length | ||||||||||||||||||||||||||||||||
| 1150 | Args : a filehandle, a buffer, and a read length | ||||||||||||||||||||||||||||||||
| 1151 | Notes : I just got tired of typing | ||||||||||||||||||||||||||||||||
| 1152 | "unless (length($buffer) == $length)" so I put it here. | ||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||
| 1154 | =cut | ||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||
| 1156 | 100 | ▶ | sub read_from_buffer { | ||||||||||||||||||||||||||||||
|
Subroutine
read_from_buffer: called CC=5 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1157 | 100 | my ($self,$fh,$buffer,$length,$start_position) = @_; | |||||||||||||||||||||||||||||||
| 1158 | # print("Reading from a buffer!!! length($length) "); | ||||||||||||||||||||||||||||||||
| 1159 | 100 | ▶ | if ($start_position) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1160 | # print(" startposition($start_position)(".sprintf("%X", $start_position).")\n"); | ||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||
| 1162 | # print("\n"); | ||||||||||||||||||||||||||||||||
| 1163 | 100 | ▶ | if ($start_position) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1164 | # print("seeking to this position in the file: (".$start_position.")\n"); | ||||||||||||||||||||||||||||||||
| 1165 | 81 | seek ($fh,$start_position,0); | |||||||||||||||||||||||||||||||
| 1166 | # print("done. here is where I am now: (".tell($fh).")\n"); | ||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||
| 1168 | else { | ||||||||||||||||||||||||||||||||
| 1169 | # print("You did not specify a start position. Going from this position (the current position) (".tell($fh).")\n"); | ||||||||||||||||||||||||||||||||
| 1170 | } | ||||||||||||||||||||||||||||||||
| 1171 | 100 | read $fh, $buffer, $length; | |||||||||||||||||||||||||||||||
| 1172 | 100 | ▶ | unless (length($buffer) == $length) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1173 | 0 | $self->warn("The read was incomplete! Trying harder."); | |||||||||||||||||||||||||||||||
| 1174 | 0 | my $missing_length = $length - length($buffer); | |||||||||||||||||||||||||||||||
| 1175 | 0 | my $buffer2; | |||||||||||||||||||||||||||||||
| 1176 | 0 | read $fh,$buffer2,$missing_length; | |||||||||||||||||||||||||||||||
| 1177 | 0 | $buffer .= $buffer2; | |||||||||||||||||||||||||||||||
| 1178 | 0 | ▶ | if (length($buffer) != $length) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1179 | 0 | $self->throw("Unexpected end of file while reading from SCF file. I should have read $length but instead got ".length($buffer)."! Current file position is ".tell($fh)."."); | |||||||||||||||||||||||||||||||
| 1180 | } | ||||||||||||||||||||||||||||||||
| 1181 | } | ||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||
| 1183 | 100 | return $buffer; | |||||||||||||||||||||||||||||||
| 1184 | } | ||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||
| 1186 | =head2 _dump_keys() | ||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||
| 1188 | Title : _dump_keys() | ||||||||||||||||||||||||||||||||
| 1189 | Usage : &_dump_keys($a_reference_to_some_hash) | ||||||||||||||||||||||||||||||||
| 1190 | Function: Dump out the keys in a hash. | ||||||||||||||||||||||||||||||||
| 1191 | Returns : Nothing. | ||||||||||||||||||||||||||||||||
| 1192 | Args : A reference to a hash. | ||||||||||||||||||||||||||||||||
| 1193 | Notes : A debugging method. | ||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||
| 1195 | =cut | ||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||
| 1197 | 0 | ▶ | sub _dump_keys { | ||||||||||||||||||||||||||||||
|
Subroutine
_dump_keys: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 1198 | 0 | my $rhash = shift; | |||||||||||||||||||||||||||||||
| 1199 | 0 | ▶ | if ($rhash !~ /HASH/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1200 | 0 | print("_dump_keys: that was not a hash.\nIt was #$rhash# which was this reference:".ref($rhash)."\n"); | |||||||||||||||||||||||||||||||
| 1201 | 0 | return; | |||||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||||||
| 1203 | 0 | print("_dump_keys: The keys for $rhash are:\n"); | |||||||||||||||||||||||||||||||
| 1204 | 0 | foreach (sort keys %$rhash) { | |||||||||||||||||||||||||||||||
| 1205 | 0 | print("$_\n"); | |||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||
| 1207 | } | ||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||
| 1209 | =head2 _dump_base_accuracies() | ||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||
| 1211 | Title : _dump_base_accuracies() | ||||||||||||||||||||||||||||||||
| 1212 | Usage : $self->_dump_base_accuracies(); | ||||||||||||||||||||||||||||||||
| 1213 | Function: Dump out the v3 base accuracies in an easy to read format. | ||||||||||||||||||||||||||||||||
| 1214 | Returns : Nothing. | ||||||||||||||||||||||||||||||||
| 1215 | Args : None. | ||||||||||||||||||||||||||||||||
| 1216 | Notes : A debugging method. | ||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||
| 1218 | =cut | ||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||
| 1220 | 0 | ▶ | sub _dump_base_accuracies { | ||||||||||||||||||||||||||||||
|
Subroutine
_dump_base_accuracies: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 1221 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 1222 | 0 | print("Dumping base accuracies! for v3\n"); | |||||||||||||||||||||||||||||||
| 1223 | 0 | print("There are this many elements in a,c,g,t:\n"); | |||||||||||||||||||||||||||||||
| 1224 | 0 | print(scalar(@{$self->{'text'}->{'v3_base_accuracy_a'}}).",".scalar(@{$self->{'text'}->{'v3_base_accuracy_c'}}).",".scalar(@{$self->{'text'}->{'v3_base_accuracy_g'}}).",".scalar(@{$self->{'text'}->{'v3_base_accuracy_t'}})."\n"); | |||||||||||||||||||||||||||||||
| 1225 | 0 | my $number_traces = scalar(@{$self->{'text'}->{'v3_base_accuracy_a'}}); | |||||||||||||||||||||||||||||||
| 1226 | 0 | ▶ | for (my $counter=0; $counter < $number_traces; $counter++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1227 | 0 | print("$counter\t"); | |||||||||||||||||||||||||||||||
| 1228 | 0 | print $self->{'text'}->{'v3_base_accuracy_a'}->[$counter]."\t"; | |||||||||||||||||||||||||||||||
| 1229 | 0 | print $self->{'text'}->{'v3_base_accuracy_c'}->[$counter]."\t"; | |||||||||||||||||||||||||||||||
| 1230 | 0 | print $self->{'text'}->{'v3_base_accuracy_g'}->[$counter]."\t"; | |||||||||||||||||||||||||||||||
| 1231 | 0 | print $self->{'text'}->{'v3_base_accuracy_t'}->[$counter]."\t"; | |||||||||||||||||||||||||||||||
| 1232 | 0 | print("\n"); | |||||||||||||||||||||||||||||||
| 1233 | } | ||||||||||||||||||||||||||||||||
| 1234 | } | ||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||
| 1236 | =head2 _dump_peak_indices_incoming() | ||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||
| 1238 | Title : _dump_peak_indices_incoming() | ||||||||||||||||||||||||||||||||
| 1239 | Usage : $self->_dump_peak_indices_incoming(); | ||||||||||||||||||||||||||||||||
| 1240 | Function: Dump out the v3 peak indices in an easy to read format. | ||||||||||||||||||||||||||||||||
| 1241 | Returns : Nothing. | ||||||||||||||||||||||||||||||||
| 1242 | Args : None. | ||||||||||||||||||||||||||||||||
| 1243 | Notes : A debugging method. | ||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||
| 1245 | =cut | ||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||
| 1247 | 0 | ▶ | sub _dump_peak_indices_incoming { | ||||||||||||||||||||||||||||||
|
Subroutine
_dump_peak_indices_incoming: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 1248 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 1249 | 0 | print("Dump peak indices incoming!\n"); | |||||||||||||||||||||||||||||||
| 1250 | 0 | my $length = $self->{'bases'}; | |||||||||||||||||||||||||||||||
| 1251 | 0 | print("The length is $length\n"); | |||||||||||||||||||||||||||||||
| 1252 | 0 | ▶ | for (my $count=0; $count < $length; $count++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1253 | 0 | print("$count\t$self->{parsed}->{peak_indices}->[$count]\n"); | |||||||||||||||||||||||||||||||
| 1254 | } | ||||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||
| 1257 | =head2 _dump_base_accuracies_incoming() | ||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||
| 1259 | Title : _dump_base_accuracies_incoming() | ||||||||||||||||||||||||||||||||
| 1260 | Usage : $self->_dump_base_accuracies_incoming(); | ||||||||||||||||||||||||||||||||
| 1261 | Function: Dump out the v3 base accuracies in an easy to read format. | ||||||||||||||||||||||||||||||||
| 1262 | Returns : Nothing. | ||||||||||||||||||||||||||||||||
| 1263 | Args : None. | ||||||||||||||||||||||||||||||||
| 1264 | Notes : A debugging method. | ||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||
| 1266 | =cut | ||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||
| 1268 | 0 | ▶ | sub _dump_base_accuracies_incoming { | ||||||||||||||||||||||||||||||
|
Subroutine
_dump_base_accuracies_incoming: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 1269 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 1270 | 0 | print("Dumping base accuracies! for v3\n"); | |||||||||||||||||||||||||||||||
| 1271 | # print("There are this many elements in a,c,g,t:\n"); | ||||||||||||||||||||||||||||||||
| 1272 | # print(scalar(@{$self->{'parsed'}->{'v3_base_accuracy_a'}}).",".scalar(@{$self->{'text'}->{'v3_base_accuracy_c'}}).",".scalar(@{$self->{'text'}->{'v3_base_accuracy_g'}}).",".scalar(@{$self->{'text'}->{'v3_base_accuracy_t'}})."\n"); | ||||||||||||||||||||||||||||||||
| 1273 | 0 | my $number_traces = $self->{'bases'}; | |||||||||||||||||||||||||||||||
| 1274 | 0 | ▶ | for (my $counter=0; $counter < $number_traces; $counter++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1275 | 0 | print("$counter\t"); | |||||||||||||||||||||||||||||||
| 1276 | 0 | foreach (qw(A T G C)) { | |||||||||||||||||||||||||||||||
| 1277 | 0 | print $self->{'parsed'}->{'base_accuracies'}->{$_}->[$counter]."\t"; | |||||||||||||||||||||||||||||||
| 1278 | } | ||||||||||||||||||||||||||||||||
| 1279 | 0 | print("\n"); | |||||||||||||||||||||||||||||||
| 1280 | } | ||||||||||||||||||||||||||||||||
| 1281 | } | ||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||
| 1284 | =head2 _dump_comments() | ||||||||||||||||||||||||||||||||
| 1285 | |||||||||||||||||||||||||||||||||
| 1286 | Title : _dump_comments() | ||||||||||||||||||||||||||||||||
| 1287 | Usage : $self->_dump_comments(); | ||||||||||||||||||||||||||||||||
| 1288 | Function: Debug dump the comments section from the scf. | ||||||||||||||||||||||||||||||||
| 1289 | Returns : Nothing. | ||||||||||||||||||||||||||||||||
| 1290 | Args : Nothing. | ||||||||||||||||||||||||||||||||
| 1291 | Notes : None. | ||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||
| 1293 | =cut | ||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||
| 1295 | 0 | ▶ | sub _dump_comments { | ||||||||||||||||||||||||||||||
|
Subroutine
_dump_comments: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 1296 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 1297 | 0 | warn ("SCF comments:\n"); | |||||||||||||||||||||||||||||||
| 1298 | 0 | foreach my $k (keys %{$self->{'comments'}}) { | |||||||||||||||||||||||||||||||
| 1299 | 0 | warn ("\t {$k} ==> ", $self->{'comments'}->{$k}, "\n"); | |||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||
| 1301 | } | ||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||
| 1303 | |||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||
| 1305 | 2 | 1; | |||||||||||||||||||||||||||||||
| 1306 | __END__ | ||||||||||||||||||||||||||||||||