Perl in A Day: Peeking Inside The Oyster
Perl in A Day: Peeking Inside The Oyster
Perl in A Day: Peeking Inside The Oyster
Perl in a Day
Class Overview
Introduction Why learn Perl? Scripting Reproducible Science Variables Making Programs Reusable Control Structures Doing Things Lots of Times (Or Not) Data Munging Perl for Bioinformatics Arrays and Hashes Groups of Things Subroutines & Modules Making Programs Really Reusable Objects Complex Data, Complex Workflow BioPerl Doing (More) Bio With Perl
4/7/2014
Perl in a Day
Perl in a Day
4/7/2014
Perl in a Day
4/7/2014
Perl in a Day
Objectives
Understand the basics of Perl Focus on what kinds of things Perl can do Don't worry too much about syntax Learn to read, modify, and run Perl scripts Learn some mistakes to avoid Answer your questions (maybe after class) Special focus on data munging
Data what?
4/7/2014
Perl in a Day
Data Munging
Doing stuff with data Getting data from many sources
Keyboard, local files, databases, ftp, web,
Combining data Analyzing data (e.g., mathematically) Filtering data Outputting data
Lots of scientific computing is just data munging Perl is very (very) good at data munging
4/7/2014
Perl in a Day
Why Perl?
Easy to learn and quick to write Rapid prototyping But scalable to large programs Kitchen sink language Combines parts of many other tools (C, sed, awk, sh, ) Call other programs Cross-Platform: Windows, Mac, UNIX Open Source lots of code already available TMTOWTDI - Theres more than one way to do it Very popular in Bioinformatics
4/7/2014
Perl in a Day
Perl in a Day
10
Perl in a Day
4/7/2014
11
Perl in a Day
Getting Started
Where is Perl? On any UNIX (Linux, Mac) computer On the HMS cluster (orchestra.med.harvard.edu) On the FAS cluster (odyssey.fas.harvard.edu) Windows: download from http://www.activestate.com/Products/ActivePerl Dont run on your own laptop! Unless you have (old) BLAST installed
4/7/2014
12
Perl in a Day
Logging in to Odyssey
Run Xming on your desktop
4/7/2014
14
Perl in a Day
cd workshop_perl
more MANIFEST
4/7/2014
15
Perl in a Day
more MANIFEST
4/7/2014
16
Perl in a Day
perl (general info, TOC) perlop (operators like +, *) perlfunc (functions like chomp: > 200!) perlretut (regular expressions: /ABC/) perlreref (regular expression reference) -f chomp (what does chomp function do?) File::IO (find out about a Perl module)
Type q to quit when viewing help pages, Space bar for next page
4/7/2014
19
Perl in a Day
4/7/2014
20
Perl in a Day
4/7/2014
21
Perl in a Day
Create a new file in gedit Type in the above program (just one line) Save it as hello.pl Run it from the command line (perl hello.pl)
[iliadaccess02:workshop_perl] perl hello.pl Hello, World!
4/7/2014
22
Perl in a Day
Create a file called hello.pl in TextEdit Type in the above program (just one line) Save it as PLAIN text (not rich text) Run it from the Terminal (perl hello.pl)
% perl hello.pl Hello, World!
4/7/2014
23
Perl in a Day
4/7/2014
26
Perl in a Day
; is used at the end of each command A command is usually one line But multi-line commands, multi-command lines OK Semicolons are (sometimes) optional Warning: Perl is case sensitive! print is not the same as Print $bio is not the same as $Bio
4/7/2014
27
Perl in a Day
is (usually) the same as print "Hi" Inside "double quotes", \n starts new line, \t prints tab A function is called with zero or more arguments Arguments are separated by commas print takes as many arguments as you give it
print("Hi")
print ""; # legal, prints nothing, not even \n print("Hi", "There"); # prints HiThere print(Hi); # illegal (calls the function Hi) print(1+1, 2+2, "\n"); # prints 24 and a newline
4/7/2014
28
Scripting
Reproducible Science via Scripting command-line calls
Perl in a Day
30
Perl in a Day
4/7/2014
31
Perl in a Day
Benefits over running from command line: Easy to repeat (reproducible science) Easy to rerun with slightly different parameters Easier if parameters are at the top of the program or program asked us for them
4/7/2014
32
Perl in a Day
perl EX_Scripting_1.pl
Exercises are in exercises_UNIX/ or Windows/ Solutions are in solutions_UNIX/ or Windows/ Look for # CHANGED lines
Perl in a Day - Scripting
33
4/7/2014
Variables
Making Programs Reusable by Storing and Manipulating Data
Perl in a Day
Scalar Variables
A box containing a single thing (value)
$e_value = 1e-4; $string = "has spaces and $vars and \n"; $species = "";
References, objects
$
Cgla
35
Has a name (label) starting with $ Value can change during a program
$species = "Cgla"; $species = "Ylip"; # later
$species
Perl in a Day
36
Perl in a Day
4/7/2014
37
Perl in a Day
Saving input files Reproducible Science! But this is a lot of work, for one or two options
4/7/2014
38
Perl in a Day
means you can type -spec, -sp, -s on command line =s means text string (=i for integer, =f for float decimal) => is a fancy comma \$species is a "reference" (pointer) to $species variable
spec
4/7/2014
39
Perl in a Day
You can input multiple parameters Call GetOptions only once near beginning of program Tell GetOptions about all possible options
GetOptions( "spec=s" => \$species, "blast=s" => \$run_blast ); GetOptions
will set $species and $run_blast (if user inputs blast and -spec)
Perl in a Day - Introduction
40
4/7/2014
Perl in a Day
You get the standard output, i.e., what would have been printed to the screen
(But standard error will still print to the screen)
4/7/2014
41
Perl in a Day
4/7/2014
42
Control Structures
Doing Things Lots of Times (Or Not) using Loops and Conditions
Perl in a Day
4/7/2014
44
Perl in a Day
Conditions
Let's stop running BLAST every time Basic if statement:
is true Run {BLOCK} of code
if (condition)
if ($run_blast eq "y") { my $db = "other_fungi"; system("blastall d $db "); } print $db; # ERROR. Unknown var
No semicolon after beginning and end braces Blocks are often indented for ease of reading One or more commands inside BLOCK, separated by ;
my
4/7/2014
Perl in a Day
Conditions II else
Let's warn user when we're not running BLAST else (if the condition wasn't true) Run the code inside the else{BLOCK}
if (condition) { do some stuff; } else { # optional do other stuff; } if ($run_blast eq "y") { system("blastall "); } else { print "Not running blast"; }
4/7/2014
46
Perl in a Day
if ($run_blast eq "y") { system("blastall "); } elsif ($run_blast eq "n") { print "Use saved BLAST\n"; } else { die "Illegal -b option\n"; }
47
Perl in a Day
4/7/2014
48
Perl in a Day
Careful!
= ==
Careful!
Text strings have numeric value 0, so "ACTG" == "GCTA"
4/7/2014
49
Perl in a Day
Multiple Comparisons
means a logical AND (all pieces must be true) || means a logical OR (at least one piece is true) Group comparisons with parentheses
&&
if (($run_blast eq "y") || ($run_blast eq "Y")) { print "Running BLAST\n"; }
negates a condition
if (!(some complicated expression)) { print "It wasn't true"; }
4/7/2014
50
Perl in a Day
Loops - foreach
A foreach loop loops over a (list)
Sets a $variable to first value in (list) Runs a {BLOCK} using that value for the $variable Repeats loop for every value in the (list)
See foreach.pl
foreach my $variable (list) { do some stuff; do more stuff; # }
# Find hits from several species foreach my $species ("Cgla", "Klac") { print "Hits for $species\n"; system("grep '$species' $blast_out"); } # Given foreach print print } sequence $DNA of any length my $i (1 .. length($DNA)) { "Letter $i of the seq is "; substr($DNA, $i-1, 1),"\n";
4/7/2014
51
Perl in a Day
Loops II - while
A while loop keeps running while a (condition) is true It checks the (condition) Runs code in the {BLOCK} if it was true Then checks again It's sort of like foreach + if
# Print numbers from 5 to 15 by fives my $i = 5; while ( $i < 20 ) { print "$i "; $i = $i + 5; } # Here, $i=20 BUT code never prints 20 # If we tested $i <= 20, wed print 20
4/7/2014
52
Perl in a Day
4/7/2014
53
Perl in a Day
4/7/2014
54
Data Munging
Perl for Bioinformatics or Reading, Filtering, Merging, Changing, and Writing Data
Perl in a Day
Math
Arithmetic operators: + - / * %
$a = 10 + 5; # $a is now 15 $a = $a + 20; # add 20 to the value of $a $a += 20; # short cut, similarly -= /= *= $a++; # shorter cut, same as $a+=1 $a = "hi" + 5; # $a=5. A text string counts as zero
11 % 3 = 2, 12 % 3 = 0
4/7/2014
56
Perl in a Day
Math II - Functions
A function takes one or more arguments Math functions: sqrt, exp, log, int, abs, A function returns a value Set a variable equal to the return value Or print it Parentheses are optional (sometimes) Better to use them unless it's really obvious
$b = int(3.2); # Remove after the decimal. $b = 3 print int(-3.2); # (Or print int -3.2) prints -3 print int -3.2; # Same
4/7/2014
57
Perl in a Day
$a = 4*3 + 2; # $a=14 $a = 4 * 3+2; # oops! Spaces can be dangerous $a = 4 * (3+2); # correct. $a = 20 # quadratic equation $x = (-$b + sqrt($b*$b - 4*$a*$c)) / (2*$a)
4/7/2014
58
Perl in a Day
"abcdef"
"a:b:c"
"a", "b", "c" substr("abcdefghi", 2, 5) "cdefg" reverse("ACTG") "GTCA" # NOT complement! "ACCTTG" =~ s/T/U/g "ACCUUG" # DNA->RNA "ACCTTG" =~ tr/ACGT/UGCA/ "UGGAAC" # complement! length("abc") 3 lc("ACTG") "actg" # uc does the opposite index("ACT", "TTTACTGAA") 3 # -1 if not found Wow! (perldoc f split, etc.)
4/7/2014
59
Perl in a Day
Regular Expressions
Patterns for searching a text string Does the string FOO appear in variable $x?
if ($x =~ /FOO/) { print "Found FOO!" }
True for $x="FOO", "aFOO", "FOOFOOFOO", "FOOLISH" False for $x="", "FO", "OOF", "foo", "F O O"
Search for wildcards (see below) One of Perl's greatest strengths (powerful) One of Perl's greatest weaknesses (confusing) perldoc perlretut, perlreref, perlre
4/7/2014
60
Perl in a Day
Regular Expressions II
matches beginning of string, $ matches end Many special characters must be \quoted
^
^ $ ( ) { } [ ] ? . @ + * / \
matches a literal dollar sign, not end of string \t tab \n newline \s (space,\t,\n) \S non-space \d digit /stuff/i - the 'i' option ignores case
I.e., \$
See match.pl
$x $x $x $x =~ =~ =~ =~ /ACTTGG/ # Finds subsequence ACTTGG in $x /^M/ # Finds seq starting with methionine /\*$/ # Sequence ends with stop codon /AACC/i # Find upper- or lower-case bases
4/7/2014
61
Perl in a Day
/ACAG|ACCG/ # Matches a profile /A.C/ # matches ABC, A1C, A C, A~C, but not AC, A\nC if (/AC([AC])G/) { # Note: ACACG will NOT match print "Wobbly base was $1\n"; }
4/7/2014
62
Perl in a Day
Regular Expressions IV
matches 0 or more copies of the previous thing + matches 1 or more copies of the previous thing ? matches if something appears or if it doesn't
*
/ab?c/ ac abc /ab*c/ /ab+c/ X ad abcd /a(bc)?d/ /a(bc)*d/ /a(bc)+d/ X
abbc
Note:
abccd
abcbcd
X
X
/CG?CA/ # Finds sequence with or without deletion if (/^>(\S+)/) {$id=$1} # FASTA ID (\S = non-space)
4/7/2014
63
Perl in a Day
Substitutions
Replace first occurrence of FOO in variable $x with BAR
$x =~ s/FOO/BAR/;
"aaaFOObbbFOO" "aaaBARbbbFOO"
"aaaFOObbbFOO" "aaaBARbbbBAR"
"aaaFOObbbFOO" "xFOObbbFOO"
"aaaFOObbbFOO" "axOO"
"aaabbb" "aaabbb"
4/7/2014
64
Perl in a Day
4/7/2014
65
Perl in a Day
I/O Overview
Filehandle A way to "hang on" to (name, refer to) a file Not the same as a file name Usually a name in all capital letters Open a filehandle to read from/write to a file <FILEHANDLE> reads a line from a file print FILEHANDLE writes to a file Multiple read/write filehandles open at once Close filehandle when done reading/writing
4/7/2014
66
Perl in a Day
Must be done before reading/writing a file Associates the file name with a filehandle
is the same as "<filename" - read from file ">filename" - write to file Note: > DELETES ANY PRIOR DATA IN THE FILE! ">>filename" - add to end of file. Doesn't delete anything. open() or die "Error: $!\n" helps diagnose problems close(FILEHANDLE) Finish writing/reading
"filename"
4/7/2014
67
Perl in a Day
(abbreviated <>)
Reads from the keyboard OR from files given as arguments to the script perl blah.pl file1 file2 Automatically opened/closed
4/7/2014
68
Perl in a Day
Great, but we're only reading one line Can we read multiple lines (without Repeating Code)? How do we know when the file is done?
4/7/2014
69
Perl in a Day
4/7/2014
70
Perl in a Day
Writing To Files
print FILEHANDLE "string", $var,
Prints one or more things to a filehandle Remember to explicitly write "\n"'s Note: no comma between FILEHANDLE and stuff to print
STDOUT
is the same as a regular print Prints to screen even if one or more filehandles are open See write_file.pl
print STDOUT
71
Perl in a Day
0
my $id = $1;
1103 1
pull out just the hit ID The regular expression we're searching with is:
Multiple non-space chars \t a tab ($species\S*) species name, followed possibly by non-space characters (AND parentheses save this string in $1) \t tab after the ID
\S+
or die
See get_hit_ids.pl
4/7/2014
72
Perl in a Day
time, as long as they have different filehandles) Solutions are SOL_Munging_1a.pl and SOL_Munging_1b.pl
4/7/2014
73
The Scriptome
Advanced Data Munging for Beginners or Perl for Wimps Busy Biologists
Perl in a Day
only reads into $_ inside a while()! /a/ matches against $_(no =~ necessary) s/A/B/ substitutes B for A in $_
<>
4/7/2014
75
Perl in a Day
One-Liners
Perl has shortcuts for data munging (You won't be tested on this!) fancy grep with full Perl functionality: get FASTA IDs
perl -wlne 'if (/^>(\S+)/) {print $1}' a.fasta > IDs
4/7/2014
76
Perl in a Day
4/7/2014
77
Perl in a Day
Scriptome Motivation
"You can't possibly learn Perl in a day " "But I need to get work done!" "If only someone would do all the work for me"
4/7/2014
78
Perl in a Day
Read the instructions Find BLAST results with > 80% identity (3rd col.=2) Expand code to see how it's done Build a protocol
4/7/2014
79
Perl in a Day
Drosophila
Please (please!) contact me about using Scriptome
4/7/2014
80
Perl in a Day
Run a tool
Program will ask you for parameters, if needed Or set parameters on command line: scriptable ScriptPack: runs on your laptop
Available on website Resources page
4/7/2014
81
Perl in a Day
Exercises Scriptome
1. Print BLAST hits from one_seq.blast with 80 85%
identity (see EX_Scriptome_1.txt) 2. Use the Scriptome to change allY.fasta, which contains four sequences, to tabular format. (see EX_Scriptome_2.txt)
4/7/2014
82
Perl in a Day
Why Arrays?
What if we want to store the hit IDs? Further analysis Different kinds of filtering Printing out We don't want to read the file multiple times! Store the IDs in an array
4/7/2014
84
Perl in a Day
Arrays
A box containing a set of things @bs = ( 35, 47, -10, 6 ); @strings = ("a", "b", "cde"); @scalars = ($a, $b, $c); Array names start with @ Best for many of the same kind of data A set of sequences, a set of fold change values Do the same thing to each array member Filter to find certain useful members
@
85
4/7/2014
Perl in a Day
35
47
-10
4/7/2014
86
Perl in a Day
@nums = ( 9,8,7 ); $nums[3] = 6; print @nums; # 9876 push @nums, 5; # push onto end - 98765 pop @nums; # pop off of the end - 9876 print scalar (@nums); # Array size = 4
Perl in a Day - Arrays
87
Perl in a Day
Now easily access percent identity, target ID, etc. lcl|Scer--YAL036C Spar--ORFN:355 92.20 1103 86 0 1 1103 1 1103 0.0 1459
my $percent_identity = $cols[2]; # count from 0! print "Score: $cols[-1]\n"; # -1 is last thing in array # Set multiple scalars from a "slice" of an array
See get_hit_cols.pl
4/7/2014
88
Perl in a Day
OR my ($num, $str, $name, $file) = @ARGV; TMTOWTDI: parse @ARGV instead of using Getopt::Long
Getopt::Long will only remove options. Files will still be in @ARGV shift(@ARGV)
shift()
removes $ARGV[0]
4/7/2014
89
Perl in a Day
Why Hashes?
Searching an array for a given value is slow Array indexes must be numbers IDs are strings "A gene" has many associated pieces of data Name Alternate name(s) Disease association(s) English description Coded protein(s) Storing diverse types of data in one array is messy Why can't we have arrays with string indexes?
4/7/2014
90
Perl in a Day
Hashes
A box containing a set of key/value pairs Only one value per key (simple case) Give it a key, it returns a value What NCBI ID represents "BRCA1"? What amino acid does "ATG" code for? What is the "DE" part of this Swiss-Prot record? http://us.expasy.org/uniprot/Q92560 Hash names start with %
4/7/2014
91
Perl in a Day
Hashes II - Declaration
%hash = (key1=>val1, key2=>val2, ...)
%sp = ( "AC" => "P30443", "ID" => "1A01_HUMAN", "DE" => "HLA class I", ); %translate = ( "ATG" => "M", "GGT" => "G", "CAT" => "H", "TAG" => "*", ); # etc. . . print "ATG encodes $translate{'ATG'}"; # ATG encodes M
%sp $sp{AC} P30443 $sp{ID} 1A01_HUMAN $sp{DE} HLA class I histocompatibility antigen...
4/7/2014
92
Perl in a Day
93
Perl in a Day
Make things unique (only one value per key) Read lines into %hash, look at keys(%hash)
4/7/2014
94
Perl in a Day
2.
with percent identity (third column) between 80 and 85 EX_Array_2.pl puts data from various columns (see "Hashes IV" above) into a %hit hash. Change the program to use that hash in the if and print statements in the while loop.
4/7/2014
95
Perl in a Day
Class Overview
Introduction Why learn Perl? Scripting Reproducible Science Variables Making Programs Reusable Control Structures Doing Things Lots of Times (Or Not) Data Munging Perl for Bioinformatics Arrays and Hashes Groups of Things The Scriptome Data Munging for Perl Beginners Subroutines & Modules Making Programs Really Reusable Objects Complex Data, Complex Workflow BioPerl Doing (More) Bio With Perl
4/7/2014
96
Perl in a Day
Subroutines Why?
my $dna1 = "CCGGCCGGAGTTCTTAGGCGTAGCCGGCCGG"; # UTR+CDS # (Shortest possible exon: +? is a "non-greedy" +) $dna1 =~ /(ATG(...)+?)TAG/; # start codon, 3N bp, stop my $len = length($1)/3; # length of translated protein # Later my $dna2 = <FASTA>; # Read in DNA from FASTA file # Do the same thing to the new sequence $dna2 =~ /(ATG(...)+?)TAG/; $len = length($1)/3;
Harder to read larger program What if theres a bug (TAG only)? Update every copy
4/7/2014
98
Perl in a Day
Subroutines Example
my $dna1 = "CCGGCCGGAGTTCTTAGGCGTAGCCGGCCGG"; my $len = &get_translated_length($dna1); # call sub print "DNA with UTR: $dna1. Protein length: $len\n"; my $dna2 = <FASTA>; # Call the subroutine again, with a different argument $len = &get_translated_length($dna2); print $len; sub get_translated_length { my ($dna) = @_; # changing $dna won't change $dna1 $dna =~ /(AGT(...)+?)TAG/; # Remove stop codon,3' UTR my $plen = length($1)/3; # resulting protein length return $plen; }
Only one copy of the code Main program becomes shorter and simpler
4/7/2014
99
Perl in a Day
Ampersand is optional
It passes one or more arguments ($dna1) Parentheses are (sometimes) optional Code in the subroutine gets executed Subroutine returns results to caller Perl subroutines can return multiple values Some subroutines return no values
4/7/2014
100
Perl in a Day
# More code
# More return ($first, $second); }
- gets the arguments - calculates, prints, does other stuff calls other subroutines? - returns stuff to caller - ends subroutine
101
Perl in a Day
is like pop, but pulls out $array[0] Inside a subroutine, shift() does shift(@_) I.e., put the first argument to the subroutine into $thing
Pass array to sub my ($arg_a, $arg_b, @arg_c) = @_; Get args inside sub
102
Perl in a Day
103
Perl in a Day
Modules
A set of related subroutines Placed in a separate file Included in the original file with the use command We've been using modules all day
use Getopt::Long;
Reads in the file /usr//perl5//Getopt/Long.pm Now &GetOptions() acts like a regular Perl function
perldoc Getopt::Long
Documentation is stored inside the module POD, a very simple HTML-ish language
strict
4/7/2014
Perl in a Day
Modules II
Getting new modules Thousands of modules available at www.cpan.org search.cpan.org (E.g., search for "transcription factor") Usually simple to install Basically, installation places .pm file(s) in /usr/ Or a different directory Perl knows to look in Benefits (like subroutine benefits, but more so) Organization: separate a set of functionality Code reuse: don't have to re-write code for every program
"Good composers borrow; great composers steal." -Stravinsky?
105
Perl in a Day
Exercise Subroutines
Move BLAST (and deciding whether to run) to a subroutine
&maybe_run_blast($run_blast, $fasta_in, $e_value,
$blast_out);
4/7/2014
106
Perl in a Day
Objects
Scalar variables storing multiple pieces of data $swiss_seq stores a whole Swiss-Prot record Easier than keeping track of complicated hashes Store many Swiss-Prot records in a hash/array Variables that can do things (by calling methods) $swiss_seq->id gets the ID Like &id($swiss_seq), but better (see below) $rev = $swiss_seq->revcom reverse complements
4/7/2014
108
Perl in a Day
4/7/2014
109
Perl in a Day
Classes
Really just a fancy module Every object belongs to one or more classes What kind of object is it? Sequence, Feature, Annotation, Tree... What fields will this object have? species, start/end, text, subtrees What can I DO with this object? I.e., what methods can I call? id, get_SeqFeatures, set_root_node
4/7/2014
110
Perl in a Day
4/7/2014
111
Perl in a Day
112
Bioperl
Doing (More) Bio with Perl by Stealing Using Collected Wisdom
Perl in a Day
BioPerl Overview
Modules useful for doing bioinformatics in Perl Many specialized modules (Annotation, Parsing,
on Odyssey
Can be a bit overwhelming Huge Mostly uses objects Documentation not always easy
4/7/2014
114
Perl in a Day
4/7/2014
115
Perl in a Day
4/7/2014
116
Perl in a Day
4/7/2014
117
Perl in a Day
4/7/2014
118
Perl in a Day
4/7/2014
119
Perl in a Day
BioPerl - Objects
Bio::Seq: main sequence object Available when sequence file is read by Bio::SeqIO It has many methods - perldoc Bio::Seq
# Make a new Bio::SeqIO object $myseqs # by opening a file for reading #(This command doesn't actually read any sequences) $myseqs = Bio::SeqIO->new( '-file' => "<inputFileName", '-format' => 'Fasta' ); # Get next (i.e., first) seq in Bio::SeqIO object # $seqobj is a Bio::Seq object $seqobj = $myseqs->next_seq();
4/7/2014
120
Perl in a Day
4/7/2014
121
Perl in a Day
BioPerl - BPlite
BPlite: Blast Parser "lite BLAST -m8 doesn't actually give us alignments But BLAST output is Hard! (see one_seq.long_blast) One of several BLAST parsers available Each matching sequence can have multiple matching regions ("hsp", high scoring pair)
use Bio::Tools::BPlite; $report = new Bio::Tools::BPlite(-file=>"$inFile"); while(my $sbjct = $report->nextSbjct) { while (my $hsp = $sbjct->nextHSP) { print $hsp->subject->seqname; } }
4/7/2014
123
Perl in a Day
4/7/2014
124
Perl in a Day
Whats missing
More Bioperl, regexps, functions, OOP, ... Testing, debugging and proactive error checking Context and other shortcuts $line = <FILE> reads just one line @foo = <FILE> reads an entire file into an array Databases and web programming Graphics Perl Golf and Obfuscated Perl
perl le '$_*=$`%9e9,//for+1=~/0*$/..pop;print$`%10' 10
Etc.
4/7/2014
125
Perl in a Day
http://bip.weizmann.ac.il/course/prog/
HUNDREDS of slides - many bio-related examples Also look at "assignments" for practice
sequel, too.) Learning Perl is more general, but gets rave reviews
4/7/2014
126
Perl in a Day
http://www.bioperl.org
Especially look at (and do) bptutorial "Howtos" describe Sequence Analysis, Phylogenetics, etc. w/ Bioperl
http://www.pasteur.fr/recherche/unites/sis/formation/bioperl/
Big Bioperl course, with lots of examples and exercises
The Scriptome
http://sysbio.harvard.edu/csb/resources/computational/scriptome
4/7/2014
127