molreps package¶
Subpackages¶
Submodules¶
molreps.descriptors module¶
Common Molecular descriptors for (classical) machine learning.
Note they are defined only for one molecule not for batches.
molreps.graph module¶
Main graph generator for making molecular graphs.
It uses networkx as graph interface and a mol object from rdkit, ase, pymatgen or similar.
- class molreps.graph.MolGraph(mol=None, **kwargs)[source]¶
Bases:
networkx.classes.graph.Graph
Molecular Graph which inherits from networkx graph.
- make(nodes=None, edges=None, state=None)[source]¶
Construct graph from mol instance.
The input is a dictionary of properties to calculate. The dict-key can be chosen freely and will be graph attributes. The identifier is a string for built-in function e.g. ‘proton’. Or if args have to be provided: key : {‘class’: identifier, ‘args’:{ args_dict }} Otherwise you can provide a custom method via the the identifier dict of the form: key : {‘class’: function/class, ‘args’:{ args_dict }} The callable object of ‘class’ must accept as first argument this instance. Then key=key and then additional args from ‘args’:{ args_dict }.
- Parameters
- Raises
AttributeError – If mol not found.
ValueError – If identifier dict is incorrect.
TypeError – If property info is incorrect.
- Returns
This instance.
- Return type
self
- to_tensor(nodes=None, edges=None, state=None, trafo_nodes=None, trafo_edges=None, trafo_state=None, default_nodes=None, default_edges=None, default_state=None, out_tensor=<built-in function array>)[source]¶
Convert the nx graph into a dict of tensors which can be directly used for GCN.
The desired attributes must be given with a suitable conversion function plus default value. Here, one can add also the type of tensor or one-Hot mappings etc. and its default/zero state, if the attributes is not specified for a specific node/edge. The properties are always mapped to numpy arrays and then converted to out_tensor.
- Parameters
nodes (list, optional) – Nodes properties. Defaults to [‘proton’].
edges (list, optional) – Edge properties. Defaults to [‘bond’].
state (list, optional) – State Properties. Defaults to [‘size’].
trafo_nodes (dict, optional) – Transformation function for nodes. Defaults to np.array.
trafo_edges (dict, optional) – Transformation function for edges. Defaults to np.array.
trafo_state (dict, optional) – Transformation function for state. Defaults to np.array.
default_nodes (dict, optional) – Zero Nodes properties. Defaults to np.array(0).
default_edges (dict, optional) – Zero Edge properties. Defaults to np.array(0).
default_state (dict, optional) – Zero State Properties. Defaults to np.array(0).
out_tensor (func) – Final Function for each node/edge/state. Default is np.array.
- Returns
Graph tensors as dictionary.
- Return type