def get_leaf_atoms(self, mol): atom_nums = self.get_leaves(self.rootNode, []) atoms = AtomSet() if len(atom_nums): atoms = mol.allAtoms.get(str(atom_nums[0])) for atnum in atom_nums[1:]: atoms.append(mol.allAtoms[atnum]) return atoms
def getCations(self, atoms): #select atoms in ARG and LYS residues arg_cations = atoms.get(lambda x: (x.parent.type=='ARG' and \ x.name in ['CZ'])) lys_cations = atoms.get(lambda x: (x.parent.type=='LYS' and \ x.name in ['NZ', 'HZ1', 'HZ2', 'HZ3'])) #select any positively-charged metal ions... cannot include CA here metal_cations = atoms.get(lambda x: x.name in ['Mn','MN', 'Mg',\ 'MG', 'FE', 'Fe', 'Zn', 'ZN']) ca_cations = atoms.get(lambda x: x.name in ['CA', 'Ca'] and x.parent.type=='CA') cations = AtomSet() #cations.extend(arg_cations) for a in arg_cations: cations.append(a) #cations.extend(lys_cations) for a in lys_cations: cations.append(a) #cations.extend(metal_cations) # including metal_cations and calcium optional if self.include_metal_cations: for a in metal_cations: cations.append(a) #cations.extend(ca_cations) for a in ca_cations: cations.append(a) return cations
def buildHydrogenBonds(self): self.results = d = {} h_pairDict = self.hydrogen_bond_builder.build(self.lig_atoms, self.macro_atoms) self.h_pairDict = h_pairDict #keys should be from lig, values from macro #sometimes are not...@@check this@@ h_results = {} for k, v in h_pairDict.items(): h_results[k] = 1 for at in v: h_results[at] = 1 all_hb_ats = AtomSet(h_results.keys()) #all macro_hb_ats = d['macro_hb_atoms'] = all_hb_ats.get(lambda x: x.top==self.macro) # process lig lig_hb_res = d['lig_hb_res'] = ResidueSet() lig_hb_sidechains = d['lig_hb_sidechains'] = AtomSet() lig_gly_atoms = AtomSet() lig_hb_ats = d['lig_hb_atoms'] = all_hb_ats.get(lambda x: x in self.lig_atoms) if len(lig_hb_ats): d['lig_hb_res'] = lig_hb_res = lig_hb_ats.parent.uniq() d['lig_hb_sidechains'] = lig_hb_sidechains = lig_hb_res.atoms.get('sidechain') #to visualize hbonding involving GLY residues which have no side chains, show backbone atoms lig_gly_res = d['lig_hb_gly_res'] = lig_hb_res.get(lambda x: x.type=='GLY') if len(lig_gly_res): lig_gly_atoms = lig_gly_res.atoms # build extended set of hbonding_atoms_to_show as lines, just in case lig_hbas = AtomSet(lig_hb_sidechains + lig_gly_atoms + lig_hb_ats) #all from lig extraAts = AtomSet() for at in lig_hbas: for b in at.bonds: at2 = b.atom1 if at2==at: at2 = b.atom2 #add it to the atomset if at2 not in lig_hbas: extraAts.append(at2) if len(lig_hbas): for at in extraAts: lig_hbas.append(at) d['lig_hbas'] = lig_hbas # process macro macro_hb_res = ResidueSet() d['macro_hb_res'] = macro_hb_res d['macro_hb_sidechains'] = AtomSet() d['macro_hb_gly_res'] = ResidueSet() if len(macro_hb_ats): macro_hb_res = macro_hb_ats.parent.uniq() #4. display sidechains of hbonding residues as sticksNballs macro_hb_sidechains = d['macro_hb_sidechains'] = macro_hb_res.atoms.get('sidechain') macro_hb_gly_res = d['macro_hb_gly_res'] = macro_hb_res.get(lambda x: x.type=='GLY') macro_hb_gly_res = ResidueSet() macro_hb_gly_atoms = AtomSet() if len(macro_hb_gly_res): macro_hb_gly_atoms = macro_hb_gly_res.atoms d['macro_hb_gly_atoms'] = macro_hb_gly_atoms # build extended set of hbonding_atoms_to_show as lines macro_hbas = d['macro_hbas'] = AtomSet() if len(macro_hb_ats): macro_hbas = d['macro_hbas'] = AtomSet(macro_hb_sidechains + macro_hb_gly_atoms + macro_hb_ats) #all from macro #add atoms bonded to hb atoms to make lines displayed more reasonable extraAts = AtomSet() for at in macro_hbas: for b in at.bonds: at2 = b.atom1 if at2==at: at2 = b.atom2 #add it to the atomset if at2 not in macro_hbas: extraAts.append(at2) if len(macro_hbas): for at in extraAts: macro_hbas.append(at) d['hbas_macro'] = macro_hbas