1 Course plan Course homepage tells you everything, updated Monday/Tuesday After each lecture, any extra material (slides, example programs) will become.

Slides:



Advertisements
Similar presentations
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Advertisements

UW CSE 190p Section 6/21, Summer 2012 Dun-Yu Hsiao.
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
EMT 2390L Lecture 4 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Processes and Job Control. Foreground and Background (1)  Unix is a multi-tasking operating system –some of these tasks are being done by other users.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Josh Goodwin
Project 1CS-3013 A-term Programming Project #1 Forking Processes Due Tuesday, September 8, 11:59 PM.
CS 497C – Introduction to UNIX Lecture 20: - The Shell Chin-Chih Chang
1 Some basic Unix commands u Understand the concept of loggin into and out of a Unix shell u Interact with the system in a basic way through keyboard and.
2 $ command Command Line Options ls –a –l hello hi Command Arguments.
Shell Control Structures CSE 2031 Fall August 2015.
Shell Programming, or Scripting Shirley Moore CPS 5401 Fall August 29,
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
Introduction to UNIX/Linux Exercises Dan Stanzione.
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
Chapter Nine Advanced Shell Scripting1 System Programming Advanced Shell Scripting.
1 Shell Programming – Extra Slides. 2 Counting the number of lines in a file #!/bin/sh #countLines1 filename=$1#Should check if arguments are given count=0.
Builtins, namespaces, functions. There are objects that are predefined in Python Python built-ins When you use something without defining it, it means.
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface What is the directory tree Some UNIX commands.
COMPSCI 101 Principles of Programming Lecture 28 – Docstrings & Doctests.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
An Overview of Programming in Python CSC 161: The Art of Programming Prof. Henry Kautz 9/9/2009 Slides stolen shamelessly from Dr. Mark Goadrich, Centenary.
Project 1, Command Shell CS-502 (EMC) Fall Programming Project #1 Command Shell CS-502, Operating Systems EMC, Fall 2009 (Slides include materials.
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
GNU Compiler Collection (GCC) and GNU C compiler (gcc) tools used to compile programs in Linux.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
Introduction to Linux OS (IV) AUBG ICoSCIS Team Prof. Volin Karagiozov March, 09 – 10, 2013 SWU, Blagoevgrad.
Writing Shell Scripts ─ part 3 CSE 2031 Fall October 2015.
Shell Scripting AFNOG IX Rabat, Morocco May 2008.
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.
LINUX programming 1. INDEX UNIT-III PPT SLIDES Srl. No. Module as per Session planner Lecture No. PPT Slide No. 1.Problem solving approaches in Unix,Using.
1 Week 2 The Crunchy Shell to the Soft and Chewy Kernel… Sarah Diesburg 8/3/2010 COP4610 / CGS5765.
This slide deck is for LPI Academy instructors to use for lectures for LPI Academy courses. ©Copyright Network Development Group Module 9 Basic Scripting.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
(A Very Short) Introduction to Shell Scripts CSCI N321 – System and Network Administration Copyright © 2000, 2003 by Scott Orr and the Trustees of Indiana.
LIN Unix Lecture 5 Unix Shell Scripts. LIN Command Coordination ; && || command1 ; command2 Interpretation: Do command 1. Then do command.
Introduction to Programming Using C An Introduction to Operating Systems.
CS252: Systems Programming Ninghui Li Slides by Prof. Gustavo Rodriguez-Rivera Topic 7: Unix Tools and Shell Scripts.
CSCI The UNIX System Shell Data Handling: Redirection and Piping
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Shell Control Statements and More
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python Karsten Hokamp, PhD Genetics TCD, 03/11/2015.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Compunet Corporation Introduction to Unix (CA263) Round and Round By Tariq Ibn Aziz Dammam Community College.
© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER FOUR – QUOTING IN DETAIL.
CSx 4091 – Python Programming Spring 2013 Lecture L2 – Introduction to Python Page 1 Help: To get help, type in the following in the interpreter: Welcome.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2014 Lecture 3 – I/O Redirection, Shell Scripts.
1 Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
1 UNIX Operating Systems II Part 2: Shell Scripting Instructor: Stan Isaacs.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
California State University Fresno
Unix Scripting Session 4 March 27, 2008.
The Linux Operating System
Shell Script Assignment 1.
Unix Operating System (Week Two)
Writing Shell Scripts ─ part 3
Engineering Innovation Center
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
Let's Learn Python and Pygame
Learning to Program in Python
(Chapter 2) John Carelli, Instructor Kutztown University
Programming Project #1 Command Shell
Programming Project #1 Fork and Command Shell
CSC 4630 Meeting 4 January 29, 2007.
The Python interpreter
Race Condition Vulnerability
Presentation transcript:

1 Course plan Course homepage tells you everything, updated Monday/Tuesday After each lecture, any extra material (slides, example programs) will become available from the schedule page

2 Today’s plan Go through the lecture note New example: distributing job over several machines Exercise session

3 A Unix Shell A shell is a ‘wrapper’ around an operating system Mediates access to its functionality: execute commands, interact with files,.. Write shell in Python: - get command from user - execute shell commands - pass on external commands to the operating system

4 A Unix Shell processes]$ python shell.py >>> echo "hello, world" Running: echo "hello, world" hello, world >>> ls Running: ls process-communication.html shell.py >>> ls *.html Running: ls *.html process-communication.html >>> quit processes]$ How interaction with the shell might look: Shell command, others are external commands

5 Executing external commands Function system from module os : system takes a command (string), executes it, returns the exit status (0 if everything went well)

6 Executing shell commands Before calling os.system, check if the given command is a shell command:

7 Executing shell commands Adding more shell commands: [2J is an ANSI terminal escape sequence

8 Print command output in red To clearly mark the output coming from external commands, change the font color before and after calling os.system :

9 Print command output in red Output:

10 Indent output Now we need access to the output of the command Use function os.popen instead of os.system: – Also runs external command but lets user give input to or read output from the command though a file object: f = os.popen(cmd, ‘r’) # for reading output f = os.popen(cmd, ‘w’) # for giving input

11 os.popen Use the object returned by os.popen as a file object: The exit status of the command is returned when closing the file: status = f.close()

12 Output

13 Redirecting output (Exercise PM.4) Redirecting output to a file using >

14 Test

15 Example program: job parallelization Sequence analysis may often be parallellized: 1.Split input Fasta file into N parts 2.Perform task on each part on some machine 3.Collect partial results into one Blast, Megablast, clustering, repeat finding,..

16 1: Split input Fasta file into N parts 1.Create new directory.dir 2.Split in N parts of approximately the same size 3.Place each part in its own directory.dir/part17/part17, put output file here too Reason: then the overall command’s output file (only one name is given) will not be overwritten for each part

17 splitfile.py (part 1 of 2)

18 splitfile.py (part 2 of 2)

19 2. Perform task on each part on some machine While not all parts have been processed: 1.Read list of available machines 2.Check which are idle 3.While idle machines: a)Assign part to idle machine and start new process 4.Sleep 30 seconds Regarding 3a): -Use rsh to start a remote shell on foreign machine -Use os.system to run command -Create empty file 6done when part 6 is done

20 Usage and timestamp methods distribute_fasta_job.py (part 1 of 4)

21 Read options, initialize distribute_fasta_job.py (part 2 of 4)

22 Various helper functions distribute_fasta_job.py (part 3 of 4)

23 Main loop distribute_fasta_job.py (part 4 of 4)

24 Test: blastn of yeti.fasta against nessie.fasta Command: python distribute_fasta_job.py -f /web/chili/public_html/TBiB2006/yeti.fasta -n 30 -c '/users/chili/BiRC/MolBio/Blast-2.2.6/blastall -p blastn -e –d /web/chili/public_html/TBiB2006/nessie.fasta -i /web/chili/public_html/TBiB2006/yeti.fasta -o yeti-nessie.b' machines.txt: threonine methionine crick watson pauling #leucine

25 Output Out-commented pauling and watson from machine list

26 Output ctd’ed Put pauling and watson back in machine list

27 3. Collect partial results into one cat yeti.fasta.dir/part*/yeti-nessie.b > yeti-nessie.b Note: all output files have same name, therefore creating one subdir for each part was necessary

28.. on to the exercises Sample files for clustalw exercise in ~chili/public_html/TBiB2006/ : sequence file: demo.fasta DNA distance matrix: multalinDNA.clustal (use option –dnamatrix= )