Skip to content

Commit

Permalink
deploy: 9cba958
Browse files Browse the repository at this point in the history
  • Loading branch information
SGenheden committed Dec 17, 2024
0 parents commit 9bc5129
Show file tree
Hide file tree
Showing 33 changed files with 6,438 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: d37b6813f3721c52ccd0afc8e5b91eea
tags: 645f666f9bcd5a90fca523b33c5a78b7
Empty file added .nojekyll
Empty file.
35 changes: 35 additions & 0 deletions _sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
route-distances documentation
===========================

route-distances contains routines and tools to compute distances between synthesis routes and to cluster them.

This is a project mostly targeting developers and researchers, not so much end-users.

There is one command line tool to process AiZynthFinder output:

.. code-block:: bash
cluster_aizynth_output --files finder_output1.hdf5 finder_output2.hdf5 --output finder_distances.hdf5
This will add a column to table in the merged ``hdf5`` file called ``distance_matrix`` with the tree edit distances, and
another column called ``distances_time`` with the timings of the calculations.

To cluster the routes as well add the ``--ncluster`` flag

.. code-block:: bash
cluster_aizynth_output --files finder_output1.hdf5 finder_output2.hdf5 --output finder_distances.hdf5 --nclusters 0
Giving 0 as the number of clusters will trigger automatic optimization of the number of clusters.
Two columns will be added to the table: ``cluster_labels`` and ``cluster_time`` holding the
cluster labels for each route and the timings of the calculation, respectively.




.. toctree::
:hidden:

python
route_distances
7 changes: 7 additions & 0 deletions _sources/modules.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
route_distances
===============

.. toctree::
:maxdepth: 4

route_distances
91 changes: 91 additions & 0 deletions _sources/python.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Python interface
================

This page gives a quick overview of how to use the Python classes and methods to compute
distances between routes.

Input format
------------

The routes or reaction tree are input as dictionaries that can be loaded from e.g. a JSON file.
The structure of the dictionary follows the output format used by AiZynthFinder, but only a small
number of fields are necessary. The structure is checked by the code, and if the validation fails,
an exception will be raised.

The structure definition and validation code can be found in the `route_distance.validation` module.

The input structure should be a the type `MoleculeNode` which is a dictionary with the following
fields

* smiles - the SMILES string of the molecule represented by the node
* type - should be the string "mol"
* children - an *optional* list, containing at most one dictionary of type `ReactionNode`

The `ReactionNode` type is a dictionary with the following fields

* type - should be the string "reaction"
* children - a list of dictionaries of type `MoleculeNode`

It is easy to realize that this is a recursive definition. All extra fields in the dictionaries are ignored.
And example dictionary is shown below

.. code-block:: python
{
"smiles": "CCCCOc1ccc(CC(=O)N(C)O)cc1",
"type": "mol",
"children": [
{
"type": "reaction",
"children": [
{
"smiles": "CCCCOc1ccc(CC(=O)Cl)cc1",
"type": "mol"
},
{
"smiles": "CNO",
"type": "mol"
}
]
}
]
}
Calculating TED
---------------

To compute the distance between two routes, we will first load them from a JSON file

.. code-block:: python
import json
with open("my_routes.json", "r") as fileobj:
routes = json.load(fileobj)
Then we will create two wrapper objects that will take care of the calculations

.. code-block:: python
from route_distances.ted.reactiontree import ReactionTreeWrapper
wrapper1 = ReactionTreeWrapper(routes[0], content="both")
wrapper2 = ReactionTreeWrapper(routes[1], content="both")
The argument `content` can be `molecules`, `reactions` or `both` and specify what nodes are included
in the calculation.

To calculate the distance between these two routes, we simple do

.. code-block:: python
wrapper1.distance_to(wrapper2)
If we have many routes, a distance matrix can be calculate using

.. code-block:: python
from route_distances.ted.distances import distance_matrix
distance_matrix(routes, content="both")
The docstrings of all modules, classes and methods can be consulted :doc:`here <route_distances>`
69 changes: 69 additions & 0 deletions _sources/route_distances.lstm.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
route\_distances.lstm package
=============================

Submodules
----------

route\_distances.lstm.data module
---------------------------------

.. automodule:: route_distances.lstm.data
:members:
:undoc-members:
:show-inheritance:

route\_distances.lstm.defaults module
-------------------------------------

.. automodule:: route_distances.lstm.defaults
:members:
:undoc-members:
:show-inheritance:

route\_distances.lstm.features module
-------------------------------------

.. automodule:: route_distances.lstm.features
:members:
:undoc-members:
:show-inheritance:

route\_distances.lstm.inference module
--------------------------------------

.. automodule:: route_distances.lstm.inference
:members:
:undoc-members:
:show-inheritance:

route\_distances.lstm.models module
-----------------------------------

.. automodule:: route_distances.lstm.models
:members:
:undoc-members:
:show-inheritance:

route\_distances.lstm.optim module
----------------------------------

.. automodule:: route_distances.lstm.optim
:members:
:undoc-members:
:show-inheritance:

route\_distances.lstm.utils module
----------------------------------

.. automodule:: route_distances.lstm.utils
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: route_distances.lstm
:members:
:undoc-members:
:show-inheritance:
47 changes: 47 additions & 0 deletions _sources/route_distances.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
route\_distances package
========================

Subpackages
-----------

.. toctree::
:maxdepth: 4

route_distances.lstm
route_distances.ted
route_distances.tools

Submodules
----------

route\_distances.clustering module
----------------------------------

.. automodule:: route_distances.clustering
:members:
:undoc-members:
:show-inheritance:

route\_distances.route\_distances module
----------------------------------------

.. automodule:: route_distances.route_distances
:members:
:undoc-members:
:show-inheritance:

route\_distances.validation module
----------------------------------

.. automodule:: route_distances.validation
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: route_distances
:members:
:undoc-members:
:show-inheritance:
37 changes: 37 additions & 0 deletions _sources/route_distances.ted.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
route\_distances.ted package
============================

Submodules
----------

route\_distances.ted.distances module
-------------------------------------

.. automodule:: route_distances.ted.distances
:members:
:undoc-members:
:show-inheritance:

route\_distances.ted.reactiontree module
----------------------------------------

.. automodule:: route_distances.ted.reactiontree
:members:
:undoc-members:
:show-inheritance:

route\_distances.ted.utils module
---------------------------------

.. automodule:: route_distances.ted.utils
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: route_distances.ted
:members:
:undoc-members:
:show-inheritance:
37 changes: 37 additions & 0 deletions _sources/route_distances.tools.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
route\_distances.tools package
==============================

Submodules
----------

route\_distances.tools.cluster\_aizynth\_output module
------------------------------------------------------

.. automodule:: route_distances.tools.cluster_aizynth_output
:members:
:undoc-members:
:show-inheritance:

route\_distances.tools.prepare\_aizynthfinder\_output module
------------------------------------------------------------

.. automodule:: route_distances.tools.prepare_aizynthfinder_output
:members:
:undoc-members:
:show-inheritance:

route\_distances.tools.train\_lstm\_model module
------------------------------------------------

.. automodule:: route_distances.tools.train_lstm_model
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: route_distances.tools
:members:
:undoc-members:
:show-inheritance:
Loading

0 comments on commit 9bc5129

Please sign in to comment.