Dr. Harpreet Singh
Head, PG Department of Bioinformatics,
Hans Raj Mahila Maha Vidyalaya,
Jalandhar, Punjab, India
e-module
Introduction to BioPerl
Introduction: What is BioPerl?
What BioPerl can do?
History of BioPerl
Organization of BioPerlcode
Programming approach
BioPerl Modules
The Perl modules, illustrated in Table given below, are organized by logical names so that, for example, the Bio∷Search hierarchy contains modules related to database searches, and Bio∷Graphics contains modules that are related to drawing. The Bio∷Perl module itself is a simplified API that provides access to the most-commonly used Bioperl functions.
Basic BioPerl functionality: Using the Bio::Perl.pm module
��
use Bio::Perl;
$seq_object = get_sequence('swiss',"ROA1_HUMAN"); write_sequence(">roa1.fasta",'fasta',$seq_object);
use Bio::Perl;
$seq = get_sequence('swiss',"ROA1_HUMAN");
# uses the default database - nr in this case
$blast_result = blast_sequence($seq); write_blast(">roa1.blast",$blast_result);
Basic BioPerl functionality: Using the Bio::Perl.pm module
Major BioPerl Objects
Sequence Objects
Seq object:
Most common sequence manipulations can be performed with Seq. Seq objects can be created explicitly. However usually Seq objects will be created for you automatically when you read in a file containing sequence data using the SeqIO object. In addition to storing its identification labels and the sequence itself, a Seq object can store multiple annotations and associated ``sequence features''. This capability can be very useful - especially in development of automated genome annotation systems
PrimarySeq object:
PrimarySeq is basically a ``stripped down'' version of Seq. It contains just the sequence data itself and a few identifying labels (id, accession number, molecule type = dna, rna, or protein)
Seq is the central sequence object in bioperl. When in doubt this is probably the object that you want to use to describe a DNA, RNA or protein sequence in bioperl.
Sequence Objects
RichSeq object:
RichSeq objects store additional annotations beyond those used by standard Seq objects.
LocatableSeq object:
It is a Seq object which is part of a multiple sequence alignment. It has ``start'' and ``end'' positions indicating from where in a larger sequence it may have been extracted. It also may have ``gap'' symbols corresponding to the alignment to which it belongs.
LargeSeq object:
Special type of Seq object used for handling very long sequences (e.g. > 100 MB).
A LiveSeq object:
It is another specialized object for storing sequence data. LiveSeq addresses the problem of features whose location on a sequence changes over time. for example, when sequence feature objects are used to store gene locations on newly sequenced genomes - locations which can change as higher quality sequencing data becomes available.
Alignment Objects
Early versions of bioperl used both UnivAln and SimpleAlign objects to represent and manipulate alignments but as of v. 1.0 only SimpleAlign.pm is supported.
This module allows the user to convert between alignment formats as well as more sophisticated operations, like extracting specific regions of the alignment and generating consensus sequences.
Location Objects
�Interface objects and implementation objects�
An interface is solely the definition of what methods one can call on an object, without any knowledge of how it is implemented.
An implementation is an actual, working implementation of an object.
In bioperl, the interface objects usually have names like Bio::MyObjectI, with the trailing I indicating it is an interface object.
The interface objects mainly provide documentation on what the interface is, and how to use it, without any implementations (though there are some exceptions).
Although interface objects are not of much direct utility to the casual bioperl user, being aware of their existence is useful since they are the basis to understanding how bioperl programs can communicate with other bioinformatics projects such as Ensembl and the Annotation Workbench
�Example 1: Accessing nucleotide and peptide sequence data from local and remote databases�
Directly enter data sequence data into a bioperl Seq object
$seq = Bio::Seq->new('-seq'=>'actgtggcgtcaact',
'-desc'=>'Sample Bio::Seq object', '-display_id' => 'something',
'-accession_number' => 'accnum',
'-alphabet' => 'dna' );
�Example 2: Accessing nucleotide and peptide sequence data from local and remote databases�
Example of accessing GenBank to retrieve a sequence:
$gb = new Bio::DB::GenBank();
# this returns a Seq object :
$seq1 = $gb->get_Seq_by_id('MUSIGHBA1');
# this returns a Seq object :
$seq2 = $gb->get_Seq_by_acc('AF303112'))
# this returns a SeqIO object :
$seqio = $gb->get_Stream_by_batch([ qw(J00522 AF303112 2981014)]));
Example 3: Transforming formats of database/ file records�
use Bio::SeqIO;
$in = Bio::SeqIO->new('-file' => "inputfilename", '-format' => 'Fasta');
$out = Bio::SeqIO->new('-file' => ">outputfilename", '-format' => 'EMBL');
while ( my $seq = $in->next_seq() ) {$out->write_seq($seq); }
Transforming sequence files (SeqIO)
A common - and tedious - bioinformatics task is that of converting sequence data among the many widely used data formats. Bioperl\'s SeqIO object, however, makes this chore a breeze.
SeqIO can read a stream of sequences - located in a single or in multiple files - in a number of formats: Fasta, EMBL, GenBank, Swissprot, PIR, GCG, SCF, phd/phred, Ace, or raw (plain sequence). Once the sequence data has been read in with SeqIO, it is available to bioperl in the form of Seq objects.
Moreover, the Seq objects can then be written to another file (again using SeqIO) in any of the supported data formats making data converters simple to implement, for example:
Example 4: Transforming formats of database/ file records�
use Bio::AlignIO;
$in = Bio::AlignIO->new('-file' => "inputfilename" ,
'-format' => 'fasta');
$out = Bio::AlignIO->new('-file' => ">outputfilename",
'-format' => 'pfam');
while ( my $aln = $in->next_aln() ) { $out->write_aln($aln); }
The only difference is that here, the returned object reference, $aln, is to a SimpleAlign object rather than a Seq object.
Transforming alignment files (AlignIO)
Data files storing multiple sequence alignments also appear in varied formats. AlignIO is the bioperl object for data conversion of alignment files. AlignIO is patterned on the SeqIO object and shares most of SeqIO\'s features.
AlignIO currently supports input in the following formats: fasta, mase, stockholm, prodom, selex, bl2seq, clustalw, msf/gcg, water, needle and output in these formats: fasta, mase, selex, clustalw, msf/gcg.
One significant difference between AlignIO and SeqIO is that AlignIO handles IO for only a single alignment at a time (SeqIO.pm handles IO for multiple sequences in a single stream.) Syntax for AlignIO is almost identical to that of SeqIO:
�Example 5: Obtaining basic sequence statistics- MW, residue & codon frequencies(SeqStats, SeqWord)�
use SeqStats;
$seq_stats = Bio::Tools::SeqStats->new($seqobj);
$weight = $seq_stats->get_mol_wt();
$monomer_ref = $seq_stats->count_monomers();
$codon_ref = $seq_stats->count_codons(); # for nucleic acid sequence
In addition to the methods directly available in the Seq object, bioperl provides various ``helper'' objects to determine additional information about a sequence.
For example, SeqStats object provides methods for obtaining the molecular weight of the sequence as well the number of occurrences of each of the component residues (bases for a nucleic acid or amino acids for a protein.) For nucleic acids, SeqStats also returns counts of the number of codons used.
�Example 6: Searching similar sequences�
@params = ('program' => 'blastn',
'database' => 'ecoli.nt');
$factory = Bio::Tools::Run::StandAloneBlast->new(@params);
One of the basic tasks in molecular biology is identifying sequences that are, in some way, similar to a sequence of interest. The Blast programs, originally developed at the NCBI, are widely used for identifying such sequences. Bioperl offers a number of modules to facilitate running Blast as well as to parse the often voluminous reports produced by Blast.
Running BLAST locally (StandAloneBlast)
There are several reasons why one might want to run the Blast programs locally - speed, data security, immunity to network problems, being able to run large batch runs etc. The NCBI provides a downloadable version of blast in a stand-alone format, and running blast locally without any use of perl or bioperl is completely straightforward. However, there are situations where having a perl interface for running the blast programs locally is convenient.
�Example 6: Searching similar sequences�
$remote_blast = Bio::Tools::Run::RemoteBlast->new(
'-prog' => 'blastp','-data' => 'ecoli','-expect' => '1e-10' );
$r = $remote_blast->submit_blast("t/data/ecolitst.fa");
while (@rids = $remote_blast->each_rid )
{ foreach $rid ( @rids ) {$rc = $remote_blast->retrieve_blast($rid);}}
Running BLAST remotely (using RemoteBlast.pm)
Bioperl supports remote execution of blasts at NCBI by means of the RemoteBlast object. The Bio::Tools::Run::RemoteBlast object is developed for this purpose.
Installing BioPerl on Windows�
The main points.
2. install Module::Build
7) At the cpan> prompt, type
install Test::Harness
8) At the cpan> prompt, type
install Test::Most
�Install BioPerl from Github�
Install the the current version of Bioperl manually using a ZIP file from the GitHub repository:
1) Go to GitHub and press the Download ZIP button. If not available at Github, you can download this file which was obtained from Github some time ago: bioperl-live-master.zip
2) Extract the archive in the normal way.
3) In a cmd window go to the directory you extracted to. Eg. if you extracted to directory ‘bioperl-live’, cd bioperl-live (I downloaded to c:\downloads\bioperl-live and went there and installed everything from that catalogue).
4) At the prompt type :
perl Build.pl
and answer the questions.
5) Type
perl Build test
All the tests should pass, but if they don’t, your usage of Bioperl may or may not be affected by the failures, so you can choose to continue anyway.
6) Type:
perl Build install
References
Thanks