(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

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.
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.
Perl I/O Learning Objectives: 1. To understand how to perform input from standard Input & how to process the input 2. To understand how to perform input.
Perl I/O Software Tools. Lecture 15 / Slide 2 Input from STDIN Reading from STDIN is easy, and we have done it many times. $a = ; In a scalar context,
CS 497C – Introduction to UNIX Lecture 4: Understanding the UNIX Command Chin-Chih Chang
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.
2 $ command Command Line Options ls –a –l hello hi Command Arguments.
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"
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.
9/16/2015BCHB Edwards Introduction to Python BCHB Lecture 5.
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.
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.
Why Linux and Not Windows?
Parsing BLAST output. Output of a local BLAST search “less” program Full path to the BLAST output file.
COMP 116: Introduction to Scientific Programming Lecture 29: File I/O.
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.
Linux Lecture #02. File Related Commands cat --Concatenate and print (display) the content of files. --Also used to create a new file. Syntax cat [Options]
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.
Chapter 14 Formatting Readable Output. Chapter Objectives  Add a column heading with a line break to a report  Format the appearance of numeric data.
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.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python, Class 2 Karsten Hokamp, PhD Genetics TCD, 17/11/2015.
File input and output and conditionals Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas.
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.
Basic Unix Commands. Listing files and directories ● ls:command is used to list the files and ● directories in present working directory ● ls command.
CIT 590 Intro to Programming Files etc. Agenda Files Try catch except A module to read html off a remote website (only works sometimes)
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
CIT 590 Intro to Programming Lecture 6. Vote in the doodle poll so we can use some fancy algorithm to pair you up You.
Python is Awesome! (and cooler than R). My Research.
Introduction to Python
Prepared by: Eng. Maryam Adel Abdel-Hady
For loops Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble.
CompSci 6 Introduction to Computer Science
Python Modules and Basic File Parsing
(optional - but then again, all of these are optional)
Python Modules and Basic File Parsing
Python Lesson 12 Mr. Kalmes.
INTRODUCTION TO UNIX: The Shell Command Interface
Ruth Anderson UW CSE 160 Winter 2016
File input and output Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble Notes from 2009: Sample problem.
CHAPTER FOUR Functions.
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.
Basic Python Review BCHB524 Lecture 8 BCHB524 - Edwards.
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.
Notes about Homework #4 Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming:
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
Python Modules and Basic File Parsing
Lab 3: File Permissions.
“Everything Else”.
Strings …again.
 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)‏

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 #1 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 #2 Write a program to print only the header lines in that FASTA file. It must not print the leading “>”.

Exercise #3 Write a program to find the record(s) where the header line contains a given text “XXX”. 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 #4 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]

Exercise #5 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.