def test_recode_freq_vector(self): """recode_freq_vector: bg freqs updated to reflect recoded alphabet """ freqs = {'A': 0.21, 'E': 0.29, 'C': 0.05, 'D': 0.45} a_def = [('A', 'AEC'), ('E', 'D')] expected = {'A': 0.55, 'E': 0.45} self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ expected) # reversal of alphabet freqs = {'A': 0.21, 'E': 0.29, 'C': 0.05, 'D': 0.45} a_def = [('A', 'D'), ('E', 'C'), ('C', 'E'), ('D', 'A')] expected = {'A': 0.45, 'E': 0.05, 'C': 0.29, 'D': 0.21} self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ expected) # no change in freqs (old alphabet = new alphabet) freqs = {'A': 0.21, 'E': 0.29, 'C': 0.05, 'D': 0.45} a_def = [('A', 'A'), ('E', 'E'), ('C', 'C'), ('D', 'D')] self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ freqs) freqs = {'A': 0.21, 'E': 0.29, 'C': 0.05, 'D': 0.45} a_def = [('X', 'AEC'), ('Y', 'D')] expected = {'X': 0.55, 'Y': 0.45} self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ expected)
def test_recode_freq_vector(self): """recode_freq_vector: bg freqs updated to reflect recoded alphabet """ freqs = {'A':0.21, 'E':0.29, 'C':0.05, 'D':0.45} a_def = [('A','AEC'),('E','D')] expected = {'A':0.55, 'E':0.45} self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ expected) # reversal of alphabet freqs = {'A':0.21, 'E':0.29, 'C':0.05, 'D':0.45} a_def = [('A','D'),('E','C'),('C','E'),('D','A')] expected = {'A':0.45,'E':0.05,'C':0.29,'D':0.21} self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ expected) # no change in freqs (old alphabet = new alphabet) freqs = {'A':0.21, 'E':0.29, 'C':0.05, 'D':0.45} a_def = [('A','A'),('E','E'),('C','C'),('D','D')] self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ freqs) freqs = {'A':0.21, 'E':0.29, 'C':0.05, 'D':0.45} a_def = [('X','AEC'),('Y','D')] expected = {'X':0.55, 'Y':0.45} self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ expected)
def test_recode_freq_vector_ignores(self): """recode_freq_vector: ignored chars are ignored """ freqs = {"A": 0.21, "B": 0.29, "C": 0.05, "D": 0.45, "X": 0.22, "Z": 0.5} a_def = [("A", "A"), ("B", "B"), ("C", "C"), ("D", "D"), ("X", "X"), ("Z", "Z")] expected = {"A": 0.21, "C": 0.05, "D": 0.45} self.assertFloatEqual(recode_freq_vector(a_def, freqs), expected) freqs = {"D": 0.21, "E": 0.29, "N": 0.05, "Q": 0.45, "B": 0.26, "Z": 0.74, "X": 1.0} a_def = [("D", "DEN"), ("Q", "Q")] expected = {"D": 0.55, "Q": 0.45} self.assertFloatEqual(recode_freq_vector(a_def, freqs), expected)
def test_recode_freq_vector_ignores(self): """recode_freq_vector: ignored chars are ignored """ freqs = {'A':0.21, 'B':0.29, 'C':0.05, 'D':0.45,'X':0.22,'Z':0.5} a_def = [('A','A'),('B','B'),('C','C'),('D','D'),('X','X'),('Z','Z')] expected = {'A':0.21,'C':0.05, 'D':0.45} self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ expected) freqs = {'D':0.21, 'E':0.29, 'N':0.05,\ 'Q':0.45,'B':0.26,'Z':0.74,'X':1.0} a_def = [('D','DEN'),('Q','Q')] expected = {'D':0.55, 'Q':0.45} self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ expected)
def test_recode_counts_and_freqs(self): """recode_counts_and_freqs: functions as expected """ alphabet = alphabets["charge_his_3"] aa_order = "ACDEFGHIKLMNPQRSTVWY" actual = recode_counts_and_freqs(alphabet) expected_matrix = recode_count_matrix(alphabet, count_matrix=DSO78_matrix, aa_order=aa_order) expected_freqs = {}.fromkeys(aa_order, 0.0) expected_freqs.update(recode_freq_vector(alphabet, DSO78_freqs)) expected = (expected_matrix, expected_freqs) self.assertEqual(actual, expected)
def test_recode_counts_and_freqs(self): """recode_counts_and_freqs: functions as expected """ alphabet = alphabets['charge_his_3'] aa_order = 'ACDEFGHIKLMNPQRSTVWY' actual = recode_counts_and_freqs(alphabet) expected_matrix = recode_count_matrix(alphabet,\ count_matrix=DSO78_matrix,aa_order=aa_order) expected_freqs = {}.fromkeys(aa_order, 0.0) expected_freqs.update(recode_freq_vector(alphabet, DSO78_freqs)) expected = (expected_matrix, expected_freqs) self.assertEqual(actual, expected)
def test_recode_freq_vector_ignores(self): """recode_freq_vector: ignored chars are ignored """ freqs = { 'A': 0.21, 'B': 0.29, 'C': 0.05, 'D': 0.45, 'X': 0.22, 'Z': 0.5 } a_def = [('A', 'A'), ('B', 'B'), ('C', 'C'), ('D', 'D'), ('X', 'X'), ('Z', 'Z')] expected = {'A': 0.21, 'C': 0.05, 'D': 0.45} self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ expected) freqs = {'D':0.21, 'E':0.29, 'N':0.05,\ 'Q':0.45,'B':0.26,'Z':0.74,'X':1.0} a_def = [('D', 'DEN'), ('Q', 'Q')] expected = {'D': 0.55, 'Q': 0.45} self.assertFloatEqual(recode_freq_vector(a_def,freqs),\ expected)
def test_recode_freq_vector(self): """recode_freq_vector: bg freqs updated to reflect recoded alphabet """ freqs = {"A": 0.21, "E": 0.29, "C": 0.05, "D": 0.45} a_def = [("A", "AEC"), ("E", "D")] expected = {"A": 0.55, "E": 0.45} self.assertFloatEqual(recode_freq_vector(a_def, freqs), expected) # reversal of alphabet freqs = {"A": 0.21, "E": 0.29, "C": 0.05, "D": 0.45} a_def = [("A", "D"), ("E", "C"), ("C", "E"), ("D", "A")] expected = {"A": 0.45, "E": 0.05, "C": 0.29, "D": 0.21} self.assertFloatEqual(recode_freq_vector(a_def, freqs), expected) # no change in freqs (old alphabet = new alphabet) freqs = {"A": 0.21, "E": 0.29, "C": 0.05, "D": 0.45} a_def = [("A", "A"), ("E", "E"), ("C", "C"), ("D", "D")] self.assertFloatEqual(recode_freq_vector(a_def, freqs), freqs) freqs = {"A": 0.21, "E": 0.29, "C": 0.05, "D": 0.45} a_def = [("X", "AEC"), ("Y", "D")] expected = {"X": 0.55, "Y": 0.45} self.assertFloatEqual(recode_freq_vector(a_def, freqs), expected)