Egon’s introductory talk about getting started with CDK
After my opening talk at the CDK workshop, Egon Willighagen gave an introduction on how to get started with the CDK. He uses the scripting environment Groovy to demonstrate things.
Egon has prepared a LaTeX document with his teaching material as well as the code examples on at http://pele.farmbio.uu.se/groovy. Turns out that Groovy scripting is a really nice environment for writing CDK code. You can say things like
molecule = new Molecule();
atom = new Atom(Elements.CARBON);
matcher = CDKAtomTypeMatcher.getInstance(
type = matcher.findMatchingAtomType(molecule, atom);
println “Atom type: $type.atomTypeName”
As you can see, you do not need to handle things like Exceptions or Data Types. Groovy, like most other scripting environments will handle that for you.
If CDK.jar is in your CLASSPATH, you can run this code inside GroovyConsole and you’ll get “C.sp3” as an output.
Egon’s course material have many more examples.