def test_ring_center_and_normal(self): mol = parse_smiles("c1ccccc1") R = 1.5 for i in range(6): atom = mol.GetAtom(i+1) atom.SetVector(R*math.cos(2*math.pi*i/6), R*math.sin(2*math.pi*i/6), 0.0) for ring in ob.OBMolRingIter(mol): break center = ob.vector3() norm1 = ob.vector3() norm2 = ob.vector3() ring.findCenterAndNormal(center, norm1, norm2) self.assertZero(center.GetX()) self.assertZero(center.GetY()) self.assertZero(center.GetZ()) self.assertZero(norm1.GetX()) self.assertZero(norm1.GetY()) self.assertClose(norm1.GetZ(), 1.0) self.assertZero(norm2.GetX()) self.assertZero(norm2.GetY()) self.assertClose(norm2.GetZ(), -1.0)
def _compute_cation_pi(protein, ligand, protein_cation_pi, ligand_cation_pi): for protein_ring in ob.OBMolRingIter(protein): if protein_ring.IsAromatic(): protein_ring_center = _compute_ring_center(protein, protein_ring) protein_ring_normal = _compute_ring_normal(protein, protein_ring) for atom in ob.OBMolAtomIter(ligand): if np.abs(atom.GetFormalCharge() - 1.0) < 0.01 or '+' in atom.GetType(): cation_position = np.array([atom.x(), atom.y(), atom.z()]) if _is_cation_pi(cation_position, protein_ring_center, protein_ring_normal): protein_cation_pi = _update_feature_dict( protein_cation_pi, idxs=protein_ring._path) ligand_cation_pi = _update_feature_dict( ligand_cation_pi, indices=[atom.GetIndex()]) return protein_cation_pi, ligand_cation_pi
def _compute_pi_stack(protein_xyz, protein, ligand_xyz, ligand, pairwise_distances=None, dist_cutoff=4.4, angle_cutoff=30.): ''' Pseudocode: for each ring in ligand: if it is aromatic: for each ring in protein: if it is aromatic: compute distance between centers compute angle. if it counts as parallel pi-pi: for each atom in ligand and in protein, add to list of atom indices if it counts as pi-T: for each atom in ligand and in protein: add to list of atom indices ''' protein_pi_parallel = {} protein_pi_t = {} ligand_pi_parallel = {} ligand_pi_t = {} for protein_ring in ob.OBMolRingIter(protein): if protein_ring.IsAromatic(): protein_ring_center = _compute_ring_center(protein, protein_ring) protein_ring_normal = _compute_ring_normal(protein, protein_ring) ligand_pi_parallel_idxs = set() ligand_pi_t_idxs = set() for ligand_ring in ob.OBMolRingIter(ligand): if ligand_ring.IsAromatic(): ligand_ring_center = _compute_ring_center( ligand, ligand_ring) ligand_ring_normal = _compute_ring_normal( ligand, ligand_ring) if _is_pi_parallel(protein_ring_center, protein_ring_normal, ligand_ring_center, ligand_ring_normal): protein_pi_parallel = _update_feature_dict( protein_pi_parallel, idxs=protein_ring._path) ligand_idxs_to_update = list( set(ligand_ring._path) - ligand_pi_parallel_idxs) ligand_pi_parallel = _update_feature_dict( ligand_pi_parallel, idxs=ligand_idxs_to_update) ligand_pi_parallel_idxs.update(set(ligand_ring._path)) if _is_pi_t(protein_ring_center, protein_ring_normal, ligand_ring_center, ligand_ring_normal): protein_pi_t = _update_feature_dict( protein_pi_t, idxs=protein_ring._path) ligand_idxs_to_update = list( set(ligand_ring._path) - ligand_pi_t_idxs) ligand_pi_t = _update_feature_dict( ligand_pi_t, idxs=ligand_idxs_to_update) ligand_pi_t_idxs.update(set(ligand_ring._path)) return (protein_pi_t, protein_pi_parallel, ligand_pi_t, ligand_pi_parallel)