perl for bioinformatics

118
Perl Tutorial For Bioinformatics Speaker: Ping-lun Liao [email protected]

Upload: pinglun-liao

Post on 09-Jan-2017

213 views

Category:

Software


0 download

TRANSCRIPT

  • Perl Tutorial For Bioinformatics

    Speaker: Ping-lun Liao

    [email protected]

  • What is Perl?Perl is an acronym that stands for Practical Extraction and Reporting Language.HistoryWritten by Larry Wall.The three chief virtues of a Perl programmer:LazinessImpatienceHubris

  • Purpose of PerlWorld Wide Web Programming (CGI)Internet Server Application Programming Interface extensionActiveX script languageSystem Administration choresObject Linking Embedded AutomationNetwork ProgrammingGraphics User Interface

  • Perl's BenefitsEase of ProgrammingRapid PrototypingPortabilitySpeedProgram Maintenance

  • SoftwareInterpreterWindowsActivePerlStrawberryPerlLinuxActivePerlperlMac OS XActivePerlPerl Download

    IDEPadreEclipse + EPICPerl ExpressOpen Perl IDE

  • Hello Perl#!/usr/bin/perl# This line is commentprint "Hello Perl";

    Save this file as hello.plType perl hello.pl from the MS command line

  • Hello Perl

  • perl cmdperl h: print summary of options"perl c: test01.pl": check syntax without running programperl v: version and patch-level of perl"perl W test01.pl": prints warnings about possible bad constructs

  • perl cmd

  • User Inputprint "Who are you?\n";$name = ;chomp $name;print "Hello, $name!\n";

    name.pl

  • Data Type(scalars)$variableName(array)@variableName(hash)%variableName

  • Scalars Perl Perl Perl

  • -> ++ -- ** ()! ~ \ =~ !~ * / % x + - . >

  • < > = lt gt le ge

    == != eq ne cmp

  • & AND| OR^ XOR&& AND()|| OR ().. ? : ($a > $b) ? $a : $b;

    = +=-=*= , => not NOTand ANDor ORxor XOR

  • Perl (stringDemo.pl)

  • (escapes)

  • stringDemo.pl

  • Perl Perl $ _

  • scalarDemo.pl

  • scalarWithStrDemo.pl

  • 0 '0'"0" ''"" "0" undef

  • randomDemo.pl

  • Data Type

  • Perl (list)()(0 )

  • ("Mmm", "NNN", "Jjj", "Kkk", "Xxx") qw ( Perl )

  • Perl @ @oklist index index 0 index $#oklist $oklist[0] $oklist[1] $oklist[2] $oklist[$#oklist]

    @oklist=(1, 2, 4, 6);@oklist 4 $oklist[0], $oklist[1], $oklist[2], $oklist[3]

    $#oklist 3 $oklist[$#oklist] 6@tiny=(); #

  • arrayDemo1.pl

  • arrayDemo2.pl

  • arrayDemo3.pl

  • for loop: arrayDemo4.pl

  • foreach: arrayDemo5.pl

  • poppushshiftunshift

  • pop:arrayDemo6.pl

  • push:arrayDemo7.pl

  • push:arrayDemo8.pl

  • shift:arrayDemo9.pl

  • unshift:arrayDemo10.pl

  • unshift:arrayDemo11.pl

  • arrayDemo12.pl

  • arrayDemo13.pl

  • ASCII:arrayDemo14.pl

  • arrayDemo15.pl

  • :arrayDemo16.pl

  • :arrayDemo17.pl

  • (key)(value) "/"

  • ${}

  • %all=("t111222333", "", "s444555666", "", "k333111555", "");

  • :HashDemo1.pl

  • reverse //

  • keys values each /exists delete

  • keys:HashDemo2.pl

  • keys:HashDemo3.pl

  • values:HashDemo4.pl

  • each/:HashDemo5.pl

  • exists:HashDemo6.pl

  • exists:HashDemo7.pl

  • delete/:HashDemo8.pl

  • /HashDemo9.pl

  • my VariableScope.pl

  • VariableCheck.pl

  • Flow Control

  • if if : IfDemo.pl

  • if if :IfDemo.pl

  • unlessunless ,:UnlessDemo.pl

  • until():UntilDemo.pl

  • untilUntilDemo.pl

  • forForDemo.pl

  • whileWhileDemo.pl

  • foreachForeachDemo.pl

  • LastDemo.pl

  • LastDemo.pl

  • NextDemo.pl

  • RedoDemo.pl

  • Subroutine

  • Subroutines v.s FunctionsSubroutines are chunk of code you defines.Functions are provided by Perl.

  • Functions

  • Subroutine

  • SubMaxDemo.pl

    my $a $b

  • SubMaxDemo.pl

  • return return Perl

  • SubGetTimeDemo.pl

  • Regular Express

  • (Regular Express)([\w\-])+@([\w\-])+(\.[\w\-])+(Pattern) Perl

  • BasicPatterns.pl$str =~ /like it/ $str "like it" ()

  • Perl

  • BasicPatterns.pl

  • BasicPatterns.pl

  • BasicPatterns.pl

  • BasicPatterns.pl

    !~

  • BasicPatterns.pl

  • SpecialCharacters.pl$& $` $'

  • SubstitutingDemo.pl

  • SubstitutingDemo.pl

  • SubstitutingDemo.pl

  • TransformDemo.pl

  • TransformDemo.pl

  • TransformDemo.pl

  • References Perl@Taiwanhttp://www.cyut.edu.tw/~ckhung/b/pl/ by Online Ebook http://www.unix.com.ua/orelly/perl/index.htmPerl