コード例 #1
0
def name_filter(sum_dict, align_dict, name_list):
    """Accepts a list of names. Returns a new Summary block and Alignment block which
    contain the info only for those names passed."""
    new_sum_dict = FSSP.FSSPSumDict()
    new_align_dict = copy.deepcopy(align_dict)
    for cur_pdb_name in name_list:
        for prot_num in sum_dict:
            if sum_dict[prot_num].pdb2 + sum_dict[prot_num].chain2 == cur_pdb_name:
                new_sum_dict[prot_num] = sum_dict[prot_num]
    prot_numbers = sorted(new_sum_dict)
    for pos_num in new_align_dict.abs_res_dict:
        new_align_dict.abs(pos_num).pos_align_dict = {}
        for prot_num in prot_numbers:
            new_align_dict.abs(pos_num).pos_align_dict[prot_num] = \
                    align_dict.abs(pos_num).pos_align_dict[prot_num]
    return new_sum_dict, new_align_dict
コード例 #2
0
def filter(sum_dict, align_dict, filter_attribute, low_bound, high_bound):
    """Filter a passed summary section and alignment section.

    Filter according to a numeric attribute in the summary section.
    Return new summary and alignment sections.
    """
    new_sum_dict = FSSP.FSSPSumDict()
    new_align_dict = copy.deepcopy(align_dict)
    for prot_num in sum_dict:
        attr_value = getattr(sum_dict[prot_num], filter_attribute)
        if attr_value >= low_bound and attr_value <= high_bound:
            new_sum_dict[prot_num] = sum_dict[prot_num]
    prot_numbers = sorted(new_sum_dict)
    for pos_num in new_align_dict.abs_res_dict:
        new_align_dict.abs(pos_num).pos_align_dict = {}
        for prot_num in prot_numbers:
            new_align_dict.abs(pos_num).pos_align_dict[
                prot_num] = align_dict.abs(pos_num).pos_align_dict[prot_num]
    return new_sum_dict, new_align_dict
コード例 #3
0
def filter(sum_dict, align_dict, filter_attribute, low_bound, high_bound):
    """filters a passed summary section and alignment section according to a numeric
    attribute in the summary section. Returns new summary and alignment sections"""
    new_sum_dict = FSSP.FSSPSumDict()
    new_align_dict = copy.deepcopy(align_dict)
#    for i in align_dict:
#        new_align_dict[i]  = copy.copy(align_dict[i])
   # new_align_dict = copy.copy(align_dict)
    for prot_num in sum_dict:
        attr_value = getattr(sum_dict[prot_num], filter_attribute)
        if attr_value >= low_bound and attr_value <= high_bound:
            new_sum_dict[prot_num] = sum_dict[prot_num]
    prot_numbers = new_sum_dict.keys()
    prot_numbers.sort()
    for pos_num in new_align_dict.abs_res_dict:
        new_align_dict.abs(pos_num).pos_align_dict = {}
        for prot_num in prot_numbers:
            new_align_dict.abs(pos_num).pos_align_dict[prot_num] = \
                    align_dict.abs(pos_num).pos_align_dict[prot_num]
    return new_sum_dict, new_align_dict
コード例 #4
0
ファイル: test_FSSP.py プロジェクト: znruss/biopython
# Copyright 2001 by Iddo Friedberg.  All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license.  Please see the LICENSE file that should have been included
# as part of this package.

from Bio import FSSP
from Bio.FSSP import FSSPTools
import sys
import os
# import pickle

test_file = os.path.join('FSSP', '1cnv.fssp')
f = sys.stdout
f.write("\nRead in %s\n" % os.path.basename(test_file))
handle = open(test_file)
head_rec, sum_rec, align_rec = FSSP.read_fssp(handle)
handle.close()
f.write("...1cnv.fssp read\n")
for i in [
        "author", "compnd", "database", "header", "nalign", "pdbid",
        "seqlength", "source"
]:
    f.write('head_rec.%s %s\n' % (i, str(getattr(head_rec, i))))
f.write("\nlen(sum_rec) = %d; head_rec.nalign = %d\n" %
        (len(sum_rec), head_rec.nalign))
f.write("The above two numbers should be the same\n")
f.write("\nCreate a multiple alignment instance using Bio.Align\n")
alignment = FSSPTools.mult_align(sum_rec, align_rec)
f.write("...Done\n")
# Percent ID filtering takes too long.. remove from test.
コード例 #5
0
ファイル: test_FSSP.py プロジェクト: zyha/biopython
 def setUpClass(cls):
     path = os.path.join("FSSP", "1cnv.fssp")
     handle = open(path)
     cls.head_rec, cls.sum_rec, cls.align_rec = FSSP.read_fssp(handle)
     handle.close()
コード例 #6
0
ファイル: test_FSSP.py プロジェクト: davidmam/biopython
from Bio import FSSP, Align
from Bio.FSSP import FSSPTools
import sys
import os
import cPickle
import time

test_file = os.path.join('FSSP', '1cnv.fssp')
f = sys.stdout
f.write("\nRead in %s\n" % os.path.basename(test_file))
handle = open(test_file)
head_rec, sum_rec, align_rec = FSSP.read_fssp(handle)
handle.close()
f.write("...1cnv.fssp read\n")
for i in ["author", "compnd", "database", "header", "nalign",
          "pdbid", "seqlength", "source"]:
    f.write('head_rec.%s %s\n' % (i, str(getattr(head_rec,i))))
f.write("\nlen(sum_rec) = %d; head_rec.nalign = %d\n" %
        (len(sum_rec), head_rec.nalign))
f.write("The above two numbers should be the same\n")
f.write("\nCreate a multiple alignment instance using Bio.Align\n")
alignment = FSSPTools.mult_align(sum_rec, align_rec)
f.write("...Done\n")
# Percent ID filtering takes too long.. remove from test.

# f.write("\nFilter in percent ID's >= 15%\n")
# sum_ge_15, align_ge_15 = FSSPTools.filter(sum_rec, align_rec, 'pID', 15,100)

# f.write("\nnumber of records filtered in: %d\n" % len(sum_ge_15))
# k = sum_ge_15.keys()
# k.sort()
コード例 #7
0
 def setUpClass(cls):
     path = os.path.join("FSSP", "1cnv.fssp")
     with open(path) as handle:
         cls.head_rec, cls.sum_rec, cls.align_rec = FSSP.read_fssp(handle)
コード例 #8
0
ファイル: test_FSSP.py プロジェクト: Mat-D/biopython
from Bio import FSSP, Align
from Bio.FSSP import FSSPTools
import sys
import os
import cPickle
import time

test_file = os.path.join('FSSP', '1cnv.fssp')
f = sys.stdout
f.write("\nRead in %s\n" % os.path.basename(test_file))
head_rec, sum_rec, align_rec = FSSP.read_fssp(open(test_file))
f.write("...1cnv.fssp read\n")
for i in ["author", "compnd", "database", "header", "nalign",
          "pdbid", "seqlength", "source"]:
    f.write('head_rec.%s %s\n' % (i, str(getattr(head_rec,i))))
f.write("\nlen(sum_rec) = %d; head_rec.nalign = %d\n" %
        (len(sum_rec), head_rec.nalign))
f.write("The above two numbers should be the same\n")
f.write("\nCreate a multiple alignment instance using Bio.Align\n")
alignment = FSSPTools.mult_align(sum_rec, align_rec)
f.write("...Done\n")
# Percent ID filtering takes too long.. remove from test.

# f.write("\nFilter in percent ID's >= 15%\n")
# sum_ge_15, align_ge_15 = FSSPTools.filter(sum_rec, align_rec, 'pID', 15,100)

# f.write("\nnumber of records filtered in: %d\n" % len(sum_ge_15))
# k = sum_ge_15.keys()
# k.sort()
# f.write("\nRecords filtered in %s\n" % k)
# Pickling takes too long.. remove from test.