CDK jobs repository contains Java code running molecular property predictions using the Chemistry Development Kit. These are made available as a "tool", typically represented as a Java class. Those tools become available as:
- a command line application
- a command line application running in a Docker container
- a Squonk2 job that runs using the Docker container
For more details on Squonk2 jobs look at our main virtual-screening repo that contains more documentation and examples.
We anticipate a wider range of functions being incoporated as additional tools in the futures. Suggestions and contributions are welcome.
One purpose of this repo is as a prototype for creating Squonk2 jobs using Java (most current ones are Python based).
This repo illustrates:
- Creating a Java class that can be executed as CLI application. See DescriptorsExec.java. We use the Apache Commons CLI library for handling the command line options.
- Use the Gradle build tool for building the Java code. See app/build.gradle for details.
- Create a Docker container image from the Dockerfile, pushed to DockerHub.
- Write the Squonk2 job definition, including a jote test. See data-manager/cdk.yaml.
You need JDK 21 and Docker. Gradle itself comes from the wrapper, so
./gradlew is all you need; it does not download a JDK for you, and the build
declares a Java 21 toolchain, so a JDK 21 has to be on the machine (or on
org.gradle.java.installations.paths).
$ ./gradlew testTo run a tool through gradle:
$ ./gradlew run --args="--all -i ../data/dhfr_3d.sdf -o foo.sdf"
> Task :app:run
2022-04-06T09:05:19+00:00 # INFO -EVENT- squonk.jobs.cdk.DescriptorsExec --all -i ../data/dhfr_3d.sdf -o foo.sdf
2022-04-06T09:05:19+00:00 # INFO -EVENT- Calculating 10 descriptors
2022-04-06T09:05:22+00:00 # INFO -EVENT- Processed 756 molecules, 0 errors.
2022-04-06T09:05:22+00:00 # INFO -COST- 7560.0 1
BUILD SUCCESSFUL in 3sThis runs the default class which reads a SDF, calculates all properties and writes out a new SDF with those
calculations as additional properties. See the build.gradle application task for more details.
Note that this is effectively executed from the app directory, hence the path to the test SDF.
Build the docker container image:
$ docker build -f Dockerfile . -t informaticsmatters/squonk2-cdk:latestThe Dockerfile is a two-stage build: it runs ./gradlew installDist in a JDK
image and copies the result onto a JRE, so it needs nothing installed locally
beyond Docker. The image used to be generated by the bmuschko
docker-java-application Gradle plugin; it is a plain Dockerfile now, which is
what CI builds.
Running the docker container:
$ docker run -it -v $PWD:$PWD -w $PWD -u 1000:1000 informaticsmatters/squonk2-cdk:latest java squonk.jobs.cdk.DescriptorsExec --all -i data/dhfr_3d.sdf -o foo.sdf
2022-04-06T09:14:40+00:00 # INFO -EVENT- squonk.jobs.cdk.DescriptorsExec --all -i data/dhfr_3d.sdf -o foo.sdf
2022-04-06T09:14:40+00:00 # INFO -EVENT- Calculating 10 descriptors
2022-04-06T09:14:44+00:00 # INFO -EVENT- Processed 756 molecules, 0 errors.
2022-04-06T09:14:44+00:00 # INFO -COST- 7560.0 1Running the Job tests:
jote runs the tests declared in the Job Definition against a locally built image. The manifest is not at jote's default path, so name it:
$ docker build -f Dockerfile . -t informaticsmatters/squonk2-cdk:ci
$ jote -m manifest-cdk.yaml --image-tag ci--image-tag overrides the tag in the Job Definition, so a new image can be
tested without editing the YAML.