def main(): # First test, pwdumb, with no scorer dna_seq1 = [c for c in "GATTACA"] dna_seq2 = [c for c in "ATAC"] alms = malign.multi_align([dna_seq1, dna_seq2], method="dumb") print("Experiment #1") print(malign.tabulate_alms(alms)) # Second test, pwnw, default scorer alms = malign.multi_align([dna_seq1, dna_seq2], method="nw") print("Experiment #2") print(malign.tabulate_alms(alms)) # Third test, pwkbest, default scorer alms = malign.multi_align([dna_seq1, dna_seq2], k=4, method="yenksp") print("Experiment #3") print(malign.tabulate_alms(alms)) # Fourth test, pwkbest, DNA scorer scorer = malign.utils.DNA_MATRIX alms = malign.multi_align([dna_seq1, dna_seq2], k=4, method="yenksp", scorer=scorer) print("Experiment #4") print(malign.tabulate_alms(alms))
def with_full_matrix(): ita_rus = malign.ScoringMatrix() ita_rus.load("docs/ita_rus.matrix") ita_grk = malign.ScoringMatrix() ita_grk.load("docs/ita_grk.matrix") # Combine the two matrices into a single one, add some points, show a couple of examples # TODO: move to function scores_ita_rus = { (key[0], key[1], None): value for key, value in ita_rus.scores.items() } scores_ita_grk = { (key[0], None, key[1]): value for key, value in ita_grk.scores.items() } scores = {**scores_ita_rus, **scores_ita_grk} full_matrix = malign.ScoringMatrix(scores) full_matrix["o", "в", "ο"] = -4.0 full_matrix["o", "в", "ς"] = -10.0 full_matrix["-", "в", "ς"] = -7.5 full_matrix["-", "в", "ο"] = -6.5 full_matrix["o", "-", "ο"] = 5.0 full_matrix["o", "-", "ς"] = -3.0 full_matrix["i", "-", "Ι"] = -4.0 full_matrix["c", "к", "κ"] = 10.0 full_matrix["-", "в", "ς"] = -10.0 full_matrix["m", "в", "β"] = 10.0 print("--------------------- FULL MATRIX #1") for key in [ ("-", "к", "ο"), ("i", "а", "Ι"), ("m", "в", "β"), ("m", "-", "β"), ("-", "в", "ς"), ("-", "-", "ς"), ("o", "-", "ς"), ("-", "-", "ο"), ("-", "в", "ο"), ]: print(key, full_matrix[key]) print("--------------------- FULL MATRIX #2") alms = malign.multi_align( ["atomo", "атом", "ατομο"], k=4, method="anw", matrix=full_matrix ) print(tabulate_alms(alms)) print("--------------------- FULL MATRIX #3") alms = malign.multi_align( ["Giacomo", "Яков", "Ιακωβος"], k=4, method="anw", matrix=full_matrix ) print(tabulate_alms(alms)) return full_matrix
def with_ita_grk(): ita_grk = malign.ScoringMatrix() ita_grk.load("docs/ita_grk.matrix") print("--------------------- ITA_GRK #1") alms = malign.multi_align(["atomo", "ατομο"], k=2, method="anw", matrix=ita_grk) print(tabulate_alms(alms)) print("--------------------- ITA_GRK #2") alms = malign.multi_align(["Giacomo", "Ιακωβος"], k=4, method="anw", matrix=ita_grk) print(tabulate_alms(alms))
def with_ita_rus(): ita_rus = malign.ScoringMatrix() ita_rus.load("docs/ita_rus.matrix") print("--------------------- ITA_RUS #1") alms = malign.multi_align(["atomo", "атом"], k=2, method="anw", matrix=ita_rus) print(tabulate_alms(alms)) print("--------------------- ITA_RUS #2") alms = malign.multi_align(["Giacomo", "Яков"], k=4, method="anw", matrix=ita_rus) print(tabulate_alms(alms))
def pairwise_dumb(): # Pairwise dumb alignment seq_a = "tra" seq_b = "fatata" print("--------------------- PAIRWISE DUMB") alms = malign.multi_align([seq_a, seq_b], method="dumb") print(tabulate_alms(alms))
def dna2(): seq_a = "GATTACA" seq_b = "ATTT" print("--------------------- DNA2") alms = malign.multi_align( [seq_a, seq_b], k=2, method="anw", matrix=malign.utils.DNA_MATRIX ) print(tabulate_alms(alms))
def test_tabulation(): """ Test alignment tabulation output """ # TODO: assertMultiLineEqual() is failing, only keeping here for coverage alms = malign.multi_align(["tra", "fatata"], method="anw", k=3) output = malign.tabulate_alms(alms) ref = """
def yenksp(full_matrix, voldemort_matrix): print("--------------------- YENKSP #1") alms = malign.multi_align( ["atomo", "атом", "ατομο"], k=2, method="yenksp", matrix=full_matrix ) print(tabulate_alms(alms)) print("--------------------- YENKSP #2") alms = malign.multi_align( ["Giacomo", "Яков", "Ιακωβος"], k=2, method="yenksp", matrix=full_matrix ) print(tabulate_alms(alms)) print("--------------------- YENKSP #3") alms = malign.multi_align( ["VOLDEMORT", "WALDEMAR", "VLADIMIR", "VOLODYMIR"], k=4, method="yenksp", matrix=voldemort_matrix, ) print(tabulate_alms(alms))
def modified_dna(): modified_DNA = malign.utils.DNA_MATRIX.copy() modified_DNA["C", "T"] = -99.0 seq_a = "GATTACA" seq_b = "ATTT" alms = malign.multi_align([seq_a, seq_b], k=4, method="anw", matrix=modified_DNA) print("--------------------- MODIFIED DNA #1") print(tabulate_alms(alms)) print("--------------------- MODIFIED DNA #2") alms = malign.multi_align( ["GATTACA", "GATTATA"], k=2, method="anw", matrix=modified_DNA ) print(tabulate_alms(alms)) print("--------------------- MODIFIED DNA #3") alms = malign.multi_align( ["GATTATA", "GATTACA"], k=2, method="anw", matrix=modified_DNA ) print(tabulate_alms(alms))
def voldemort(): seqs = ["VOLDEMORT", "WALDEMAR", "VLADIMIR", "VOLODYMIR"] voldemort_matrix = malign.utils.identity_matrix(seqs) print("--------------------- VOLDEMORT #1") for key in [ ("T", "-", "-", "-"), ("T", "R", "R", "R"), ("-", "R", "R", "R"), ("R", "R", "R", "R"), ("O", "A", "I", "I"), ]: print(key, voldemort_matrix[key]) print("--------------------- VOLDEMORT #2") alms = malign.multi_align(seqs, k=4, method="anw", matrix=voldemort_matrix) print(tabulate_alms(alms)) return voldemort_matrix
def multiwise_dumb(): seqs = ["tra", "fra", "batata", "virp", "x"] print("--------------------- MULTIWISE DUMB") alms = malign.multi_align(seqs, method="dumb") print(tabulate_alms(alms))