def test01(self): alphabet= "ACTG" matrix = build_scoring_matrix(alphabet, 10,4,-2) self.assertEquals(matrix['-']['-'],-2) self.assertEquals(matrix['A']['A'],10) self.assertEquals(matrix['C']['A'],4)
def test01(self): alphabet = "ACTG" matrix = build_scoring_matrix(alphabet, 10, 4, -2) self.assertEquals(matrix['-']['-'], -2) self.assertEquals(matrix['A']['A'], 10) self.assertEquals(matrix['C']['A'], 4)
def check_spelling(checked_word, dist, words): mispelled = [] scoring_matrix = build_scoring_matrix(string.ascii_lowercase, 2, 1, 0) for word in words: if calculate_distance(checked_word, word, scoring_matrix) <= dist: mispelled.append(word) return mispelled
def test01(self): alphabet= "ACTG" matrix = build_scoring_matrix(alphabet, 10,4,-2) S = compute_alignment_matrix("AA", "TAAT", matrix, True) (score,x,y) = compute_global_alignment("AA", "TAAT", matrix, S) self.assertEqual(score,16) self.assertEquals(x,"-AA-") self.assertEquals(y,"TAAT")
def testGlobal(self): alphabet= "ACTG" matrix = build_scoring_matrix(alphabet, 10,4,-2) S = compute_alignment_matrix("AA", "TAAT", matrix, True) self.assertEquals(S[0][0], 0) self.assertLess(S[0][1], 0) self.assertLess(S[1][0], 0) self.assertEquals(S[2][3],18)
def test01(self): alphabet = "ACTG" matrix = build_scoring_matrix(alphabet, 10, 4, -2) S = compute_alignment_matrix("AA", "TAAT", matrix, True) (score, x, y) = compute_local_alignment("AA", "TAAT", matrix, S) self.assertEqual(score, 20) self.assertEquals(x, "AA") self.assertEquals(y, "AA")
def testGlobal(self): alphabet = "ACTG" matrix = build_scoring_matrix(alphabet, 10, 4, -2) S = compute_alignment_matrix("AA", "TAAT", matrix, True) self.assertEquals(S[0][0], 0) self.assertLess(S[0][1], 0) self.assertLess(S[1][0], 0) self.assertEquals(S[2][3], 18)
# coding: utf-8 # In[32]: import seq_align from Bio import SeqIO, Seq # In[22]: score_mat = seq_align.build_scoring_matrix(set(["A", "T", "G", "C"]), 10, -10, 0) # In[33]: seq_recs = SeqIO.parse("/Users/richard/Downloads/rosalind_lcsq.txt", "fasta") seq_x, seq_y = [str(seq.seq) for seq in seq_recs] # In[34]: align_mat = seq_align.compute_alignment_matrix(seq_x, seq_y, score_mat, True) # In[35]: _, align1, align2 = seq_align.compute_global_alignment(seq_x, seq_y, score_mat, align_mat) print align1 print align2