1 of 26

Dr. Harpreet Singh

Head, PG Department of Bioinformatics,

Hans Raj Mahila Maha Vidyalaya,

Jalandhar, Punjab, India

e-module

Introduction to BioPerl

2 of 26

Introduction: What is BioPerl?

  • a set of Perl modules for manipulating genomic and other biological data
  • an open source project to develop free Perl tools for computational molecular biology. 
  • is an international open-source collaboration of biologists, bioinformaticians, and computer scientists
  • provides an easy-to-use, stable, and consistent programming interface for bioinformatics application programmers.
  • played an integral role in the Human Genome Project
  • available at http://bioperl.org

3 of 26

What BioPerl can do?

  • Read in sequence data from a file in standard formats (FASTA, GenBank, EMBL, SwissProt,...)
  • Manipulate sequences, reverse complement, translate coding DNA sequence to protein.
  • Analyse and process results from programs such as BLAST, ClustalW, or the EMBOSS suite.
  • Bioperl provides access to data stores such as GenBank and SwissProt via a flexible series of sequence input/output modules, and to the emerging common sequence data storage format of the Open Bioinformatics Database Access project.
  • It often serves as a bridge between different computational biology applications assisting the user to construct analysis pipelines.
  • Interoperation with modules written in Python and Java is supported through the evolving BioCORBA bridge.

4 of 26

History of BioPerl

  • Early Developers
    • Students of the 1996 award winning VSNS-BCD BioComputing Course of Bielefeld University,Germany driven by Georg Fuellen (VSNS-BCD chief organizer)
    • Steven Brenner,University of California
    • Lincoln Stein,Cold Spring Harbour Lab
  • Later taken up by developers at large genome centres :
    • Stanford
    • Washington University Genome Sequencing Centre (St Louis)
    • Sanger Centre (Cambridge UK)
  • The current core group consists of Ewan Birney, Hilmar Lapp, Jason Stajich, Lincoln Stein, Heikki Lehväslaiho, Brian Osborne, Sendu Bala, Christopher Fields, and Chris Dagdigian
  • To manage the growth of Bioperl and the other Bio* projects (eg, BioJava), the Open Bioinformatics Foundation (OBF) was formed in 2001

5 of 26

Organization of BioPerlcode

  • bioperl-live - Core packages
  • bioperl-run - for running applications
  • bioperl-ext - C language extension
  • bioperl-db - bioperl BioSQL implementation
  • bioperl-pedigree, bioperl-microarray are sideprojects

6 of 26

Programming approach

  • BioPerl is based on Object-oriented programming approach.
  • Object-oriented programming is the practice of grouping related tasks together into logical and broadly applicable components.
  • For example, a DNA sequence component could contain methods to retrieve the sequence's accession number, reverse complement the DNA, or translate it into a protein sequence. 
  • Object-oriented methodology allows to create clean, generic, and reusable modules to represent data structures and operations common to the life sciences.
  • By separating the components into logical groups such as sequences, alignments, and databases, BioPerl has been able to add features to a specific module without necessarily affecting the rest of the toolkit library.
  • Initially, the components and operations in BioPerl centered around biological sequence analysis and annotation. Recently, the project has expanded to address new areas including phylogenetics, maps, protein structure, and bibliographic references.
  • The project has >500 modules that have been written and maintained by an international group of volunteers.

7 of 26

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.

8 of 26

  • Bio::Perl has a number of other easy-to-use functions, including
    • get_sequence - gets a sequence from standard, internet accessible databases
    • read_sequence - reads a sequence from a file
    • read_all_sequences - reads all sequences from a file
    • new_sequence - makes a Bioperl sequence just from a string
    • write_sequence - writes a single or an array of sequence to a file
    • translate - provides a translation of a sequence
    • translate_as_string - provides a translation of a sequence, returning back just the sequence as a string
    • blast_sequence - BLASTs a sequence against standard databases at NCBI
    • write_blast - writes a blast report out to a file

Basic BioPerl functionality: Using the Bio::Perl.pm module

9 of 26

��

  • it is possible to manipulate sequence data in Bioperl without explicitly creating the Seq or SeqIO objects
  • this script will retrieve a swissprot sequence and write it out in fasta format

use Bio::Perl;

$seq_object = get_sequence('swiss',"ROA1_HUMAN"); write_sequence(">roa1.fasta",'fasta',$seq_object);

  • an example to blast a sequence using the facilities as NCBI

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

10 of 26

Major BioPerl Objects

  • Sequence objects
  • Alignment objects
  • Location objects
  • Interface objects
  • Implementation objects

11 of 26

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.

12 of 26

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.

13 of 26

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.

14 of 26

Location Objects

  • Designed to be associated with a Sequence Feature object in order to show where the feature is on a longer sequence.
  • Can also be standalone objects used to described positions.
  • Complications
  • Some objects have multiple locations or sub -locations locations (e.g. a gene's (e.g. a gene's exons may have multiple start and stop locations).
  • In unfinished genomes, the precise locations of features is not known with certainty.

15 of 26

�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

16 of 26

�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' );

17 of 26

�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)]));

18 of 26

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:

19 of 26

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:

20 of 26

�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.

21 of 26

�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.

22 of 26

�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.

23 of 26

Installing BioPerl on Windows�

The main points.

  1. Install Strawberry perl from http://strawberryperl.com/
  2. Test installation by typing perl -v in the cmd (command promt) window
  3. Install Bioperl by following the instructions at bioperl.org above:

      • 1) Open a cmd window�2) Type cpan to enter the CPAN shell. If CPAN is not recognized you may have to set the PATH to C:\Strawberry\perl\lib (or the location where CPAN.pm is installed).�3) At the cpan> prompt, type install CPAN to upgrade to the latest version.�4) Quit (by typing q) and reload CPAN. You may be asked some configuration questions; accepting default questions should work fine.�5) At the cpan> prompt, type o conf prefer_installer MB to tell CPAN to prefer to use Build.PL scripts for installation, and the type o conf commit to save the choice.�6) At the cpan> prompt, type

2. install Module::Build

7) At the cpan> prompt, type

install Test::Harness

8) At the cpan> prompt, type

  install Test::Most

24 of 26

�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

25 of 26

References

26 of 26

Thanks