This example code
supplements Topology Analyser Plugin
shortestPath
functionality with retrieval of atoms on the shortest path. When multiple, equal length shortest paths are
present, all of them can be enumerated.
IMPORTANT: This example is provided AS-IS. Please note that in the future this functionality might be made available in the plugin and/or through other utility classes, possibly in an incompatible way.
The code in this example depends on Chemaxon proprietary jchem.jar
available
in JChem Engines platform independent (.zip) distribution. This
distribution can be downloaded manually or retrieved from the Chemaxon Public Repository
with proper credentials. This Gradle project uses the second approach.
- Chemaxon licenses for the used functionalities are available and installed. For details, see https://docs.chemaxon.com/display/docs/license-installation.md
- Access to the Chemaxon Public Repository. For details, see https://docs.chemaxon.com/display/docs/public-repository.md
Call
./gradlew build -PcxnHubUser=<YOUR_PASS_EMAIL> -PcxnHubPassword=<YOUR_HUB_API_KEY>
or, if you are using Windows,
./gradlew.bat build -PcxnHubUser=<YOUR_PASS_EMAIL> -PcxnHubPassword=<YOUR_HUB_API_KEY>
./gradlew run -PcxnHubUser=<YOUR_PASS_EMAIL> -PcxnHubPassword=<YOUR_HUB_API_KEY>
or, if you are using Windows,
./gradlew.bat run -PcxnHubUser=<YOUR_PASS_EMAIL> -PcxnHubPassword=<YOUR_HUB_API_KEY>
The expected output:
Find shortest paths in CN1C=NC2=C1C(=O)N(C(=O)N2C)C Caffeine
Using central atom # 0
FindShortestPaths instance: a1: 0, shortest distances from a1: [0, 1, 2, 3, 3, 2, 3, 4, 4, 5, 6, 4, 5, 5]
0 - 1 length: 1, path: [0, 1]
0 - 2 length: 2, path: [0, 1, 2]
0 - 3 length: 3, path: [0, 1, 2, 3]
0 - 4 length: 3, path: [0, 1, 5, 4]
0 - 5 length: 2, path: [0, 1, 5]
0 - 6 length: 3, path: [0, 1, 5, 6]
0 - 7 length: 4, path: [0, 1, 5, 6, 7]
0 - 8 length: 4, path: [0, 1, 5, 6, 8]
0 - 9 length: 5, path: [0, 1, 5, 6, 8, 9]
all paths:
[0, 1, 5, 6, 8, 9]
[0, 1, 5, 4, 11, 9]
union of all paths:
{0, 1, 4, 5, 6, 8, 9, 11}
0 - 10 length: 6, path: [0, 1, 5, 6, 8, 9, 10]
all paths:
[0, 1, 5, 6, 8, 9, 10]
[0, 1, 5, 4, 11, 9, 10]
union of all paths:
{0, 1, 4, 5, 6, 8, 9, 10, 11}
0 - 11 length: 4, path: [0, 1, 5, 4, 11]
0 - 12 length: 5, path: [0, 1, 5, 4, 11, 12]
0 - 13 length: 5, path: [0, 1, 5, 6, 8, 13]
Using central atom # 1
FindShortestPaths instance: a1: 1, shortest distances from a1: [1, 0, 1, 2, 2, 1, 2, 3, 3, 4, 5, 3, 4, 4]
1 - 2 length: 1, path: [1, 2]
1 - 3 length: 2, path: [1, 2, 3]
1 - 4 length: 2, path: [1, 5, 4]
1 - 5 length: 1, path: [1, 5]
1 - 6 length: 2, path: [1, 5, 6]
1 - 7 length: 3, path: [1, 5, 6, 7]
1 - 8 length: 3, path: [1, 5, 6, 8]
1 - 9 length: 4, path: [1, 5, 6, 8, 9]
all paths:
[1, 5, 6, 8, 9]
[1, 5, 4, 11, 9]
union of all paths:
{1, 4, 5, 6, 8, 9, 11}
1 - 10 length: 5, path: [1, 5, 6, 8, 9, 10]
all paths:
[1, 5, 6, 8, 9, 10]
[1, 5, 4, 11, 9, 10]
union of all paths:
{1, 4, 5, 6, 8, 9, 10, 11}
1 - 11 length: 3, path: [1, 5, 4, 11]
1 - 12 length: 4, path: [1, 5, 4, 11, 12]
1 - 13 length: 4, path: [1, 5, 6, 8, 13]
...
Sanity tests are available in src/test/java/
. Use test
task to run them:
./gradlew test -PcxnHubUser=<YOUR_PASS_EMAIL> -PcxnHubPassword=<YOUR_HUB_API_KEY>
or, if you are using Windows,
./gradlew.bat test -PcxnHubUser=<YOUR_PASS_EMAIL> -PcxnHubPassword=<YOUR_HUB_API_KEY>
This project is distributed under the Apache License 2.0. Some dependencies of this project are Chemaxon proprietary products which are not covered by this license. Please note that redistribution of Chemaxon proprietary products is not allowed.