Molecule#
- class pyjess.Atom#
A single atom in a molecule.
Added in version 0.4.0: Equality, hashing and pickle protocol support.
- __init__(*, serial, name, altloc, residue_name, chain_id, residue_number, insertion_code, x, y, z, occupancy=0.0, temperature_factor=0.0, segment='', element='', charge=0)#
Create a new atom.
- Raises:
MemoryError – When the system allocator fails to allocate enough memory for the atom storage.
ValueError – When either of the
name,residue_name,segment,elementorchain_idstrings is too long.
- 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.
- class pyjess.Molecule#
A molecule structure, as a sequence of
Atomobjects.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__(atoms=(), id=None)#
Create a new molecule.
- Parameters:
- Raises:
MemoryError – When the system allocator fails to allocate enough memory for the molecule storage.
- __len__()#
Return len(self).
- 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 load(file, id=None, ignore_endmdl=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 PDB molecule.id (
str, optional) – The identifier of the molecule. IfNonegiven, the parser will attempt to extract it from theHEADERline.ignore_endmdl (
bool) – PassTrueto 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 firstENDMDLline.
- Returns:
Molecule– The molecule parsed from the PDB file.
- classmethod loads(text, id=None, ignore_endmdl=False)#
Load a molecule from a PDB string.
- 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 PDB molecule.id (
str, optional) – The identifier of the molecule. IfNonegiven, the parser will attempt to extract it from theHEADERline.ignore_endmdl (
bool) – PassTrueto 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 firstENDMDLline.
- Returns:
Molecule– The molecule parsed from the PDB file.
See also
Molecule.loadto load a PDB molecule from a file-like object or from a path.