# NSCI 580A5 fall 2017

### Sidebar

NSCI 580A5

Instructors
Tai Montgomery
Asa Ben-Hur

assignments:2017nsci580a5assignment2

## ASSIGNMENT 2

Due date: 10/3/17 by 10 am

These exercises should be completed using only material covered so far.

### Exercise 1

REVISED: Write a script that:
a) prompts the user to enter a sequence
b) prompts the user to indicate if the sequence is DNA or RNA
c) if RNA, tests if the sequence contains Ts, and if DNA, tests if the sequence contains Us and prints an error message if Ts are identified in an RNA sequence or if Us are identified in a DNA sequence

### Exercise 1

ORIGINAL (optional, can do the revised Ex 1 above instead): Can be done with material we've covered thus far, but challenging:
Write a script that:
a) prompts the user to enter a sequence
b) prompts the user to indicate if the sequence is DNA or RNA
c) if RNA, prints the RNA complement, and if DNA, prints the DNA complement on a single line

### Exercise 2

Write a script that:
a) prompts the user for a peptide sequence (amino acids are represented by all letters but B,J,O,U,X,Z). Don't bother checking for non peptide characters
b) if the sequence has a length of 0 (i.e. they hit return without entering anything), prints an error message.
c) if the user enters a sequence, identifies the length of the RNA template of the peptide (3 nt/amino acid)

### Exercise 3

Write a script that:
a) prompts the user for a sequence of RNA
b) if the sequence has a length greater than 0, identifies the maximum number of codons it contains
c) if the user fails to enter a sequence (i.e. they hit return without entering anything; don't bother checking for non RNA characters), catches the exception/error using a try clause and prints an error message using an except clause

### Exercise 4

Write a function that computes the sum of up to 4 numbers (i.e. the user can enter 1-4 numbers). The numbers should be passed to the function using:

if __name__ == '__main__':

print(modulename(arguments))

### Exercise 5

Write a function stop_codon(rna) that tests for the presence of a stop codon (UGA, UAA, and UGA) in an RNA sequence and returns a Boolean value indicating whether the sequence contains a stop codon. The sequence should be passed to the function as in 4.

### Exercise 6

Write a script that:
a) prompts the user for an RNA sequence
b) imports the module containing the stop_codon() function from exercise 5 and tests for the presence of a stop codon in the sequence
c) prints a message indicating whether the sequence contains a stop codon based on the return value of stop_codon()

To submit your assignment, combine the scripts into one text file with each exercise clearly labeled and upload it to Canvas.