Jun
28
#metsoc2015 Converting SMILES annotation into InChIKey annotation
One of the questions I had in the hackathon today is about how to use the CDK to convert SMILES string into InChIs and InChIKeys (see doi:10.1186/1758-2946-5-14). So, here goes. This is the Groovy variant, though you can access the CDK just as well in other programming languages (Python, Java, JavaScript). We'll use the binary jar for CDK 1.5.10. We can then run code, say test.groovy, using the CDK with:
groovy -cp cdk-1.5.10.jar test.groovy
With that out of the way, let's look at the code. Let's assume we start with a text file with one SMILES string on each line, say test.smi, then we parse this file with:
new File("test.smi").eachLine { line ->
mol = parser.parseSmiles(line)
}
This already parses the SMILES string into a chemical graph.
groovy -cp cdk-1.5.10.jar test.groovy
With that out of the way, let's look at the code. Let's assume we start with a text file with one SMILES string on each line, say test.smi, then we parse this file with:
new File("test.smi").eachLine { line ->
mol = parser.parseSmiles(line)
}
This already parses the SMILES string into a chemical graph.