Molecule#

class pyjess.Atom#

A single atom in a molecule.

Added in version 0.4.0: Equality, hashing and pickle protocol support.

__init__(*args, **kwargs)#
copy()#

Create a copy of this atom.

Returns:

Atom – A newly allocated atom with identical attributes.

Added in version 0.4.0.

classmethod load(file)#

Load an atom from the given file.

Parameters:

file (file-like object) – A file-like object opened in text mode to read the atom from.

classmethod loads(text)#

Load an atom from the given string.

Parameters:

text (str, bytes or bytearray) – The atom line to read the atom metadata from.

altloc#

The alternate location indicator for the atom.

Type:

str

chain_id#

The identifier of the chain the atom belongs to.

Type:

str

charge#

The atom charge.

Type:

int

element#

The element symbol.

Type:

str

insertion_code#

The code for insertion of residues.

Type:

str

name#

The atom name.

Type:

str

occupancy#

The atom occupancy.

Type:

float

residue_name#

The residue name.

Type:

str

residue_number#

The residue sequence number.

Type:

int

segment#

The segment identifier.

Type:

str

serial#

The atom serial number.

Type:

int

temperature_factor#

The atom temperature factor.

Type:

float

x#

The atom coordinate in the 1st dimension.

Type:

float

y#

The atom coordinate in the 2nd dimension.

Type:

float

z#

The atom coordinate in the 3rd dimension.

Type:

float

class pyjess.Molecule#

A molecule structure, as a sequence of Atom objects.

Added in version 0.2.2: Support identifiers of arbitrary length.

Added in version 0.4.0: Equality, hashing and pickle protocol support.

__getitem__(key, /)#

Return self[key].

__init__(*args, **kwargs)#
__len__()#

Return len(self).

conserved(cutoff=0.0)#

Get a molecule containing only a subset of conserved atoms.

Parameters:

cutoff (float) – The conservation cutoff for atoms. Atoms with a temperature_factor lower than this value will be removed from the result.

Returns:

Molecule – A new molecule with atoms below the conservation cutoff removed.

copy()#

Create a copy of this molecule and its atoms.

Returns:

Molecule – A newly allocated molecule with the same identifier and atoms.

Added in version 0.4.0.

classmethod from_biopython(structure, id=None)#

Create a new Molecule from a Bio.PDB.Structure.

Parameters:
  • structure (Bio.PDB.Structure or Bio.PDB.Model) – The Biopython object containing the structure data.

  • id (str or None) – The identifier to give to the newly created molecule. If None given, will use the value of structure.id.

Returns:

Molecule – A molecule object suitable for using in Jess.query.

Added in version 0.7.0.

classmethod from_biotite(atom_array, id=None)#

Create a new Molecule from a biotite.structure.AtomArray.

Parameters:

structure (biotite.structure.AtomArray) – The biotite object containing the structure data.

Returns:

Molecule – A molecule object suitable for using in Jess.query.

Caution

If loading data with the biotite.structure.io.pdb.PDBFile module, ensure that you are requesting all atoms and all extra fields in get_structure:

db_file = PDBFile.read("data/1AMY.pdb")
structure = pdb_file.get_structure(
    altloc="all",
    extra_fields=["atom_id", "b_factor", "occupancy", "charge"],
)
molecule = Molecule.from_biotite(structure[0])

Added in version 0.7.0.

classmethod from_gemmi(model, id=None)#

Create a new Molecule from a gemmi.Model.

Parameters:
  • structure (gemmi.Model) – The gemmi object containing the structure data.

  • id (str or None) – The identifier to give to the newly created molecule.

Returns:

Molecule – A molecule object suitable for using in Jess.query.

Added in version 0.7.0.

classmethod load(file, format='detect', *, id=None, ignore_endmdl=False, use_author=False, skip_hetatm=False)#

Load a molecule from a PDB file.

Parameters:
  • file (str, os.PathLike, or file-like object) – Either the path to a file, or a file-like object opened in text mode containing a molecule.

  • format (str) – The format to parse the file. Supported formats are: pdb for the Protein Data Bank format, cif for Crystallographic Information File format (additionally requires the gemmi module), or detect to attempt auto-detection (the default).

Keyword Arguments:
  • id (str, optional) – The identifier of the molecule. If None given, the parser will attempt to extract it from the HEADER line (for PDB files) or the block name (for CIF files).

  • ignore_endmdl (bool) – Pass True to make the parser read all the atoms from the PDB file. By default, the parser only reads the atoms of the first model, and stops at the first ENDMDL line. Ignored for CIF files.

  • use_author (bool) – Pass True to use the author-defined labels while parsing CIF files, e.g. read the chain name from _atom_site.auth_asym_id rather than _atom_site.label_asym_id. Ignored for PDB files.

  • skip_hetatm (bool) – Pass True to skip parsing of heteroatoms (HETATM) in the input file.

Returns:

Molecule – The molecule parsed from the PDB file.

See also

Molecule.loads to load a PDB molecule from a string.

Caution

Parsing from PDB file retains the heteroatoms (HETATM lines) while parsing from mmCIF usually discard them. This is because mmCIF files store heteroatoms but do not require them to have an associated residue number, which can throw off the way atoms are modeled in Jess.

Added in version 0.7.0: The format and skip_hetatm arguments, and mmCIF support.

classmethod loads(text, format='pdb', *, id=None, ignore_endmdl=False, use_author=False, skip_hetatm=False)#

Load a molecule from a PDB string.

Parameters:
  • text (str) – The serialized molecule to parse into a new object.

  • format (str) – The format to parse the file. Supported formats are: pdb for the Protein Data Bank format, cif for Crystallographic Information File format (additionally requires the gemmi module), or detect to attempt auto-detection (the default).

Keyword Arguments:
  • id (str, optional) – The identifier of the molecule. If None given, the parser will attempt to extract it from the HEADER line (for PDB files) or the block name (for CIF files).

  • ignore_endmdl (bool) – Pass True to make the parser read all the atoms from the PDB file. By default, the parser only reads the atoms of the first model, and stops at the first ENDMDL line. Ignored for CIF files.

  • use_author (bool) – Pass True to use the author-defined labels while parsing CIF files, e.g. read the chain name from _atom_site.auth_asym_id rather than _atom_site.label_asym_id. Ignored for PDB files.

Returns:

Molecule – The molecule parsed from the PDB file.

See also

Molecule.load to load a PDB molecule from a file-like object or from a path.

Caution

Parsing from PDB file retains the heteroatoms (HETATM lines) while parsing from mmCIF usually discard them. This is because mmCIF files store heteroatoms but do not require them to have an associated residue number, which can throw off the way atoms are modeled in Jess.

Added in version 0.7.0: The format argument, and support for CIF parsing.