def __init__(self , antigen , antibody): OrderedDefaultDict.__init__(self , lambda :list([0] * 60)) self.antigen = antigen self.antibody = antibody self.nearby_relation = defaultdict(dict)#for cache self.nearby_reses_in_antigen = OrderedDefaultDict(lambda : defaultdict(list))#surrouding residues in antigen for each residue self.nearby_reses_in_antibody = OrderedDefaultDict(lambda : defaultdict(list))#surrouding residues in antibody for each residue self.fp_rule = {#property id and the corresponding residue code 0 : ['TYR', 'ASN', 'GLU', 'SER', 'CYS', 'THR', 'GLY'], #polar 1 : ['PHE', 'LEU', 'ILE', 'TRP', 'VAL', 'MET', 'PRO', 'ALA'], #hydrop 2 : ['ARG', 'ASP', 'GLU', 'LYS', 'HIS'], #charged 3 : ['ALA', 'VAL', 'LEU', 'ILE', 'MET', 'ASN', 'GLU', 'LYS',\ 'ARG', 'GLY', 'SER', 'THR', 'CYS', 'ASP', 'PHE'], #lipids 4 : ['PHE', 'TYR', 'TRP'], #aromatic 5 : ['PRO','HIS'], #heterocyclic }#the key represents the group index, value for the residue code self.res_prop_ids = defaultdict(list)#the property ids that a given residue has #we need to do some conversion for fp_rule for better performance print "initializing FingerPrint_60 object" for prop_id , residues in self.fp_rule.items(): for res_code in residues: self.res_prop_ids[res_code].append(prop_id) #print "res_prop_ids",self.res_prop_ids self.atom_dist_cutoff = 4.0 self.dist_group_cache = defaultdict(dict)
def __init__(self,res, bitlength, values = None): """(Residue, int, dict or list) => BaseResidueFingerprint""" OrderedDefaultDict.__init__(self,float) self.bitlength = bitlength self.min_idx = 0 self.max_idx = self.min_idx + bitlength self.res = res if values is not None: #if it's dict if isinstance(values, dict): self.set_val(values) #if it's list elif isinstance(values, list): self.set_val(OrderedDict(enumerate(values))) else: raise ValueError("invalid values type, either dict or list")