Yes - that would not make sense, the bond holds atom references and knows nothing about the molecule. Giving it indices (FixNum) only makes sense in the context of a molecule which is where the addBond method is. The method may be missing on this version (1.2.2 i believe) which is nearly 5 years old.


On 24 Feb 2014, at 22:42, Yannick .Djoumbou <> wrote:

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,