Programming basics &
This presentation is the property of its rightful owner.
Sponsored Links
1 / 18

Programming basics & introduction to PERL Mats Pettersson PowerPoint PPT Presentation


  • 40 Views
  • Uploaded on
  • Presentation posted in: General

Programming basics & introduction to PERL Mats Pettersson. Some jargon: Source code – plain text files with commands Language – collection of definition Compiler – “translator” from text to binary files Interpreter – executes a source file line by line

Download Presentation

Programming basics & introduction to PERL Mats Pettersson

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Programming basics introduction to perl mats pettersson

Programming basics &

introduction to PERL

Mats Pettersson


Programming basics introduction to perl mats pettersson

Some jargon:

Source code – plain text files with commands

Language – collection of definition

Compiler – “translator” from text to binary files

Interpreter – executes a source file line by line

Algorithm – a “recipe” to get from input to output

Variable – data “container”

Assignment – putting data into a variable


Programming basics introduction to perl mats pettersson

Algorithms

Define the task

Break it down to small steps

Find a way to achieve each step

- implementation


Programming basics introduction to perl mats pettersson

Fundamental operations

Reading input

Manipulating data

- Math

- Data reshuffling

- Flow control

Writing output


Programming basics introduction to perl mats pettersson

Control statements

Conditional statements

- if – elseif – else

Loops

- for – foreach – while


Programming basics introduction to perl mats pettersson

Data manipulation

Extracting subsets of data

- pattern matching

Data structures

- connecting different types of data

- representing matrices or tables


Programming basics introduction to perl mats pettersson

The PERL language

Primarily for text manipulation

- Deals very well with large files

High-level language

- Very concise scripts

- Readability is an issue

Large amounts of existing modules

- BioPerl


Programming basics introduction to perl mats pettersson

PERL data types

Scalar($)

Single value variable

Array(@)

Ordered collection of values (“row”)

Hash(%)

Unordered, but names, collection of values


Programming basics introduction to perl mats pettersson

PERL data types

$scalar = 5

@array = (1, 2, 3)

$array[0]

%hash = (“key1” => 3, “key2” => 4)

$hash{“key1”}


Programming basics introduction to perl mats pettersson

PERL I/O operations

Open

- modes (>/<)

- file handle

Read

- <> operator

Close


Programming basics introduction to perl mats pettersson

PERL I/O operations

open HANDLE “>filename”

print HANDLE “Hello world!”

close HANDLE


Programming basics introduction to perl mats pettersson

PERL string manipulation

Split

- creates an array from a string

Join

- reverse split

Chomp

- removes trailing newline symbol (\n)


Programming basics introduction to perl mats pettersson

PERL string matching

Regular expressions

- generalized string patterns

- character groups []

- special symbols (^, $, ., \, +, ?,/)

The =~ operator

- “binds” the string of interest to the pattern

- modifiers (s, g)


Programming basics introduction to perl mats pettersson

PERL references

Scalar that “point” to arrays or hashes

$aref = \@array

$href = \@hash

$aref = [1,2,3]

$href = {“key1” => 3, “key2” => 4}

Useful for 2D structures


Programming basics introduction to perl mats pettersson

PERL references

Dereferencing

@{$aref}

%{$href}

$aref->[0]

$href->{“key1”}


Programming basics introduction to perl mats pettersson

PERL oddities

The default variable ($_)

- stores latest result

- default argument for methods

Implicit declaration

- variable type deduced from context

Very flexible syntax

- hard to read

- mistakes happen


Programming basics introduction to perl mats pettersson

PERL tutorials

http://perldoc.perl.org/index-tutorials.html

http://www.bioperl.org/wiki/HOWTOs


Programming basics introduction to perl mats pettersson

BioPerl

A larger collection of modules intended for

use in bioinformatics

- Sequence retrieval

- Database searches

- Alignment


  • Login