Utilities

scine_chemoton.utilities.queries.calculation_exists_in_structure(job_order, structure_id_list, model, structures, calculations, settings=None, auxiliaries=None)[source]

Check if a calculation exists that corresponds to the given structures, mode, settings, etc.

Parameters
  • job_order (str) – The job order of the calculations to consider.

  • structure_id_list (List[db.ID]) – The list of structure ids of interest.

  • model (db.Model) – The model the calculations shall use.

  • structures (db.Collection) – The structure collection.

  • calculations (db.Collection) – The calculation collection.

  • settings (dict (optional)) – The settings of the calculation.

  • auxiliaries (dict (optional)) – The auxiliaries of the calculation.

Return type

True, if such a calculation exists. False, otherwise.

scine_chemoton.utilities.queries.get_calculation_id(job_order, structure_id_list, model, calculations, settings=None, auxiliaries=None)[source]
Return type

Optional[ID]

scine_chemoton.utilities.queries.get_calculation_id_from_structure(job_order, structure_id_list, model, structures, calculations, settings=None, auxiliaries=None)[source]

Search for a calculation corresponding to the given settings. If the calculation is found, its ID is returned.

Parameters
  • job_order (str) – The job order of the calculations to consider.

  • structure_id_list (List[db.ID]) – The list of structure ids of interest.

  • model (db.Model) – The model the calculations shall use.

  • structures (db.Collection) – The structure collection.

  • calculations (db.Collection) – The calculation collection.

  • settings (dict (optional)) – The settings of the calculation.

  • auxiliaries (dict (optional)) – The auxiliaries of the calculation.

Return type

Returns the calculation ID if found. Returns None if no calculation corresponds to the given specification.

scine_chemoton.utilities.queries.identical_reaction(lhs_aggregates, rhs_aggregates, lhs_types, rhs_types, reactions)[source]

Searches for a reaction with the same aggregates, forward and backward reactions are categorized as the same reaction.

Parameters
  • : (reactions) – List[db.ID]: The ids of the aggregates of the left hand side

  • : – List[db.ID]: The ids of the aggregates of the right hand side

  • : – List[db.ID]: The types of the LHS aggregates.

  • : – List[db.ID]: The types of the RHS aggregates.

  • : – db.Collection (Scine::Database::Collection):

Returns

The identical reaction or None if no identical reaction found in the collection

Return type

reaction :: Union[db.Reaction, None]

scine_chemoton.utilities.queries.model_query(model)[source]

Generates a query that fits the given model, meaning that any field in the model given as ‘any’ will not be queried, while all other fields must match.

Parameters

: (model) – Scine::Database::Model: The model for which a query list will be generated.

Returns

A list of queries for each element of the Model class. The list can be added to any ‘$and’ or ‘$or’ expression.

Return type

query :: List[dict]

Examples

>>> selection = {'$and': [
>>>     {'some': 'logic'},
>>>     {'more': 'logic'}
>>> ] + model_query(model)
>>> }
>>> for s in collection.iterate_structures(dumps(selection)):
>>>     pass
scine_chemoton.utilities.queries.select_calculation_by_structures(job_order, structure_id_list, model)[source]

Sets up a query for calculations with a specific job order and model working on all of the given structures irrespective of their ordering.

Parameters
  • job_order (str) – The job order of the calculations to consider.

  • structure_id_list (List[db.ID]) – The list of structure ids of interest.

  • model (db.Model) – The model the calculations shall use.

Returns

The selection query dictionary.

Return type

dict

scine_chemoton.utilities.queries.stationary_points()[source]

Setup query for 1) optimized structures linked to an aggregate and 2) transition states

Return type

dict

class scine_chemoton.utilities.queries.stop_on_timeout(loop)[source]

Iterator class/function that gracefully stops database loops if the loop cursor times out.

Parameters

: (loop) – Iterator: The original iterator statement of a DB loop.

Examples

>>> def inner_loop():
>>>     for i in range(10):
>>>         if i%2 ==0:
>>>             yield i
>>>         else:
>>>              raise RuntimeError('socket error or timeout , Failed at '+str(i))
>>>
>>> for i in stop_on_timeout(inner_loop()):
>>>     print(i)
class scine_chemoton.utilities.reactive_complexes.ReactiveComplexes[source]

The base class for all reactive complex generators.

class Options[source]

Options attribute to be implemented by child classes

set_options(option_dict)[source]

Sets the options for the ReactiveComplexes from a dictionary. Generates a warning if an option is unknown.

Parameters
  • : (option_dict) – Dict[str: Dictionary with options to be used for generating reactive complexes.

  • Union[bool – Dictionary with options to be used for generating reactive complexes.

  • int – Dictionary with options to be used for generating reactive complexes.

  • float]] – Dictionary with options to be used for generating reactive complexes.

class scine_chemoton.utilities.reactive_complexes.inter_reactive_complexes.InterReactiveComplexes[source]

Class to generate reactive complexes from two structures.

class Options[source]

The options for the InterReactiveComplexes

multiple_attack_points

bool Whether to consider multiple attack points for each active centers involved in intermolecular reactive pairs or just one. (default: True)

number_rotamers

int The number of rotamers to be generated for reactive complexes with at least one active center being an atom. (default: 2)

number_rotamers_two_on_two

int The number of rotamers to be generated for reactive complexes with both reactive centers being diatomic. (default: 1)

generate_reactive_complexes(structure1, structure2, reactive_inter_coords)[source]

Generates a set of reactive complexes for two given structures arising from the given intermolecular reactive pairs.

Parameters
  • structure1 (Structure) – The two structures for which a set of reactive complexes is to be generated. The structures have to be linked to a collection.

  • : (structure2) – scine_database.Structure (Scine::Database::Structure): The two structures for which a set of reactive complexes is to be generated. The structures have to be linked to a collection.

  • reactive_inter_coords (List[List[Tuple[int, int]]]) – A list of intermolecular reactive atom pairs corresponding to one trial reaction coordinate. Each reactive pair tuple has to be ordered such that its first element belongs to structure1 and the second to structure2. The indices are expected to refer to be on structure level, i.e. the first atom of structure2 has index 0 and not index n_atoms(structure1).

Yields
  • inter_coord (Tuple[Tuple[Tuple[int]]) – Tuple of Tuples of one or two atom pairs composing the reactive atoms of the interstructural component of this reactive complex reaction. First atom per pair belongs to structure1, second to structure2.

  • align1, align2 (np.array) – Rotation matrices aligning the two sites along the x-axis (rotations assume that the geometric mean of the reactive atoms of each structure is translated into the origin)

  • xrot (float) – Angle of rotation around the x-axis

  • spread (float) – Spread to be applied along the x-axis between the two structures.

Return type

Generator[Tuple[List[Tuple[int, int]], ndarray, ndarray, float, float], None, None]

scine_chemoton.utilities.reactive_complexes.inter_reactive_complexes.assemble_reactive_complex(atoms1, atoms2, lhs_list, rhs_list, x_alignment_0=None, x_alignment_1=None, x_rotation=0.0, x_spread=2.0, displacement=0.0)[source]

Assembles a reactive complex from the parameters generated by the InterReactiveComplexes class.

Parameters
  • atoms1 (AtomCollection) – The atoms of both structures, that are to be combined in the reactive complex. atoms1 refers to the LHS and atoms2 to the RHS.

  • : (displacement) – utils.AtomCollection: The atoms of both structures, that are to be combined in the reactive complex. atoms1 refers to the LHS and atoms2 to the RHS.

  • lhs_list (List[int]) – Indices of the reactive sites within the reactive complex. The lhs_list should correspond to atoms1 and rhs_list to atoms2.

  • : – List[int]: Indices of the reactive sites within the reactive complex. The lhs_list should correspond to atoms1 and rhs_list to atoms2.

  • : – List[float]: In case of two structures building the reactive complex, this option describes a rotation of the first structure (index 0) that aligns the reaction coordinate along the x-axis (pointing towards +x). The rotation assumes that the geometric mean position of all atoms in the reactive site (lhs_list) is shifted into the origin.

  • length=9 – In case of two structures building the reactive complex, this option describes a rotation of the first structure (index 0) that aligns the reaction coordinate along the x-axis (pointing towards +x). The rotation assumes that the geometric mean position of all atoms in the reactive site (lhs_list) is shifted into the origin.

  • : – List[float]: In case of two structures building the reactive complex, this option describes a rotation of the second structure (index 1) that aligns the reaction coordinate along the x-axis (pointing towards -x). The rotation assumes that the geometric mean position of all atoms in the reactive site (rhs_list) is shifted into the origin.

  • length=9 – In case of two structures building the reactive complex, this option describes a rotation of the second structure (index 1) that aligns the reaction coordinate along the x-axis (pointing towards -x). The rotation assumes that the geometric mean position of all atoms in the reactive site (rhs_list) is shifted into the origin.

  • : – float: In case of two structures building the reactive complex, this option describes a rotation angle around the x-axis of one of the two structures after x_alignment_0 and x_alignment_1 have been applied.

  • : – float: In case of two structures building the reactive complex, this option gives the distance by which the two structures are moved apart along the x-axis after x_alignment_0, x_alignment_1, and x_rotation have been applied.

  • : – float: In case of two structures building the reactive complex, this option adds a random displacement to all atoms (random direction, random length). The maximum length of this displacement (per atom) is set to be the value of this option.

Returns

  • utils.AtomCollection – The reactive complex structure.

  • List[int], List[int] – The LHS and RHS lists with indices adapted to the reactive complex structure.

class scine_chemoton.utilities.reactive_complexes.lebedev_sphere.LebedevSphere[source]

A 5810 point Lebedev unit sphere and the nearest neighbors for each point.

property nearest_neighbors: List[List[int]]

List[List[int]] :: The nearest neighbors of all points on the sphere.

Return type

List[List[int]]

property points: ndarray

np.ndarray :: The points of the Lebedev sphere.

Return type

ndarray

class scine_chemoton.utilities.reactive_complexes.unit_circle.UnitCircle[source]

A class holding a unit circle of 100 points.

property nearest_neighbors: List[List[int]]

List[List[int]] :: The nearest neighbors of all points on the circle.

Return type

List[List[int]]

property points: ndarray

np.ndarray :: The points of the circle.

Return type

ndarray

scine_chemoton.utilities.insert_initial_structure.insert_initial_structure(database, molecule_path, charge, multiplicity, model, label=scine_database.Label.USER_GUESS, job=scine_database.Job, settings=scine_utilities.ValueCollection)[source]

Insert a structure to the database and set up a calculation working on it.

Parameters
  • : (settings) – db.Manager: Database to use.

  • molecule_path (Union[str, utils.AtomCollection]) – Atom collection or path to the xyz file with the structure to be inserted.

  • : – int: Charge of the structure.

  • : – int: Multiplicity of the structure.

  • : – db.Model: Model to be used for the calculation.

  • : – db.Label: Label of the inserted structure, by default db.Label.MINIMUM_GUESS.

  • optional – Label of the inserted structure, by default db.Label.MINIMUM_GUESS.

  • : – db.Job: Job to be performed on the initial structure, by default db.Job(‘scine_geometry_optimization’).

  • optional – Job to be performed on the initial structure, by default db.Job(‘scine_geometry_optimization’).

  • : – utils.ValueCollection: Job settings, by default none.

  • optional – Job settings, by default none.

Returns

The inserted structure and the calculation generated for it

Return type

db.Structure, db.Calculation

class scine_chemoton.utilities.masm.ComponentDistanceTuple(mol_idx, components, distance)
property components

Alias for field number 1

property distance

Alias for field number 2

property mol_idx

Alias for field number 0

scine_chemoton.utilities.masm.deserialize_molecules(structure)[source]

Retrieves all molecules stored for a structure

Parameters

: (structure) – db.Structure: The structure whose contained molecules to deserialize

Returns

A list of all the molecules contained in the database structure

Return type

molecules :: List[masm.Molecule]

scine_chemoton.utilities.masm.distinct_atoms(mol, h_only)[source]

Generates a list of distinct atom indices

Parameters
  • : (h_only) – masm.Molecule: A molecule whose atoms to list distinct atoms for

  • : – bool: Whether to only apply ranking deduplication to hydrogen atoms

Returns

A list of ranking-distinct atoms

Return type

components :: List[int]

scine_chemoton.utilities.masm.distinct_components(mol, h_only)[source]

Generates a flat map of atom index to component identifier

Parameters
  • : (h_only) – masm.Molecule: A molecule whose atoms to generate distinct components for

  • : – bool: Whether to only apply ranking deduplication to hydrogen atoms

Returns

A flat per-atom index mapping to a component index. Contains only sequential numbers starting from zero.

Return type

components :: List[int]

scine_chemoton.utilities.masm.distinguish_components(components, map_unary)[source]

Splits components by the result of a unary mapping function

Parameters
  • : (map_unary) – List[int]: A per-index mapping to a component index. Must contain only sequential numbers starting from zero.

  • : – Callable[[int]: A unary callable that is called with an index, not a component index, yielding some comparable type. Components of indices are then split by matching results of invocations of this callable.

  • Any] – A unary callable that is called with an index, not a component index, yielding some comparable type. Components of indices are then split by matching results of invocations of this callable.

Returns

A per-index mapping to a component index. Contains only sequential numbers starting from zero.

Return type

components :: List[int]

scine_chemoton.utilities.masm.get_atom_pairs(structure, distance_bounds, prune='None', superset=None)[source]

Gets a list of all atom pairs whose graph distance is smaller or equal to max_graph_distance and larger or equal to min_graph_distance on the basis of the interpreted graph representation.

Parameters
  • : (superset) – utils.AtomCollection: The atom collection that is investigated.

  • : – Tuple[int: The minimum and maximum distance between two points that is allowed so that they are considered a valid atom pair.

  • int] – The minimum and maximum distance between two points that is allowed so that they are considered a valid atom pair.

  • : – str: Whether to prune atom pairings by molassembler’s ranking distinct atoms descriptor. Allowed values: ‘None’, ‘Hydrogen’, ‘All’

  • : – Optional[Set[Tuple[int: Optional superset of pairs to filter. If set, will filter the passed set. Otherwise generates atom pairings from all possible pairs in the molecule.

  • int]]] – Optional superset of pairs to filter. If set, will filter the passed set. Otherwise generates atom pairings from all possible pairs in the molecule.

Returns

The indices of valid atom pairs.

Return type

pairs :: Set[Tuple[int, int]]

scine_chemoton.utilities.masm.make_sorted_pair(a, b)[source]
Return type

Tuple[int, int]

scine_chemoton.utilities.masm.mol_from_cbor(cbor_str)[source]

Convert base-64 encoded CBOR to a molassembler Molecule

Converts a single base-64 encoded CBOR string (no ‘;’ separator as stored in the database) into a molecule

Parameters

: (cbor_str) – str: String to deserialize into a Molecule

Returns

The deserialized molecule

Return type

molecule :: masm.Molecule

scine_chemoton.utilities.masm.mol_to_cbor(mol)[source]

Convert a molecule into a base-64 encoded CBOR serialization

Parameters

: (mol) – masm.Molecule: Molecule to serialize

Returns

The string-serialized molecule representation

Return type

serialization :: str

scine_chemoton.utilities.masm.pruned_atom_pairs(molecules, idx_map, distance_bounds, prune)[source]
Return type

Set[Tuple[int, int]]

scine_chemoton.utilities.masm.unpruned_atom_pairs(molecules, idx_map, distance_bounds)[source]

Helper function to generate the set of unpruned atom pairs

Return type

Set[Tuple[int, int]]