Custom substitution matrix in biopython pairwise2 aligner
1
Is there a way to use custom matrix for nucleotide aligner in Biopython pairwise2 module?
I want to decrease penalties for A->G, C->T substitutions.
import Bio
from Bio import pairwise2
seq1='AGTCGATCATCGGA'
seq2='ATTAGATCATCGGGGA'
alignment = pairwise2.align.localms(seq1, seq2, 2,-1,-2,-1,one_alignment_only=True)
print(format_alignment(*alignment[0]))
AGTCGATCATCGGA--
|.|.|||||||||
ATTAGATCATCGGGGA
Score=20
Biopython
pairwise2
alignment
• 2.4k views
how about trying somethig like this
import Bio
from Bio import pairwise2
from Bio.pairwise2 import format_alignment
seq1 = 'AGTCGATCATCGGA'
seq2 = 'ATTAGATCATCGGGGA'
match_dic = {}
match_dic[('A', 'A')] = 2
match_dic[('A', 'C')] = -1
match_dic[('A', 'T')] = -1
match_dic[('A', 'G')] = 1
match_dic[('C', 'A')] = -1
match_dic[('C', 'C')] = 2
match_dic[('C', 'T')] = 1
match_dic[('C', 'G')] = -1
match_dic[('G', 'A')] = -1
match_dic[('G', 'C')] = -1
match_dic[('G', 'T')] = -1
match_dic[('G', 'G')] = 2
match_dic[('T', 'A')] = -1
match_dic[('T', 'C')] = -1
match_dic[('T', 'T')] = 2
match_dic[('T', 'G')] = -1
alignment = pairwise2.align.localds(
seq1, seq2, match_dic, -2, -1, one_alignment_only=True)
print(alignment[0])
print(format_alignment(*alignment[0]))
Login before adding your answer.
Traffic: 2487 users visited in the last hour
Yes! Thank you very much!