| 1 | # | ||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::Tools::Gel | ||||||||||||||||||||||||||||
| 3 | # Copyright Allen Day <allenday@ucla.edu> | ||||||||||||||||||||||||||||
| 4 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | Bio::Tools::Gel - Calculates relative electrophoretic migration distances | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | use Bio::PrimarySeq; | ||||||||||||||||||||||||||||
| 15 | use Bio::Restriction::Analysis; | ||||||||||||||||||||||||||||
| 16 | use Bio::Tools::Gel; | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # get a sequence | ||||||||||||||||||||||||||||
| 19 | my $d = 'AAAAAAAAAGAATTCTTTTTTTTTTTTTTGAATTCGGGGGGGGGGGGGGGGGGGG'; | ||||||||||||||||||||||||||||
| 20 | my $seq1 = Bio::Seq->new(-id=>'groundhog day',-seq=>$d); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # cut it with an enzyme | ||||||||||||||||||||||||||||
| 23 | my $ra=Bio::Restriction::Analysis->new(-seq=>$seq1); | ||||||||||||||||||||||||||||
| 24 | @cuts = $ra->fragments('EcoRI'), 3; | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # analyse the fragments in a gel | ||||||||||||||||||||||||||||
| 27 | my $gel = Bio::Tools::Gel->new(-seq=>\@cuts,-dilate=>10); | ||||||||||||||||||||||||||||
| 28 | my %bands = $gel->bands; | ||||||||||||||||||||||||||||
| 29 | foreach my $band (sort {$b <=> $a} keys %bands){ | ||||||||||||||||||||||||||||
| 30 | print $band,"\t", sprintf("%.1f", $bands{$band}),"\n"; | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | #prints: | ||||||||||||||||||||||||||||
| 34 | #20 27.0 | ||||||||||||||||||||||||||||
| 35 | #25 26.0 | ||||||||||||||||||||||||||||
| 36 | #10 30.0 | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | This takes a set of sequences or Bio::Seq objects, and calculates their | ||||||||||||||||||||||||||||
| 41 | respective migration distances using: | ||||||||||||||||||||||||||||
| 42 | distance = dilation * (4 - log10(length(dna)); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | Source: Molecular Cloning, a Laboratory Manual. Sambrook, Fritsch, Maniatis. | ||||||||||||||||||||||||||||
| 45 | CSHL Press, 1989. | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | Bio::Tools::Gel currently calculates migration distances based solely on | ||||||||||||||||||||||||||||
| 48 | the length of the nucleotide sequence. Secondary or tertiary structure, | ||||||||||||||||||||||||||||
| 49 | curvature, and other biophysical attributes of a sequence are currently | ||||||||||||||||||||||||||||
| 50 | not considered. Polypeptide migration is currently not supported. | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head1 FEEDBACK | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head2 Mailing Lists | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||
| 57 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||
| 58 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||
| 61 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head2 Support | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||
| 70 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||
| 71 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||
| 72 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||
| 77 | of the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||
| 78 | web: | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head1 AUTHOR - Allen Day | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Email allenday@ucla.edu | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head1 APPENDIX | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||
| 89 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | package Bio::Tools::Gel; | ||||||||||||||||||||||||||||
| 95 | 2 | $Bio::Tools::Gel::VERSION = '1.7.3'; | |||||||||||||||||||||||||||
| 96 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 2 | ▶ | use Bio::PrimarySeq; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 2 | ▶ | use base qw(Bio::Root::Root); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head2 new | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | Title : new | ||||||||||||||||||||||||||||
| 105 | Usage : my $gel = Bio::Tools::Gel->new(-seq => $sequence,-dilate => 3); | ||||||||||||||||||||||||||||
| 106 | Function: Initializes a new Gel | ||||||||||||||||||||||||||||
| 107 | Returns : Bio::Tools::Gel | ||||||||||||||||||||||||||||
| 108 | Args : -seq => Bio::Seq(s), scalar(s) or list of either/both | ||||||||||||||||||||||||||||
| 109 | (default: none) | ||||||||||||||||||||||||||||
| 110 | -dilate => Expand band migration distances (default: 1) | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =cut | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 115 | 0 | my ($class, @args) = @_; | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||
| 118 | 0 | my ($seqs, $dilate) = $self->_rearrange([qw(SEQ DILATE)], @args); | |||||||||||||||||||||||||||
| 119 | 0 | ▶ | if( ! ref($seqs) ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 120 | 0 | $self->add_band([$seqs]); | |||||||||||||||||||||||||||
| 121 | ▶ | } elsif( ref($seqs) =~ /array/i || | |||||||||||||||||||||||||||
|
Condition0%0/3
ref($seqs) =~ /array/i or $seqs->isa("Bio::PrimarySeqI")
MC/DC0%0/2
ref($seqs) =~ /array/i or $seqs->isa("Bio::PrimarySeqI")
ref($seqs) =~ /array/i
$seqs->isa("Bio::PrimarySeqI")
Truth table0%0/3
A or B
A= ref($seqs) =~ /array/iB= $seqs->isa("Bio::PrimarySeqI")
| |||||||||||||||||||||||||||||
| 122 | $seqs->isa('Bio::PrimarySeqI') ) { | ||||||||||||||||||||||||||||
| 123 | 0 | $self->add_band($seqs); | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $self->dilate($dilate || 1); | ||||||||||||||||||||||||||
|
Condition0%0/2
$dilate || 1
MC/DC0%0/1
$dilate || 1
$dilate
Truth table0%0/2
A
A= $dilate
| |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | return $self; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | =head2 add_band | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | Title : add_band | ||||||||||||||||||||||||||||
| 134 | Usage : $gel->add_band($seq); | ||||||||||||||||||||||||||||
| 135 | Function: Calls _add_band with a (possibly created) Bio::Seq object. | ||||||||||||||||||||||||||||
| 136 | Returns : | ||||||||||||||||||||||||||||
| 137 | Args : Bio::Seq, scalar sequence, or list of either/both. | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =cut | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub add_band { | ||||||||||||||||||||||||||
|
Subroutine
add_band: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 142 | 0 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 0 | foreach my $arg (@$args){ | |||||||||||||||||||||||||||
| 145 | 0 | my $seq; | |||||||||||||||||||||||||||
| 146 | 0 | ▶ | if( ! ref $arg ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if( $arg =~ /^\d+/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | # $arg is a number | ||||||||||||||||||||||||||||
| 149 | 0 | $seq = Bio::PrimarySeq->new(-seq=>'N'x$arg, -id => $arg); | |||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||
| 151 | # $arg is a sequence string | ||||||||||||||||||||||||||||
| 152 | 0 | $seq = Bio::PrimarySeq->new(-seq=>$arg, -id=>length $arg); | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | } elsif( $arg->isa('Bio::PrimarySeqI') ) { | ||||||||||||||||||||||||||||
| 155 | # $arg is a sequence object | ||||||||||||||||||||||||||||
| 156 | 0 | $seq = $arg; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | $self->_add_band($seq); | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | 0 | return 1; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | =head2 _add_band | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | Title : _add_band | ||||||||||||||||||||||||||||
| 168 | Usage : $gel->_add_band($seq); | ||||||||||||||||||||||||||||
| 169 | Function: Adds a new band to the gel. | ||||||||||||||||||||||||||||
| 170 | Returns : | ||||||||||||||||||||||||||||
| 171 | Args : Bio::Seq object | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =cut | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub _add_band { | ||||||||||||||||||||||||||
|
Subroutine
_add_band: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 176 | 0 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( defined $arg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | push (@{$self->{'bands'}},$arg); | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | 0 | return 1; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | =head2 dilate | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | Title : dilate | ||||||||||||||||||||||||||||
| 187 | Usage : $gel->dilate(1); | ||||||||||||||||||||||||||||
| 188 | Function: Sets/retrieves the dilation factor. | ||||||||||||||||||||||||||||
| 189 | Returns : dilation factor | ||||||||||||||||||||||||||||
| 190 | Args : Float or none | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =cut | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | sub dilate { | ||||||||||||||||||||||||||
|
Subroutine
dilate: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 195 | 0 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||
| 196 | 0 | ▶ | return $self->{dilate} unless $arg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $self->throw("-dilate should be numeric") if defined $arg and $arg =~ /[^e\d\.]/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg and $arg =~ /[^e\d\.]/
MC/DC0%0/2
defined $arg and $arg =~ /[^e\d\.]/
defined $arg
$arg =~ /[^e\d\.]/
Truth table0%0/3
A and B
A= defined $argB= $arg =~ /[^e\d\.]/
| |||||||||||||||||||||||||||||
| 198 | 0 | $self->{dilate} = $arg; | |||||||||||||||||||||||||||
| 199 | 0 | return $self->{dilate}; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub migrate { | ||||||||||||||||||||||||||
|
Subroutine
migrate: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 204 | 0 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||
| 205 | 0 | ▶ | $arg = $self unless $arg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ( $arg ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 0 | return 4 - log10($arg); | |||||||||||||||||||||||||||
| 208 | } else { | ||||||||||||||||||||||||||||
| 209 | 0 | return 0; | |||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | =head2 bands | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | Title : bands | ||||||||||||||||||||||||||||
| 217 | Usage : $gel->bands; | ||||||||||||||||||||||||||||
| 218 | Function: Calculates migration distances of sequences. | ||||||||||||||||||||||||||||
| 219 | Returns : hash of (seq_id => distance) | ||||||||||||||||||||||||||||
| 220 | Args : | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | =cut | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | ▶ | sub bands { | ||||||||||||||||||||||||||
|
Subroutine
bands: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 225 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 226 | 0 | ▶ | $self->throw("bands() is read-only") if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | my %bands = (); | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | foreach my $band (@{$self->{bands}}){ | |||||||||||||||||||||||||||
| 231 | 0 | my $distance = $self->dilate * migrate($band->length); | |||||||||||||||||||||||||||
| 232 | 0 | $bands{$band->id} = $distance; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | return %bands; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | =head2 log10 | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | Title : log10 | ||||||||||||||||||||||||||||
| 242 | Usage : log10($n); | ||||||||||||||||||||||||||||
| 243 | Function: returns base 10 log of $n. | ||||||||||||||||||||||||||||
| 244 | Returns : float | ||||||||||||||||||||||||||||
| 245 | Args : float | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | =cut | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | # from "Programming Perl" | ||||||||||||||||||||||||||||
| 250 | 0 | ▶ | sub log10 { | ||||||||||||||||||||||||||
|
Subroutine
log10: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 251 | 0 | my $n = shift; | |||||||||||||||||||||||||||
| 252 | 0 | return log($n)/log(10); | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 2 | 1; | |||||||||||||||||||||||||||