Computer Programming for Biologists Class 6 Nov 21 th, 2014 Karsten Hokamp

Slides:



Advertisements
Similar presentations
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 9 Strings.
Advertisements

Computer Programming for Biologists Class 9 Dec 4 th, 2014 Karsten Hokamp
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.
Introduction to Perl Bioinformatics. What is Perl? Practical Extraction and Report Language A scripting language Components an interpreter scripts: text.
CS 330 Programming Languages 10 / 11 / 2007 Instructor: Michael Eckmann.
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.
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.
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.
Scripting Languages Chapter 8 More About Regular Expressions.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Group practice in problem design and problem solving
Lecture 8: Basic concepts of subroutines. Functions In perl functions take the following format: – sub subname – { my $var1 = $_[0]; statements Return.
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
Computer Programming for Biologists Class 7 Nov 27 th, 2014 Karsten Hokamp
Computer Programming for Biologists Class 5 Nov 20 st, 2014 Karsten Hokamp
Chapter 9 Character Strings 9.1 Character String Constants A character string constant is a sequence of characters enclosed in double quotation mark. Examples.
MCB 5472 Assignment #6: HMMER and using perl to perform repetitive tasks February 26, 2014.
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.
Computer Programming for Biologists Class 10 Dec 5 th, 2014 Karsten Hokamp

Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
CS 330 Programming Languages 10 / 07 / 2008 Instructor: Michael Eckmann.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
Why? – Examples Speaking Computer-ise – How – What – Environment (windows) Basic Instructions – Declare – Conditional – Loop – Input Write a quiz game.
Coding Design Tools Rachel Gauci. Task: Counting On Create a program that will print out a sequence of numbers from "1" to a "number entered”. Decision’s.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Introduction to Unix – CS 21
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Computer Programming for Biologists Class 3 Nov 13 th, 2014 Karsten Hokamp
Introduction to Perl “Practical Extraction and Report Language” “Pathologically Eclectic Rubbish Lister”
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.
Iteration While / until/ for loop. While/ Do-while loops Iteration continues until condition is false: 3 important points to remember: 1.Initialise condition.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Susie’s lecture notes are in the presenter’s notes, below the slides Disclaimer: Susie may have made errors in transcription or understanding. If there.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
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.
13. Strings. String Literals String literals are enclosed in double quotes: "Put a disk in drive A, then press any key to continue\n“ A string literal.
Perl Scripting III Arrays and Hashes (Also known as Data Structures) Ed Lee & Suzi Lewis Genome Informatics.
2.1 Scalar data - revision numeric e-14 ( = 6.35 × )‏ operators: + (addition) - (subtraction) * (multiplication) / (division)
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
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
Part 4 Arrays: Stacks foreach command Regular expressions: String structure analysis and substrings extractions and substitutions Command line arguments:
02/03/ Strings Left, Right and Trim. 202/03/2016 Learning Objectives Explain what the Left, Right and Trim functions do.
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
Arrays and Lists. What is an Array? Arrays are linear data structures whose elements are referenced with subscripts. Just about all programming languages.
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.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
Strings. String Literals String literals are enclosed in double quotes: "Put a disk in drive A, then press any key to continue\n“ A string literal may.
13. Strings. String Literals String literals are enclosed in double quotes: "Put a disk in drive A, then press any key to continue\n“ A string literal.
Programming Languages Meeting 12 November 18/19, 2014.
1 Sections 3.1 – 3.2a Basic Syntax and Semantics Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Introduction to Python
Computer Programming ||
Perl Programming Language Design and Implementation (4th Edition)
Turing Machines.
CSC141 Computer Science I Zhen Jiang Dept. of Computer Science
Peer Instruction 6 Java Arrays.
Perl Variables: Array Web Programming.
Use proper case (ie Caps for the beginnings of words)
Introduction to Python
Python Strings.
Presentation transcript:

Computer Programming for Biologists Class 6 Nov 21 th, 2014 Karsten Hokamp

Computer Programming for Biologists  Pragmas  Project Overview

Instructions to Perl interpreter Changes behaviour when running your script Helps avoiding mistakes and writing better code! Safer Programming Adding pragmas use warnings; use strict; my $input = shift; declare variables at FIRST occurrence require declaration of variables turn on warning messages

Safer Programming Adding pragmas use warnings; use strict; my $dna = ''; while (my $input = <>) { chomp my $input; my $dna.= $input; }

Safer Programming Adding pragmas use warnings; use strict; my $dna = ''; while (my $input = <>) { chomp my $input; my $dna.= $input; } correct – first occurrence wrong – subsequent occurrence

Safer Programming Adding pragmas use warnings; use strict; my $dna = ''; while (my $input = <>) { chomp $input; $dna.= $input; }

Functions split turn a string into a list split at regular expression join combine a list into a string join using specified character(s) split and join

Functions Example = split //, $string;  Turn string into an array Example = split /$motif/i, $sequence;  Simulate enzyme digestion Example 3: $output = join  Connect elements with TAB for printing split and join

Practical

Computer Programming for Biologists Extend your sequence analysis tool: -add warnings and strict pragmas -add 'my' to variable initialisation -add capability to report GC content -count number of G's and C's (using substr or split to access one nucleotide at a time) -divide by length of sequence  me at with questions or Exercises