[bug 2637]
[bioperl-live.git] / examples / rev_and_trans.pl
blob7ea6a291cefe3dd9ab9e987fa165d35757f1947a
1 #!/usr/bin/perl
3 # PROGRAM : rev_and_trans.pl
4 # PURPOSE : Simple driver for Bio::Seq revcom and translate
5 # AUTHOR : Ewan Birney birney@sanger.ac.uk
6 # CREATED : Tue Oct 27 1998
7 # REVISION : $Id$
9 # INSTALLATION
10 # If you have installed bioperl using the standard
11 # makefile system everything should be fine and
12 # dandy.
14 # if not edit the use lib "...." line to point the directory
15 # containing your Bioperl modules.
19 use Bio::Seq;
20 use Bio::SeqIO;
22 # new sequence from raw memory...
23 # it is *very* important to get the type right so it
24 # is translated correctly.
26 $seq = Bio::Seq->new ( -id => "myseq",
27 -seq => "CGCCGAAGAAGCATCGTTAAAGTCTCTCTTCACCCTGCCGTCATGTCTAAGTCAGAGTCTCCT",
28 -type => 'Dna');
30 $seqout = Bio::SeqIO->new('-format' => 'fasta', -fh => \*STDOUT);
32 # make a reverse complement sequence
34 $rev = $seq->revcom();
36 # the actual sequence is here
38 $actual_bases = $rev->seq();
40 print "Reversed sequence as a string is [$actual_bases]\n";
42 # we could also write it as fasta formatted output
44 $seqout->write_seq($rev);
46 # make a translation
48 $trans = $seq->translate();
50 print "Translated sequence!\n";
52 $seqout->write_seq($trans);