Back to index

python-biopython  1.60
Classes | Functions
Bio.FSSP.FSSPTools Namespace Reference

Classes

class  FSSPAlign
class  FSSPMultAlign

Functions

def mult_align
def filter
def name_filter

Function Documentation

def Bio.FSSP.FSSPTools.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

Definition at line 54 of file FSSPTools.py.

00054 
00055 def filter(sum_dict,align_dict,filter_attribute,low_bound, high_bound):
00056    """filters a passed summary section and alignment section according to a numeric
00057    attribute in the summary section. Returns new summary and alignment sections"""
00058    new_sum_dict = FSSP.FSSPSumDict()
00059    new_align_dict = copy.deepcopy(align_dict)
00060 #   for i in align_dict:
00061 #      new_align_dict[i]  = copy.copy(align_dict[i])
00062    # new_align_dict = copy.copy(align_dict)
00063    for prot_num in sum_dict:
00064       attr_value = getattr(sum_dict[prot_num],filter_attribute)
00065       if (attr_value >= low_bound and
00066           attr_value <= high_bound):
00067          new_sum_dict[prot_num] = sum_dict[prot_num]
00068    prot_numbers = new_sum_dict.keys()
00069    prot_numbers.sort()
00070    for pos_num in new_align_dict.abs_res_dict:
00071       new_align_dict.abs(pos_num).pos_align_dict = {}
00072       for prot_num in prot_numbers:
00073          new_align_dict.abs(pos_num).pos_align_dict[prot_num] = \
00074                    align_dict.abs(pos_num).pos_align_dict[prot_num]
00075    return new_sum_dict, new_align_dict

Here is the caller graph for this function:

def Bio.FSSP.FSSPTools.mult_align (   sum_dict,
  align_dict 
)
Returns a biopython multiple alignment instance (Bio.Align.Generic)

Definition at line 18 of file FSSPTools.py.

00018 
00019 def mult_align(sum_dict,align_dict):
00020    """Returns a biopython multiple alignment instance (Bio.Align.Generic)"""
00021    mult_align_dict = {}
00022    for j in align_dict.abs(1).pos_align_dict:
00023       mult_align_dict[j] = ''
00024    
00025    for i in range(1,len(align_dict)+1):
00026       # loop on positions
00027       for j in align_dict.abs(i).pos_align_dict:
00028          # loop within a position
00029          mult_align_dict[j] += align_dict.abs(i).pos_align_dict[j].aa
00030    seq_order = mult_align_dict.keys()
00031    seq_order.sort()
00032    fssp_align = Generic.Alignment(Alphabet.Gapped(
00033                                   Alphabet.IUPAC.extended_protein))
00034    for i in seq_order:
00035       fssp_align.add_sequence(sum_dict[i].pdb2+sum_dict[i].chain2,
00036                                  mult_align_dict[i])
00037 #        fssp_align._add_numbering_table()
00038    return fssp_align
00039 
00040 
00041 # Several routines used to extract information from FSSP sections
00042 # filter:
00043 # filters a passed summary section and alignment section according to a numeric
00044 # attribute in the summary section. Returns new summary and alignment sections
00045 # For example, to filter in only  those records which have a zscore greater than
00046 # 4.0 and lesser than 7.5:
00047 # new_sum, new_align = filter(sum, align, 'zscore', 4, 7.5)
00048 #
00049 # Warning: this function really slows down when filtering large FSSP files.
00050 # The reason is the use of copy.deepcopy() to copy align_dict into
00051 # new_align_dict. I have to figure out something better.
00052 # Took me ~160 seconds for the largest FSSP file (1reqA.fssp)
00053 #

def Bio.FSSP.FSSPTools.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.

Definition at line 76 of file FSSPTools.py.

00076 
00077 def name_filter(sum_dict, align_dict, name_list):
00078    """ Accepts a list of names. Returns a new Summary block and Alignment block which
00079        contain the info only for those names passed."""
00080    new_sum_dict = FSSP.FSSPSumDict()
00081    new_align_dict = copy.deepcopy(align_dict)
00082    for cur_pdb_name in name_list:
00083       for prot_num in sum_dict:
00084          if sum_dict[prot_num].pdb2+sum_dict[prot_num].chain2 == cur_pdb_name:
00085             new_sum_dict[prot_num] = sum_dict[prot_num]
00086    prot_numbers = new_sum_dict.keys()
00087    prot_numbers.sort()
00088    for pos_num in new_align_dict.abs_res_dict:
00089       new_align_dict.abs(pos_num).pos_align_dict = {}
00090       for prot_num in prot_numbers:
00091          new_align_dict.abs(pos_num).pos_align_dict[prot_num] = \
00092                    align_dict.abs(pos_num).pos_align_dict[prot_num]
00093    return new_sum_dict, new_align_dict
00094