Dear John
Thanks for your valuable insight.
I messed up with the indices in my first post where I numbered atoms
sequentially for clarity purpose of the question, but I should have
mentioned about CDK indices and renumbering in the NewHeptane atom
container, which I am quite aware of, (thanks a lot for your clarity in
explaining it)
To me, it seems that the real issue is with the model builder. (After
generating SMILES)
When I tried creating a 3d model of the NewHeptane using model3dbuilder I
get an exception
*org.openscience.cdk.exception.NoSuchAtomTypeException: Atom is unkown:
Symbol:C does not MATCH AtomType. HoseCode:C-5;CC(C,C/C,/)*
By the way, I checked with AtomContainerManipulator.perceiveatomsandconfigure()
and all atoms in the NewHeptane Iatomcontainer has C.Sp3 hybridized.
// Below is the code with CDK atom indices
NewHeptane.add(Propane)
*NewHeptane.addBond(1, // second atom in heptane
4, // first atom in propane*
* IBond.Order.Single);*
*NewHeptane.addBond(2, // third atom in heptane (was sixth before we
deleted some)*
* 6, // third atom in propane*
* IBond.Order.Single);*
//Generate smiles
SmilesGenerator sg = SmilesGenerator.absolute();
String smi = sg.create(NewHeptane);
//Parse smiles
SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer m = sp.parseSmiles(smi);
// Build 3d model
ModelBuilder3D builder3d = ModelBuilder3D.getInstance(m.getBuilder());
IAtomContainer newHeptane = builder3d.generate3DCoordinates(m, false);
Any insights in the right direction are highly appreciated. Thank you.
On Sat, Oct 28, 2017 at 5:38 PM, John Mayfield <[email protected]>
wrote:
> Can't run the code without more context but I think I know what's
> happening.
>
> Firstly atom indices start at 0, so to remove atom numbers 3, 4, 5 (as in
> picture) you remove 2, 3, 4. Secondly, when you delete atoms the indices
> are renumbered/repacked. So the new indices will always be 0, 1, 2
> (previously index 5 - atom number 6).
>
> [image: Inline images 1]
>
> Now this wouldn't actually cause the error because you're adding
> pentane... but 5 atoms from pentane + the 3 from the fragmented hexane
> means the maximum index as 7 but you've requested atom 10...
>
> NewHeptane.addBond(6,10, IBond.Order.Single)
>
>
> There are a couple of ways to do this for example tagging atoms, map
> indices, or use the atom object to create the bonds (most efficient).
>
> NewHeptane.add(Propane)
>> //adding bonds
>> NewHeptane.addBond(1, // second atom in heptane
>> 4, // was second atom in propane...
>> 3+1
>> IBond.Order.Single);
>> NewHeptane.addBond(2, // third atom in heptane (was sixth before we
>> deleted some)
>> 6, // was forth atom in propane 3+3
>
> IBond.Order.Single)
>
>
> Using the addBond() API you can get the index in the new molecule as
> follows... which makes it easier
>
> NewHeptane.add(Propane)
>> //adding bonds
>> NewHeptane.addBond(1, // second atom in heptane
>> NewHeptane.indexOf(Propane.getAtom(1)),
>> // second atom in propane -> find index in the combined mol
>> IBond.Order.Single);
>> NewHeptane.addBond(2, // third atom in heptane (was sixth before we
>> deleted some)
>> NewHeptane.indexOf(Propane.getAtom(3)),
>> // forth atom in propane -> find index in the combined mol
>
> IBond.Order.Single)
>>
>
> Hope that helps,
> John
>
> On 25 October 2017 at 12:53, Vinothkumar Mohanakrishnan <
> [email protected]> wrote:
>
>> Dear All
>>
>> I am using CDK to create a tool (Java GUI) for editing molecules. To
>> start with I am considering linear alkanes. I will describe my problem
>> briefly.
>>
>> I have an IAtomcontainer with *Heptane(H) *molecule loaded into it (all
>> atoms and bonds are connected)
>>
>> I* removed atoms 3,4,5* from the container and the bonds connecting
>> them. So now I have two fragments of ethane(*atom1 - atom2 connected *
>> similarly* atom6-atom7 connected*) in the atom container.
>>
>> I have another IAtomcontainer with *Propane(P)* (say with *atom numbers
>> 8, 9, 10*) loaded into it (again all atoms and bonds are connected )
>>
>> I added the propane Iatomcontainer to the heptane Iatomcontaner. Then I
>> added a bond between (atom2(H) -atom8(P)) and (atom6(H)-atom10(P)) and
>> created a new molecule called NewHeptane.
>>
>> When I tried creating a 3d model of the NewHeptane using model3dbuilder I
>> get an exception
>>
>> *org.openscience.cdk.exception.NoSuchAtomTypeException: Atom is unkown:
>> Symbol:C does not MATCH AtomType. HoseCode:C-5;CC(C,C/C,/)*
>>
>> By the way, I checked with
>> AtomContainerManipulator.perceiveatomsandconfigure()
>> and all atoms in the NewHeptane Iatomcontainer has C.Sp3 hybridized.
>>
>>
>> *Below is the code*
>>
>> //add propane to heptane
>> NewHeptane.add(Propane)
>>
>> //adding bonds
>> NewHeptane.addBond(2,8,IBond.Order.Single)
>> NewHeptane.addBond(6,10, IBond.Order.Single)
>>
>> //Generate smiles
>> SmilesGenerator sg = SmilesGenerator.absolute();
>> String smi = sg.create(NewHeptane);
>>
>> //Parse smiles
>> SmilesParser sp = new SmilesParser(SilentChemObjectB
>> uilder.getInstance());
>> IAtomContainer m = sp.parseSmiles(smi);
>>
>> // Build 3d model
>> ModelBuilder3D builder3d = ModelBuilder3D.getInstance(m.getBuilder());
>> IAtomContainer newHeptane = builder3d.generate3DCoordinates(m, false);
>>
>>
>> Any suggestion in the right direction is highly appreciated. Thank you.
>>
>> --
>> Regards
>> Vinothkumar Mohanakrishnan
>>
>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Cdk-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/cdk-user
>>
>>
>
--
Regards
Vinothkumar Mohanakrishnan
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user