User Tools

Site Tools


exam

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
exam [2018/11/05 09:20]
dokuroot
exam [2018/11/05 09:24]
dokuroot
Line 7: Line 7:
 \\ \\
 \\ \\
-**You cannot use any modules that have to be imported into your code.**+You cannot use any modules that have to be imported into your code.
 \\ \\
 \\ \\
-Upload a single file named **exam_yourname.py** containing your functions ​to Canvas.  **Any content outside of the function must be commented (#)**.+Upload a single file named **exam_yourname.py** containing your functions.  **Any content outside of the function must be commented (#)**.
 \\ \\
 \\ \\
-1. [20 pts] Write a function, ''​nt_content(sequence)'',​ that calculates the proportion of each nucleotide (A, C, G, T) in a sequence. For example, the sequence ​'​AATTGCCCCC' ​would return ​A: 0.2, C: 0.5, G: 0.1, T: 0.2+1. [20 pts] Write a function, ''​gc_content(sequence)'',​ that calculates the proportion of nucleotides ​in a sequence ​that are either G or C. For example, the sequence ​ATGC would return 0.5.
 \\ \\
 \\ \\
-2. [20 pts] Write a function, ''​character_count(input_file)'',​ that returns the number of characters (all characters including white space, except new lines) in a file. The return value should be a single number.  The function should work with any size file (i.e. don't read the entire file into memory). The function should exit gracefully if the file can't be opened and should not leave the file open. +2. [20 pts] Write a function, ''​word_count(input_file)'',​ that returns the number of lines and characters (all characters including white space, except new lines) in a file. The return value should be a tuple.  The function should work with any size file (i.e. don't read the entire file into memory). The function should exit gracefully if the file can't be opened and should not leave the file open. 
 \\ \\
 \\ \\
Line 24: Line 24:
   >seq2   >seq2
   CTA   CTA
-would return 16 (i.e. 16 characters)+would return ​(4, 16(i.e. 4 lines, ​16 characters)
 \\ \\
 \\ \\
-3. [20] Write a function, ''​matrix_mean(matrix)'',​ that returns the mean value for each column ​in a  matrix as a list. For example, the matrix %%[[%%1,​2,​3],​ [5,6,7]] would return [34, 5].+3. [20] Write a function, ''​matrix_mean(matrix)'',​ that returns the mean value for each row in a  matrix as a list. For example, the matrix %%[[%%1,​2,​3],​ [5,6,7]] would return [26].
 \\ \\
 \\ \\
-4. [20] Write a function, ''​element_finder(some_list, some_element)''​ that returns ​as a dictionary ​key-value ​the number of occurrences ​for a particular ​element ​(some_element) ​in list (some_list). For example, ​element_finder(['​ATG',​ '​TAG',​ '​TTT',​ '​TAG',​ '​TTT'​], '​TTT'​) ​would return {'​TTT':​ 2}.+4. [20] Write a function, ''​element_counter(some_list)''​ that returns a dictionary ​of each unique element and the corresponding ​number of occurrences ​of the element in the list. For example, ​the list ['​ATG',​ '​TAG',​ '​TTT',​ '​TAG',​ '​TTT'​] would return {'​ATG':​ 1, '​TAG':​ 2, '​TTT':​ 2}
 \\ \\
 \\ \\
-5. [20] Write a function, ''​motif_finder(sequence, motif)'',​ that returns the number of occurences ​of the substring ​motif in the string ​sequence. ​ For example, given the sequence ​'​CCCGAGCCCGAGGAGCCC' ​and the motif '​GAG'​, the function would return ​3.+5. [20] Write a function, ''​motif_coordinates(sequence, motif)'',​ that returns the start and end position ​of the first occurrence of a motif within a sequence ​as a tuple. Report the position relative to  a starting position of 1 not the first python index of 0.  For example, given the sequence ​ATGCTGTTAGCAG ​and the motif CAG, the function would return ​(11, 13).
exam.txt · Last modified: 2018/11/05 09:24 by dokuroot