# Computational biology at CSU

assignment2

## ASSIGNMENT 2

Due date: 10/2/18 by 10 am

The exercises can be completed using only material covered so far.

### Exercise 1

Write a function called `nt_id()` that evaluates whether or not a sequence entered by the user is DNA or RNA or unknown.

The sequence should be passed to the function and the return value printed as follows:

```if __name__ == '__main__':
seq = input('Enter a sequence: ')
print(nt_id(seq))```

`if name == 'main':` basically means to execute the code within the body of the `if` statement only if the file is executed from the command line as a script.

### Exercise 2

Write a function called `stop_codon()` that tests for the presence of a stop codon (UAG, 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 1.

### Exercise 3

Write a function called `peptide_length()` that computes the maximum peptide length (an integer) that can be generated from a DNA or RNA sequence input by the user.

### Exercise 4

Write a function called `cube_root()` that computes the cube root of a number. The function should contain a try and except clause that returns an informative error message if a non-numerical value is entered.

Hints:
1) Reassign the value input by the user to a float type in the `cube_root()` function, not in the input function.
2) The return value should be the cube root of the number if a valid number is entered or an error message if a valid number is not entered.

### Exercise 5

Write a function called `sum_num()` that computes the sum of up to 4 numbers. You do not need to prompt the user for the numbers.

### Exercise 6

Write a script that prompts the user for an RNA sequence, imports the module containing the `stop_codon()` function from exercise 2 and tests for the presence of a stop codon in the sequence. The script should print a message indicating whether the sequence contains a stop codon based on the return value of `stop_codon()`.

To submit your assignment, combine the functions in exercise 1-5 along with the script in exercise 6 into one text file and upload it to Canvas.
{"ft_lang_label":"__label__en","ft_lang_prob":0.83787614,"math_prob":0.85225785,"size":2017,"snap":"2019-26-2019-30","text_gpt3_token_len":447,"char_repetition_ratio":0.14157973,"word_repetition_ratio":0.06760564,"special_character_ratio":0.22756569,"punctuation_ratio":0.067010306,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95347404,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-07-20T14:40:04Z\",\"WARC-Record-ID\":\"<urn:uuid:968a460a-34a5-4740-9f2d-df8b122601ab>\",\"Content-Length\":\"19734\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f4b5a528-548e-4908-a432-eb3ba25d8183>\",\"WARC-Concurrent-To\":\"<urn:uuid:a1ae9f91-e4d5-424a-8f21-3080f09a9d8c>\",\"WARC-IP-Address\":\"129.82.100.202\",\"WARC-Target-URI\":\"http://rna.colostate.edu/dokuwiki/doku.php?id=assignment2&amp;image=092518_hts.pdf&amp;ns=&amp;tab_details=view&amp;do=media\",\"WARC-Payload-Digest\":\"sha1:NUUT2A3TKYZZ4Q27WWZJEYY4JQBOWZOE\",\"WARC-Block-Digest\":\"sha1:HG3GEIHEKCKEQIJUB2WMBWKUMEPKDCFI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-30/CC-MAIN-2019-30_segments_1563195526517.67_warc_CC-MAIN-20190720132039-20190720154039-00201.warc.gz\"}"}