Back to index

python-biopython  1.60
make_subsmat.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """Example of generating a substitution matrix from an alignment.
00003 """
00004 # standard library
00005 import sys
00006 
00007 # Biopython
00008 from Bio import SubsMat
00009 from Bio import Clustalw
00010 from Bio.Alphabet import IUPAC
00011 from Bio.Align import AlignInfo
00012 
00013 # get an alignment object from a Clustalw alignment output
00014 c_align = Clustalw.parse_file('protein.aln', IUPAC.protein)
00015 summary_align = AlignInfo.SummaryInfo(c_align)
00016 
00017 # get a replacement dictionary and accepted replacement matrix
00018 # exclude all amino acids that aren't charged polar
00019 replace_info = summary_align.replacement_dictionary(["G", "A", "V", "L", "I",
00020                                                      "M", "P", "F", "W", "S",
00021                                                      "T", "N", "Q", "Y", "C"])
00022 
00023 my_arm = SubsMat.SeqMat(replace_info)
00024 
00025 print replace_info
00026 
00027 my_lom = SubsMat.make_log_odds_matrix(my_arm)
00028 
00029 print 'log_odds_mat:', my_lom
00030 
00031 my_lom.print_mat()
00032