Find the program on your desktop called "Secure Shell Client" or "Putty" or "MobaXterm". Log into the course server: bb485.science.oregonstate.edu
Within your home directory, create a directory called "Scripts":
$ mkdir Scripts
This directory will be used to keep the scripts that you write and download in this course. Next, let's create a simple python script example. First, let's open emacs to create a file:
$ emacs Scripts/helloworld.py
Next, we'll type into the file the following command:
print "Hello, world!"
To save the file, let's simply type Control-X, Control-S. Then to close emacs, type Control-X, Control-C. Once you've successfully saved and closed the file, we can run it with the following command:
$ python Scripts/helloworld.py
If you haven't programmed anything before, this is your first program!
Now let's download a script file, and a fasta file. You can do this with the command wget, which can be run on the command line to directly download any file from the web:
$ wget https://hendrixlab.cgrb.oregonstate.edu/teaching/readFastaFile.py $ wget https://hendrixlab.cgrb.oregonstate.edu/teaching/sequences.fasta
Try printing the contents of the fasta file to the screen:
$ cat sequences.fasta
Move this file into your scripts directory. You can do this with the command "mv readFastaFile.py Scripts/.". You can run this script by simply typing the following:
$ python Scripts/readFastaFile.py sequences.fasta
What is the output? Now let's go over each line of this script as a class.
Now modify the script to print out a new fasta file containing the reverse complement of each of the input sequences.
Create a script that takes in "raw input" from the user. For example, consider trying out the following code in a python script:
your_name = input("What is your name? ") print("Nice to meet you, " + your_name)
How would you modify this to take in a sequence from the command line/user?
Create a script that takes in input from the user for a DNA sequence. For example, consider trying out the following code in a python script:
DNA_text = input("Please enter a DNA sequence that is a valid ORF ") DNA = Seq(DNA_text) print("You have entered: " + DNA)
Your task is to use the coding ideas we have talked about htis week, and to take this DNA sequence as input, check if has a length that is a multiple of three, then check if it has a valid start and stop codon, and print the resulting translation if so. If it fails these criteria, you could either exit with an error message, or ask them to enter another sequence.