Lecture 7 You’re on your own now...

Slides:



Advertisements
Similar presentations
Lecture 6 More advanced Perl…. Substitute Like s/// function in vi: #cut with EcoRI and chew back $linker = “GGCCAATTGGAAT”; $linker =~ s/CAATTG/CG/g;
Advertisements

JAVA Programming Environment © Juhani Välimäki 2003.
Input from STDIN STDIN, standard input, comes from the keyboard. STDIN can also be used with file re-direction from the command line. For instance, if.
Layout by orngjce223, CC-BY Custom BLAST Databases A Primer Shawn Houston UAF Life Science Informatics.
Advanced Perl for Bioinformatics Lecture 5. Regular expressions - review You can put the pattern you want to match between //, bind the pattern to the.
Introduction to bioperl. What is perl? Production Engineering Research Laboratory Practically Everything Really Likeable Pre-positioned Equipment Requirement.
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.
LING 388: Language and Computers Sandiway Fong Lecture 3: 8/28.
13.1 Wrapping up Running Other Programs 13.3 You may run programs using the system function: $exitValue = system("blastall.exe..."); if ($exitValue!=0)
Basic Unix Dr Tim Cutts Team Leader Systems Support Group Infrastructure Management Team.
Linux & Shell Scripting Small Group Lecture 4 How to Learn to Code Workshop group/ Erin.
Prof. R. Willingale Department of Physics and Astronomy 2nd Year C+R 2 nd Year C and R Workshop Part of module PA2930 – 2.5 credits Venue: Computer terminal.
Advanced Perl for Bioinformatics Lecture 5. Regular expressions - review You can put the pattern you want to match between //, bind the pattern to the.
2 $ command Command Line Options ls –a –l hello hi Command Arguments.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
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
MCB Lecture #3 Sept 2/14 Intro to UNIX terminal.
Introduction to Perl Matt Hudson. Review blastall: Do a blast search HMMER hmmpfam: search against HMM database hmmsearch: search proteins with HMM hmmbuild:
Portable perl How to write code that will work everywhere.
Introduction to Perl Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister or …
Introduction to Perl & BioPerl Dr G. P. S. Raghava Bioinformatics Centre Bioinformatics Centre IMTECH, Chandigarh Web:
1 An Introduction to Perl Part 1 CSC8304 – Computing Environments for Bioinformatics - Lecture 7.
Computer Programming for Biologists Class 5 Nov 20 st, 2014 Karsten Hokamp
MCB 5472 Assignment #6: HMMER and using perl to perform repetitive tasks February 26, 2014.
Unix Tutorial for FreeSurfer Users. Helpful To Know FreeSurfer Tutorial Wiki:
Computer Programming for Biologists Class 10 Dec 5 th, 2014 Karsten Hokamp
Unix Tutorial for FreeSurfer Users. Helpful To Know FreeSurfer Tutorial Wiki:
This slide deck is for LPI Academy instructors to use for lectures for LPI Academy courses. ©Copyright Network Development Group Module 9 Basic Scripting.
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.
CS 346 – Chapter 4 Threads –How they differ from processes –Definition, purpose Threads of the same process share: code, data, open files –Types –Support.
Assignment feedback Everyone is doing very well!
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
CS4710 Why Progam?. Why learn to program? Utility of programming skills: understand tools modify tools create your own automate repetitive tasks automate.
Introduction to Perl “Practical Extraction and Report Language” “Pathologically Eclectic Rubbish Lister”
General rules 1. Rule: 2. Rule: 3. Rule: 10. Rule: Ask questions ……………………. 11. Rule: I do not know your skill. If I tell you things you know, please stop.
Iteration While / until/ for loop. While/ Do-while loops Iteration continues until condition is false: 3 important points to remember: 1.Initialise condition.
A Genomics View of Unix. General Unix Tips To use the command line start X11 and type commands into the “xterm” window A few things about unix commands:
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Perl COEN 351  Thomas Schwarz, S.J Perl Scripting Language Developed by Larry Wall 1987 to speed up system administration tasks. Design principles.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
Introducing Bioperl Toward the Bioinformatics Perl programmer's nirvana.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Perl Subroutines User Input Perl on linux Forks and Pipes.
UNIX Review CS 2204 Class meeting 15. (C) S. S. Gifford, Virginia Tech, Study Hints You should have: Read all required material Finished all labs.
1 Lecture 8 Shell Programming – Control Constructs COP 3353 Introduction to UNIX.
Linux CSE 1222 CSE1222: Lecture 1BThe Ohio State University1.
File I/O. I/O Flags Flags are passed to give some information about how the file is to be used. – Read only file – flag=0x0 – Write only file – flag=0x1.
Introduction to Unix for FreeSurfer Users
First Day in Lab Making a C++ program
Input from STDIN STDIN, standard input, comes from the keyboard.
UNIX Review CS 2204 Class meeting 15.
Install external command line softwares
Running external programs
The Linux Operating System
Perl A simple test.
Introduction to computing
CGS 3763 Operating Systems Concepts Spring 2013
Modification of the bioperl script for parsing BLAST output
2/25/08 Frans Kaashoek MIT OS abstractions 2/25/08 Frans Kaashoek MIT
Comparative Genomics.
Header files.
More advanced BASH usage
Tutorial: The Programming Interface
Python programming exercise
CSE 303 Concepts and Tools for Software Development
More Variables and Data Types: references/matricies
Input and Output Python3 Beginner #3.
Presentation transcript:

Lecture 7 You’re on your own now..

More reading files Using regexes within while (<FH>): />(.+)/; #regex acts on $_ by default push @anlines, $1; #keep annotation }

last and next while (<FH>) { next if (/>/); last unless (/[ACGT]/); $sequence = chomp $_; push @anlines, $sequence; }

Confounding problems Windows, Mac and UNIX file endings: Perl is looking for the UNIX file ending on UNIX, the Windows one on ActivePerl for Windows So \n means different things depending on the computer

Reformatting in Perl Unix uses LF (carriage return, \015) Windows line ending is CR LF (\015\012) Need to remove LFs (s/\012//g) Mac line ending (to OS9) is CR (\012) Need to replace CR with LF (s/\012/\015/g)

Reformatting in UNIX Can also be done on the UNIX command line: dos2unix file.txt Linux has got quite good at dealing with dos files, but you will still have problems with other UNIXes (eg Solaris) If there is a problem, the extra character (CR) will print as “^M”

System calls There are three commands that can be used to make system calls – i.e., to make UNIX commands from within Perl exec system `` (“backticks”)

examples exec “ls”; system “ls”; my $ls = `ls`; Tell UNIX “ls” then die. Results will be printed to the terminal system “ls”; Tell UNIX “ls”, wait for it to finish, then continue with the program. Results will be printed to the terminal my $ls = `ls`; Tell UNIX “ls”, but don’t print any output to the terminal. Wait until the command has finished, then capture the output in the variable $ls

Doing BLAST from within Perl So now we can operate BLAST, or any other command, from inside our Perl script: open FASTA, “>seq.fas”; print FASTA, “>seq\n$sequence”; close FASTA; my $res = `blastall –i seq.fas –p blastp –d nr`; if ($res =~/Sequences producing significant/) { print “BLAST hits found!\n”;} else {print “No BLAST hits!\n”;}

Rules for successful programming Trust no-one (I mean, to write code for you. I am especially thinking of Bioperl! Often it is quicker to write it yourself in the long run) Don’t get bogged down in complexity. There is probably a simpler way to do it. Try alternative approaches Be vicariously lazy (Larry Wall)