(optional - but then again, all of these are optional)

Slides:



Advertisements
Similar presentations
For loops Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas.
Advertisements

While loops Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas.
Input and Output READ WRITE OPEN. FORMAT statement Format statements allow you to control how data are read or written. Some simple examples: Int=2; real=
MODULE 4 File and Folder Management. Creating file and folder A computer file is a resource for storing information, which is available to a computer.
File input and output if-then-else Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble.
The Unix File System. What are the three parts of every file on a Unix filesystem? And where is each stored? Filename - stored in directories Inode -
James Tam Introduction To Files In Python In this section of notes you will learn how to read from and write to files in your programs.
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Josh Goodwin
James Tam Introduction To Files In Python In this section of notes you will learn how to read from and write to files in your programs.
James Tam Introduction To Files In Python In this section of notes you will learn how to read from and write to files in your programs.
Python programs How can I run a program? Input and output.
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
“Everything Else”. Find all substrings We’ve learned how to find the first location of a string in another string with find. What about finding all matches?
The if statement and files. The if statement Do a code block only when something is True if test: print "The expression is true"
Computer Programming for Biologists Class 5 Nov 20 st, 2014 Karsten Hokamp
LIN 6932 Unix Lecture 6 Hana Filip. LIN 6932 HW6 - Part II solutions posted on my website see syllabus.
Builtins, namespaces, functions. There are objects that are predefined in Python Python built-ins When you use something without defining it, it means.
MCB 5472 Assignment #6: HMMER and using perl to perform repetitive tasks February 26, 2014.
Subroutines and Files Bioinformatics Ellen Walker Hiram College.
Working on exercises (a few notes first). Comments Sometimes you want to make a comment in the Python code, to remind you what’s going on. Python ignores.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
Intro Python: Variables, Indexing, Numbers, Strings.
Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
File I/O Ruth Anderson UW CSE 160 Spring File Input and Output As a programmer, when would one use a file? As a programmer, what does one do with.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
Why Linux and Not Windows?
Parsing BLAST output. Output of a local BLAST search “less” program Full path to the BLAST output file.
By Corey Stokes 9/14/10. What is grep? Global Regular Expression Print grep is a command line search utility in Unix Try: Search for a word in a.cpp file.
Working on exercises (a few notes first)‏. Comments Sometimes you want to make a comment in the Python code, to remind you what’s going on. Python ignores.
GEO375 Final Project: From Txt to Geocoded Data. Goal My Final project is to automate the process of separating, geocoding and processing 911 data for.
File I/O Ruth Anderson UW CSE 140 Winter File Input and Output As a programmer, when would one use a file? As a programmer, what does one do with.
Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
CSC 108H: Introduction to Computer Programming Summer 2011 Marek Janicki.
Sequence File Parsing using Biopython
Introduction to Python
Prepared by: Eng. Maryam Adel Abdel-Hady
Microsoft Word 2010.
(optional - but then again, all of these are optional)‏
Loop Structures.
Sequence File Parsing using Biopython
Week 6 Discussion Word Cloud.
File input and output Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble Notes from 2009: Sample problem.
CHAPTER FOUR Functions.
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
While loops Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble.
For loops Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble Notes for 2010: I skipped slide 10. This is.
I/O in C Lecture 6 Winter Quarter Engineering H192 Winter 2005
Topics Introduction to File Input and Output
Basic Python Review BCHB524 Lecture 8 BCHB524 - Edwards.
Functions In Matlab.
Next Gen. Sequencing Files and pysam
More for loops Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble.
While loops Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble.
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
Notes about Homework #4 Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming:
Regression testing Tor Stållhane.
Introduction to Python
Introduction to Python
Basic Python Review BCHB524 Lecture 8 BCHB524 - Edwards.
While loops Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble.
Next Gen. Sequencing Files and pysam
Next Gen. Sequencing Files and pysam
The Emacs Editor Read: Forouzan, Appendix C
Sequence File Parsing using Biopython
“Everything Else”.
Strings …again.
Topics Introduction to File Input and Output
 A function is a named sequence of statement(s) that performs a computation. It contains  line of code(s) that are executed sequentially from top.
Presentation transcript:

(optional - but then again, all of these are optional) Advanced Exercises (optional - but then again, all of these are optional)

Exercise 1 I posted solution to all the previous exercises. Go through my solutions and compare to yours. Experiment with some of the alternatives I show. Let me know of any mistakes. (I know there’s at least one.)

#2, FASTA files I put a FASTA file at /coursehome/dalke/ls_orchid.fasta (It’s part of the Biopython regression suite.) Take a look at the file using more (or less). Can you figure out the file format?

FASTA format A FASTA file contains 0 or more records Each record starts with a header line The first character of the header is a “>” After that are a bunch of sequence lines After the sequence lines is a blanks line (In real FASTA files that line is optional. Don’t worry about that, since this version is easier to parse.)

Write a program to count the number of records in a FASTA file. Exercise #3 Write a program to count the number of records in a FASTA file. Once done, modify that program to print the total number of bases present and the total count of each base found.

Exercise #4 Write a program to print only the header lines in that FASTA file. It must not print the leading “>”.

Exercise #5 Write a program to find the record(s) where the header line contains the text P.tonsum. Print it out, in FASTA format. (That is, the output should not be changed.)

Command-line arguments In Python you can get the list of command-line arguments with sys.argv. This is a normal Python list. > cat print_args.py import sys print "Command-line arguments are:", sys.argv > python print_args.py Command-line arguments are: ['print_args.py'] > python print_args.py ls_orchid.fasta Command-line arguments are: ['print_args.py', 'ls_orchid.fasta'] > python print_args.py *.seq Command-line arguments are: ['print_args.py', '10_sequences.seq', 'ambiguous_sequences.seq', 'many_sequences.seq', 'sequences.seq'] >

Exercise #6 Write a program which gets two command line arguments, turns them into floats, and prints the sum. Note that sys.argv[0] is always the name of the Python program so you’ll need to use [1] and [2] You can find this program in the worked out solutions, under the first Monday. Compare it to yours.

Exercise #7 Modify your solution from #5 so that it uses the first user argument (sys.argv[0]) as the text to search for in the header. Have it print all FASTA records which contain that text. A good test case is “P.”

Exercise #8 Write a program to read a FASTA file and print the header line (without the leading “>”) if and only if the sequence ends with a C. Use a command-line argument to get the filename. Test it against both FASTA files in my directory.