User Tools

Site Tools


examkey

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
examkey [2018/12/10 10:54]
dokuroot
examkey [2018/12/10 10:59]
dokuroot
Line 2: Line 2:
 ---- ----
 <file python exam_key.py>​ <file python exam_key.py>​
 +
 +"""​
 +DSCI 511 Exam Answer Key
 +"""​
  
 def gc_content(sequence):​ def gc_content(sequence):​
 + """​
 + Caclulates GC content in a sequence
 + """​
  gc = 0  gc = 0
  for nt in sequence:  for nt in sequence:
Line 14: Line 21:
   
 def word_count(input_file):​ def word_count(input_file):​
 + """​
 + Counts the numbers of lines and characters in a file
 + """​
  try:  try:
  file_handle = open(input_file)  file_handle = open(input_file)
Line 29: Line 39:
  
 def matrix_mean(matrix):​ def matrix_mean(matrix):​
 + """​
 + Calculates the mean of each row in a matrix
 + """​
  l = []  l = []
  for i in range(len(matrix)):​  for i in range(len(matrix)):​
Line 39: Line 52:
   
 def element_counter(some_list):​ def element_counter(some_list):​
 + """​
 + Counts occurences of each element in a list
 + """​
  d = {}  d = {}
  for element in some_list:  for element in some_list:
Line 46: Line 62:
   
 def motif_coordinates(sequence,​ motif): def motif_coordinates(sequence,​ motif):
 + """​
 + Identifies the coordinates of a motif within a sequence
 + """​
  for i in range(len(sequence) - len(motif) + 1):  for i in range(len(sequence) - len(motif) + 1):
  if sequence[i:​i+len(motif)] == motif:  if sequence[i:​i+len(motif)] == motif:
Line 51: Line 70:
   
 if __name__ == '​__main__':​ if __name__ == '​__main__':​
 + """​
 + Code for testing functions
 + """​
  print(gc_content('​ATTGCC'​)) # 0.5  print(gc_content('​ATTGCC'​)) # 0.5
  print(word_count('​test.txt'​)) # (2, 6)  print(word_count('​test.txt'​)) # (2, 6)
Line 58: Line 80:
   
 </​file>​ </​file>​
 +
examkey.txt ยท Last modified: 2018/12/10 10:59 by dokuroot