Reverse Complementation Page

This script gives the reverse complementation of a sequence.

#!/usr/bin/perl
# file: reversec.pl

use CGI ':standard';

print header;
print start_html('Reverse Complementation'),
  h1('Reverse Complementator'),
  start_form,
  "Enter your sequence here:",br,
  textarea(-name=>'sequence',-rows=>5,-cols=>60),
  submit('Reverse Complement'),
  end_form,
  hr;

if ( param ) {
  my $sequence = param('sequence');

  my $reversec = do_reverse($sequence);
  $reversec    =~ s/(.{60})/$1\n/g;  # do word wrap

  print h2('Reverse complement');
  print pre($reversec);
}

print end_html;

sub do_reverse {
  my $seq = shift;
  $seq =~ s/\s//g;               # strip whitespace
  $seq =~ tr/gatcGATC/ctagCTAG/; # complement
  $seq = reverse $seq;           # and reverse
  return $seq;
}

http://your.site/cgi-bin/reversec.pl


<< Previous Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Fri Oct 22 10:58:20 EDT 1999