qm_atlas

qm_atlas.constants.DEFAULT_SCR

Default scratch directory, resolved at import time by qm_atlas.utils.get_scratch_dir().

qm_atlas.utils.get_scratch_dir()[source]

Returns a scratch directory for temporary files. The function first checks if the environment variable TMPDIR is set and returns its value as a Path object. If TMPDIR is not set, it attempts to create a scratch directory in /scratch/<user>/qm_atlas_tmp, where <user> is the current user’s username. If this fails due to permission issues, it falls back to creating a scratch directory in the current working directory.

Raises:

OSError – If the scratch directory cannot be created.

Returns:

The path to the scratch directory.

Return type:

Path

qm_atlas.utils.are_equal(mol_1, mol_2)[source]

checks if two molecules are the same

Parameters:
  • mol_1 (Mol) – the first molecule

  • mol_2 (Mol) – the seond molecule

Returns:

whether they correspond to the same structure

Return type:

bool

qm_atlas.utils.has_macrocycle(mol, ring_threshold=10)[source]
Checks whether a molecule has a macrocycle, i.e. if the largest ring has more

atoms than a given threshold

Parameters:
  • mol (Mol) – The molecule to check

  • ring_threshold (int) – The threshold for the ring size. Defaults to 10.

Returns:

whether the molecule contains a macrocycle

Return type:

bool

qm_atlas.utils.conformer_is_3d(mol, conf_id=0)[source]

Checks whether a molecule has 3D coordinates. The check is more extensive than simply checking for a non-zero z-coordinate. Instead it checks if there are any four consecutive atoms, for which the position vectors are linearly independent.

Parameters:
  • mol (Mol) – The molecule to check

  • conf_id (int)

Returns:

whether the molecule has 3D coordinates

Return type:

bool

qm_atlas.utils.remove_conformers(mol, idcs_to_remove, reset_idcs=True)[source]

Removes Conformers from an rdkit molecule object. Modifies the molecule in place.

Parameters:
  • mol (Mol) – The molecule.

  • idcs_to_remove (Iterable[int]) – The conformer indices to be removed.

  • reset_idcs (bool)

Return type:

None

qm_atlas.utils.has_hydrogens(mol)[source]
Parameters:

mol (Mol)

qm_atlas.utils.as_float(value)[source]

Return value as float, if possible. If the value cannot be parsed as a float, the original value is returned

Return type:

float

qm_atlas.utils.meta_func(func, args, **kwargs)[source]

meta func to translate positional args to tuple

qm_atlas.utils.store_atom_indices(mol)[source]
Parameters:

mol (Mol)

qm_atlas.utils.get_atom_indices_map(mol)[source]

returns a list mapping the original atom indices to the new ones.

Parameters:

mol (Mol) – The molecule to get the atom indices from

Returns:

A dictionary mapping the original atom indices to the new ones.

Return type:

dict[int, int]

qm_atlas.utils.restore_atom_indices(mol)[source]
Return type:

Mol

Parameters:

mol (Mol)

qm_atlas.utils.is_zwitterion(mol)[source]

Check if a molecule is a zwitterion

Parameters:

mol (Mol) – The molecule to check

Returns:

True if the molecule is a zwitterion, False otherwise

Return type:

bool

qm_atlas.utils.intervals_overlap(interval1, interval2)[source]
Checks whether two intervals overlap. Touching counts as overlapping as well.

For example, the intervals [1, 2] and [2, 3] overlap.

Parameters:
  • interval1 (tuple[float, float]) – The first interval, values are expected to be in ascending order.

  • interval2 (tuple[float, float]) – The second interval, values are expected to be in ascending order.

Returns:

True if the intervals overlap, False otherwise.

Return type:

bool

qm_atlas.utils.remove_salt(smiles, saltfile=None)[source]

Remove salt and small molecules from smiles

  • Does not remove all non-covalented molecules

  • Does not neutralize the molecule

>>> uncharger = rdMolStandardize.Uncharger()
>>> mol = uncharger.uncharge(mol) # remove salt and adjust charges
Return type:

str | None

Parameters:

saltfile (Path | None)

qm_atlas.software_environment.get_python_activation_command()[source]

Auto-detect the activation command for the currently active Python virtual environment.

Checks VIRTUAL_ENV (set by any activated venv/virtualenv) and falls back to sys.prefix. Returns None when no virtual environment is detected (e.g. running in the system Python).

Return type:

str | None

qm_atlas.software_environment.get_cosmo_solvents_dir_key(level)[source]

Get the appropriate global settings key for COSMO solvents directories based on level.

Parameters:

level (str) – The cosmotherm level of theory (e.g. “bp-tzvpd”, “bp-tzvp”, “bp-svp”, “dmol3-pbe”)

Returns:

The global settings key to use for retrieving the solvents directories for the given level

class qm_atlas.software_environment.SoftwareEnvironment(*, commands, environment_variables, thread_control_variables, available=False)[source]
Parameters:
commands: dict[str, str]
environment_variables: dict[str, str]
thread_control_variables: list[str]
available: bool = False
qm_atlas.software_environment.get_env_from_modules(module_names, module_paths=None)[source]
Return type:

dict[str, str]

Parameters:
class qm_atlas.software_environment.EnvironmentManager(config_file=None)[source]
Parameters:

config_file (Path | None)

ALLOWED_SUBMISSION_KEYS = {'command_prepend', 'module_load', 'module_purge', 'module_use'}
ALLOWED_GLOBAL_SETTINGS_KEYS = {'cosmo_solvents_dir_bp-svp', 'cosmo_solvents_dir_bp-tzvp', 'cosmo_solvents_dir_bp-tzvpd', 'cosmo_solvents_dir_dmol3-pbe', 'moka_model'}
software_available(software)[source]
Return type:

bool

Parameters:

software (str)

command_available(software, command_name)[source]
Return type:

bool

Parameters:
  • software (str)

  • command_name (str)

get_command(software, command_name)[source]
Return type:

str

Parameters:
  • software (str)

  • command_name (str)

get_environment_variables(software, n_cores=1)[source]
Return type:

dict[str, str]

Parameters:
  • software (str)

  • n_cores (int)

get_run_environment(software, n_cores=1)[source]

Get the complete runtime environment for a software package.

Parameters:
  • software (str) – Name of the software environment

  • n_cores (int)

Return type:

dict[str, str]

Returns:

Complete environment dictionary combining system env + software env + thread control

get_submission_config()[source]
Return type:

dict[str, Any]

get_global_settings()[source]
Return type:

dict[str, Any]

qm_atlas.software_environment.get_config_file()[source]

Return the user-supplied software config file path, or None if the environment variable SOFTWARE_CONFIG_ENV_VAR is not set.

Raises EnvironmentError when the variable is set but points to a file that does not exist, so typos are caught early.

Return type:

Path | None

qm_atlas.software_environment.load_environment_manager(config_file=None)[source]
Return type:

EnvironmentManager

Parameters:

config_file (Path | None)

class qm_atlas.software_environment.SoftwareConfig[source]
get_environment_manager()[source]
Return type:

EnvironmentManager

reload_environment_manager(config_file=None)[source]
Return type:

None

Parameters:

config_file (Path | None)

qm_atlas.software_environment.get_moka_model()[source]

Get the default MoKa model path from global settings.

Return type:

Path | None

Returns:

Path to the model file or None if not configured

qm_atlas.software_environment.get_cosmo_solvents_dirs(level)[source]

Get the appropriate COSMO solvents directories for a given cosmotherm level.

Parameters:

level (str) – The cosmotherm level of theory (e.g. “bp-tzvpd”, “bp-tzvp”, “bp-svp”, “dmol3-pbe”)

Return type:

list[Path]

Returns:

List of paths to the solvents directories appropriate for the given level