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.
- 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__(*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 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.
- classmethod from_biopython(structure, id=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.
- Returns:
Molecule– A molecule object suitable for using inJess.query.
Added in version 0.7.0.
- classmethod from_biotite(atom_array, id=None)#
Create a new
Moleculefrom abiotite.structure.AtomArray.- Parameters:
structure (
biotite.structure.AtomArray) – Thebiotiteobject containing the structure data.- 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)#
Create a new
Moleculefrom agemmi.Model.- Parameters:
- Returns:
Molecule– A molecule object suitable for using inJess.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: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).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. Ignored for CIF files.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.
- 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: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).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. Ignored for CIF files.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.