luna.interaction.contact module

get_all_contacts(entity, radius=6.2, level='A')[source]

Recover all residue-residue or atom-atom contacts in entity.

Parameters
  • entity (Entity) – The PDB object from where atoms and residues will be recovered.

  • radius (float) – The cutoff distance (in Å) for defining contacts. The default value is 6.2.

  • level ({‘R’, ‘A’}) – Return residues (‘R’) or atoms (‘A’) in contact with source.

Returns

Each tuple contains either a pair of residues or atoms in contact.

Return type

list of tuple of (Residue or Atom, Residue or Atom)

Raises

EntityLevelError – If level is neither ‘R’ nor ‘A’.

Examples

In this example, we will identify all residue-residue contacts within 2.5 Å in the PDB 3QQK. So, let’s first parse the PDB file.

>>> from luna.util.default_values import LUNA_PATH
>>> from luna.MyBio.PDB.PDBParser import PDBParser
>>> pdb_parser = PDBParser(PERMISSIVE=True, QUIET=True)
>>> structure = pdb_parser.get_structure("Protein", f"{LUNA_PATH}/tutorial/inputs/3QQK.pdb")

Then, to recover all residue-residue contacts within 2.5 Å use get_all_contacts() with level set to ‘R’ and radius set to 2.5.

>>> from luna.interaction.contact import get_all_contacts
>>> contacts = get_all_contacts(structure, radius=2.5, level="R")
>>> print(len(contacts))
314
get_contacts_with(entity, source, target=None, radius=6.2, level='A')[source]

Recover atoms or residues in contact with source.

Parameters
  • entity (Entity) – The PDB object from where atoms and residues will be recovered.

  • source (Entity) – The reference, which can be any Entity instance (structure, model, chain, residue, or atom).

  • target (Entity, optional) – If provided, only contacts with the target will be considered.

  • radius (float) – The cutoff distance (in Å) for defining contacts. The default value is 6.2.

  • level ({‘R’, ‘A’}) – Return residues (‘R’) or atoms (‘A’) in contact with source.

Returns

Each tuple contains two items: the first corresponds to a residue/atom from the source, and the second corresponds to a residue/atom in contact with source.

Return type

set of tuple of (Residue or Atom, Residue or Atom)

Raises

EntityLevelError – If level is neither ‘R’ nor ‘A’.

Examples

Example 1) In this example, we will identify residue-residue contacts between a ligand and nearby residues.

First, let’s parse a PDB file to work with.

>>> from luna.util.default_values import LUNA_PATH
>>> from luna.MyBio.PDB.PDBParser import PDBParser
>>> pdb_parser = PDBParser(PERMISSIVE=True, QUIET=True)
>>> structure = pdb_parser.get_structure("Protein", f"{LUNA_PATH}/tutorial/inputs/3QQK.pdb")

Now, we define the target ligand.

>>> ligand = structure[0]["A"][('H_X02', 497, ' ')]

Then, to recover contacts between this ligand and nearby residues we use get_contacts_with() with level set to ‘R’.

>>> from luna.interaction.contact import get_contacts_with
>>> contacts = sorted(get_contacts_with(structure, ligand, radius=3, level="R"))
>>> for pair in contacts:
...     print(pair)
(<Residue X02 het=H_X02 resseq=497 icode= >, <Residue GLU het=  resseq=81 icode= >)
(<Residue X02 het=H_X02 resseq=497 icode= >, <Residue LEU het=  resseq=83 icode= >)
(<Residue X02 het=H_X02 resseq=497 icode= >, <Residue X02 het=H_X02 resseq=497 icode= >)
(<Residue X02 het=H_X02 resseq=497 icode= >, <Residue HOH het=W resseq=321 icode= >)

Example 2) In this example, we will identify atom-atom contacts between a ligand and a given residue.

First, let’s parse a PDB file to work with.

>>> from luna.util.default_values import LUNA_PATH
>>> from luna.MyBio.PDB.PDBParser import PDBParser
>>> pdb_parser = PDBParser(PERMISSIVE=True, QUIET=True)
>>> structure = pdb_parser.get_structure("Protein", f"{LUNA_PATH}/tutorial/inputs/3QQK.pdb")

Now, we define the target ligand and residue.

>>> ligand = structure[0]["A"][('H_X02', 497, ' ')]
>>> residue = structure[0]["A"][(' ', 81, ' ')]

Then, to recover contacts between these compounds we use get_contacts_with(). As we need atom-wise contacts, set level to ‘A’.

>>> from luna.interaction.contact import get_contacts_with
>>> contacts = sorted(get_contacts_with(structure, ligand, target=residue, radius=4, level="A"))
>>> for pair in contacts:
...     print(pair)
(<Atom C7>, <Atom O>)
(<Atom N10>, <Atom C>)
(<Atom N10>, <Atom O>)
get_cov_contacts_with(entity, source, target=None)[source]

Recover potential covalent bonds with source.

Covalent bonds between two nearby atoms A and B are determined as in Open Babel:

\[0.4 <= \overrightarrow{\|AB\|} <= A_{cov} + B_{cov} + 0.45\]

Where \(\overrightarrow{\|AB\|}\) is the distance between atoms A and B, and \(A_{cov}\) and \(B_{cov}\) are the covalent radius of atoms A and B, respectively.

Parameters
  • entity (Entity) – The PDB object from where atoms will be recovered.

  • source (Entity) – The reference, which can be any Entity instance (structure, model, chain, residue, or atom).

  • target (Entity, optional) – If provided, only covalent bonds with the target will be considered.

Returns

Pairs of atoms with potential covalent bonds.

Return type

set of tuple of (Atom, Atom)

Examples

In this example, we will identify all covalent bonds involving a given residue in the PDB 3QQK. So, let’s first parse the PDB file.

>>> from luna.util.default_values import LUNA_PATH
>>> from luna.MyBio.PDB.PDBParser import PDBParser
>>> pdb_parser = PDBParser(PERMISSIVE=True, QUIET=True)
>>> structure = pdb_parser.get_structure("Protein", f"{LUNA_PATH}/tutorial/inputs/3QQK.pdb")

Now, we select the residue of our interest.

>>> residue = structure[0]["A"][(' ', 81, ' ')]

Finally, let`s recover potential covalent bonds involving this residue with get_cov_contacts_with(). In the below snippet, pairs of atoms are sorted by atoms` serial number, and the residue information is printed together with the atom name.

>>> from luna.interaction.contact import get_cov_contacts_with
>>> cov_bonds = sorted(get_cov_contacts_with(structure, residue), key=lambda x: (x[0].serial_number, x[1].serial_number))
>>> for atm1, atm2 in cov_bonds:
>>>     pair = ("%s%d/%s" % (atm1.parent.resname, atm1.parent.id[1], atm1.name),
...             "%s%d/%s" % (atm2.parent.resname, atm2.parent.id[1], atm2.name))
>>>     print(pair)
('PHE80/C', 'GLU81/N')
('GLU81/N', 'GLU81/CA')
('GLU81/CA', 'GLU81/C')
('GLU81/CA', 'GLU81/CB')
('GLU81/C', 'GLU81/O')
('GLU81/C', 'PHE82/N')
('GLU81/CB', 'GLU81/CG')
('GLU81/CG', 'GLU81/CD')
('GLU81/CD', 'GLU81/OE1')
('GLU81/CD', 'GLU81/OE2')
get_proximal_compounds(source, radius=2.2)[source]

Recover proximal compounds to source.

Parameters
  • source (Residue) – The reference compound.

  • radius (float) – The cutoff distance (in Å) for defining proximity. The default value is 2.2, which may recover potential residues bound to source through covalent bonds.

Returns

The list of proximal compounds always include source.

Return type

list of Residue

Raises

IllegalArgumentError – If source is not a Residue

Examples

In this example, we will identify all proximal compounds to a given residue in the PDB 3QQK. So, let’s first parse the PDB file.

>>> from luna.util.default_values import LUNA_PATH
>>> from luna.MyBio.PDB.PDBParser import PDBParser
>>> pdb_parser = PDBParser(PERMISSIVE=True, QUIET=True)
>>> structure = pdb_parser.get_structure("Protein", f"{LUNA_PATH}/tutorial/inputs/3QQK.pdb")

Now, we select the residue of our interest.

>>> residue = structure[0]["A"][(' ', 81, ' ')]

Finally, we call get_proximal_compounds().

>>> from luna.interaction.contact import get_proximal_compounds
>>> compounds = get_proximal_compounds(residue)
>>> for c in compounds:
...    print(c)
<Residue PHE het=  resseq=80 icode= >
<Residue GLU het=  resseq=81 icode= >
<Residue PHE het=  resseq=82 icode= >