Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp

Slides:



Advertisements
Similar presentations
Computer Programming for Biologists Class 9 Dec 4 th, 2014 Karsten Hokamp
Advertisements

Dynamic Arrays Lecture 4. Arrays In many languages the size of the array is fixed however in perl an array is considered to be dynamic: its size can be.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Master Manipulator perl Perl is.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
CS 898N – Advanced World Wide Web Technologies Lecture 8: PERL Chin-Chih Chang
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.
Scalar Variables Start the file with: #! /usr/bin/perl –w No spaces or newlines before the the #! “#!” is sometimes called a “shebang”. It is a signal.
Introduction to Perl Learning Objectives: 1. To introduce the features provided by Perl 2. To learn the basic Syntax & simple Input/Output control in Perl.
Introduction to Perl. How to run perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Your program/script.
Introduction to Python
1ex.1 Perl Programming for Biology Exercise 1 The Bioinformatics Unit G.S. Wise Faculty of Life Science Tel Aviv University, Israel March 2009 Eyal Privman.
Introduction to Perl Software Tools. Slide 2 Introduction to Perl l Perl is a scripting language that makes manipulation of text, files, and processes.
UNIX Filters.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Lecture 8: Basic concepts of subroutines. Functions In perl functions take the following format: – sub subname – { my $var1 = $_[0]; statements Return.
Python programs How can I run a program? Input and output.
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
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
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.
Computer Programming for Biologists Class 10 Dec 5 th, 2014 Karsten Hokamp
Programming Languages Meeting 13 December 2/3, 2014.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Scripting Languages Course 2 Diana Trandab ă ț Master in Computational Linguistics - 1 st year
CS465 - UNIX The Bourne Shell.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
CS 330 Programming Languages 10 / 07 / 2008 Instructor: Michael Eckmann.
COMP519: Web Programming Autumn 2010 Perl Tutorial: The very beginning  A basic Perl Program The first line Comments and statements Simple printing 
Introduction to Perl Yupu Liang cbio at MSKCC
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: 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 Sending Data Using an Online Form CGI/Perl Programming By Diane Zak.
Computer Programming for Biologists Class 3 Nov 13 th, 2014 Karsten Hokamp
1 Introduction to Perl CIS*2450 Advanced Programming Techniques.
5 1 Data Files CGI/Perl Programming By Diane Zak.
Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks.
CS 330 Programming Languages 10 / 02 / 2007 Instructor: Michael Eckmann.
Computer Programming for Biologists Class 6 Nov 21 th, 2014 Karsten Hokamp
Perl, CGI and DBI Ashley George March 7th, 2005.
Topic 2: Working with scalars CSE2395/CSE3395 Perl Programming Learning Perl 3rd edition chapter 2, pages 19-38, Programming Perl 3rd edition chapter.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python Karsten Hokamp, PhD Genetics TCD, 03/11/2015.
GE3M25: Computer Programming for Biologists Python, Class 5
Basic Variables & Operators Web Programming1. Review: Perl Basics Syntax ► Comments: start with # (ignored by Perl) ► Statements: ends with ; (performed.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python, Class 4 Karsten Hokamp, PhD Genetics TCD, 01/12/2015.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python, Class 2 Karsten Hokamp, PhD Genetics TCD, 17/11/2015.
Computer Programming for Biologists Class 4 Nov 14 th, 2014 Karsten Hokamp
8 1 String Manipulation CGI/Perl Programming By Diane Zak.
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
Learning basic Unix command It 325 operating system.
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
Programming Perl in UNIX Course Number : CIT 370 Week 2 Prof. Daniel Chen.
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
CS 330 Programming Languages 09 / 30 / 2008 Instructor: Michael Eckmann.
Unix Lab Fall Shell Scripting ●Through the shell (LXTerminal) you can: ●Run programs. ●Interact with the file system. ●Change settings. ●Send/receive.
Shell scripts – part 1 Cs 302. Shell scripts  What is Shell Script? “Shell Script is series of command written in plain text file. “  Why to Write Shell.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
CS 330 Class 7 Comments on Exam Programming plan for today:
Prepared by: Eng. Maryam Adel Abdel-Hady
Intro to PHP & Variables
Perl Variables: Array Web Programming.
Linux Shell Script Programming
Introduction to Perl Learning Objectives:
Presentation transcript:

Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp

Computer Programming for Biologists  recap  project  scalar variables  built-in functions  exercises Overview

Computer Programming for Biologists Topics covered in the first class: 1.Unix 2.Perl Recap

Computer Programming for Biologists 1. Unix details  commands: mkdir, cd, ls, pwd, rm, chmod  command parameters (ls -l)  command line extension with TAB key  command history (arrow up or down)  special treatment of spaces (quotes or backslash)  information and help in manual pages (man ls) Recap

Computer Programming for Biologists 2. Perl details variables ($repeat, $message) statements ($repeat = 4;) print function (print ‘Hello world!’;) newline (print “Hello world!\n”;) x operator (print $message x 4;) reading user input from command line ($repeat = shift; or $repeat = <>;) Recap

Computer Programming for Biologists Overall goal: development of a Perl script for sequence analysis Input: file with sequences in FASTA format and command line options Output: number and length of sequences GC content base / aminoacid composition reverse complement translations virtual enzyme digest Course project

> ATGCCACCGAAGTTCGACCCCAACGAGATCAAGGTCGTATACCTGAGGTGCACCAGAGGTGAAGTCGGTG CCACTTCTGCCCTGGCCCCCAAGATCGGCCCCCTGGGTCTGTCTCCAAAAAAGGTTGGTGATGACATTGC CAAGGCAACGGGTGACTGGAAGGGCCTGAGGATTACAGTGAAACTGACCATTGAGAACAGACAGGCCCAG AACAGAAAAACATTAAACACAATGGGAATATCACTTTTGATGAGATCGTCAACATTGCTCGACAGATGCG CTAGTTAA > ATGCCACCGAAGTTCGACCCCAACGAGATCAAGGTCGTATACCTGAGGTGCACCAGAGGTGAAGTCGGTG CCACTTCTGCCCTGGCCCCCAAGATCGGCCCCCTGGGTCTGTCTCCAAAAAAGGTTGGTGATGACATTGC CAAGGCAACGGGTGACTGGAAGGGCCTGAGGATTACGGTGAAACTGACCATTGAGAACAGACAGGCCCAG AACAGAAAAACATTAAACACAATGGGAATATCACTTTTGATGAGATCGTCAACATTGCTCGACAGATGCG CTAGTTAA > ATGCCACCGAAGTTCGACCCCAACGAGATCAAGGTCGTATACCTGAGGTGCACCAGAGGTGAAGTCGGTG CCACTTCTGCCCTGGCCCCCAAGATCGGCCCCCTGGGTCTGTCTCCAAAAAAGGTTGGTGATGACATTGC CAAGGCAACGGGTGACTGGAAGGGCCTGAGGATTACGGTGAAACTGACCATTGAGAACAGACAGGCCCAG AACAGAAAAACATTAAACACAATGGGAATATCACTTTTGATGAGATCGTCAACATTGCTCGACAGATGCG CTAGTTAA Computer Programming for Biologists FASTA Format headers (starting with ‘>’ followed by sequence ID)

> ATGCCACCGAAGTTCGACCCCAACGAGATCAAGGTCGTATACCTGAGGTGCACCAGAGGTGAAGTCGGTG CCACTTCTGCCCTGGCCCCCAAGATCGGCCCCCTGGGTCTGTCTCCAAAAAAGGTTGGTGATGACATTGC CAAGGCAACGGGTGACTGGAAGGGCCTGAGGATTACAGTGAAACTGACCATTGAGAACAGACAGGCCCAG AACAGAAAAACATTAAACACAATGGGAATATCACTTTTGATGAGATCGTCAACATTGCTCGACAGATGCG CTAGTTAA > ATGCCACCGAAGTTCGACCCCAACGAGATCAAGGTCGTATACCTGAGGTGCACCAGAGGTGAAGTCGGTG CCACTTCTGCCCTGGCCCCCAAGATCGGCCCCCTGGGTCTGTCTCCAAAAAAGGTTGGTGATGACATTGC CAAGGCAACGGGTGACTGGAAGGGCCTGAGGATTACGGTGAAACTGACCATTGAGAACAGACAGGCCCAG AACAGAAAAACATTAAACACAATGGGAATATCACTTTTGATGAGATCGTCAACATTGCTCGACAGATGCG CTAGTTAA > ATGCCACCGAAGTTCGACCCCAACGAGATCAAGGTCGTATACCTGAGGTGCACCAGAGGTGAAGTCGGTG CCACTTCTGCCCTGGCCCCCAAGATCGGCCCCCTGGGTCTGTCTCCAAAAAAGGTTGGTGATGACATTGC CAAGGCAACGGGTGACTGGAAGGGCCTGAGGATTACGGTGAAACTGACCATTGAGAACAGACAGGCCCAG AACAGAAAAACATTAAACACAATGGGAATATCACTTTTGATGAGATCGTCAACATTGCTCGACAGATGCG CTAGTTAA sequence (split across multiple lines) Computer Programming for Biologists FASTA Format

Computer Programming for Biologists Example usage: sequence length and GC content Course project command output

Computer Programming for Biologists Example usage: base composition and reverse complement Course project

Computer Programming for Biologists Example usage: translation and digest Course project

Computer Programming for Biologists Basic elements for programming:  hold information  allow changing of information  organize data  complex constructs possible  special operations for data handling Variables

Computer Programming for Biologists Three different types in Perl: 1.scalar 2.array 3.hash Variables

Computer Programming for Biologists 1) Scalars:  Content: number or string of characters  Variable name starts with dollar sign ($) followed by letter or number, can contain underscore Variables

Computer Programming for Biologists Variables

Computer Programming for Biologists Variables

Computer Programming for Biologists Special scalars:  $_default scalar  $a, $bspace holders for comparisons  $0name of program  $!system error messages See man perlvar for many more special variables Variables

Computer Programming for Biologists Practical session:  Go to and try the ‘Recap’ exercises Scalars

Built-in functions for scalars lc (change letters in string to lower case) uc (change letters in string to upper case) chop (remove last character) chomp (remove last character if it’s whitespace reverse (reverse list or string) length (calculate length of a string) split (split a string into a list) substr (extract parts of a string) tr (translation of text) Computer Programming for Biologists

Built-in functions for scalars Different ways of using functions: $out = uc($in); $out = uc $in; $out = uc; # works on default variable $_ Combination of functions: $out = uc(reverse($in)); $out = uc reverse $in; Computer Programming for Biologists

Built-in functions  online help:  more help available on the command line:  man perlfunc  overview of all built-in functions  perldoc -f command  information on a specific command only Computer Programming for Biologists

Practical session:  Go to and try the ‘Functions’ exercises Built-in functions

Computer Programming for Biologists 1)Write a program that takes some text from the command line, prints it out in capital letters and also reports the length of the text, e.g.: caps.pl ‘Hello World!’ returns: HELLO WORLD! (length: 12) 2)Write a program that takes a DNA sequence from the command line and prints out the reverse complement. Make sure that it works both with small and capital letters, e.g. revcomp.pl aatTTgggcca returns: TGGCCCAAATT Excercises