htmd.builder.builder module#

exception htmd.builder.builder.BuildError(text, errors=())#

Bases: Exception

exception htmd.builder.builder.MissingAngleError(text, values=())#

Bases: _MissingErrorType

exception htmd.builder.builder.MissingAtomTypeError(text, values=())#

Bases: _MissingErrorType

exception htmd.builder.builder.MissingBondError(text, values=())#

Bases: _MissingErrorType

exception htmd.builder.builder.MissingParameterError(text, values=())#

Bases: _MissingErrorType

exception htmd.builder.builder.MissingResidueError(text, values=())#

Bases: _MissingErrorType

exception htmd.builder.builder.MissingTorsionError(text, values=())#

Bases: _MissingErrorType

exception htmd.builder.builder.MixedSegmentError#

Bases: Exception

exception htmd.builder.builder.ResidueInsertionError#

Bases: Exception

htmd.builder.builder.convertDisulfide(mol, disu)#

Convert disulfide selection-string pairs to UniqueResidueID pairs.

Parameters:
  • mol (Molecule) – The molecule the selections refer to.

  • disu (list) – A list of pairs of atom selection strings, each pair identifying the two residues forming a disulfide bond.

Returns:

newdisu – The same pairs with each selection string resolved to a UniqueResidueID.

Return type:

list

htmd.builder.builder.detectCisPeptideBonds(mol, respect_bonds=False)#

Detect and warn about cis peptide bonds in a protein.

Projects the protein omega dihedrals and logs a warning for every frame and residue whose omega angle indicates a cis peptide bond.

Parameters:
  • mol (Molecule) – The molecule to check for cis peptide bonds.

  • respect_bonds (bool) – If True, only report cis bonds whose backbone atoms form a connected component in the molecule’s bond graph.

Return type:

None

htmd.builder.builder.detectDisulfideBonds(mol, thresh=3)#

Automatically detect disulfide bonds in a molecule.

Finds all SG atoms in cysteine-like residues (resnames starting with “CY”) and returns pairs whose inter-sulfur distance is below thresh.

Parameters:
  • mol (Molecule) – The molecule for which to detect disulfide bonds.

  • thresh (float) – Distance threshold in Angstroms below which two sulfur atoms are considered bonded.

Returns:

disubonds – A list of pairs of UniqueResidueID objects representing the detected disulfide bonds, sorted by residue ID.

Return type:

list

Raises:

RuntimeError – If segment names are not defined, if multiple SG atoms are found in the same residue, or if a sulfur atom has more than one possible bond partner.

htmd.builder.builder.embed(mol1, mol2, gap=1.3)#

Embed one molecule into another, removing overlapping residues.

Removes residues of mol2 that have collisions with atoms of mol1, then appends mol1 into mol2.

Parameters:
  • mol1 (Molecule) – The first Molecule object (embedded into mol2).

  • mol2 (Molecule) – The second Molecule object (residues clashing with mol1 are removed).

  • gap (float) – Minimum distance in Angstroms between atoms of the two molecules below which a residue is considered to clash.

Returns:

newmol – The resulting Molecule object with mol1 embedded into mol2.

Return type:

Molecule

Examples

>>> merged = embed(memb, prot)
htmd.builder.builder.lipid_inaccessible_points(solute, thickness, probe=2.5, resolution=1.0, min_volume=1200.0)#

Points inside the bilayer slab that no lipid can reach.

The free space in the slab is flood-filled inward from its lateral edges with a probe the size of an acyl methylene. Whatever the fill cannot reach is walled off from the bulk lipid by the solute, so no lipid could ever diffuse into it and none should be placed there. Space that is merely concave, such as a groove between protomers or a lateral fenestration, stays reachable and is left alone. That reachability is what separates a sealed pore from a homodimer interface lipids legitimately fill; the shape of the space does not.

The solute must be pre-aligned with the bilayer centered at z=0, which is how get_opm_pdb returns it.

Parameters:
  • solute (Molecule) – The membrane-embedded solute, centered on the bilayer midplane.

  • thickness (float) – Full bilayer thickness in Angstrom. Only |z| < thickness / 2 is searched, since that is the span lipids occupy. This is the hydrocarbon core, not a head-to-head thickness, and it must not reach past the solute’s hydrophobic belt: a taller slab runs into the vestibules above and below the belt, where the fill enters from the side and comes back down into the region being tested. Erring thin is safe, erring tall is not, and the error is one of omission either way (nothing reported sealed rather than something sealed that is not).

  • probe (float) – Radius in Angstrom of the probe that must reach a point for a lipid to occupy it, i.e. one acyl methylene.

  • resolution (float) – Grid spacing in Angstrom.

  • min_volume (float) – Sealed regions below this volume in cubic Angstrom are ignored, since nothing large enough to matter fits inside them. One POPC displaces roughly 1200 A^3.

Returns:

points – An (N, 3) array of grid points, one per sealed voxel. Empty when the solute seals nothing off, which is the common case.

Return type:

ndarray

Examples

>>> from moleculekit.opm import get_opm_pdb
>>> mol, thickness = get_opm_pdb("5YIL")
>>> pts = lipid_inaccessible_points(mol, thickness)
htmd.builder.builder.minimalRotation(prot)#

Find the rotation around Z that minimizes the X and Y dimensions of the protein to best fit in a box.

Essentially PCA in 2D

htmd.builder.builder.removeAtomsInHull(mol1, mol2, hullsel, removesel)#

Calculate the convex hull of an atom selection in mol1 and remove atoms within that hull in mol2.

Parameters:
  • mol1 (Molecule) – Molecule for which to calculate the convex hull.

  • mol2 (Molecule) – Molecule containing atoms to check for hull membership.

  • hullsel (str | ndarray) – An atom selection string, a boolean mask, or an integer index array (see Molecule.atomselect) for atoms in mol1 from which to calculate the convex hull.

  • removesel (str | ndarray) – An atom selection string, a boolean mask, or an integer index array (see Molecule.atomselect) for atoms in mol2 from which to remove those located within the hull.

Return type:

tuple

Returns:

  • newmol2 (Molecule) – mol2 without atoms located within the convex hull.

  • numrem (int) – Number of fragments removed.

htmd.builder.builder.removeHET(prot)#

Remove all HETATM residues from a structure.

Each unique HETATM residue name is removed, assuming it is a bound ligand or other heteroatom group.

Parameters:

prot (Molecule) – The molecule to clean.

Returns:

prot – A copy of the input molecule with all HETATM residues removed.

Return type:

Molecule

htmd.builder.builder.removeLipidsInProtein(prot, memb, lipidsel='lipids')#

Calculates the convex hull of the protein. If a lipid lies inside the hull it gets removed.

This does not work well for lipids crossing out of the hull. If even one atom of the lipid is outside it will change the hull and will not get removed. I assume it will get removed by the clashes with the protein though.

htmd.builder.builder.tileMembrane(memb, xmin, ymin, xmax, ymax, buffer=1.5)#

Tile a membrane in the X and Y dimensions to reach a specific size.

Parameters:
  • memb (Molecule) – The membrane to be tiled.

  • xmin (float) – Minimum x coordinate.

  • ymin (float) – Minimum y coordinate.

  • xmax (float) – Maximum x coordinate.

  • ymax (float) – Maximum y coordinate.

  • buffer (float) – Buffer distance in Angstroms between tiles.

Returns:

megamemb – A tiled membrane Molecule covering the specified dimensions.

Return type:

Molecule