However, this seems to work

And by the way, does not work with (FixNum, FixNum, IBond.Order, IBond.Stereo)  but with arguments (IAtom, IAtom, IBond.Order, IBond.Stereo).



On Mon, Feb 24, 2014 at 3:35 PM, Yannick .Djoumbou <> wrote:
Eaxctly, I understand the relationship between IBond and Order.
I tried both options but they do not work. Ruby seems to just represent Order as a method of the IBond class.

I also tried this:
 - I deleted line  >> import 'org.openscience.cdk.interfaces.IBond::Order'

- I ran, 1, IBond::Order.SINGLE), but got the following message:

NoMethodError: undefined method `SINGLE' for Java::OrgOpenscienceCdkInterfaces::Order:Class

With this call, jruby seems to recognize Order as a class, but SINGLE as a method for the class Order.


On Mon, Feb 24, 2014 at 3:08 PM, John May <> wrote:
The Order is a not method of IBond it is an nested class - perhaps the wrappers can’t represent it but it's pretty common so I doubt that’s the case.

I’m flying blind having only spent about 5 mins in Ruby but either try

import ‘org.openscience.cdk.interfaces.IBond.Order'


import ‘org.openscience.cdk.interfaces.IBond’ 

with IBond.Order.SINGLE


On 24 Feb 2014, at 21:53, Yannick .Djoumbou <> wrote:


I have imported the following classes relative to bonds:

  import 'org.openscience.cdk.Bond'
  import 'org.openscience.cdk.interfaces.IBond'
  import 'org.openscience.cdk.interfaces.IBond$Order'
  import 'org.openscience.cdk.interfaces.IBond$Stereo'

When using the command you just mentioned, I still get the following error:

  NoMethodError: undefined method `Order' for Java::OrgOpenscienceCdkInterfaces::IBond:Module


On Mon, Feb 24, 2014 at 2:15 PM, John May <> wrote:
Sorry, I was going on what you had and presumed ruby was loading Order directly. The full name is IBond.Order.SINGLE., mol.getAtom(1), IBond.Order.SINGLE)

- John

On 24 Feb 2014, at 21:10, Yannick .Djoumbou <> wrote:

Thanks for the very quick reply.

I actually use the Bond class.
I've tried the following options: 
 - bond =, mol.getAtom(1), Order.SINGLE)

       NoMethodError: undefined method `SINGLE' for Java::OrgOpenscienceCdkInterfaces::Order:Class
from (irb):37:in `evaluate'
from org/jruby/ `eval'
from org/jruby/ `loop'
from org/jruby/ `catch'
from org/jruby/ `catch'

 - mol.addBond(0,1,Order.Single)
     NoMethodError: undefined method `Single' for Java::OrgOpenscienceCdkInterfaces::Order:Class
from (irb):38:in `evaluate'
from org/jruby/ `eval'
from org/jruby/ `loop'
from org/jruby/ `catch'
from org/jruby/ `catch'

I guess it comes from the fact that I am using Jruby. I should normally not have a problem with this. It's kind of confusing. Do you have a hint?



On Mon, Feb 24, 2014 at 1:21 PM, John May <> wrote:
Hi Yannick,

I don’t now about ruby wrappers but can answer 2 and 3. Also looks like rcdk is used for ruby and R bindings which is a little confusing.

2) IBond is an interface you need to use the concrete class. There are a couple of way to do this, you can use Bond concrete class (silent package is best), mol.getAtom(1), Order.SINGLE)

use a builder - 

SilentChemObjectBuilder.getInstance().newInstance(IBond.class, mol.getAtom(0), mol.getAtom(1), Order.SINGLE)

or use the convince method on the molecule - 

molcule.addBond(0,1, Order.Single);

3-1) CDKHydrogenAdder is only for implicit hydrogens - you only need this if you have null hydrogen values. For explicit hydrogens use the manipulator.


3-2) You have a SMARTS pattern and so need to use the SMARTSQueryTool. I don’t think that will be available in the version you are using. Here’s the java code anyways.

SMARTSQueryTool sqt = new SMARTSQueryTool(“[#8]=[#6]”);
for (List<Integer> mapping : sqt.getAllMappings()) {
    for (int i = 0; i < mapping.size(); i++) {
        System.out.println(mapping.get(i) + 1);

Hope that helps,