Bioperl What’S Bioperl?
Total Page:16
File Type:pdf, Size:1020Kb
Bioperl What’s Bioperl? Bioperl is not a new language It is a collection of Perl modules that facilitate the development of Perl scripts for bioinformatics applications. Bioperl and perl Bioperl Modules Perl Modules Perls script input Perl Interpreter output Bioperl and Perl Why bioperl for bioinformatics? Perl is good at file manipulation and text processing, which make up a large part of the routine tasks in bioinformatics. Perl language, documentation and many Perl packages are freely available. Perl is easy to get started in, to write small and medium-sized programs. Where to get help Type perldoc <modulename> in terminal Search for particular module in https://metacpan.org Bioperl Document Object-oriented and Process-oriented programming Process-oriented: Yuan Hao eats chicken Name object: $name Action method: eat Food object: $food Object-oriented: $name->eat($food) Modularize the program Platform and Related Software Required Perl 5.6.1 or higher Version 5.8 or higher is highly recommended make for Mac OS X, this requires installing the Xcode Developer Tools Installation On Linux or Max OS X Install from cpanminus: perlbrew install-cpanm cpanm Bio::Perl Install from source code: git clone https://github.com/bioperl/bioperl-live.git cd bioperl-live perl Build.PL ./Build test (optional) ./Build install Installation On Windows Install MinGW (MinGW is incorporated in Strawberry Perl, but must it be installed through PPM for ActivePerl) : ppm install MinGW Install Module::Build, Test::Harness and Test::Most through CPAN: Type cpan to enter the CPAN shell. At the cpan> prompt, type install CPAN Quit (by typing ‘q’) and reload CPAN. You may be asked some configuration questions, accept defaults At the cpan> prompt, type o conf prefer_installer MB then type o conf commit At the cpan> prompt, type install Module::Build. At the cpan> prompt, type install Test::Harness. At the cpan> prompt, type install Test::Most. Installation On Windows Finish install from cpan: type /d/bioperl/ .... Distribution C/CJ/CJFIELDS/BioPerl-1.007001.tar.gz type install C/CJ/CJFIELDS/BioPerl-1.007001.tar.gz Finish install from source code: Go to GitHub and press the Download ZIP button. Extract the archive in the normal way. In a cmd window cd to the directory you extracted to. Eg. if you extracted to directory ‘bioperl-live’, cd bioperl-live Type perl Build.PL and answer the questions appropriately. Type perl Build test. All the tests should pass, but if they don’t, let us know. Your usage of Bioperl may not be affected by the failure, so you can choose to continue anyway. Type perl Build install to install Bioperl. Show the capability of bioperl in following examples Creating a sequence, and an Object #!/usr/bin/perl -w use Bio::Seq; my $seq_obj = Bio::Seq->new(-seq => 'aaaatgggggggggggccccgtt', -alphabet => 'dna' ); object class method argument Creating a sequence, and an Object #!/usr/bin/perl -w use Bio::Seq; my $seq_obj = Bio::Seq->new(-seq => 'aaaatgggggggggggccccgtt', -alphabet => 'dna' ); print $seq_obj->seq . "\n" More True-to-life example #!/usr/bin/perl -w use Bio::Seq; my $seq_obj = Bio::Seq->new(-seq => "aaaatgggggggggggccccgtt", -display_id => "#12345", -desc => "example 1", -alphabet => "dna" ); print $seq_obj->seq(); Write Sequence to File #!/usr/bin/perl -w use Bio::Seq; use Bio::SeqIO; my $seq_obj = Bio::Seq->new(-seq => 'aaaatgggggggggggccccgtt', -alphabet => 'dna' ); my $seqio_obj = Bio::SeqIO->new(-file => '>sequence.fasta', -format => 'fasta' ); Create object for IO from class Bio::SeqIO Write Sequence to File #!/usr/bin/perl -w use Bio::Seq; use Bio::SeqIO; my $seq_obj = Bio::Seq->new(-seq => "aaaatgggggggggggccccgtt", -display_id => "#12345", -desc => "example 1", -alphabet => "dna" ); my $seqio_obj = Bio::SeqIO->new(-file => '>sequence.fasta', -format => 'fasta' ); $seqio_obj->write_seq($seq_obj); Write Sequence to File #!/usr/bin/perl -w use Bio::Seq; use Bio::SeqIO; my $seq_obj = Bio::Seq->new(-seq => "aaaatgggggggggggccccgtt", -display_id => "#12345", -desc => "example 1", -alphabet => "dna" ); my $seqio_obj = Bio::SeqIO->new(-file => '>sequence.fasta', -format => 'Genbank' ); $seqio_obj->write_seq($seq_obj); Unified Programming~~ Retrieving a Sequence from a File #!/usr/bin/perl -w use Bio::SeqIO; my $seqio_obj = Bio::SeqIO->new(-file => "sequence.fasta", -format => "genbank" ); my $seq_obj = $seqio_obj->next_seq; print $seq_obj->seq . "\n"; Multiple Sequences Alignment #!/usr/bin/perl -w use Bio::Tools::Run::Alignment::Muscle; use Bio::AlignIO; my @params = (quiet => 0, maxiters => '100'); my $factory = Bio::Tools::Run::Alignment::Muscle->new(@params); my $inputfilename = "$ARGV[0]"; my $aln = $factory->align($inputfilename); my $out = Bio::AlignIO->new(-file => ">$ARGV[1]", -format => 'fasta'); $out->write_aln($aln); Bioperl can incorporate with other software Retrieving a Sequence from a Database #!/usr/bin/perl -w use strict; use Bio::EnsEMBL::Registry; my $registry = 'Bio::EnsEMBL::Registry'; $registry->load_registry_from_db( -host => 'ensembldb.ensembl.org', -user => 'anonymous', ); my $slice_adaptor = $registry->get_adaptor( 'Human', 'Core', 'Slice' ); my $slice = $slice_adaptor->fetch_by_gene_stable_id('ENSG00000128573'); print $slice->seq . "\n"; Application Programming Interface (API) Database Bioperl provides various kind of API to extract user-defined dataset from database efficiently even you aren’t familiar with data structure of them Obstacle in Learning OOP Programming in a total different way Familiar with different object, method and class That’s worthwhile !!! Thanks.