3 # BioPerl module for Bio::Tools::Gel
4 # Copyright Allen Day <allenday@ucla.edu>
5 # You may distribute this module under the same terms as perl itself
7 # POD documentation - main docs before the code
11 Bio::Tools::Gel - Calculates relative electrophoretic migration distances
16 use Bio::Restriction::Analysis;
20 my $d = 'AAAAAAAAAGAATTCTTTTTTTTTTTTTTGAATTCGGGGGGGGGGGGGGGGGGGG';
21 my $seq1 = Bio::Seq->new(-id=>'groundhog day',-seq=>$d);
23 # cut it with an enzyme
24 my $ra=Bio::Restriction::Analysis->new(-seq=>$seq1);
25 @cuts = $ra->fragments('EcoRI'), 3;
27 # analyse the fragments in a gel
28 my $gel = Bio::Tools::Gel->new(-seq=>\@cuts,-dilate=>10);
29 my %bands = $gel->bands;
30 foreach my $band (sort {$b <=> $a} keys %bands){
31 print $band,"\t", sprintf("%.1f", $bands{$band}),"\n";
42 This takes a set of sequences or Bio::Seq objects, and calculates their
43 respective migration distances using:
44 distance = dilation * (4 - log10(length(dna));
46 Source: Molecular Cloning, a Laboratory Manual. Sambrook, Fritsch, Maniatis.
49 Bio::Tools::Gel currently calculates migration distances based solely on
50 the length of the nucleotide sequence. Secondary or tertiary structure,
51 curvature, and other biophysical attributes of a sequence are currently
52 not considered. Polypeptide migration is currently not supported.
58 User feedback is an integral part of the evolution of this and other
59 Bioperl modules. Send your comments and suggestions preferably to
60 the Bioperl mailing list. Your participation is much appreciated.
62 bioperl-l@bioperl.org - General discussion
63 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
67 Please direct usage questions or support issues to the mailing list:
69 I<bioperl-l@bioperl.org>
71 rather than to the module maintainer directly. Many experienced and
72 reponsive experts will be able look at the problem and quickly
73 address it. Please include a thorough description of the problem
74 with code and data examples if at all possible.
78 Report bugs to the Bioperl bug tracking system to help us keep track
79 of the bugs and their resolution. Bug reports can be submitted via the
82 http://bugzilla.open-bio.org/
84 =head1 AUTHOR - Allen Day
86 Email allenday@ucla.edu
90 The rest of the documentation details each of the object methods.
91 Internal methods are usually preceded with a _
96 # Let the code begin...
99 package Bio
::Tools
::Gel
;
104 use base
qw(Bio::Root::Root);
109 Usage : my $gel = Bio::Tools::Gel->new(-seq => $sequence,-dilate => 3);
110 Function: Initializes a new Gel
111 Returns : Bio::Tools::Gel
112 Args : -seq => Bio::Seq(s), scalar(s) or list of either/both
114 -dilate => Expand band migration distances (default: 1)
119 my($class,@args) = @_;
121 my $self = $class->SUPER::new
(@args);
122 my ($seqs,$dilate) = $self->_rearrange([qw(SEQ DILATE)],
125 $self->add_band([$seqs]);
126 } elsif( ref($seqs) =~ /array/i ||
127 $seqs->isa('Bio::PrimarySeqI') ) {
128 $self->add_band($seqs);
130 $self->dilate($dilate || 1);
139 Usage : $gel->add_band($seq);
140 Function: Calls _add_band with a (possibly created) Bio::Seq object.
142 Args : Bio::Seq, scalar sequence, or list of either/both.
147 my($self,$args) = @_;
149 foreach my $arg (@
$args){
152 if( $arg =~ /^\d+/ ) {
153 $seq= Bio
::PrimarySeq
->new(-seq
=>"N"x
$arg, -id
=> $arg);
155 $seq= Bio
::PrimarySeq
->new(-seq
=>$arg,-id
=>length($arg));
157 } elsif( $arg->isa('Bio::PrimarySeqI') ) {
161 $seq->validate_seq or $seq->throw("invalid symbol in sequence".$seq->seq()."\n");
162 $self->_add_band($seq);
169 Usage : $gel->_add_band($seq);
170 Function: Adds a new band to the gel.
172 Args : Bio::Seq object
179 push (@
{$self->{'bands'}},$arg);
186 Usage : $gel->dilate(1);
187 Function: Sets/retrieves the dilation factor.
188 Returns : dilation factor
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
};
202 my ($self,$arg) = @_;
203 $arg = $self unless $arg;
205 return 4 - log10
($arg);
213 Function: Calculates migration distances of sequences.
214 Returns : hash of (seq_id => distance)
221 $self->throw("bands() is read-only") if @_;
225 foreach my $band (@
{$self->{bands
}}){
226 my $distance = $self->dilate * migrate
($band->length);
227 $bands{$band->id} = $distance;
237 Function: returns base 10 log of $n.
243 #from programming perl
246 return log($n)/log(10);