Introduction to Bioinformatic Computation. Lecture #

Slides:



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

Programming and Perl for Bioinformatics Part III.
Bioinformatics Lecture 7: Introduction to Perl. Introduction Basic concepts in Perl syntax: – variables, strings, input and output – Conditional and iteration.
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.
Lecture 2 BNFO 240. Perl online references
5.1 Previously on... PERL course (let ’ s practice some more loops)
Getting Started with Perl (and Excel) Biophysics 101 September 17, 2003 Griffin Weber (With material from Jon Radoff and Ivan Ovcharenko)
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.
Lecture 2 BNFO 135 Usman Roshan. Perl variables Scalar –Number –String Examples –$myname = “Roshan”; –$year = 2006;
The Linnaeus Centre for Bioinformatics Short introduction to perl & gff Marcus Ronninger The Linnaeus Centre for Bioinformatics.
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";
An Introduction to Textual Programming
Lecture 7: Perl pattern handling features. Pattern Matching Recall =~ is the pattern matching operator A first simple match example print “An methionine.
Computer Programming for Biologists Class 5 Nov 20 st, 2014 Karsten Hokamp
Lecture 8 perl pattern matching features
Subroutines and Files Bioinformatics Ellen Walker Hiram College.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
Bioinformatics 生物信息学理论和实践 唐继军
1 Perl Syntax: control structures Learning Perl, Schwartz.
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 9: Perl Programming Practical Extraction and Report Language Some materials are taken from Sams Teach Yourself Perl 5 in 21 Days, Second Edition.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
9/14/2015BCHB Edwards Introduction to Python BCHB Lecture 4.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Perl II Part III: Motifs and Loops. Objectives Search for motifs in DNA or Proteins Interact with users at the keyboard Write data to files Use loops.
Computer Programming for Biologists Class 3 Nov 13 th, 2014 Karsten Hokamp
Iteration While / until/ for loop. While/ Do-while loops Iteration continues until condition is false: 3 important points to remember: 1.Initialise condition.
Computer Programming for Biologists Class 6 Nov 21 th, 2014 Karsten Hokamp
CPTG286K Programming - Perl Chapter 4: Control Structures.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Introduction to Perl October 4, 2004 Class Meeting 7 * Notes on Perl by Lenwood Heath, Virginia Tech © 2004.
1 Lecture 9 Shell Programming – Command substitution Regular expressions and grep Use of exit, for loop and expr commands COP 3353 Introduction to UNIX.
CPTG286K Programming - Perl Chapter 1: A Stroll Through Perl Instructor: Denny Lin.
Introduction to PERL Genetics PERL is a language that is easy to use and was designed to do certain tasks (like reading, writing, moving text.
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.
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";
 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.
1 More Perl CIS*2450 Advanced Programming Concepts.
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.
Part 4 Arrays: Stacks foreach command Regular expressions: String structure analysis and substrings extractions and substitutions Command line arguments:
Chapter 23 The String Section (String Manipulation) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
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
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
Chapter 5 Arrays F Introducing Arrays F Declaring Array Variables, Creating Arrays, and Initializing Arrays F Passing Arrays to Methods F Copying Arrays.
Chapter 7 - Introduction to Common Gateway Interface (CGI)
Introduction to Bioinformatic Computation. Lecture #
Lecture 2 BNFO 601.
PROGRAMMING IN HASKELL
Perl Programming Language Design and Implementation (4th Edition)
Teaching Materials by Ivan Ovcharenko
Chapter 5 - Control Structures: Part 2
Miscellaneous Items Loop control, block labels, unless/until, backwards syntax for “if” statements, split, join, substring, length, logical operators,
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong.
Perl Variables: Array Web Programming.
Pemrosesan Teks Herika Hayurani Sept 19, 2006
Introduction to Computer Science
Introduction to Bioinformatic Computation. Lecture #
Introduction to Bioinformatic Computation. Lecture #
Introduction to Bioinformatic Computation. Lecture #
Presentation transcript:

Introduction to Bioinformatic Computation. Lecture #3 02-02-2010 Objectives for today Practicing in PERL programming on bioinformatic examples

READING THE BOOK (Learning Perl, O’Reilly) You have already learned (chapters 1,2) This week we will touch (chapters 3,6,7,8,9) Next week (chapters 5, 10, 11, 15) After this reading you should be experienced programmers!

Operation with strings $seq1 = ‘agtcctgatggatt’; $seq2 = ‘ttagggctctca’; Concatenation: $new = $seq1 . $seq2; Substring: $new = substr($seq1, 5,3); Reverse: $new = reverse($seq1); Length: $N_characters = length($seq1); Return value of operator length is number of characters in the string.

chop operator remove last character (chop.pl) #!/usr/local/perl $seq1 = ‘agtcctgatggatt’; print “original sequence $seq1 \n”; chop($seq1); print “sequence after first step $seq1 \n”; $last = chop($seq1); print “sequence after second step $seq1 \n”; print “return value of chop is $last”;

Random numbers in perl (rand.pl) #!/usr/local/perl $our_variable = int(rand(7)); print “$our_variable \n”; #try several times and get 0,1,2,3,4,5,6

Interaction with PERL program from keyboard (keyboard.pl) #!/usr/local/perl print “please type in your variable \n”; $input_variable = <STDIN>; chomp ($input_variable); print “You just typed $input_variable \n”;

Random number game (game.pl) #!/usr/local/perl $r = int(rand(7)); print “please guess the rand number 0-6 \n”; $guess = <STDIN>; chomp ($guess); if ($r != $guess) {print “You are wrong my value is $r \n”;} else {print “Congratulations Homo sapiens! You are very smart! \n”;}

Random number game with loop (game2.pl) #!/usr/local/perl ALEXEI: { $r = int(rand(7)); print “please guess the rand number 0-6 \n”; $guess = <STDIN>; chomp ($guess); if ($r != $guess) { print “You are wrong my value is $r \n”; redo ALEXEI; } else {print “Congratulations Homo sapiens! You are very smart! \n”;}

Syntax is extremely important! Parentheses, brackets, and braces () [] {} Label block must be in capital letters only Colon, semicolon, comma, period : ; , .

print into the screen and file Now we can: print into the screen and file interact with the computer form our keyboard Our next step is to make PERL to read data from a file However, for this purpose we must learn about ARRAYS.

Array keeps many variables in a strict order (array.pl) #!/usr/local/perl $seq1 = ‘agtcctgatggatt’; $seq2 = ‘ttagggctctca’; $a = 5; $b = 100; $c = 333; @alexei = ($seq1, $seq2, $a, $b, $c); #five elements in the array: element 0, 1, 2, 3, 4. # if you need second element, get it as $alexei[1], etc for $n (0..10) { print “element $n is $alexei[$n] \n”; }

How to get an array of characters from a string variable (array2.pl) #!/usr/local/perl $seq1 = ‘agtcctgatggatt’; $length = length($seq1); @array = split(“”, $seq1); for $n (0..($length-1)) { print “letter $n is $array[$n] \n”; }

Let’s count nucleotides in our sequence (nulceotides.pl) #!/usr/local/perl $seq1 = ‘agtcctgatggatttccccgatatagcctact’; $length = length($seq1); $a = $c = $g = $t = 0; @array = split(“”, $seq1); for $n (0..($length-1)) { if ($array[$n] eq ‘a’) {$a++;} #The same as $a=$a+1; elsif ($array[$n] eq ‘c’) {$c++;} elsif ($array[$n] eq ‘g’) {$g++;} elsif ($array[$n] eq ‘t’) {$t++;} } print “number of a is $a \t c is $c \t g is $g \t t is $t \n”;

Now it is time to let perl read files and make some useful calculations (read.pl) #!/usr/local/perl $a = $c = $g = $t = 0; $line =0; open (ALEXEI, “gene23534”); while (<ALEXEI>) { $line++; if ($line > 1) { @array = split(“”, $_); #current variable $_ is text line for $n (0..80) { if ($array[$n] eq ‘a’) {$a++;} elsif ($array[$n] eq ‘c’) {$c++;} elsif ($array[$n] eq ‘g’) {$g++;} elsif ($array[$n] eq ‘t’) {$t++;} } print “number of a is $a \t c is $c \t g is $g \t t is $t \n”;

EST database is the largest in GenBank gbest1.gz - gbest279.gz gbest database format is the same as format of gene entries:

Regular expressions (chapters 7-9) $seq = ‘agttctgaaatcggtcaatgccctcggcat’; Substitution $seq =~ s/t/u/g; Transliteration $seq =~ tr/gatc/ctag/; Matching pattern: if ($seq =~m/ttca/) {print “it is found! \n”;} else {print “pattern is absent \n”;}

Looking for pattern (pattern.pl) #!/usr/local/perl $seq = ‘agttctgaaatcggtcaatgccctcggcat’; print “enter pattern to search inside seq \n”; $p = <STDIN>; chomp ($p); if ($seq =~m/$p/) {print “$p is found! \n”;} else {print “pattern $p is absent \n”;}

prog_species_EST1 (in /home/afedorov/EST) #!/usr/bin/perl -w $prefix = $ARGV[0]; open(OUT, ">${prefix}.EST") || die "Could not create ${prefix}.EST\n"; open(IN, "gbest2.seq") || die "Could not open gbest1.seq\n"; $/ = "\/\/\n"; while(<IN>){ $check = 0; undef($seq); undef($locus); $start = $end = 0; @lines = split("\n", $_); for $n (0..$#lines) { if ($lines[$n] =~ /^LOCUS/){$locus = $lines[$n];} if ($lines[$n] =~ /ORGANISM\s+Drosophila\s+melanogaster/) {$check = 1;} if ($lines[$n] =~ /^ORIGIN/){$start = $n + 1; last;} } if ($check) { $end = $#lines -1; for $n ($start..$end) { $lines[$n] =~ s/\s+//g; $lines[$n] =~ s/\d+//g; $seq .= $lines[$n]; print OUT '> ', $locus, "\n", $seq, "\n";

Loop for prog_species_EST1 for $n (1..5) { $file = ‘gbest’ . $n . ‘.seq’; open (FH, “$file”); prog_species_EST1 }