SlideShare a Scribd company logo
FBW
08-10-2013
Wim Van Criekinge
Bioinformatics.be
• Communiceren van praktische zaken: waar en
wanneer gaan de lessen door
• Ter beschikking stellen van lesmateriaal
• Aanvullend educatief materiaal (FAQ, Web Links)
• Practicum opgaven en programmacode
Voordelen
• Gebruik van het webtechnologie bij het assimileren
van de cursus
• Veel vragen/antwoorden kunnen interessant voor
meerdere mensen, Vermijden van terugkerende
vragen
• Permante discussie (tijdens het jaar) tussen
studenten, prof maar ook thesis en
doctoraatsstudenten
Practicum
• Practicum regeling ?
– Inleiding van 45min over de gebruikte editor,
programmeertaal, websites
– 15min toelichting tot de opgaven
– Normaal in PC-zaal D (check bioinformatics.be!)
Perl for Bioinformatics
Part 1: Beginning
Part 2: Mastering
Practicum Bioinformatica
• Practicum
– Inleiding tot Perl
– Write your first PERL program !
– Execute your first.pl
• Perl is a High-level Scripting language
• Larry Wall created Perl in 1987
– Practical Extraction (a)nd Reporting
Language
– (or Pathologically Eclectic Rubbish Lister)
• Born from a system administration tool
• Faster than sh or csh
• Sslower than C
• No need for sed, awk, tr, wc, cut, …
• Perl is open and free
• http://conferences.oreillynet.com/e
urooscon/
What is Perl ?
• Perl is available for most computing
platforms: all flavors of UNIX (Linux),
MS-DOS/Win32, Macintosh, VMS, OS/2,
Amiga, AS/400, Atari
• Perl is a computer language that is:
– Interpreted, compiles at run-time (need for
perl.exe !)
– Loosely “typed”
– String/text oriented
– Capable of using multiple syntax formats
• In Perl, “there‟s more than one way to do it”
What is Perl ?
• Ease of use by novice programmers
• Flexible language: Fast software prototyping (quick
and dirty creation of small analysis programs)
• Expressiveness. Compact code, Perl Poetry:
@{$_[$#_]||[]}
• Glutility: Read disparate files and parse the relevant
data into a new format
• Powerful pattern matching via “regular expressions”
(Best Regular Expressions on Earth)
• With the advent of the WWW, Perl has become the
language of choice to create Common Gateway
Interface (CGI) scripts to handle form submissions
and create compute severs on the WWW.
• Open Source – Free. Availability of Perl modules
for Bioinformatics and Internet.
Why use Perl for bioinformatics ?
• Some tasks are still better done with other
languages (heavy computations / graphics)
– C(++),C#, Fortran, Java (Pascal,Visual Basic)
• With perl you can write simple programs
fast, but on the other hand it is also suitable
for large and complex programs. (yet, it is
not adequate for very large projects)
– Python
• Larry Wall: “For programmers, laziness is
a virtue”
Why NOT use Perl for bioinformatics ?
• Sequence manipulation and analysis
• Parsing results of sequence analysis
programs (Blast, Genscan, Hmmer etc)
• Parsing database (eg Genbank) files
• Obtaining multiple database entries
over the internet
• …
What bioinformatics tasks are suited to Perl ?
Example of problems we will be solving
• Primary Sequence analysis
• Perform alignments
• Simulation experiments to explain
Blast statistics
• Predicting protein topology
• Predicting secondary structures
• “Real-life” problems
– Proteomics: Given aa masses find protein
in database
– …
• Perl (op USB):
– Perl is available for various operating systems. To
download Perl and install it on your computer, have a
look at the following resources:
– www.perl.com (O'Reilly).
• Downloading Perl Software
– ActiveState. ActivePerl for Windows, as well as for
Linux and Solaris.
• ActivePerl binary packages.
– CPAN
• http://www.bioinformatics.be/n
ew/faq/setup/
Perl installation
Check installation
• Command-line flags for perl
– Perl – v
• Gives the current version of Perl
– Perl –e
• Executes Perl statements from the comment
line.
– Perl –e “print 42;”
– Perl –e “print ”Twonlinesn”;”
– Perl –we
• Executes and print warnings
– Perl –we “print „hello‟;x++;”
How to enter your first program ?
• Gebruik een editor
– DOS: EDIT
– Windows:
• NOTEPAD (Let op!)
• Word(Pad) -> TEXT FILE
– Scite:
http://www.scintilla.org/SciTE.html
– Textpad
– Others
• VIM
• Eclipse
Path:
 Route followed by OS to
locate, save, and/or
retrieve a file
Brief Introduction to Subdirectories—The Path
• Probleem
– Ofwel kan je perl starten
– Ofwel kan je het script niet vinden
– Ofwel kan je een file nodig in het script niet
vinden
• Oplossing
– Don‟t panic !
– Gebruikt absolute path-namen
• D:Perlbinperl.exe D:tempTest.pl
– Let wel in je script met je de slash “escape”
• $filename = “d:Temppdb.fasta”
Het absolute pad probleem …
• Oplossingen (II)
– Kopieer al de files in dezelfde directory !
– Dus als je perl start vanuit D:Perlbin met perl
kan je wel verwijzen naar D:Temptest.pl maar
dan moet ook de absolute verwijzing gebruikt
worden voor $filename ofwel moet je pdb.fasta
copieren naar D:PerlBin
– Pas het zoekpad aan zodat je perl overal kan
starten
• Path (geeft het zoekpad)
• Set Path (past het pad aan, Voorzichtig !). Gebruik de
dos environment variabele %path% om een directory
toe te voegen
• Set path=%path%;d:Perlbin
• (nadien kan de aanpassing controleren door “path” uit
te voeren)
Keyboard:
 Standard input device
Screen:
 Standard output device
Redirection
Redirection . . .
 changes output from monitor to
somewhere else (usually file or
printer).
Textpad
Minimal install: via Minerva save file
textpad.be to your folder. Create
system folder in the same location. In
system folder save plumb.exe
(Minerva) and perl syntax files
(textpad.com)
• Syntax Highlighting
– Document Class
• Launch Perl
– Tools
Perl
• Perl is mostly a free format language: add
spaces, tabs or new lines wherever you
want.
• For clarity, it is recommended to write
each statement in a separate line, and use
indentation in nested structures.
• Comments: Anything from the # sign to
the end of the line is a comment. (There
are no multi-line comments).
• A perl program consists of all of the Perl
statements of the file taken collectively as
one big routine to execute.
General Remarks
How does the real perl program look like:
#!/usr/local/bin/perl
print “Hello everyonen”;
Mandatory first line (on UNIX)
How to run it:
1. Save the text of your code as a file -- program.pl
2. Execute it:
perl program.pl
Hello everyone
Three Basic Data Types
• Scalars - $
• Arrays of scalars - @
• Associative arrays of
scalers or Hashes - %
2+2 = ?
$a = 2;
$b = 2;
$c = $a + $b;
$ - indicates a variable
; - ends every command
= - assigns a value to a variable
$c = 2 + 2;or
$c = 2 * 2;or
$c = 2 / 2;or
$c = 2 ^ 4;or 2^4 <-> 24 =16
$c = 1.35 * 2 - 3 / (0.12 + 1);or
Ok, $c is 4. How do we know it?
print “Hello n”;
print command:
$c = 4;
print “$c”;
“ ” - bracket output expression
n - print a end-of-the-line character
(equivalent to pressing ‘Enter’)
print “Hello everyonen”;
print “Hello” . ” everyone” . “n”;
Strings concatenation:
Expressions and strings together:
print “2 + 2 = “ . (2+2) . ”n”;
expression
2 + 2 = 4
Loops and cycles (for statement):
# Output all the numbers from 1 to 100
for ($n=1; $n<=100; $n+=1) {
print “$n n”;
}
1. Initialization:
for ( $n=1 ; ; ) { … }
2. Increment:
for ( ; ; $n+=1 ) { … }
3. Termination (do until the criteria is satisfied):
for ( ; $n<=100 ; ) { … }
4. Body of the loop - command inside curly brackets:
for ( ; ; ) { … }
FOR & IF -- all the even numbers from 1 to 100:
for ($n=1; $n<=100; $n+=1) {
if (($n % 2) == 0) {
print “$n”;
}
}
Note: $a % $b -- Modulus
-- Remainder when $a is divided by $b
Two brief diversions (warnings & strict)
• Use warnings
• strict – forces you to „declare‟ a variable the
first time you use it.
– usage: use strict; (somewhere near the top of
your script)
• declare variables with „my‟
– usage: my $variable;
– or: my $variable = „value‟;
• my sets the „scope‟ of the variable. Variable
exists only within the current block of code
• use strict and my both help you to debug
errors, and help prevent mistakes.
Unary Arithmetic Operators eg. Autoincrement ++
• If you place one of the auto operators before the variable, it is
known as a pre-incremented (pre-decremented) variable. Its
value will be changed before it is referenced. If it is placed
after the variable, it is known as a post-incremented (post-
decremented) variable and its value is changed after it is used
For example:
• $a = 5; # $a is assigned 5
• $b = ++$a; # $b is assigned the incremented value of $a, 6
• $c = $a--; # $c is assigned 6, then $a is decremented to 5
#!e:perlbinperl.exe
• $getal1 = 5;
• print $getal1."n";
• print $getal1++."n";
• print ++$getal1."n";
Logical and Comparison operators
• Equal (True if $a is equal to $b)
– Numeric: ==
– String: eq
• And: &&
• Or: ||
Schuifoperatoren
• Schuifoperatoren zijn handing voor
manipulaties op bit-niveau: bv 40
256 128 64 32 16 8 4 2 1
0 0 0 1 0 1 0 0 0
0 0 0 1 0 1 0 00
000 1 0 1 0 0 0
Program
• $getal1 = 40;
• print "/4 ".($getal1 >> 2)."n";
• print "*8 ".($getal1 << 3)."n";
>>2
<<3
Text Processing Functions
The substr function
• Definition
• The substr function extracts a substring out of a
string and returns it. The function receives 3
arguments: a string value, a position on the string
(starting to count from 0) and a length.
Example:
• $a = "university";
• $k = substr ($a, 3, 5);
• $k is now "versi" $a remains unchanged.
• If length is omitted, everything to the end of the
string is returned.
Random
#!c:perlbinperl.exe -w
#srand(time|$$);
$x = rand(1);
• srand
– The default seed for srand, which used to be time, has
been changed. Now it's a heady mix of difficult-to-predict
system-dependent values, which should be sufficient for
most everyday purposes. Previous to version 5.004,
calling rand without first calling srand would yield the
same sequence of random numbers on most or all
machines. Now, when perl sees that you're calling rand
and haven't yet called srand, it calls srand with the default
seed. You should still call srand manually if your code
might ever be run on a pre-5.004 system, of course, or if
you want a seed other than the default
• Oefening hoe goed zijn de random
nummers ?
• Als ze goed zijn kan je er Pi mee
berekenen …
• Een goede random generator is
belangrijk voor goede
randomsequenties die we nadien
kunnen gebruiken in simulaties
Bereken Pi aan de hand van twee random getallen
1
x
y

More Related Content

What's hot

Homology modeling
Homology modelingHomology modeling
Gene prediction methods vijay
Gene prediction methods  vijayGene prediction methods  vijay
Gene prediction methods vijay
Vijay Hemmadi
 
String.pptx
String.pptxString.pptx
String.pptx
RitikaChoudhary57
 
Multiple sequence alignment
Multiple sequence alignmentMultiple sequence alignment
Multiple sequence alignment
Subhranil Bhattacharjee
 
I- Tasser
I- TasserI- Tasser
I- Tasser
Animesh Kumar
 
sequence of file formats in bioinformatics
sequence of file formats in bioinformaticssequence of file formats in bioinformatics
sequence of file formats in bioinformatics
nadeem akhter
 
Protein folding slids
Protein folding slidsProtein folding slids
Protein folding slids
anam tariq
 
Dot matrix Analysis Tools (Bioinformatics)
Dot matrix Analysis Tools (Bioinformatics)Dot matrix Analysis Tools (Bioinformatics)
Dot matrix Analysis Tools (Bioinformatics)
Safa Khalid
 
Flux balance analysis
Flux balance analysisFlux balance analysis
Flux balance analysis
JyotiBishlay
 
Structural Variation Detection
Structural Variation DetectionStructural Variation Detection
Structural Variation Detection
Jennifer Shelton
 
Genome annotation
Genome annotationGenome annotation
Genome annotation
Rezwana Nishat
 
Global and local alignment (bioinformatics)
Global and local alignment (bioinformatics)Global and local alignment (bioinformatics)
Global and local alignment (bioinformatics)
Pritom Chaki
 
Sequence alignment global vs. local
Sequence alignment  global vs. localSequence alignment  global vs. local
Sequence alignment global vs. local
benazeer fathima
 
Msa
MsaMsa
Structural databases
Structural databases Structural databases
Structural databases
Priyadharshana
 
Needleman-wunch algorithm harshita
Needleman-wunch algorithm  harshitaNeedleman-wunch algorithm  harshita
Needleman-wunch algorithm harshita
Harshita Bhawsar
 
Perl
PerlPerl
Scoring schemes in bioinformatics (blosum)
Scoring schemes in bioinformatics (blosum)Scoring schemes in bioinformatics (blosum)
Scoring schemes in bioinformatics (blosum)
SumatiHajela
 
Scop database
Scop databaseScop database
Scop database
Sayantani Roy
 
Needleman-Wunsch Algorithm
Needleman-Wunsch AlgorithmNeedleman-Wunsch Algorithm
Needleman-Wunsch Algorithm
ProshantaShil
 

What's hot (20)

Homology modeling
Homology modelingHomology modeling
Homology modeling
 
Gene prediction methods vijay
Gene prediction methods  vijayGene prediction methods  vijay
Gene prediction methods vijay
 
String.pptx
String.pptxString.pptx
String.pptx
 
Multiple sequence alignment
Multiple sequence alignmentMultiple sequence alignment
Multiple sequence alignment
 
I- Tasser
I- TasserI- Tasser
I- Tasser
 
sequence of file formats in bioinformatics
sequence of file formats in bioinformaticssequence of file formats in bioinformatics
sequence of file formats in bioinformatics
 
Protein folding slids
Protein folding slidsProtein folding slids
Protein folding slids
 
Dot matrix Analysis Tools (Bioinformatics)
Dot matrix Analysis Tools (Bioinformatics)Dot matrix Analysis Tools (Bioinformatics)
Dot matrix Analysis Tools (Bioinformatics)
 
Flux balance analysis
Flux balance analysisFlux balance analysis
Flux balance analysis
 
Structural Variation Detection
Structural Variation DetectionStructural Variation Detection
Structural Variation Detection
 
Genome annotation
Genome annotationGenome annotation
Genome annotation
 
Global and local alignment (bioinformatics)
Global and local alignment (bioinformatics)Global and local alignment (bioinformatics)
Global and local alignment (bioinformatics)
 
Sequence alignment global vs. local
Sequence alignment  global vs. localSequence alignment  global vs. local
Sequence alignment global vs. local
 
Msa
MsaMsa
Msa
 
Structural databases
Structural databases Structural databases
Structural databases
 
Needleman-wunch algorithm harshita
Needleman-wunch algorithm  harshitaNeedleman-wunch algorithm  harshita
Needleman-wunch algorithm harshita
 
Perl
PerlPerl
Perl
 
Scoring schemes in bioinformatics (blosum)
Scoring schemes in bioinformatics (blosum)Scoring schemes in bioinformatics (blosum)
Scoring schemes in bioinformatics (blosum)
 
Scop database
Scop databaseScop database
Scop database
 
Needleman-Wunsch Algorithm
Needleman-Wunsch AlgorithmNeedleman-Wunsch Algorithm
Needleman-Wunsch Algorithm
 

Viewers also liked

bioinformatics simple
bioinformatics simple bioinformatics simple
bioinformatics simple nadeem akhter
 
Bioinformatics
BioinformaticsBioinformatics
Bioinformatics
Nuno Barreto
 
Bioinformatics
BioinformaticsBioinformatics
Bioinformatics
Promila Sharan
 
Introduction to bioinformatics
Introduction to bioinformaticsIntroduction to bioinformatics
Introduction to bioinformatics
Hamid Ur-Rahman
 
Bioinformatics Final Presentation
Bioinformatics Final PresentationBioinformatics Final Presentation
Bioinformatics Final PresentationShruthi Choudary
 
Application of bioinformatics
Application of bioinformaticsApplication of bioinformatics
Application of bioinformatics
Kamlesh Patade
 
Basics of bioinformatics
Basics of bioinformaticsBasics of bioinformatics
Basics of bioinformaticsAbhishek Vatsa
 
Bioinformatics
BioinformaticsBioinformatics
Bioinformaticsbiinoida
 
Application of Bioinformatics in different fields of sciences
Application of Bioinformatics in different fields of sciencesApplication of Bioinformatics in different fields of sciences
Application of Bioinformatics in different fields of sciences
Sobia
 
Bioinformatics
BioinformaticsBioinformatics
Bioinformatics
JTADrexel
 

Viewers also liked (12)

bioinformatics simple
bioinformatics simple bioinformatics simple
bioinformatics simple
 
Bioinformatics
BioinformaticsBioinformatics
Bioinformatics
 
Bioinformatics
BioinformaticsBioinformatics
Bioinformatics
 
Introduction to bioinformatics
Introduction to bioinformaticsIntroduction to bioinformatics
Introduction to bioinformatics
 
blast bioinformatics
blast bioinformaticsblast bioinformatics
blast bioinformatics
 
Bioinformatics Final Presentation
Bioinformatics Final PresentationBioinformatics Final Presentation
Bioinformatics Final Presentation
 
Application of bioinformatics
Application of bioinformaticsApplication of bioinformatics
Application of bioinformatics
 
Bioinformatics principles and applications
Bioinformatics principles and applicationsBioinformatics principles and applications
Bioinformatics principles and applications
 
Basics of bioinformatics
Basics of bioinformaticsBasics of bioinformatics
Basics of bioinformatics
 
Bioinformatics
BioinformaticsBioinformatics
Bioinformatics
 
Application of Bioinformatics in different fields of sciences
Application of Bioinformatics in different fields of sciencesApplication of Bioinformatics in different fields of sciences
Application of Bioinformatics in different fields of sciences
 
Bioinformatics
BioinformaticsBioinformatics
Bioinformatics
 

Similar to Bioinformatics p1-perl-introduction v2013

Bioinformatics v2014 wim_vancriekinge
Bioinformatics v2014 wim_vancriekingeBioinformatics v2014 wim_vancriekinge
Bioinformatics v2014 wim_vancriekinge
Prof. Wim Van Criekinge
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
Prof. Wim Van Criekinge
 
Bioinformatica p1-perl-introduction
Bioinformatica p1-perl-introductionBioinformatica p1-perl-introduction
Bioinformatica p1-perl-introduction
Prof. Wim Van Criekinge
 
Intro to Perl
Intro to PerlIntro to Perl
Intro to Perl
primeteacher32
 
Learn perl in amc square learning
Learn perl in amc square learningLearn perl in amc square learning
Learn perl in amc square learning
ASIT Education
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Bioinformatics p4-io v2013-wim_vancriekinge
Bioinformatics p4-io v2013-wim_vancriekingeBioinformatics p4-io v2013-wim_vancriekinge
Bioinformatics p4-io v2013-wim_vancriekinge
Prof. Wim Van Criekinge
 
Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood edition
Dave Diehl
 
System Programming and Administration
System Programming and AdministrationSystem Programming and Administration
System Programming and Administration
Krasimir Berov (Красимир Беров)
 
Perl Programming - 01 Basic Perl
Perl Programming - 01 Basic PerlPerl Programming - 01 Basic Perl
Perl Programming - 01 Basic Perl
Danairat Thanabodithammachari
 
2012 03 08_dbi
2012 03 08_dbi2012 03 08_dbi
2012 03 08_dbi
Prof. Wim Van Criekinge
 
Python ppt
Python pptPython ppt
Python ppt
Mohita Pandey
 
Python Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part IPython Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part I
DUSPviz
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
rICh morrow
 
php fundamental
php fundamentalphp fundamental
php fundamental
zalatarunk
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of phppooja bhandari
 
Pearl
PearlPearl
perl lauange
perl lauangeperl lauange
perl lauange
Naga Dinesh
 

Similar to Bioinformatics p1-perl-introduction v2013 (20)

Bioinformatics v2014 wim_vancriekinge
Bioinformatics v2014 wim_vancriekingeBioinformatics v2014 wim_vancriekinge
Bioinformatics v2014 wim_vancriekinge
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
 
Bioinformatica p1-perl-introduction
Bioinformatica p1-perl-introductionBioinformatica p1-perl-introduction
Bioinformatica p1-perl-introduction
 
Intro to Perl
Intro to PerlIntro to Perl
Intro to Perl
 
Learn perl in amc square learning
Learn perl in amc square learningLearn perl in amc square learning
Learn perl in amc square learning
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Bioinformatics p4-io v2013-wim_vancriekinge
Bioinformatics p4-io v2013-wim_vancriekingeBioinformatics p4-io v2013-wim_vancriekinge
Bioinformatics p4-io v2013-wim_vancriekinge
 
Holy PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood editionHoly PowerShell, BATman! - dogfood edition
Holy PowerShell, BATman! - dogfood edition
 
System Programming and Administration
System Programming and AdministrationSystem Programming and Administration
System Programming and Administration
 
Perl Programming - 01 Basic Perl
Perl Programming - 01 Basic PerlPerl Programming - 01 Basic Perl
Perl Programming - 01 Basic Perl
 
2012 03 08_dbi
2012 03 08_dbi2012 03 08_dbi
2012 03 08_dbi
 
Python ppt
Python pptPython ppt
Python ppt
 
firststeps
firststepsfirststeps
firststeps
 
Python Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part IPython Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part I
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
php
phpphp
php
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
Pearl
PearlPearl
Pearl
 
perl lauange
perl lauangeperl lauange
perl lauange
 

More from Prof. Wim Van Criekinge

2020 02 11_biological_databases_part1
2020 02 11_biological_databases_part12020 02 11_biological_databases_part1
2020 02 11_biological_databases_part1
Prof. Wim Van Criekinge
 
2019 03 05_biological_databases_part5_v_upload
2019 03 05_biological_databases_part5_v_upload2019 03 05_biological_databases_part5_v_upload
2019 03 05_biological_databases_part5_v_upload
Prof. Wim Van Criekinge
 
2019 03 05_biological_databases_part4_v_upload
2019 03 05_biological_databases_part4_v_upload2019 03 05_biological_databases_part4_v_upload
2019 03 05_biological_databases_part4_v_upload
Prof. Wim Van Criekinge
 
2019 03 05_biological_databases_part3_v_upload
2019 03 05_biological_databases_part3_v_upload2019 03 05_biological_databases_part3_v_upload
2019 03 05_biological_databases_part3_v_upload
Prof. Wim Van Criekinge
 
2019 02 21_biological_databases_part2_v_upload
2019 02 21_biological_databases_part2_v_upload2019 02 21_biological_databases_part2_v_upload
2019 02 21_biological_databases_part2_v_upload
Prof. Wim Van Criekinge
 
2019 02 12_biological_databases_part1_v_upload
2019 02 12_biological_databases_part1_v_upload2019 02 12_biological_databases_part1_v_upload
2019 02 12_biological_databases_part1_v_upload
Prof. Wim Van Criekinge
 
P7 2018 biopython3
P7 2018 biopython3P7 2018 biopython3
P7 2018 biopython3
Prof. Wim Van Criekinge
 
P6 2018 biopython2b
P6 2018 biopython2bP6 2018 biopython2b
P6 2018 biopython2b
Prof. Wim Van Criekinge
 
P4 2018 io_functions
P4 2018 io_functionsP4 2018 io_functions
P4 2018 io_functions
Prof. Wim Van Criekinge
 
P3 2018 python_regexes
P3 2018 python_regexesP3 2018 python_regexes
P3 2018 python_regexes
Prof. Wim Van Criekinge
 
T1 2018 bioinformatics
T1 2018 bioinformaticsT1 2018 bioinformatics
T1 2018 bioinformatics
Prof. Wim Van Criekinge
 
P1 2018 python
P1 2018 pythonP1 2018 python
P1 2018 python
Prof. Wim Van Criekinge
 
Bio ontologies and semantic technologies[2]
Bio ontologies and semantic technologies[2]Bio ontologies and semantic technologies[2]
Bio ontologies and semantic technologies[2]
Prof. Wim Van Criekinge
 
2018 05 08_biological_databases_no_sql
2018 05 08_biological_databases_no_sql2018 05 08_biological_databases_no_sql
2018 05 08_biological_databases_no_sql
Prof. Wim Van Criekinge
 
2018 03 27_biological_databases_part4_v_upload
2018 03 27_biological_databases_part4_v_upload2018 03 27_biological_databases_part4_v_upload
2018 03 27_biological_databases_part4_v_upload
Prof. Wim Van Criekinge
 
2018 03 20_biological_databases_part3
2018 03 20_biological_databases_part32018 03 20_biological_databases_part3
2018 03 20_biological_databases_part3
Prof. Wim Van Criekinge
 
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
Prof. Wim Van Criekinge
 
2018 02 20_biological_databases_part1_v_upload
2018 02 20_biological_databases_part1_v_upload2018 02 20_biological_databases_part1_v_upload
2018 02 20_biological_databases_part1_v_upload
Prof. Wim Van Criekinge
 
P7 2017 biopython3
P7 2017 biopython3P7 2017 biopython3
P7 2017 biopython3
Prof. Wim Van Criekinge
 
P6 2017 biopython2
P6 2017 biopython2P6 2017 biopython2
P6 2017 biopython2
Prof. Wim Van Criekinge
 

More from Prof. Wim Van Criekinge (20)

2020 02 11_biological_databases_part1
2020 02 11_biological_databases_part12020 02 11_biological_databases_part1
2020 02 11_biological_databases_part1
 
2019 03 05_biological_databases_part5_v_upload
2019 03 05_biological_databases_part5_v_upload2019 03 05_biological_databases_part5_v_upload
2019 03 05_biological_databases_part5_v_upload
 
2019 03 05_biological_databases_part4_v_upload
2019 03 05_biological_databases_part4_v_upload2019 03 05_biological_databases_part4_v_upload
2019 03 05_biological_databases_part4_v_upload
 
2019 03 05_biological_databases_part3_v_upload
2019 03 05_biological_databases_part3_v_upload2019 03 05_biological_databases_part3_v_upload
2019 03 05_biological_databases_part3_v_upload
 
2019 02 21_biological_databases_part2_v_upload
2019 02 21_biological_databases_part2_v_upload2019 02 21_biological_databases_part2_v_upload
2019 02 21_biological_databases_part2_v_upload
 
2019 02 12_biological_databases_part1_v_upload
2019 02 12_biological_databases_part1_v_upload2019 02 12_biological_databases_part1_v_upload
2019 02 12_biological_databases_part1_v_upload
 
P7 2018 biopython3
P7 2018 biopython3P7 2018 biopython3
P7 2018 biopython3
 
P6 2018 biopython2b
P6 2018 biopython2bP6 2018 biopython2b
P6 2018 biopython2b
 
P4 2018 io_functions
P4 2018 io_functionsP4 2018 io_functions
P4 2018 io_functions
 
P3 2018 python_regexes
P3 2018 python_regexesP3 2018 python_regexes
P3 2018 python_regexes
 
T1 2018 bioinformatics
T1 2018 bioinformaticsT1 2018 bioinformatics
T1 2018 bioinformatics
 
P1 2018 python
P1 2018 pythonP1 2018 python
P1 2018 python
 
Bio ontologies and semantic technologies[2]
Bio ontologies and semantic technologies[2]Bio ontologies and semantic technologies[2]
Bio ontologies and semantic technologies[2]
 
2018 05 08_biological_databases_no_sql
2018 05 08_biological_databases_no_sql2018 05 08_biological_databases_no_sql
2018 05 08_biological_databases_no_sql
 
2018 03 27_biological_databases_part4_v_upload
2018 03 27_biological_databases_part4_v_upload2018 03 27_biological_databases_part4_v_upload
2018 03 27_biological_databases_part4_v_upload
 
2018 03 20_biological_databases_part3
2018 03 20_biological_databases_part32018 03 20_biological_databases_part3
2018 03 20_biological_databases_part3
 
2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload2018 02 20_biological_databases_part2_v_upload
2018 02 20_biological_databases_part2_v_upload
 
2018 02 20_biological_databases_part1_v_upload
2018 02 20_biological_databases_part1_v_upload2018 02 20_biological_databases_part1_v_upload
2018 02 20_biological_databases_part1_v_upload
 
P7 2017 biopython3
P7 2017 biopython3P7 2017 biopython3
P7 2017 biopython3
 
P6 2017 biopython2
P6 2017 biopython2P6 2017 biopython2
P6 2017 biopython2
 

Recently uploaded

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 

Recently uploaded (20)

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 

Bioinformatics p1-perl-introduction v2013

  • 1.
  • 3. Bioinformatics.be • Communiceren van praktische zaken: waar en wanneer gaan de lessen door • Ter beschikking stellen van lesmateriaal • Aanvullend educatief materiaal (FAQ, Web Links) • Practicum opgaven en programmacode Voordelen • Gebruik van het webtechnologie bij het assimileren van de cursus • Veel vragen/antwoorden kunnen interessant voor meerdere mensen, Vermijden van terugkerende vragen • Permante discussie (tijdens het jaar) tussen studenten, prof maar ook thesis en doctoraatsstudenten
  • 4.
  • 5. Practicum • Practicum regeling ? – Inleiding van 45min over de gebruikte editor, programmeertaal, websites – 15min toelichting tot de opgaven – Normaal in PC-zaal D (check bioinformatics.be!) Perl for Bioinformatics Part 1: Beginning Part 2: Mastering
  • 6. Practicum Bioinformatica • Practicum – Inleiding tot Perl – Write your first PERL program ! – Execute your first.pl
  • 7. • Perl is a High-level Scripting language • Larry Wall created Perl in 1987 – Practical Extraction (a)nd Reporting Language – (or Pathologically Eclectic Rubbish Lister) • Born from a system administration tool • Faster than sh or csh • Sslower than C • No need for sed, awk, tr, wc, cut, … • Perl is open and free • http://conferences.oreillynet.com/e urooscon/ What is Perl ?
  • 8. • Perl is available for most computing platforms: all flavors of UNIX (Linux), MS-DOS/Win32, Macintosh, VMS, OS/2, Amiga, AS/400, Atari • Perl is a computer language that is: – Interpreted, compiles at run-time (need for perl.exe !) – Loosely “typed” – String/text oriented – Capable of using multiple syntax formats • In Perl, “there‟s more than one way to do it” What is Perl ?
  • 9. • Ease of use by novice programmers • Flexible language: Fast software prototyping (quick and dirty creation of small analysis programs) • Expressiveness. Compact code, Perl Poetry: @{$_[$#_]||[]} • Glutility: Read disparate files and parse the relevant data into a new format • Powerful pattern matching via “regular expressions” (Best Regular Expressions on Earth) • With the advent of the WWW, Perl has become the language of choice to create Common Gateway Interface (CGI) scripts to handle form submissions and create compute severs on the WWW. • Open Source – Free. Availability of Perl modules for Bioinformatics and Internet. Why use Perl for bioinformatics ?
  • 10. • Some tasks are still better done with other languages (heavy computations / graphics) – C(++),C#, Fortran, Java (Pascal,Visual Basic) • With perl you can write simple programs fast, but on the other hand it is also suitable for large and complex programs. (yet, it is not adequate for very large projects) – Python • Larry Wall: “For programmers, laziness is a virtue” Why NOT use Perl for bioinformatics ?
  • 11. • Sequence manipulation and analysis • Parsing results of sequence analysis programs (Blast, Genscan, Hmmer etc) • Parsing database (eg Genbank) files • Obtaining multiple database entries over the internet • … What bioinformatics tasks are suited to Perl ?
  • 12. Example of problems we will be solving • Primary Sequence analysis • Perform alignments • Simulation experiments to explain Blast statistics • Predicting protein topology • Predicting secondary structures • “Real-life” problems – Proteomics: Given aa masses find protein in database – …
  • 13. • Perl (op USB): – Perl is available for various operating systems. To download Perl and install it on your computer, have a look at the following resources: – www.perl.com (O'Reilly). • Downloading Perl Software – ActiveState. ActivePerl for Windows, as well as for Linux and Solaris. • ActivePerl binary packages. – CPAN • http://www.bioinformatics.be/n ew/faq/setup/ Perl installation
  • 14. Check installation • Command-line flags for perl – Perl – v • Gives the current version of Perl – Perl –e • Executes Perl statements from the comment line. – Perl –e “print 42;” – Perl –e “print ”Twonlinesn”;” – Perl –we • Executes and print warnings – Perl –we “print „hello‟;x++;”
  • 15. How to enter your first program ? • Gebruik een editor – DOS: EDIT – Windows: • NOTEPAD (Let op!) • Word(Pad) -> TEXT FILE – Scite: http://www.scintilla.org/SciTE.html – Textpad – Others • VIM • Eclipse
  • 16. Path:  Route followed by OS to locate, save, and/or retrieve a file Brief Introduction to Subdirectories—The Path
  • 17. • Probleem – Ofwel kan je perl starten – Ofwel kan je het script niet vinden – Ofwel kan je een file nodig in het script niet vinden • Oplossing – Don‟t panic ! – Gebruikt absolute path-namen • D:Perlbinperl.exe D:tempTest.pl – Let wel in je script met je de slash “escape” • $filename = “d:Temppdb.fasta” Het absolute pad probleem …
  • 18. • Oplossingen (II) – Kopieer al de files in dezelfde directory ! – Dus als je perl start vanuit D:Perlbin met perl kan je wel verwijzen naar D:Temptest.pl maar dan moet ook de absolute verwijzing gebruikt worden voor $filename ofwel moet je pdb.fasta copieren naar D:PerlBin – Pas het zoekpad aan zodat je perl overal kan starten • Path (geeft het zoekpad) • Set Path (past het pad aan, Voorzichtig !). Gebruik de dos environment variabele %path% om een directory toe te voegen • Set path=%path%;d:Perlbin • (nadien kan de aanpassing controleren door “path” uit te voeren)
  • 19. Keyboard:  Standard input device Screen:  Standard output device Redirection Redirection . . .  changes output from monitor to somewhere else (usually file or printer).
  • 20. Textpad Minimal install: via Minerva save file textpad.be to your folder. Create system folder in the same location. In system folder save plumb.exe (Minerva) and perl syntax files (textpad.com) • Syntax Highlighting – Document Class • Launch Perl – Tools
  • 21. Perl
  • 22. • Perl is mostly a free format language: add spaces, tabs or new lines wherever you want. • For clarity, it is recommended to write each statement in a separate line, and use indentation in nested structures. • Comments: Anything from the # sign to the end of the line is a comment. (There are no multi-line comments). • A perl program consists of all of the Perl statements of the file taken collectively as one big routine to execute. General Remarks
  • 23. How does the real perl program look like: #!/usr/local/bin/perl print “Hello everyonen”; Mandatory first line (on UNIX) How to run it: 1. Save the text of your code as a file -- program.pl 2. Execute it: perl program.pl Hello everyone
  • 24. Three Basic Data Types • Scalars - $ • Arrays of scalars - @ • Associative arrays of scalers or Hashes - %
  • 25. 2+2 = ? $a = 2; $b = 2; $c = $a + $b; $ - indicates a variable ; - ends every command = - assigns a value to a variable $c = 2 + 2;or $c = 2 * 2;or $c = 2 / 2;or $c = 2 ^ 4;or 2^4 <-> 24 =16 $c = 1.35 * 2 - 3 / (0.12 + 1);or
  • 26. Ok, $c is 4. How do we know it? print “Hello n”; print command: $c = 4; print “$c”; “ ” - bracket output expression n - print a end-of-the-line character (equivalent to pressing ‘Enter’) print “Hello everyonen”; print “Hello” . ” everyone” . “n”; Strings concatenation: Expressions and strings together: print “2 + 2 = “ . (2+2) . ”n”; expression 2 + 2 = 4
  • 27. Loops and cycles (for statement): # Output all the numbers from 1 to 100 for ($n=1; $n<=100; $n+=1) { print “$n n”; } 1. Initialization: for ( $n=1 ; ; ) { … } 2. Increment: for ( ; ; $n+=1 ) { … } 3. Termination (do until the criteria is satisfied): for ( ; $n<=100 ; ) { … } 4. Body of the loop - command inside curly brackets: for ( ; ; ) { … }
  • 28. FOR & IF -- all the even numbers from 1 to 100: for ($n=1; $n<=100; $n+=1) { if (($n % 2) == 0) { print “$n”; } } Note: $a % $b -- Modulus -- Remainder when $a is divided by $b
  • 29. Two brief diversions (warnings & strict) • Use warnings • strict – forces you to „declare‟ a variable the first time you use it. – usage: use strict; (somewhere near the top of your script) • declare variables with „my‟ – usage: my $variable; – or: my $variable = „value‟; • my sets the „scope‟ of the variable. Variable exists only within the current block of code • use strict and my both help you to debug errors, and help prevent mistakes.
  • 30. Unary Arithmetic Operators eg. Autoincrement ++ • If you place one of the auto operators before the variable, it is known as a pre-incremented (pre-decremented) variable. Its value will be changed before it is referenced. If it is placed after the variable, it is known as a post-incremented (post- decremented) variable and its value is changed after it is used For example: • $a = 5; # $a is assigned 5 • $b = ++$a; # $b is assigned the incremented value of $a, 6 • $c = $a--; # $c is assigned 6, then $a is decremented to 5 #!e:perlbinperl.exe • $getal1 = 5; • print $getal1."n"; • print $getal1++."n"; • print ++$getal1."n";
  • 31. Logical and Comparison operators • Equal (True if $a is equal to $b) – Numeric: == – String: eq • And: && • Or: ||
  • 32. Schuifoperatoren • Schuifoperatoren zijn handing voor manipulaties op bit-niveau: bv 40 256 128 64 32 16 8 4 2 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 00 000 1 0 1 0 0 0 Program • $getal1 = 40; • print "/4 ".($getal1 >> 2)."n"; • print "*8 ".($getal1 << 3)."n"; >>2 <<3
  • 33. Text Processing Functions The substr function • Definition • The substr function extracts a substring out of a string and returns it. The function receives 3 arguments: a string value, a position on the string (starting to count from 0) and a length. Example: • $a = "university"; • $k = substr ($a, 3, 5); • $k is now "versi" $a remains unchanged. • If length is omitted, everything to the end of the string is returned.
  • 34. Random #!c:perlbinperl.exe -w #srand(time|$$); $x = rand(1); • srand – The default seed for srand, which used to be time, has been changed. Now it's a heady mix of difficult-to-predict system-dependent values, which should be sufficient for most everyday purposes. Previous to version 5.004, calling rand without first calling srand would yield the same sequence of random numbers on most or all machines. Now, when perl sees that you're calling rand and haven't yet called srand, it calls srand with the default seed. You should still call srand manually if your code might ever be run on a pre-5.004 system, of course, or if you want a seed other than the default
  • 35. • Oefening hoe goed zijn de random nummers ? • Als ze goed zijn kan je er Pi mee berekenen … • Een goede random generator is belangrijk voor goede randomsequenties die we nadien kunnen gebruiken in simulaties
  • 36. Bereken Pi aan de hand van twee random getallen 1 x y