Bioperl: Finding Restriction Enzyme Sites
1
0
Entering edit mode
12.1 years ago
cindylanzao ▴ 10
#!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);
@fragment=$analysis->fragments($my_enzyme);
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 • 4.2k views
ADD COMMENT
0
Entering edit mode

(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 REPLY
0
Entering edit mode

Thank you very much,

ADD REPLY
0
Entering edit mode

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 REPLY
5
Entering edit mode
12.1 years ago
Neilfws 49k

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 COMMENT
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1807 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6