-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexercise_sheet8.py
85 lines (71 loc) · 2.41 KB
/
exercise_sheet8.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from typing import Tuple, List
import numpy as np
def nucleotide_freq_calculation(sym_align: Tuple[str, str]) -> List[float]:
"""
Implement the calculation of the nucleotide frequencies for a symmetric
alignment. Make sure that the indexing works the followin way:
[0] = A
[1] = C
[2] = T
[3] = G
sym align: Tuple of strings representing the symmetric alignment
"""
first_seq, second_seq = sym_align
freq_list = [] # Frequencies should be in order A,C,T,G
return freq_list
def mutation_calculation(sym_align: Tuple[str, str]) -> List[List[float]]:
"""
Implement the calculation of the mutations remember indexing in any
dimension should be done in order:
[0] = A
[1] = C
[2] = T
[3] = G
Hint: You can use your already implemented functions here
"""
first_seq, second_seq = sym_align
freq_matrix = [[0] * 4 for _ in range(4)]
return freq_matrix
def scores_calculation(sym_align: Tuple[str, str]) -> List[List[int]]:
"""
Implement the calculation of the scores remember indexing in any
dimension should be done in order:
[0] = A
[1] = C
[2] = T
[3] = G
Hint: You can use your already implemented functions here
"""
score_matrix = None
return score_matrix
def gamma_calculation(sym_align: Tuple[str, str]) -> float:
"""
Implement the calculation of gamma.
Hint: You can use your already implemented functions here
"""
gamma = None
return gamma
def probabilities_calculation(sym_align: Tuple[str, str]) -> List[List[float]]:
"""
Implement the calculation of probabilities matrix.
Hint: You can use your already implemented functions here
"""
probability_matrix = None
return probability_matrix
def norm_probabilities_calculation(sym_align: Tuple[str, str]) -> List[List[float]]:
"""
Implement the calculation of normalized probabilities matrix.
Hint: You can use your already implemented functions here
"""
norm_matrix = None
return norm_matrix
def pam_calculation(sym_align: Tuple[str, str], power: int) -> List[List[int]]:
"""
Implement the calculation of pam matrix Make sure to round values to
integers. ( Notice that casting to int does not do the correct
rounding)
power: the power of the PAM matrix e.g. PAM1 or PAM250
Hint: You can use your already implemented functions here
"""
pam = None
return pam