Download presentation
Presentation is loading. Please wait.
Published byLynne Norris Modified over 6 years ago
1
Introduction to Bioinformatic Computation. Lecture 6 02-22-2010
Objectives for today Packages, Modules, Objects /home/afedorov/IBC1_PROGRAMS/LECTURE13
2
prog_log #!/usr/bin/perl/ use POSIX qw(log10); $r = 10000;
$log = log10($r); print $log, "\n";
3
export PERL5LIB=/home/foobar/code echo PERL5LIB perl INC
export PERL5LIB=/home/foobar/code echo PERL5LIB perl INC.pl
4
#!/usr/local/bin/perl
#color.pl program # use Term::ANSIColor; print color 'bold blue'; print "This text is bold blue.\n"; print color 'reset'; print "This text is normal.\n"; print colored ("Yellow on magenta.\n", 'yellow on_magenta'); print colored ['yellow on_magenta'], "Yellow on magenta.\n"; use Term::ANSIColor qw(uncolor); print uncolor '01;31', "\n"; use Term::ANSIColor qw(:constants); print BOLD, BLUE, "This text is in bold blue.\n", RESET; $Term::ANSIColor::AUTORESET = 1; print BOLD BLUE "This text is in bold blue.\n";
5
prog_INC #!/usr/local/perl $i=0;
foreach $x {printf "%d %s\n", $i++, $x}
6
Our previous approach: invocation of a perl program by another perl script (EID, lecture 9)
makeEID.pl first_parse.pl check_translations.pl finalmakeCHECK.pl
7
more makeEID.pl #!/usr/bin/perl -w # Serge Saxonov, Iraj Daizadeh, Alexei Fedorov, Walter Gilbert ($#ARGV != -1) || die "Usage: $0 prefix\n"; $prefix = $ARGV[0]; unless(-e "seqfiles.list"){ die "Need to have seqfiles.list in the current directory\n"; } system("perl first_parse.pl $prefix"); system("cat $prefix.RAW |perl check_translations.pl $prefix"); system("rm -f $prefix.RAW"); system("finalmakeCHECK.pl $prefix"); system("rm -f $prefix.RAWchecked");
8
New approach: invocation of a perl program from a module (file with
New approach: invocation of a perl program from a module (file with .pm on the end) In your perl script write: use Module_name; (let’s, for example, look at our bioperl programs)
9
Examples of Bioperl COMPUTER: mco321125.mco.edu
DIR: /home/afedorov/IBC1_PROGRAMS/LECTURE13 bioperl_test.pl (bring the information about my sequence from the web) bioperl_blast.pl (open NCBI blast web site and perform blast of my sequence)
10
more bioperl_blast.pl #!/usr/local/perl 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);
11
Modification of bioperl_blast.pl for obtaining another alignment
vi bioperl_blast.pl Change line 4 (input: MALK_ECOLI) Change line 7 (output file)
12
find / -name Perl.pm –print >where_is_Perl.pm
/usr/lib/perl5/site_perl/5.8.0/Bio/Perl.pm
13
more /usr/lib/perl5/site_perl/5.8.0/Bio/Perl.pm
Other modules inside Perl.pm $DBOKAY); use strict; use Carp; use Exporter; use Bio::SeqIO; use Bio::Seq;
14
Bioperl http://www.bioperl.org/ BioPerl 1.4 Tutorial
Pasteur Institute Bioperl Course BioPerl 1.4 Module Documentation
15
Additional information on www.bioperl.org
Getting Started Just learning about perl and computational biology? Read Lincoln Stein's classic article, "How Perl Saved the Human Genome Project" Join a Bioperl mailing list Visit perl.com Find a local users group The International Society for Computational Biology (iscb.org)
16
Is it possible to accomplish our project using available modules?
NO However, you, probably, could perform some very helpful steps using Bioperl and other modules.
17
CPAN is the Comprehensive Perl Archive Network, a large collection of Perl software and documentation. 6200 modules available CPAN Frequently Asked Questions
18
Definition of Package Cookbook pp395-400
Package is a compile-time declaration that sets the default package prefix for unqualified global identifiers Any variable not declared with my is associated with a package $current_package = __PACKAGE__;
19
PACKAGE [afedorov@intron BIOPERL]$ more test_package.pl
#!/usr/local/perl package Alpha; $name = 'first'; package Omega; $name = 'last'; package main; print " Alpha is $Alpha::name Omega is $Omega::name \n";
20
Definition of module Traditional modules (define subroutines and variables for the caller to import and use) Object-oriented modules (outside the scope of this course)
21
MODULE example more MYTEST.pm package MYTEST; use strict;
%EXPORT_TAGS $VERSION); use Exporter; $VERSION = 1.00; @ISA = qw(Exporter); ################################### #PUT WHATEVER YOU WANT HERE our $test = 5; our $seq1 = 'atg'; our $seq2 = 'fdndidfdndfkf'; = ('a', 't', 'g', 'c'); 1;
22
more test2.pl #!/usr/local/perl use MYTEST; print "value is $MYTEST::seq1 \n array \n";
23
Export variables and functions
more TestExport.pm package TestExport; use strict; %EXPORT_TAGS $VERSION); use Exporter; $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = ################################### #PUT WHATEVER YOU WANT HERE our $test = 5; our $seq1 = 'atg'; our $seq2 = 'fdndidfdndfkf'; = ('a', 't', 'g', 'c'); 1;
24
Export variables and functions from a module
more test3.pl #!/usr/local/perl use TestExport; print "seq1 is $seq1 \n seq2 is $seq2 \n array \n";
25
Export variables and functions from a module by a request
Inside a module create a line @EXPORT_OK =qw(&alexei %fedorov); Load the module with the request for your variables use YourModule qw(alexei %fedorov);
26
%EXPORT_TAGS %EXPORT_TAGS = (
Variables1 => [qw($seq1 Seq2 alexei)], Var2 => $seq2 %fedorov], ); use YourModule
27
How to prepare a module in a standard distribution format
COMMAND LINE: h2xs –XA –n OurFirstModule perl Makefile.PL make dist (to create name.tar.gz file)
28
RepeatMasker program (lecture 11)
use Getopt::Long; use POSIX qw(:sys_wait_h); use File::Copy; use File::Basename; use Cwd;
29
How to install a module (example Bioperl in INTRON)
Get step by step instructions from web sites (CPAN, bioperl, etc) Example: read INSTALL file (in bioperl ->download ->docs) >gunzip bioperl-1.2.tar.gz >tar xvf bioperl-1.2.tar >cd bioperl-1.2
30
What’s inside @INC array? (INTRON ~/BIOPERL)
BIOPERL]$ perl prog_INC 0 /usr/lib/perl5/5.8.0/i386-linux-thread-multi 1 /usr/lib/perl5/5.8.0 2 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi 3 /usr/lib/perl5/site_perl/5.8.0 4 /usr/lib/perl5/site_perl 5 /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi 6 /usr/lib/perl5/vendor_perl/5.8.0 7 /usr/lib/perl5/vendor_perl 8 .
31
BIOPERL INSTALL FILE THE EASY WAY
The Bioperl modules are distributed as a tar file in standard perl CPAN distribution form. This means that installation is very simple. Once you have unpacked the tar distribution there is a directory called bioperl-xx/, which is where this file is. Move into that directory (you may well be already in the right place!) and issue the following commands: perl Makefile.PL # makes a system-specific makefile make # makes the distribution make test # runs the test code make install # [may need root access for system install. # See below for how to get around this.]
32
tar xvf current_core_stable.tar
cd bioperl-1.4 su – make install
33
BIOPERL TUTORIAL perl bptutorial.pl 1 perl bptutorial.pl 9
perl bptutorial.pl 100 swiss perl bptutorial.pl 100 Bio::Tools::SeqStats
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.