BioPerl Tutorial: Retrieving Sequece from BioPerl (Bio::DB) GenBank Module

bioperl tutorialContinuing with BioPerl Tutorial series, we will see how to access sequences remotely with help of Bio::DB BioPerl module.

NOTE: To install BioPerl or for knowing about coding in BioPerl, BioPerl modules see index of this BioPerl Tutorial series.

About Bio::DB

Bio::DB BioPerl module allows you to fetch biological sequences from local as remote databases. We can retrieve GenBank, SwissProt, EMBL sequences. To use the module we will be declaring it in following syntax:

use Bio::DB::GenBank;


This will tell Perl application that we will be using GenBank module of Bio::DB. In case, we have to use for SwissProt we will mention that as

use Bio::DB::SwissProt;

Creating Object

Now we will be creating an Bio::DB::GenBank object. I will be naming it as $db_obj

The syntax will be:

$db_obj = Bio::DB::GenBank->new;

In this case, we will be using the same new() method but will not be passing any arguments.

Retrieving Sequence from GenBank

Now we will be retrieving sequence from GenBank Database.

NOTE: You need an active internet connection to fetch GenBank sequences using Bio::DB Bioperl Module.

We will be retrieving sequence by its ID. ID is an identifier in GenBank. Let’s assume we take ID as 8. To retrieve the sequence we will be using get_Seq_by_id() method. We can also use get_Seq_by_acc() method to retrieve sequences if we know how accession number of GenBank sequences.

We will be storing the sequence retrieved in sequence object $seq_obj. The syntax will be:

$seq_obj = $db_obj->get_Seq_by_id(8);

Printing the retrieved Sequence

Now we will be printing the retrieved sequence using print method. The code for printing sequences will be:

print $seq_obj->seq;

The complete code will be:

use Bio::DB::GenBank;
$db_obj = Bio::DB::GenBank->new;
$seq_obj = $db_obj->get_Seq_by_id(8);
print "\nThe sequence retrieved is:";
print $seq_obj->seq;

The screenshot of code is:

genbank bioperl 1

The output will be:

Note: It might take some time for output to appear depending on your internet connection.

biodb genbank 2

Hope you enjoyed this BioPerl tutorial of using Bio::DB::GenBank BioPerl module to retrieve GenBank sequences. Feel free to ask any question!

In next article, we will see how to read multiple sequences from GenBank

About Brij

Bhrat Brij is a SEO expert, Internet Marketer, Affiliate Marketer and Bioinformatician. My short bio or have a look on my Google Profile

Comments

  1. pankaj tripathi says:

    Hello
    I want to download sequence database by using bioperl . On the given above code we can download only some sequence by their sequence id . But i want to download all sequence from gene bank or NCBI Database for making a local database without any condition( like – By sequence id ).

Speak Your Mind

*