Reading SMILES with MX

December 03, 2008

The latest release of MX, the Java toolkit for cheminformatics, now supports reading a subset of SMILES strings. Although incomplete, full support for this feature is planned within a few releases.

To get an idea of how to use the new SMILES reader, we can use interactive JRuby. Assuming we've downloaded the mx-0.105.0 jarfile to our working directory, we can use:

$ jirb
irb(main):001:0> require 'mx-0.105.0.jar'                            
=> true
irb(main):002:0> import
=> Java::ComMetamolecularMxIoDaylight::SMILESReader
irb(main):003:0> bromobenzene = 'C1=CC=CC=C1Br'    
=> #<Java::ComMetamolecularMxModel::DefaultMolecule:0x8a2023>
irb(main):004:0> bromobenzene.count_atoms                            
=> 7
irb(main):005:0> bromobenzene.get_atom(6).get_symbol                 
=> "Br"