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
6 # POD documentation - main docs before the code
10 Bio::Tools::Gel - Calculates relative electrophoretic migration distances
15 use Bio::Restriction::Analysis;
19 my $d = 'AAAAAAAAAGAATTCTTTTTTTTTTTTTTGAATTCGGGGGGGGGGGGGGGGGGGG';
20 my $seq1 = Bio::Seq->new(-id=>'groundhog day',-seq=>$d);
22 # cut it with an enzyme
23 my $ra=Bio::Restriction::Analysis->new(-seq=>$seq1);
24 @cuts = $ra->fragments('EcoRI'), 3;
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";
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));
44 Source: Molecular Cloning, a Laboratory Manual. Sambrook, Fritsch, Maniatis.
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.
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.
60 bioperl-l@bioperl.org - General discussion
61 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
65 Please direct usage questions or support issues to the mailing list:
67 I<bioperl-l@bioperl.org>
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.
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
80 https://github.com/bioperl/bioperl-live/issues
82 =head1 AUTHOR - Allen Day
84 Email allenday@ucla.edu
88 The rest of the documentation details each of the object methods.
89 Internal methods are usually preceded with a _
94 package Bio
::Tools
::Gel
;
99 use base
qw(Bio::Root::Root);
104 Usage : my $gel = Bio::Tools::Gel->new(-seq => $sequence,-dilate => 3);
105 Function: Initializes a new Gel
106 Returns : Bio::Tools::Gel
107 Args : -seq => Bio::Seq(s), scalar(s) or list of either/both
109 -dilate => Expand band migration distances (default: 1)
114 my ($class, @args) = @_;
116 my $self = $class->SUPER::new
(@args);
117 my ($seqs, $dilate) = $self->_rearrange([qw(SEQ DILATE)], @args);
119 $self->add_band([$seqs]);
120 } elsif( ref($seqs) =~ /array/i ||
121 $seqs->isa('Bio::PrimarySeqI') ) {
122 $self->add_band($seqs);
124 $self->dilate($dilate || 1);
133 Usage : $gel->add_band($seq);
134 Function: Calls _add_band with a (possibly created) Bio::Seq object.
136 Args : Bio::Seq, scalar sequence, or list of either/both.
141 my ($self, $args) = @_;
143 foreach my $arg (@
$args){
146 if( $arg =~ /^\d+/ ) {
148 $seq = Bio
::PrimarySeq
->new(-seq
=>'N'x
$arg, -id
=> $arg);
150 # $arg is a sequence string
151 $seq = Bio
::PrimarySeq
->new(-seq
=>$arg, -id
=>length $arg);
153 } elsif( $arg->isa('Bio::PrimarySeqI') ) {
154 # $arg is a sequence object
158 $self->_add_band($seq);
167 Usage : $gel->_add_band($seq);
168 Function: Adds a new band to the gel.
170 Args : Bio::Seq object
175 my ($self, $arg) = @_;
177 push (@
{$self->{'bands'}},$arg);
186 Usage : $gel->dilate(1);
187 Function: Sets/retrieves the dilation factor.
188 Returns : dilation factor
194 my ($self, $arg) = @_;
195 return $self->{dilate
} unless $arg;
196 $self->throw("-dilate should be numeric") if defined $arg and $arg =~ /[^e\d\.]/;
197 $self->{dilate
} = $arg;
198 return $self->{dilate
};
203 my ($self, $arg) = @_;
204 $arg = $self unless $arg;
206 return 4 - log10
($arg);
217 Function: Calculates migration distances of sequences.
218 Returns : hash of (seq_id => distance)
225 $self->throw("bands() is read-only") if @_;
229 foreach my $band (@
{$self->{bands
}}){
230 my $distance = $self->dilate * migrate
($band->length);
231 $bands{$band->id} = $distance;
242 Function: returns base 10 log of $n.
248 # from "Programming Perl"
251 return log($n)/log(10);