Cool,
What about the function getCharge(). Moreover, I get a NameError method
when caling the following methods:
- getMass, getMassno, getAtno.
Cheers,
Yannick
BTW thanks for the quick reply. This is awesome.
On Mon, Feb 24, 2014 at 4:12 PM, John May <[email protected]> wrote:
> AtomContainerManipulator and CDKHydrogenAdder again - you had the method
> in your SMARTS example. You need to perceive atom types and add hydrogens.
>
> Also remember these are indices so atom 1 = 0, atom 2 = 1 and not how one
> would number atoms in an editor.
>
> J
>
> On 24 Feb 2014, at 23:07, Yannick .Djoumbou <[email protected]> wrote:
>
> Exactly.
> Having added a new atom and linked it to an already existing atom, I
> realize that specific properties of the atom have not been set
> automatically. For example, the AtomTypeName of the newly added atom is
> still nil. How do I get these to be set?
>
> In the current example, mol.getAtom(2).getAtomTypeName() and
> mol.getAtom(2).getCharge() both return nil.
>
> Cheers,
>
> Yannick
>
>
> On Mon, Feb 24, 2014 at 3:46 PM, John May <[email protected]> wrote:
>
>> 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.
>> John
>>
>> On 24 Feb 2014, at 22:42, Yannick .Djoumbou <[email protected]> wrote:
>>
>> However, this seems to work
>>
>> Bond.newI(mol.getAtom(0),mol.getAtom(1),Bond::Order::SINGLE).
>> And by the way, Bond.new does not work with (FixNum, FixNum, IBond.Order,
>> IBond.Stereo) but with arguments (IAtom, IAtom, IBond.Order, IBond.Stereo).
>>
>> Thanks,
>>
>> Yannick
>>
>>
>> On Mon, Feb 24, 2014 at 3:35 PM, Yannick .Djoumbou
>> <[email protected]>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 Bond.new(0, 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.
>>>
>>> Yannick
>>>
>>>
>>>
>>> On Mon, Feb 24, 2014 at 3:08 PM, John May <[email protected]> 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'
>>>>
>>>>
>>>> or
>>>>
>>>> import 'org.openscience.cdk.interfaces.IBond'
>>>>
>>>>
>>>> with IBond.Order.SINGLE
>>>>
>>>> J
>>>>
>>>> On 24 Feb 2014, at 21:53, Yannick .Djoumbou <[email protected]>
>>>> wrote:
>>>>
>>>> HI,
>>>>
>>>> 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
>>>>
>>>> Cheers,
>>>> Yannick
>>>>
>>>>
>>>> On Mon, Feb 24, 2014 at 2:15 PM, John May <[email protected]> wrote:
>>>>
>>>>> Sorry, I was going on what you had and presumed ruby was loading Order
>>>>> directly. The full name is IBond.Order.SINGLE.
>>>>>
>>>>> Bond.new(mol.getAtom(0), mol.getAtom(1), IBond.Order.SINGLE)
>>>>>
>>>>>
>>>>> - John
>>>>>
>>>>> On 24 Feb 2014, at 21:10, Yannick .Djoumbou <[email protected]>
>>>>> wrote:
>>>>>
>>>>> Thanks for the very quick reply.
>>>>>
>>>>> I actually use the Bond class.
>>>>> I've tried the following options:
>>>>> - bond = Bond.new(mol.getAtom(0), mol.getAtom(1), Order.SINGLE)
>>>>>
>>>>> NoMethodError: undefined method `SINGLE' for
>>>>> Java::OrgOpenscienceCdkInterfaces::Order:Class
>>>>> from (irb):37:in `evaluate'
>>>>> from org/jruby/RubyKernel.java:1121:in `eval'
>>>>> from org/jruby/RubyKernel.java:1517:in `loop'
>>>>> from org/jruby/RubyKernel.java:1282:in `catch'
>>>>> from org/jruby/RubyKernel.java:1282:in `catch'
>>>>>
>>>>> - mol.addBond(0,1,Order.Single)
>>>>>
>>>>> NoMethodError: undefined method `Single' for
>>>>> Java::OrgOpenscienceCdkInterfaces::Order:Class
>>>>> from (irb):38:in `evaluate'
>>>>> from org/jruby/RubyKernel.java:1121:in `eval'
>>>>> from org/jruby/RubyKernel.java:1517:in `loop'
>>>>> from org/jruby/RubyKernel.java:1282:in `catch'
>>>>> from org/jruby/RubyKernel.java:1282:in `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?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Yannick
>>>>>
>>>>>
>>>>> On Mon, Feb 24, 2014 at 1:21 PM, John May <[email protected]> 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<http://docs.oracle.com/javase/tutorial/java/concepts/interface.html>
>>>>>> 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)
>>>>>>
>>>>>> Bond.new(mol.getAtom(0), 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<http://pele.farmbio.uu.se/nightly/api/org/openscience/cdk/tools/manipulator/AtomContainerManipulator.html#convertImplicitToExplicitHydrogens(org.openscience.cdk.interfaces.IAtomContainer)>
>>>>>> .
>>>>>>
>>>>>> AtomContainerManipulator.convertImplicitToExplicitHydrogens(mol)
>>>>>>
>>>>>>
>>>>>> 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]");
>>>>>> sqt.matches(mol);
>>>>>> for (List<Integer> mapping : sqt.getAllMappings()) {
>>>>>> for (int i = 0; i < mapping.size(); i++) {
>>>>>> System.out.println(mapping.get(i) + 1);
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> Hope that helps,
>>>>>> John
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user