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";
41 This takes a set of sequences or Bio::Seq objects, and calculates their
42 respective migration distances using:
43 distance = dilation * (4 - log10(length(dna));
45 Source: Molecular Cloning, a Laboratory Manual. Sambrook, Fritsch, Maniatis.
48 Bio::Tools::Gel currently calculates migration distances based solely on
49 the length of the nucleotide sequence. Secondary or tertiary structure,
50 curvature, and other biophysical attributes of a sequence are currently
51 not considered. Polypeptide migration is currently not supported.
57 User feedback is an integral part of the evolution of this and other
58 Bioperl modules. Send your comments and suggestions preferably to
59 the Bioperl mailing list. Your participation is much appreciated.
61 bioperl-l@bioperl.org - General discussion
62 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
66 Please direct usage questions or support issues to the mailing list:
68 I<bioperl-l@bioperl.org>
70 rather than to the module maintainer directly. Many experienced and
71 reponsive experts will be able look at the problem and quickly
72 address it. Please include a thorough description of the problem
73 with code and data examples if at all possible.
77 Report bugs to the Bioperl bug tracking system to help us keep track
78 of the bugs and their resolution. Bug reports can be submitted via the
81 https://redmine.open-bio.org/projects/bioperl/
83 =head1 AUTHOR - Allen Day
85 Email allenday@ucla.edu
89 The rest of the documentation details each of the object methods.
90 Internal methods are usually preceded with a _
95 # Let the code begin...
98 package Bio
::Tools
::Gel
;
103 use base
qw(Bio::Root::Root);
108 Usage : my $gel = Bio::Tools::Gel->new(-seq => $sequence,-dilate => 3);
109 Function: Initializes a new Gel
110 Returns : Bio::Tools::Gel
111 Args : -seq => Bio::Seq(s), scalar(s) or list of either/both
113 -dilate => Expand band migration distances (default: 1)
118 my($class,@args) = @_;
120 my $self = $class->SUPER::new
(@args);
121 my ($seqs,$dilate) = $self->_rearrange([qw(SEQ DILATE)],
124 $self->add_band([$seqs]);
125 } elsif( ref($seqs) =~ /array/i ||
126 $seqs->isa('Bio::PrimarySeqI') ) {
127 $self->add_band($seqs);
129 $self->dilate($dilate || 1);
138 Usage : $gel->add_band($seq);
139 Function: Calls _add_band with a (possibly created) Bio::Seq object.
141 Args : Bio::Seq, scalar sequence, or list of either/both.
146 my($self,$args) = @_;
148 foreach my $arg (@
$args){
151 if( $arg =~ /^\d+/ ) {
152 $seq= Bio
::PrimarySeq
->new(-seq
=>"N"x
$arg, -id
=> $arg);
154 $seq= Bio
::PrimarySeq
->new(-seq
=>$arg,-id
=>length($arg));
156 } elsif( $arg->isa('Bio::PrimarySeqI') ) {
160 $seq->validate_seq or $seq->throw("invalid symbol in sequence".$seq->seq()."\n");
161 $self->_add_band($seq);
168 Usage : $gel->_add_band($seq);
169 Function: Adds a new band to the gel.
171 Args : Bio::Seq object
178 push (@
{$self->{'bands'}},$arg);
185 Usage : $gel->dilate(1);
186 Function: Sets/retrieves the dilation factor.
187 Returns : dilation factor
194 return $self->{dilate
} unless $arg;
195 $self->throw("-dilate should be numeric") if defined $arg and $arg =~ /[^e\d\.]/;
196 $self->{dilate
} = $arg;
197 return $self->{dilate
};
201 my ($self,$arg) = @_;
202 $arg = $self unless $arg;
204 return 4 - log10
($arg);
212 Function: Calculates migration distances of sequences.
213 Returns : hash of (seq_id => distance)
220 $self->throw("bands() is read-only") if @_;
224 foreach my $band (@
{$self->{bands
}}){
225 my $distance = $self->dilate * migrate
($band->length);
226 $bands{$band->id} = $distance;
236 Function: returns base 10 log of $n.
242 #from programming perl
245 return log($n)/log(10);