Back to index

python-biopython  1.60
test_FSSP.py
Go to the documentation of this file.
00001 from Bio import FSSP, Align
00002 from Bio.FSSP import FSSPTools
00003 import sys
00004 import os
00005 import cPickle
00006 import time
00007 
00008 test_file = os.path.join('FSSP', '1cnv.fssp')
00009 f = sys.stdout
00010 f.write("\nRead in %s\n" % os.path.basename(test_file))
00011 handle = open(test_file)
00012 head_rec, sum_rec, align_rec = FSSP.read_fssp(handle)
00013 handle.close()
00014 f.write("...1cnv.fssp read\n")
00015 for i in ["author", "compnd", "database", "header", "nalign",
00016           "pdbid", "seqlength", "source"]:
00017     f.write('head_rec.%s %s\n' % (i, str(getattr(head_rec,i))))
00018 f.write("\nlen(sum_rec) = %d; head_rec.nalign = %d\n" %
00019         (len(sum_rec), head_rec.nalign))
00020 f.write("The above two numbers should be the same\n")
00021 f.write("\nCreate a multiple alignment instance using Bio.Align\n")
00022 alignment = FSSPTools.mult_align(sum_rec, align_rec)
00023 f.write("...Done\n")
00024 # Percent ID filtering takes too long.. remove from test.
00025 
00026 # f.write("\nFilter in percent ID's >= 15%\n")
00027 # sum_ge_15, align_ge_15 = FSSPTools.filter(sum_rec, align_rec, 'pID', 15,100)
00028 
00029 # f.write("\nnumber of records filtered in: %d\n" % len(sum_ge_15))
00030 # k = sum_ge_15.keys()
00031 # k.sort()
00032 # f.write("\nRecords filtered in %s\n" % k)
00033 # Pickling takes too long.. remove from test.
00034 # f.write("\nLet's Pickle this\n")
00035 # dump_file = os.path.join('FSSP', 'mydump.pik')
00036 # cPickle.dump((head_rec, sum_rec, align_rec),open(dump_file, 'w'))
00037 
00038 f.write("\nFilter by name\n")
00039 name_list = ['2hvm0', '1hvq0', '1nar0', '2ebn0']
00040 f.write("\nname list %s\n" % str(name_list))
00041 sum_newnames, align_newnames = FSSPTools.name_filter(sum_rec, align_rec,
00042                                                      name_list)
00043 
00044 ks = sum_newnames.keys()
00045 ks.sort()
00046 for key in ks:
00047     f.write("%s : %s\n" % (key, sum_newnames[key]))
00048     
00049 dict = align_newnames['0P168'].pos_align_dict
00050 ks = dict.keys()
00051 ks.sort()
00052 for key in ks:
00053     f.write("%s : %s\n" % (key, dict[key]))
00054