Molecule#
- class pyjess.Atom#
A single atom in a molecule.
Added in version 0.4.0: Equality, hashing and pickle protocol support.
- 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.
- __init__(*, serial, name, residue_name, chain_id, residue_number, x, y, z, occupancy=0.0, temperature_factor=0.0, altloc=' ', insertion_code=' ', 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.
- dump(file, format='pdb')#
Write the atom to a file.
- Parameters:
file (file-like object) – A file opened in text mode where the atom will be written.
format (
str) – The format in which to write the hit. Currently only supportspdb, which writes the hits in the same format as Jess.
Added in version 0.9.0.
- dumps(format='pdb')#
Write the atom to a string.
- Parameters:
format (
str) – The format in which to write the atom. Currently only supportspdb, which writes the hits in the same format as Jess.
Added in version 0.9.0.
- transform(matrix)#
Apply a geometric transformation to the atom coordinates.
- Parameters:
matrix (
Mat4) – A 4x4 matrix in homogeneous coordinates describing the transformation to apply.
Added in version 0.10.0.
- 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.
- classmethod from_biopython(structure, id=None, date=None, name=None)#
Create a new
Moleculefrom aBio.PDB.Structure.- Parameters:
structure (
Bio.PDB.StructureorBio.PDB.Model) – The Biopython object containing the structure data.id (
strorNone) – The identifier to give to the newly created molecule. IfNonegiven, will use the value ofstructure.id.date (
datetime.dateorNone) – The deposition date to give to the newly created molecule.name (
strorNone) – The name to give to the newly created molecule.
- Returns:
Molecule– A molecule object suitable for using inJess.query.
Added in version 0.7.0.
- classmethod from_biotite(atom_array, id=None, date=None, name=None)#
Create a new
Moleculefrom abiotite.structure.AtomArray.- Parameters:
atom_array (
biotite.structure.AtomArray) – Thebiotiteobject containing the structure data.id (
strorNone) – The id to give to the newly created molecule.date (
datetime.dateorNone) – The deposition date to give to the newly created molecule.name (
strorNone) – The name to give to the newly created molecule.
- Returns:
Molecule– A molecule object suitable for using inJess.query.
Caution
If loading data with the
biotite.structure.io.pdb.PDBFilemodule, ensure that you are requesting all atoms and all extra fields inget_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, date=None, name=None)#
Create a new
Moleculefrom agemmi.Model.- Parameters:
structure (
gemmi.Model) – Thegemmiobject containing the structure data.id (
strorNone) – The identifier to give to the newly created molecule.date (
datetime.dateorNone) – The deposition date to give to the newly created molecule.name (
strorNone) – The name to give to the newly created molecule.
- Returns:
Molecule– A molecule object suitable for using inJess.query.
Added in version 0.7.0.
- classmethod load(file, format='detect', *, id=None, date=None, name=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:pdbfor the Protein Data Bank format,ciffor Crystallographic Information File format (additionally requires thegemmimodule), ordetectto attempt auto-detection (the default).
- Keyword Arguments:
id (
str, optional) – The identifier of the molecule. IfNonegiven, the parser will attempt to extract it from theHEADERline (for PDB files) or the block name (for CIF files).date (
datetime.date, optional) – The deposition date of the structure. IfNonegiven, the parser will attempt to extract it from theHEADERline (for PDB files) or the earliest revision data (for CIF files).name (
str, optional) – The name of the structure. IfNonegiven, the parser will attempt to extract it from theHEADERline (for PDB files) or the _struct_keywords.pdbx_keywords (for CIF files).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 - or for CIF files stops if the PDB model > 1.use_author (
bool) – PassTrueto use the author-defined labels while parsing CIF files, e.g. read the chain name from_atom_site.auth_asym_idrather than_atom_site.label_asym_id. Ignored for PDB files.skip_hetatm (
bool) – PassTrueto skip parsing of heteroatoms (HETATM) in the input file.
- Returns:
Molecule– The molecule parsed from the PDB file.
See also
Molecule.loadsto load a PDB molecule from a string.Caution
Parsing from PDB file retains the heteroatoms (
HETATMlines) 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
formatandskip_hetatmarguments, and mmCIF support.Added in version 0.9.0: The
dateandnamearguments.
- classmethod loads(text, format='pdb', *, id=None, date=None, name=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:pdbfor the Protein Data Bank format,ciffor Crystallographic Information File format (additionally requires thegemmimodule), ordetectto attempt auto-detection (the default).
- Keyword Arguments:
id (
str, optional) – The identifier of the molecule. IfNonegiven, the parser will attempt to extract it from theHEADERline (for PDB files) or the block name (for CIF files).date (
datetime.date, optional) – The deposition date of the structure. IfNonegiven, the parser will attempt to extract it from theHEADERline (for PDB files) or the earliest revision data (for CIF files)name (
str, optional) – The name of the structure. IfNonegiven, the parser will attempt to extract it from theHEADERline (for PDB files) or the _struct_keywords.pdbx_keywords (for CIF files)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 - or for CIF files stops if the PDB model > 1.use_author (
bool) – PassTrueto use the author-defined labels while parsing CIF files, e.g. read the chain name from_atom_site.auth_asym_idrather than_atom_site.label_asym_id. Ignored for PDB files.
- 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.Caution
Parsing from PDB file retains the heteroatoms (
HETATMlines) 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
formatargument, and support for CIF parsing.Added in version 0.9.0: The
dateandnamearguments.
- __getitem__(key, /)#
Return self[key].
- __init__(atoms=(), id=None, date=None, name=None)#
Create a new molecule.
- Parameters:
atoms (sequence of
Atom) – The atoms of the molecule.id (
str, optional) – The identifier of the molecule.date (
datetime.date, optional) – The deposition date of the molecule.name (
str, optional) – The name of the molecule.
- Raises:
MemoryError – When the system allocator fails to allocate enough memory for the molecule storage.
- __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 atemperature_factorlower 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.
- dump(file, format='pdb', write_header=True)#
Write the molecule to a file.
- Parameters:
Added in version 0.9.0.
- dumps(format='pdb', write_header=True)#
Write the molecule to a string.
- Parameters:
Added in version 0.9.0.
- transform(matrix)#
Apply a geometric transformation to all atoms of the molecule.
- Parameters:
matrix (
Mat4) – A 4x4 matrix in homogeneous coordinates describing the transformation to apply.
Added in version 0.10.0.
- date#
The deposition date of the molecule.
Added in version 0.9.0.
- Type: