3.1 Ifs and Loops. 3.2 Revision: variables Scalar variables can store scalar values: Variable declaration my ($priority); Numerical assignment $priority.

Slides:



Advertisements
Similar presentations
A primer on Perl programming First structures (with examples)
Advertisements

Ruby (on Rails) CSE 190M, Spring 2009 Week 2. Arrays Similar to PHP, Ruby arrays… – Are indexed by zero-based integer values – Store an assortment of.
CSET4100 – Fall 2009 Perl Introduction Scalar Data, Operators & Control Blocks Acknowledgements: Slides adapted from NYU Computer Science course on UNIX.
Programming and Perl for Bioinformatics Part I. A Taste of Perl: print a message perltaste.pl: Greet the entire world. #!/usr/bin/perl #greet the entire.
4.1 Controls: Ifs and Loops. 4.2 Controls: if ? Controls allow non-sequential execution of commands, and responding to different conditions else { print.
4ex.1 More loops. 4ex.2 Loops Commands inside a loop are executed repeatedly (iteratively): my $num=0; print "Guess a number.\n"; while ($num != 31) {
1 Controlling Script Flow! David Lash Chapter 3 Conditional Statements.
Practical Extraction & Report Language Picture taken from
Gene Expression Analysis by SAGE. Gene Expression Some challenges: –Large number of genes How do you keep samples and equipment small and affordable?
4.1 Revision. 4.2 if, elsif, else It’s convenient to test several conditions in one if structure: print "Please enter your grades average:\n"; my $number.
5.1 Revision: Ifs and Loops. 5.2 if, elsif, else It’s convenient to test several conditions in one if structure: print "Please enter your grades average:\n";
4.1 More loops. 4.2 Loops Commands inside a loop are executed repeatedly (iteratively): my $num=0; print "Guess a number.\n"; while ($num != 31) { $num.
2.1 Lists and Arrays Summary of 1 st lesson Single quoted and double quoted strings Backslash ( \ ) – the escape character: \t \n Operators:
2ex.1 Lists and Arrays. 2ex.2 Comments on exercises Always run your script with “ perl -w ” and take care of all warnings  submitted scripts should not.
3ex.1 Note: use strict on the first line Because of a bug in the Perl Express debugger you have to put “use strict;” on the first line of your scripts.
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
Practical Extraction & Report Language PERL Joseph Beltran.
1 Operating Systems Lecture 3 Shell Scripts. 2 Shell Programming 1.Shell scripts must be marked as executable: chmod a+x myScript 2. Use # to start a.
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
Computer Programming for Biologists Class 5 Nov 20 st, 2014 Karsten Hokamp
Perl Tutorial Presented by Pradeepsunder. Why PERL ???  Practical extraction and report language  Similar to shell script but lot easier and more powerful.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Bioinformatics 生物信息学理论和实践 唐继军
Introduction to Perl Giorgos Georgakilas Graduated from C.E.I.D.Graduated from C.E.I.D. M.Sc. degree in ITMBM.Sc. degree in ITMB Ph.D. student in DIANA-LabPh.D.
Books. Perl Perl (Practical Extraction and Report Language) by Larry Wall Perl 1.0 was released to usenet's alt.comp.sources in 1987 Perl 5 was released.
Perl Language Yize Chen CS354. History Perl was designed by Larry Wall in 1987 as a text processing language Perl has revised several times and becomes.
Perl: Lecture 1 The language. What Perl is Merger of Unix tools – Very popular under UNIX – shell, sed, awk Programming language – C syntax Scripting.
3.1 Revision: variables & arrays Array declaration Array = ('A','B','C','D'); = = (); Array.
Python uses boolean variables to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated.
Introduction to Unix – CS 21
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Computer Programming for Biologists Class 3 Nov 13 th, 2014 Karsten Hokamp
Agenda Basic Logic Purpose if statement if / else statement
Computer Programming for Biologists Class 6 Nov 21 th, 2014 Karsten Hokamp
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
CPTG286K Programming - Perl Chapter 4: Control Structures.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
1 STRINGS String data type Basic operations on strings String functions String procedures.
More Perl Data Types Scalar: it may be a number, a character string, or a reference to another data type. -the sigil $ is used to denote a scalar(or reference)
Topic 2: Working with scalars CSE2395/CSE3395 Perl Programming Learning Perl 3rd edition chapter 2, pages 19-38, Programming Perl 3rd edition chapter.
Introduction to Perl NICOLE VECERE. Background General Purpose Language ◦ Procedural, Functional, and Object-oriented Developed for text manipulation.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
8.1 Common Errors – Exercise #3 Assuming something on the variable part of the input file. When parsing a format file (genebank, fasta or any other format),
5.1 Revision: Ifs and Loops. 5.2 if, elsif, else It’s convenient to test several conditions in one if structure: print "Please enter your grades average:\n";
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
中国免疫学信息网 SAGE 的原理及其应用 新乡医学院免疫学研究中心 王 辉.
2.1 Scalar data - revision numeric e-14 ( = 6.35 × )‏ operators: + (addition) - (subtraction) * (multiplication) / (division)
Computer Programming for Biologists Class 4 Nov 14 th, 2014 Karsten Hokamp
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
Part 4 Arrays: Stacks foreach command Regular expressions: String structure analysis and substrings extractions and substitutions Command line arguments:
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
Ligate tags SAGE: Procedure Digest with “Tagging enzyme” BsmFI tm Isolate mRNA, RT to cDNA Digest with “Anchoring.
File Handle and conditional Lecture 2. File Handling The Files associated with Perl are often text files: e.g. text1.txt Files need to be “opened for.
The Scripting Programming Language
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Loops ( while and for ) CSE 1310 – Introduction to Computers and Programming Alexandra Stefan 1.
Introduction to Programming the WWW I CMSC Winter 2004 Lecture 8.
Chapter 17 Arrays Perl to denote an array, for = (10, 20, 30, 50); Array subscripts are number from 0. Array elements require scalar.
Control Structures: for & while Loops
Computer Science Core Concepts
The Selection Structure
INTRODUCTION to PERL PART 1.
Karan Thaker CS 265 Section 001
Control Structures.
Presentation transcript:

3.1 Ifs and Loops

3.2 Revision: variables Scalar variables can store scalar values: Variable declaration my ($priority); Numerical assignment $priority = 1; String assignment $priority = 'high';

3.3 Revision: arrays Array List value = (1,2,3,"hi"); Array element: print $a[1]; 2 $a[0] = "*"; Array size: print 4 Reading a list of = ;

3.4 Revision: arrays Push & pop 123hi6 my $x = 123hi print $x; 6 Unshift & shift 0123hi my $x = 123hi print $x; 3210 "hi"321

3.5 Revision: arrays $str = = split("-", $str); $str = join("!! ); print "$str\n"; So!! Long!! and!! thanks!! for!! all!! the!! fish reverse(1,2,3);sort("b","a","d","c",);

3.6 Controls: Ifs and Loops

3.7 Controls: if ? Controls allow non-sequential execution of commands, and responding to different conditions. else { print "Are you doing anything tomorrow night?\n"; } print "How old are you?\n"; my $age = ; if ($age < 18) { print "Sorry, I’m not allowed to chat with minors\n"; }

3.8 if, elsif, else It’s convenient to test several conditions in one if structure: if ($age < 18) { print "Sorry, I’m not allowed to chat with minors\n"; } elsif ($age < 25) { print "Are you doing anything tomorrow night?\n"; } elsif ($age < 35) { print "Are you married?\n"; } else { print "Do you need help crossing the street?\n"; }

3.9 Comparison operators StringNumericComparison eq==Equal ne!=Not equal lt<Less than gtgt>Greater than le<= Less than or equal to ge>= Greater than or equal to if ($age == 18){... } if ($name eq "Yossi")... if ($name ne "Yossi")... if ($name lt "n")... NumericComparison ==Equal !=Not equal <Less than >Greater than <= Less than or equal to >= Greater than or equal to Found = in conditional, should be == at

3.10 Boolean operators if (($age==18) || ($name eq "Yossi")){... } if (($age==18) && ($name eq "Yossi")){... } if (!($name eq "Yossi")){... } And && Or || Not !

3.11 Controls: Loops Commands inside a loop are executed repeatedly (iteratively): while ($name ne "Yossi") { chomp($name = ); print "Hello $name!\n"; = ; foreach $name { print "Hello $name!\n"; } * There are also until, do-while and do-until loops

3.12 Loops $i=0; while { $name = $names[$i]; print "Hello $name!\n"; $i++; } for ($i=0; $i++) { $name = $names[$i]; print "Hello $name!\n"; } A for loop is controlled by three statements: 1 st is executed before the first iteration 2 nd is the stop condition 3 rd is executed before every re-iteration These are equivalent foreach $name { print "Hello $name!\n" }

3.13 Breaking out of loops next – skip to the next iteration last – skip out of the loop = ; foreach $line { if (substr($line,0,1) ne ">") { next; } print(substr($line,1)); if (substr($line,0,4) eq ">ehd") { last; } }

3.14 Breaking out of loops die – end the program and print an error message to the standard error if ($score < 0) { die "score must be positive"; } score must be positive at test.pl line 8. Note: if you end the string with a "\n" then only your message will be printed * warn does the same thing as die without ending the program

3.15 “ The Programming Process ”

3.16 The programming process It pays to plan ahead before writing a computer program: 1.Define the purpose of the program 2.Identify the required inputs 3.Decide how to present the outputs 4.Make an overall design of the program 5.Refine the design, specify more details 6.Write the code – one stage at a time and test each stage 7.Debug…

3.17 An example: SAGE libraries 1.Double-stranded cDNA is generated from cell extracts 2.The cDNA is cleaved with a restriction enzyme (NlaIII) 3.The most 3'-end of the cDNA is then collected by their poly-A 4.The fragments are ligated to linkers containing a recognition site for a type IIS restriction enzyme and a PCR primer site 5.This restriction enzyme cuts 20bp away from its recognition site 6.Ligation, PCR, cleavage, concatenation, cloning, sequencing…  A 10bp tag sequence from each mRNA 7.10bp sequences are searched in an mRNA database and the corresponding genes are identified SAGE (Serial Analysis of Gene Expression) is used to identify all transcripts that are expressed in a tissue: (1) (2&3) (4&5)

3.18 An example: SAGE libraries SAGE (Serial Analysis of Gene Expression) is used to identify all transcripts that are expressed in a tissue:

3.19 Predicting the SAGE tag of an mRNA It would be useful to know what tag to expect for each mRNA in the database. So lets write a script: 1. Purpose: To predict the 10bp sequence of the SAGE tag of a given mRNA 2. Inputs: A list of mRNA sequences in FASTA format >gi| |ref|NM_ | Mus musculus EH-domain containing 4 (EHD4), mRNA GTGGTATTTCTTCGTTGTCTCTGGCGTGGTCACGTTGATTGGTCCGCTATCTGGACCGAAAAAAGTCGTA GTCGACGGCGATGGGTTCCTGGACTCTGACGAGTTCGCGCTGGCCTTGCACTTAATCAACGTCAAGCTGG AAGGCTGCGAGCTGCCCACCGTGCTGCCGGAGCACTTAGTACCGCCGTCGAAGCGCTATGACTAGTGTCC TGTAGCATACGCATACGCACACTAGATCACACAGCCTCACAATTCCCAAAAAAAAAAAAAAAA >gi| |ref|NM_ | Mus musculus EH-domain containing 3 (EHD3), mRNA GGTAGGGCGCTACCGCCTCCGCCCGCCTCTCGCGCTGTTCCTCCGCGGTATGCCCGCGCCGGCAGCCGGC TATTATATAGAGAAATATATTGTGTATGTAGGATGTGCTTATTGCATTACATTTATCACTTGTCTTAACT AGAATGCATTAACCTTTTTTGTACCCTGGTCCTAAAACATTATTAAAAAGAAAGGCTAAAAAAAAAAAAA AAAA >gi| |ref|NM_ | Mus musculus EH-domain containing 2 (Ehd2), mRNA TGAGGGGGCCTGGGGCCCGCCCTGCTCGCCGCTCCTAGCGCACGCGGCCCCACCCGTCTCACTCCACTGC......

3.20 Predicting the SAGE tag of an mRNA 3. Decide how to present the results Simply print the header line of each mRNA and then it’s predicted 10bp tag, like so: > gi| |ref|NM_ | Mus musculus EH-domain containing 4 (EHD4), mRNA ATCACACAGC >gi| |ref|NM_ | Mus musculus EH-domain containing 3 (EHD3), mRNA AATGCATTAA...

3.21 Predicting the SAGE tag of an mRNA 4. Overall design: 1.For each mRNA in the input: 1.Read the sequence 2.Find the most downstream recognition site of NlaII (CTAG) 3.Get the 10bp tag after that site 4.Print it

3.22 Predicting the SAGE tag of an mRNA 5.Refine the design, specify more details: 1.For each mRNA in the input (use a loop): 1.Read the sequence 1.Store its header line in one string variable 2.Concatenate all lines of the sequence and store it in another string variable 2.Find the most downstream recognition site of NlaII (CTAG) 1.Go over the sequence with a loop, starting from the 3’ tail, and going back until the first CTAG is found 3.Get the 10bp tag after that site 1.Take a substr of length 10 4.Print it 6.Write the code