Computer Programming for Biologists Class 4 Nov 14 th, 2014 Karsten Hokamp

Slides:



Advertisements
Similar presentations
Arrays A list is an ordered collection of scalars. An array is a variable that holds a list. Arrays have a minimum size of 0 and a very large maximum size.
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.
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
The Linux Operating System Lecture 6: Perl for the Systems Administrator Tonga Institute of Higher Education.
● Perl reference
Computer Programming for Biologists Class 9 Dec 4 th, 2014 Karsten Hokamp
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
CSET4100 – Fall 2009 Perl Introduction Scalar Data, Operators & Control Blocks Acknowledgements: Slides adapted from NYU Computer Science course on UNIX.
Part 2 Biophysics 101 Jon Radoff, TF Teaching materials by Ivan Ovcharenko
CS 898N – Advanced World Wide Web Technologies Lecture 8: PERL Chin-Chih Chang
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
Scripting Languages Chapter 6 I/O Basics. Input from STDIN We’ve been doing so with $line = chomp($line); Same as chomp($line= ); line input op gives.
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.
3.1 Ifs and Loops. 3.2 Revision: variables Scalar variables can store scalar values: Variable declaration my ($priority); Numerical assignment $priority.
2.1 Lists and Arrays Summary of 1 st lesson Single quoted and double quoted strings Backslash ( \ ) – the escape character: \t \n Operators:
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.
Perl Programming WeeSan Lee
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
Practical Extraction & Report Language PERL Joseph Beltran.
PERL Variables and data structures Andrew Emerson, High Performance Systems, CINECA.
Computer Programming for Biologists Class 7 Nov 27 th, 2014 Karsten Hokamp
Introduction to Perl & BioPerl Dr G. P. S. Raghava Bioinformatics Centre Bioinformatics Centre IMTECH, Chandigarh Web:
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.
Computer Programming for Biologists Oct 30 th – Dec 11 th, 2014 Karsten Hokamp  Fill out.
Computer Programming for Biologists Class 8 Nov 28 th, 2014 Karsten Hokamp
Subroutines and Files Bioinformatics Ellen Walker Hiram College.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
1 Shell Scripting (C shell) SungHo Maeung 10/27/2000 Tutorial section Computer Science Lab.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Shell Script & Perl Programming Lesson 9. Shell Programming A shell script is a text file that contains Linux (UNIX) commands, which you enter using any.
Meet Perl, Part 2 Flow of Control and I/O. Perl Statements Lots of different ways to write similar statements –Can make your code look more like natural.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
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.
Chapter 10: BASH Shell Scripting Fun with fi. In this chapter … Control structures File descriptors Variables.
Introduction to Unix – CS 21
Time to talk about your class projects!. Shell Scripting Awk (lecture 2)
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
Introduction to Perl “Practical Extraction and Report Language” “Pathologically Eclectic Rubbish Lister”
Computer Programming for Biologists Class 6 Nov 21 th, 2014 Karsten Hokamp
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.
Topic 4:Subroutines CSE2395/CSE3395 Perl Programming Learning Perl 3rd edition chapter 4, pages 56-72, Programming Perl 3rd edition pages 80-83,
Getting started in Perl: Intro to Perl for programmers Matthew Heusser – xndev.com - Presented to the West Michigan Perl User’s Group.
Introduction to Perl October 4, 2004 Class Meeting 7 * Notes on Perl by Lenwood Heath, Virginia Tech © 2004.
Topic 2: Working with scalars CSE2395/CSE3395 Perl Programming Learning Perl 3rd edition chapter 2, pages 19-38, Programming Perl 3rd edition chapter.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python, Class 4 Karsten Hokamp, PhD Genetics TCD, 01/12/2015.
2.1 Scalar data - revision numeric e-14 ( = 6.35 × )‏ operators: + (addition) - (subtraction) * (multiplication) / (division)
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python, Class 2 Karsten Hokamp, PhD Genetics TCD, 17/11/2015.
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:
CSC 4630 Meeting 17 March 21, Exam/Quiz Schedule Due to ice, travel, research and other commitments that we all have: –Quiz 2, scheduled for Monday.
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
The Scripting Programming Language
PZ02CX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ02CX - Perl Programming Language Design and Implementation.
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
Shell Script & Perl Programming
Perl Programming Language Design and Implementation (4th Edition)
Miscellaneous Items Loop control, block labels, unless/until, backwards syntax for “if” statements, split, join, substring, length, logical operators,
Perl Variables: Array Web Programming.
Presentation transcript:

Computer Programming for Biologists Class 4 Nov 14 th, 2014 Karsten Hokamp

Computer Programming for Biologists  Revision  Loop control  Project Overview

Computer Programming for Biologists  expressions 42 $base eq 'T' $num – 1 == 0  statements $seq = 'atgaacgt'; print "hello world!\n"; Revision: program components  operators +, -, *, /, +=, ++, …  built-in functions print, shift, length, …  key words foreach, while, if, …

Computer Programming for Biologists  ordered list of elements  indicated by 'at' symbol  index starts at = ('a'..'z'); #  (a, b, c, d, e, …, x, y, z)  Use $ and [] when working on individual elements: $letters[0] = 'A'; $first = $letters[0]; $last = $letters[-1]; Revision: Arrays Index:

Computer Programming for Biologists $upper = uc($in); $upper_first = uc_first($in); $backwards = reverse($in); $len = length($sequence); $num = $file = $aa; Revision: built-in = split //, $seq; $out = = keys = sort { $a $b $codon = substr $seq, 0, 3, ''; print "Hello world!\n";

Computer Programming for Biologists  branching: if ($base eq 't') { $base = 'u'; }  also unless () if ($base eq 't') { $base = 'a'; } elsif ($base eq 'a') { $base = 't'; } else { … } Revision: structures  loops: while ($in = <>) { $out.= uc($in); }  also until () foreach $element { $i++; print "$i) $element"; … }

Computer Programming for Biologists  Representative values:  Examples: while (1) {... } # endless loop if ($text) {... } # true if text neither '' nor 0 if {... } # true if array is not empty until ($i > 100) {... } # comparison or expression while ($out = substr $seq, 0, 3, '') {... } Revision: conditions truefalse 10 'some characters''' ('some element')()

Computer Programming for Biologists  word(s) from list of command line parameters: $in = shift;  equivalent to the following:  $in = Revision: data input (command line arguments)

Reading from STDIN, default input stream: $in = <>;  equivalent to $in = ; Shell tries to stream from file(s) if command line argument(s) present: $ perl prog.pl input.txt STDIN Computer Programming for Biologists Revision: data input

Computer Programming for Biologists  Ways of breaking the loops: next; # continues with next loop last; # continues after loop exit; # exits program Structures: Breaks  example print "Type 'y' to continue, 'q' to quit: "; while (<>) { if ($_ eq 'y') { last; } elsif ($_ eq 'q') { exit; } else { next; }

Computer Programming for Biologists  start with pseudo code (comments)  code small bits and run  watch for warnings and errors  dare to try things out  check Perl documentation Programming Strategy

Computer Programming for Biologists Implement the following in a program: 1. Print a welcome message 2. Read input from a file 3. Separate header from sequence 4. Report length of sequence 5. Make sequence all upper case 6. Reformat sequence into 60 bp width 7. Reverse-complement the sequence 8. Provide position numbers at each line  Go to Project