Usage

To generate graphs we need to setup a GraphGenerator object that operates based on a set of settings that correspond to a specific representation. The easiest way to do so is to use one of the implemented settings used in the publication. In the example below we use the baseline representation. After the GraphGenerator is set up we can use it to generate graphs of molecules. For this we need to call the .generate_graph() function providing it with a dictionary (qm_data_dict) of the relevant QM data. The required information and correct formatting of this dictionary is detailed in section Input.

 1 import HyDGL
 2
 3 # get the QM data dictionary for the moleulce
 4 qm_data_dict = # your code for obtaining the dictionary
 5
 6 # get the default settings for baseline graphs
 7 ggs = HyDGL.GraphGeneratorSettings.baseline()
 8 # setup the graph generator with these settings
 9 gg = HyDGL.GraphGenerator(settings=ggs)
10 # generate a graph according to these settings using a
11 # dict of the relevant QM data of a specific molecule
12 hydgl_graph = gg.generate_graph(HyDGL.QmData.from_dict(qm_data_dict))

Aside from .baseline() also the .uNatQ() and .dNatQ() representations are implemented. Their exact specifications can be found in the publication.

The above code will generate the graphs without target values for the use in machine learning applications. To include such targets we can pass a list of target identifiers to the constructor to imbue all generated graphs with these targets. For this we need to make use of the enumeration class QmTarget. In the example below we use two targets, the polarisability and dipole moment.

 1 import HyDGL
 2
 3 # get the QM data dictionary for the moleulce
 4 qm_data_dict = # your code for obtaining the dictionary
 5
 6 # set up the list of target identifiers
 7 target_list = [HyDGL.enums.QmTarget.POLARISABILITY,
 8                HyDGL.enums.QmTarget.TZVP_DIPOLE_MOMENT]
 9
10 # get the default settings for baseline graphs
11 ggs = HyDGL.GraphGeneratorSettings.baseline(target_list)
12 # setup the graph generator with these settings
13 gg = HyDGL.GraphGenerator(settings=ggs)
14 # generate a graph according to these settings using a
15 # dict of the relevant QM data of a specific molecule
16 hydgl_graph = gg.generate_graph(HyDGL.QmData.from_dict(qm_data_dict))

Graph export

Graph objects can be exported either as networkx or pytorch_geometric graphs.

1 # get networkx object
2 nx_graph = hydgl_graph.get_networkx_graph_object()
3 # get pytorch object
4 pyg_graph = hydgl_graph.get_pytorch_data_object()

Using the respective libraries you can further manipulate the graphs of write them to disc.

This will display the graph in your browser and is done by using the plotly library. For advanced settings concerning the rendering of plots refer to their documentation.

Graph import

Graph objects can be imported from networkx using:

1 hydgl_graph = Graph.from_networkx(nx_graph)

This will display the graph in your browser and is done by using the plotly library. For advanced settings concerning the rendering of plots refer to their documentation.

Graph visualisation

You can visualise the graph you generated by calling the .visualise() function of the graph object:

1 graph.visualise()

This will display the graph in your browser and is done by using the plotly library. For advanced settings concerning the rendering of plots refer to their documentation.