Question: Bioperl: Finding Restriction Enzyme Sites
gravatar for cindylanzao
6.5 years ago by
cindylanzao10 wrote:
#!usr/bin/perl -w
use Bio::DB::GenBank;
use Bio::Restriction::EnzymeCollection;
use Bio::Restriction::Analysis;

my $gb=new Bio::DB::GenBank();
my $seq=$gb->get_Seq_by_acc('AF303112');
print $seq->seq,"\n";
my $all_collection=Bio::Restriction::EnzymeCollection;
my $my_enzyme=$all_collection->get_enzyme('EcoRI');
my $analysis=Bio::Restriction::Analysis->new(-seq=>$seq);
print "@fragment\n";
my $pro_obj=$seq->translate(-complete=>1);
print $pro_obj->seq;

I want to get a sequence by accession number, and then find if there is a EcoRI enzyme site in this sequence and finally translate this sequence into protein. But the output is only the Nuclear Acid sequence, what's wrong, can someone tell me? Thanks!

bioperl • 2.7k views
ADD COMMENTlink modified 6.5 years ago by Neilfws48k • written 6.5 years ago by cindylanzao10

(1) I've indented your lines of code with 4 spaces: note how this improves readability. (2) I think you wanted to post this under category "question", not "forum"; changed that too.

ADD REPLYlink modified 6.5 years ago • written 6.5 years ago by Neilfws48k

Thank you very much,

ADD REPLYlink written 6.5 years ago by cindylanzao10

Changed the title too. "Bioperl" is not very informative. Nor were "beginner's" or "task" as tags. Good titles and tags make your question easier to find and answer.

ADD REPLYlink written 6.5 years ago by Neilfws48k
gravatar for Neilfws
6.5 years ago by
Sydney, Australia
Neilfws48k wrote:

First: if you're going to declare your variables using my, you should:

use strict;

Second - now that we are using strict, you need to change @fragment to:

my @fragment = $analysis->fragments($my_enzyme);

Third: having done those things, you should now see the error:

Bareword "Bio::Restriction::EnzymeCollection" not allowed while "strict subs" in use at...

I suspect that what you want is:

my $all_collection = Bio::Restriction::EnzymeCollection->new;

Your code should now run and print the sequence, fragment and translation. In this example, there does not appear to be an EcoRI site since the sequence and fragment are the same.

Finally: Perl code is much more readable if you put in more spaces and align related lines. For example, compare this to what you typed:

my $all_collection = Bio::Restriction::EnzymeCollection->new;
my $my_enzyme      = $all_collection->get_enzyme('EcoRI');
my $analysis       = Bio::Restriction::Analysis->new(-seq => $seq);
my @fragment       = $analysis->fragments($my_enzyme);
ADD COMMENTlink written 6.5 years ago by Neilfws48k

Regarding writing readable Perl code, there are some automatic plug-ins for VIM, EMACs or JEDIT, or you can simply use PerlTidy:

ADD REPLYlink written 6.5 years ago by JC7.7k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 842 users visited in the last hour