meeko/analysis/interactions.py
def find(self, ligand, receptor):
        """Find Hydrogen bond-like interactions between ligand and receptor.

        Args:
            ligand (PDBQTMolecularr): ligand
            receptor (PDBQTReceptor): receptor

        Returns:
            np.ndarray: array of (ligand_atom_index, receptor_atom_index, distance, donor_angle, acceptor_angle)
                for each interaction between ligand and rigid receptor
            np.ndarray: array of (ligand_atom_index, receptor_atom_index, distance, donor_angle, acceptor_angle)
                for each interaction between ligand and flexible sidechain

        """
        dtype = [('ligand_idx', int), ('receptor_idx', int), 
                 ('distance', float), ('angle_don', float), ('angle_acc', float)]
        rigid_interactions = []
        flex_interactions = []
        lig_hb_pre_position = None
        rec_hb_pre_position = None
        lig_atom_property, rec_atom_property = self._atom_properties

        has_flexible_residues = ligand.has_flexible_residues()

        if lig_atom_property == 'water':
            lig_atoms = ligand.atoms_by_properties([lig_atom_property])
        else:
            lig_atoms = ligand.atoms_by_properties(['ligand', lig_atom_property])

        for lig_atom in lig_atoms:
            # Get pre-acceptor position (if acceptor) or pre-hydrogen position (if donor) for that atom in the ligand
            lig_bound_atoms_index = ligand.neighbor_atoms(lig_atom['idx'])
            if any(lig_bound_atoms_index):
                lig_bound_atoms = ligand.atoms(lig_bound_atoms_index[0])
                # This is not accurate when bonds don't have the same length
                lig_hb_pre_position = np.mean(lig_bound_atoms['xyz'], axis=0)
            else:
                # If no atom bound, likely a water molecule attached to the ligand
                lig_hb_pre_position = None

            # Get rigid part of the receptor
            rec_rigid_atoms = receptor.closest_atoms_from_positions(lig_atom['xyz'], self._distance, rec_atom_property)
            rec_rigid_flex = [receptor]
            rec_rigid_flex_atoms = [rec_rigid_atoms]
            rec_rigid_flex_types = ['rigid']

            # Get the flexible part of the receptor (if present)
            if has_flexible_residues:
                rec_flex_atoms = ligand.closest_atoms_from_positions(lig_atom['xyz'], self._distance, ['flexible_residue', rec_atom_property])
                rec_rigid_flex.append(ligand)
                rec_rigid_flex_atoms.append(rec_flex_atoms)
                rec_rigid_flex_types.append('flex')

            # Add interactions
            for rec, rec_atoms, rec_type in zip(rec_rigid_flex, rec_rigid_flex_atoms, rec_rigid_flex_types):
                for rec_atom in rec_atoms:
                    distance = np.linalg.norm(lig_atom['xyz'] - rec_atom['xyz'])

                    if distance <= self._distance:
                        # Get pre-acceptor position (if acceptor) or pre-hydrogen position (if donor) for that atom in the ligand
                        rec_bound_atoms_index = rec.neighbor_atoms(rec_atom['idx'])
                        if any(rec_bound_atoms_index):
                            rec_bound_atoms = rec.atoms(rec_bound_atoms_index[0])
                            # This is not accurate when bonds don't have the same length
                            rec_hb_pre_position = np.mean(rec_bound_atoms['xyz'], axis=0)
                        else:
                            # If no atom bound, likely a water molecule in the receptor
                            rec_hb_pre_position = None

                        if lig_hb_pre_position is not None:
                            angle_1 = _compute_angle(lig_atom['xyz'] - lig_hb_pre_position, lig_atom['xyz'] - rec_atom['xyz'])
                        else:
                            angle_1 = np.radians(180)

                        if rec_hb_pre_position is not None:
                            angle_2 = _compute_angle(rec_atom['xyz'] - rec_hb_pre_position, rec_atom['xyz'] - lig_atom['xyz'])
                        else:
                            angle_2 = np.radians(180)

                        if (angle_1 >= self._angles[0]) & (angle_2 >= self._angles[1]):
                            tmp = [lig_atom['idx'], rec_atom['idx'], distance]
                            if lig_atom_property == 'hb_don':
                                tmp += [np.degrees(angle_1), np.degrees(angle_2)]
                            else:
                                tmp += [np.degrees(angle_2), np.degrees(angle_1)]

                            if rec_type == 'rigid':
                                rigid_interactions.append(tuple(tmp))
                            else:
                                flex_interactions.append(tuple(tmp))

        return np.array(rigid_interactions, dtype=dtype), np.array(flex_interactions, dtype=dtype)
Find Hydrogen bond-like interactions between ligand and receptor.

        Args:
            ligand (PDBQTMolecularr): ligand
            receptor (PDBQTReceptor): receptor

        Returns:
            np.ndarray: array of (ligand_atom_index, receptor_atom_index, distance, donor_angle, acceptor_angle)
                for each interaction between ligand and rigid receptor
            np.ndarray: array of (ligand_atom_index, receptor_atom_index, distance, donor_angle, acceptor_angle)
                for each interaction between ligand and flexible sidechain

        
Find Hydrogen bond-like interactions between ligand and receptor.
Find Hydrogen bond - like interactions between ligand and receptor .
def find(self, ligand, receptor):
        dtype = [('ligand_idx', int), ('receptor_idx', int), 
                 ('distance', float), ('angle_don', float), ('angle_acc', float)]
        rigid_interactions = []
        flex_interactions = []
        lig_hb_pre_position = None
        rec_hb_pre_position = None
        lig_atom_property, rec_atom_property = self._atom_properties
        has_flexible_residues = ligand.has_flexible_residues()
        if lig_atom_property == 'water':
            lig_atoms = ligand.atoms_by_properties([lig_atom_property])
        else:
            lig_atoms = ligand.atoms_by_properties(['ligand', lig_atom_property])
        for lig_atom in lig_atoms:
            lig_bound_atoms_index = ligand.neighbor_atoms(lig_atom['idx'])
            if any(lig_bound_atoms_index):
                lig_bound_atoms = ligand.atoms(lig_bound_atoms_index[0])
                lig_hb_pre_position = np.mean(lig_bound_atoms['xyz'], axis=0)
            else:
                lig_hb_pre_position = None
            rec_rigid_atoms = receptor.closest_atoms_from_positions(lig_atom['xyz'], self._distance, rec_atom_property)
            rec_rigid_flex = [receptor]
            rec_rigid_flex_atoms = [rec_rigid_atoms]
            rec_rigid_flex_types = ['rigid']
            if has_flexible_residues:
                rec_flex_atoms = ligand.closest_atoms_from_positions(lig_atom['xyz'], self._distance, ['flexible_residue', rec_atom_property])
                rec_rigid_flex.append(ligand)
                rec_rigid_flex_atoms.append(rec_flex_atoms)
                rec_rigid_flex_types.append('flex')
            for rec, rec_atoms, rec_type in zip(rec_rigid_flex, rec_rigid_flex_atoms, rec_rigid_flex_types):
                for rec_atom in rec_atoms:
                    distance = np.linalg.norm(lig_atom['xyz'] - rec_atom['xyz'])
                    if distance <= self._distance:
                        rec_bound_atoms_index = rec.neighbor_atoms(rec_atom['idx'])
                        if any(rec_bound_atoms_index):
                            rec_bound_atoms = rec.atoms(rec_bound_atoms_index[0])
                            rec_hb_pre_position = np.mean(rec_bound_atoms['xyz'], axis=0)
                        else:
                            rec_hb_pre_position = None
                        if lig_hb_pre_position is not None:
                            angle_1 = _compute_angle(lig_atom['xyz'] - lig_hb_pre_position, lig_atom['xyz'] - rec_atom['xyz'])
                        else:
                            angle_1 = np.radians(180)
                        if rec_hb_pre_position is not None:
                            angle_2 = _compute_angle(rec_atom['xyz'] - rec_hb_pre_position, rec_atom['xyz'] - lig_atom['xyz'])
                        else:
                            angle_2 = np.radians(180)
                        if (angle_1 >= self._angles[0]) & (angle_2 >= self._angles[1]):
                            tmp = [lig_atom['idx'], rec_atom['idx'], distance]
                            if lig_atom_property == 'hb_don':
                                tmp += [np.degrees(angle_1), np.degrees(angle_2)]
                            else:
                                tmp += [np.degrees(angle_2), np.degrees(angle_1)]
                            if rec_type == 'rigid':
                                rigid_interactions.append(tuple(tmp))
                            else:
                                flex_interactions.append(tuple(tmp))
        return np.array(rigid_interactions, dtype=dtype), np.array(flex_interactions, dtype=dtype)
def find ( self , ligand , receptor ) : dtype = [ ( 'ligand_idx' , int ) , ( 'receptor_idx' , int ) , ( 'distance' , float ) , ( 'angle_don' , float ) , ( 'angle_acc' , float ) ] rigid_interactions = [ ] flex_interactions = [ ] lig_hb_pre_position = None rec_hb_pre_position = None lig_atom_property , rec_atom_property = self . _atom_properties has_flexible_residues = ligand . has_flexible_residues ( ) if lig_atom_property == 'water' : lig_atoms = ligand . atoms_by_properties ( [ lig_atom_property ] ) else : lig_atoms = ligand . atoms_by_properties ( [ 'ligand' , lig_atom_property ] ) for lig_atom in lig_atoms : lig_bound_atoms_index = ligand . neighbor_atoms ( lig_atom [ 'idx' ] ) if any ( lig_bound_atoms_index ) : lig_bound_atoms = ligand . atoms ( lig_bound_atoms_index [ 0 ] ) lig_hb_pre_position = np . mean ( lig_bound_atoms [ 'xyz' ] , axis = 0 ) else : lig_hb_pre_position = None rec_rigid_atoms = receptor . closest_atoms_from_positions ( lig_atom [ 'xyz' ] , self . _distance , rec_atom_property ) rec_rigid_flex = [ receptor ] rec_rigid_flex_atoms = [ rec_rigid_atoms ] rec_rigid_flex_types = [ 'rigid' ] if has_flexible_residues : rec_flex_atoms = ligand . closest_atoms_from_positions ( lig_atom [ 'xyz' ] , self . _distance , [ 'flexible_residue' , rec_atom_property ] ) rec_rigid_flex . append ( ligand ) rec_rigid_flex_atoms . append ( rec_flex_atoms ) rec_rigid_flex_types . append ( 'flex' ) for rec , rec_atoms , rec_type in zip ( rec_rigid_flex , rec_rigid_flex_atoms , rec_rigid_flex_types ) : for rec_atom in rec_atoms : distance = np . linalg . norm ( lig_atom [ 'xyz' ] - rec_atom [ 'xyz' ] ) if distance <= self . _distance : rec_bound_atoms_index = rec . neighbor_atoms ( rec_atom [ 'idx' ] ) if any ( rec_bound_atoms_index ) : rec_bound_atoms = rec . atoms ( rec_bound_atoms_index [ 0 ] ) rec_hb_pre_position = np . mean ( rec_bound_atoms [ 'xyz' ] , axis = 0 ) else : rec_hb_pre_position = None if lig_hb_pre_position is not None : angle_1 = _compute_angle ( lig_atom [ 'xyz' ] - lig_hb_pre_position , lig_atom [ 'xyz' ] - rec_atom [ 'xyz' ] ) else : angle_1 = np . radians ( 180 ) if rec_hb_pre_position is not None : angle_2 = _compute_angle ( rec_atom [ 'xyz' ] - rec_hb_pre_position , rec_atom [ 'xyz' ] - lig_atom [ 'xyz' ] ) else : angle_2 = np . radians ( 180 ) if ( angle_1 >= self . _angles [ 0 ] ) & ( angle_2 >= self . _angles [ 1 ] ) : tmp = [ lig_atom [ 'idx' ] , rec_atom [ 'idx' ] , distance ] if lig_atom_property == 'hb_don' : tmp += [ np . degrees ( angle_1 ) , np . degrees ( angle_2 ) ] else : tmp += [ np . degrees ( angle_2 ) , np . degrees ( angle_1 ) ] if rec_type == 'rigid' : rigid_interactions . append ( tuple ( tmp ) ) else : flex_interactions . append ( tuple ( tmp ) ) return np . array ( rigid_interactions , dtype = dtype ) , np . array ( flex_interactions , dtype = dtype )
Find Hydrogen bond-like interactions between ligand and receptor.
Find Hydrogen bond - like interactions between ligand and receptor .
"""Find Hydrogen bond-like interactions between ligand and receptor.

        Args:
            ligand (PDBQTMolecularr): ligand
            receptor (PDBQTReceptor): receptor

        Returns:
            np.ndarray: array of (ligand_atom_index, receptor_atom_index, distance, donor_angle, acceptor_angle)
                for each interaction between ligand and rigid receptor
            np.ndarray: array of (ligand_atom_index, receptor_atom_index, distance, donor_angle, acceptor_angle)
                for each interaction between ligand and flexible sidechain

        """ # Get pre-acceptor position (if acceptor) or pre-hydrogen position (if donor) for that atom in the ligand # This is not accurate when bonds don't have the same length # If no atom bound, likely a water molecule attached to the ligand # Get rigid part of the receptor # Get the flexible part of the receptor (if present) # Add interactions # Get pre-acceptor position (if acceptor) or pre-hydrogen position (if donor) for that atom in the ligand # This is not accurate when bonds don't have the same length # If no atom bound, likely a water molecule in the receptor
array of (ligand_atom_index, receptor_atom_index, distance, donor_angle, acceptor_angle)
for each interaction between ligand and rigid receptor
np.ndarray: array of (ligand_atom_index, receptor_atom_index, distance, donor_angle, acceptor_angle)
for each interaction between ligand and flexible sidechain
array of ( ligand_atom_index receptor_atom_index distance donor_angle acceptor_angle ) for each interaction between ligand and rigid receptor np . ndarray : array of ( ligand_atom_index receptor_atom_index distance donor_angle acceptor_angle ) for each interaction between ligand and flexible sidechain
np.ndarray
self
ligand
None
receptor
None