The utils package#

These are the utility modules of buildamol. They mostly serve in the background and keep everything going. Most users will not directly need to use these. However, they are documented here for completeness.

Default settings and constants#

buildamol.utils.constants.BASE = '/home/docs/checkouts/readthedocs.org/user_builds/biobuild/envs/dev/lib/python3.11/site-packages/buildamol'#

The base directory of the package

buildamol.utils.constants.RESOURCES = '/home/docs/checkouts/readthedocs.org/user_builds/biobuild/envs/dev/lib/python3.11/site-packages/buildamol/resources'#

The resources directory of the package

buildamol.utils.defaults.DEFAULT_BOND_LENGTH = 1.6#

The default length of a bond in Angstrom

buildamol.utils.defaults.DEFAULT_CHARMM_TOPOLOGY_FILE = '/home/docs/checkouts/readthedocs.org/user_builds/biobuild/envs/dev/lib/python3.11/site-packages/buildamol/resources/topology.pkl'#

The path to the default CHARMM topology file

buildamol.utils.defaults.DEFAULT_PDBE_COMPONENT_FILES = {'amino_acids': '/home/docs/checkouts/readthedocs.org/user_builds/biobuild/envs/dev/lib/python3.11/site-packages/buildamol/resources/components_amino_acids.pkl', 'base': '/home/docs/checkouts/readthedocs.org/user_builds/biobuild/envs/dev/lib/python3.11/site-packages/buildamol/resources/components_base.pkl', 'lipids': '/home/docs/checkouts/readthedocs.org/user_builds/biobuild/envs/dev/lib/python3.11/site-packages/buildamol/resources/components_lipids.pkl', 'nucleotides': '/home/docs/checkouts/readthedocs.org/user_builds/biobuild/envs/dev/lib/python3.11/site-packages/buildamol/resources/components_nucleotides.pkl', 'small_molecules': '/home/docs/checkouts/readthedocs.org/user_builds/biobuild/envs/dev/lib/python3.11/site-packages/buildamol/resources/components_small.pkl', 'sugars': '/home/docs/checkouts/readthedocs.org/user_builds/biobuild/envs/dev/lib/python3.11/site-packages/buildamol/resources/components_sugars.pkl'}#

The paths to the default PDBe component files

buildamol.utils.defaults.DEFAULT_SASA_N = 300#

The default number of points used to calculate solvent accessible surface area

buildamol.utils.defaults.DEFAULT_SASA_PROBE_RADIUS = 1.4#

The default probe radius for calculating solvent accessible surface area

buildamol.utils.defaults.get_default_instance(key)[source]#

Get the default instance of a class

Parameters:

key (str) – The key of the default instance

Returns:

The default instance of the class

Return type:

obj

buildamol.utils.defaults.set_default_instance(key, obj)[source]#

Set the default instance of a class

Parameters:
  • key (str) – The key of the default instance

  • obj – The new default instance

Other auxiliary utilities#

Utility and auxiliary functions

class buildamol.utils.auxiliary.AtomIterator(atoms)[source]#

Bases: object

Dummy class defining the get_atoms method for iterating over atoms in a list

get_atoms()[source]#
class buildamol.utils.auxiliary.DummyBar(*args, **kwargs)[source]#

Bases: object

A dummy progress bar

update(*args, **kwargs)[source]#
class buildamol.utils.auxiliary.DummyStructure(residues)[source]#

Bases: object

A dummy pdb structure

Used for the surface residue inference

Parameters:

residues (list of Bio.PDB.Residue.Residue) – The residues to include in the structure

get_atoms()[source]#
get_chains()[source]#
get_models()[source]#
get_residues()[source]#
buildamol.utils.auxiliary.chain_id_maker(cdx: int)[source]#

Make a string chain id from a counting integer

Parameters:

cdx (int) – The counting integer

Returns:

The chain id

Return type:

str

buildamol.utils.auxiliary.change_suffix(filename, suffix)[source]#

Change the suffix of a filename

Parameters:
  • filename (str) – The filename

  • suffix (str) – The new suffix

Returns:

The filename with the new suffix

Return type:

str

buildamol.utils.auxiliary.coord_array(*objs) ndarray[source]#

Creates a numpy array of coordinates from objects with a get_coord() method or a coord attribute

buildamol.utils.auxiliary.deprecation_warning(message)[source]#

Issue a deprecation warning

Parameters:

message (str) – The warning message

buildamol.utils.auxiliary.dont_use_ic()[source]#

Don’t use internal coordinates when connecting molecules

buildamol.utils.auxiliary.dont_use_numba()[source]#

Don’t use Numba

buildamol.utils.auxiliary.element_range(symbol: str, n: int, start: int = 1)[source]#

Generate a range of systemic atom ids based on element symbol and number of atoms

Parameters:
  • symbol (str) – The element symbol

  • n (int) – The number of elements

  • start (int, optional) – The start number, by default 1

Returns:

The element names

Return type:

list of str

Examples

>>> element_range("C", 3)
['C1', 'C2', 'C3']
buildamol.utils.auxiliary.filename_to_id(filename)[source]#

Extract the id from a filename

Parameters:

filename (str) – The filename

Returns:

The id

Return type:

str

buildamol.utils.auxiliary.get_args(func, namespace)[source]#

Filter a dictionary based on the argument-namespace of a function

Parameters:
  • func (function) – The function whose argument-namespace will be used for filtering

  • namespace (dict) – The dictionary to be filtered

Returns:

The filtered dictionary

Return type:

dict

buildamol.utils.auxiliary.has_package(name)[source]#
buildamol.utils.auxiliary.lazy_module(fullname)[source]#
buildamol.utils.auxiliary.load_pickle(filename)[source]#

Load an object from a pickle file

buildamol.utils.auxiliary.make_formula(atoms)[source]#

Make a chemical formula from a list of atoms

Parameters:

atoms (list of Atoms) – The atoms. Each atom must have an element attribute (str).

Returns:

The chemical formula

Return type:

str

buildamol.utils.auxiliary.njit(func)[source]#
buildamol.utils.auxiliary.progress_bar(*args, **kwargs)[source]#
buildamol.utils.auxiliary.remove_nonprintable(text)[source]#

Remove non-printable characters from a string

Parameters:

text (str) – The string

Returns:

The string without non-printable characters

Return type:

str

buildamol.utils.auxiliary.save_pickle(obj, filename)[source]#

Save an object to a pickle file

buildamol.utils.auxiliary.use_all_numba()[source]#

Use Numba if available to speed up all functions

buildamol.utils.auxiliary.use_ic()[source]#

Use internal coordinates when connecting molecules (where available)

buildamol.utils.auxiliary.use_numba()[source]#

Use Numba if available to speed up some functions