User 568550d85a
04-03-2008 17:01:21
Hello
I am trying to extract fragments from a molecule while preserving 3D information. In the output of the example below I see that setLocation works correctly (the XYZ coordinates for the original and cloned atom are the same). But if I export the fragment into an sdf file the coordinates change and begin to differ from these of the original. How can I preserve the geometry? And btw is it possible to simplify the mainatom.getBond(j).getOtherAtom(mainatom)
stuff?
lorenz
Output:
I am trying to extract fragments from a molecule while preserving 3D information. In the output of the example below I see that setLocation works correctly (the XYZ coordinates for the original and cloned atom are the same). But if I export the fragment into an sdf file the coordinates change and begin to differ from these of the original. How can I preserve the geometry? And btw is it possible to simplify the mainatom.getBond(j).getOtherAtom(mainatom)
stuff?
lorenz
Code: |
import chemaxon.struc.*; import chemaxon.util.*; public class Test { public static void main(String[] args) throws Exception{ MolHandler mh = new MolHandler("CC"); //try "C" Molecule mol = mh.getMolecule(); mol.clean(3, "[hydrogenize]"); for (MolAtom mainatom : mol.getAtomArray()) { if (mainatom.getAtno() == 1) { continue; } Molecule frag = new Molecule(); frag.insertNode(0, mainatom); frag.getAtom(0).setLocation(mainatom.getLocation()); for (int j = 0; j < mainatom.getBondCount(); j++) { frag.insertNode(j + 1, mainatom.getBond(j).getOtherAtom(mainatom)); frag.getAtom(j + 1).setLocation(mainatom.getBond(j).getOtherAtom(mainatom).getLocation()); frag.insertEdge(j, mainatom.getBond(j)); System.out.println(mainatom.getBond(j).getOtherAtom(mainatom).getX() + " " + mainatom.getBond(j).getOtherAtom(mainatom).getY() + " " + mainatom.getBond(j).getOtherAtom(mainatom).getZ()); System.out.println(frag.getAtom(j + 1).getX() + " " + frag.getAtom(j + 1).getY() + " " + frag.getAtom(j + 1).getZ()); } System.out.println(mol.toFormat("sdf")); System.out.println(frag.toFormat("sdf")); } } } |
Output:
Code: |
-0.004135215811178268 4.663123038772693E-9 1.0777383085071771E-8 -0.004135215811178268 4.663123038772693E-9 1.0777383085071771E-8 1.8974685491445111 -6.818612039206698E-9 1.0276618661018329 1.8974685491445111 -6.818612039206698E-9 1.0276618661018329 1.897468543770874 -0.8899812800298335 -0.513830916884841 1.897468543770874 -0.8899812800298335 -0.513830916884841 1.897468554518149 0.8899812663926094 -0.513830916884841 1.897468554518149 0.8899812663926094 -0.513830916884841 Marvin 03040817483D 8 7 0 0 0 0 999 V2000 1.5341 -0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -0.0041 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 1.8975 -0.0000 1.0277 H 0 0 0 0 0 0 0 0 0 0 0 0 1.8975 -0.8900 -0.5138 H 0 0 0 0 0 0 0 0 0 0 0 0 1.8975 0.8900 -0.5138 H 0 0 0 0 0 0 0 0 0 0 0 0 -0.3675 0.0000 1.0277 H 0 0 0 0 0 0 0 0 0 0 0 0 -0.3675 0.8900 -0.5138 H 0 0 0 0 0 0 0 0 0 0 0 0 -0.3675 -0.8900 -0.5138 H 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 1 3 1 0 0 0 0 1 4 1 0 0 0 0 1 5 1 0 0 0 0 2 6 1 0 0 0 0 2 7 1 0 0 0 0 2 8 1 0 0 0 0 M END $$$$ Marvin 03040817482D 5 4 0 0 0 0 999 V2000 0.8219 -0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -0.0022 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 1.0165 -0.0000 0.5505 H 0 0 0 0 0 0 0 0 0 0 0 0 1.0165 -0.4768 -0.2753 H 0 0 0 0 0 0 0 0 0 0 0 0 1.0165 0.4768 -0.2753 H 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 1 3 1 0 0 0 0 1 4 1 0 0 0 0 1 5 1 0 0 0 0 M END $$$$ 1.534135215811178 -4.624833737327012E-9 1.0777383545691104E-8 1.534135215811178 -4.624833737327012E-9 1.0777383545691104E-8 -0.36746854914451194 6.8569013406523816E-9 1.0276618661018322 -0.36746854914451194 6.8569013406523816E-9 1.0276618661018322 -0.367468543770874 0.8899812800681228 -0.5138309168848416 -0.367468543770874 0.8899812800681228 -0.5138309168848416 -0.36746855451814886 -0.8899812663543201 -0.5138309168848416 -0.36746855451814886 -0.8899812663543201 -0.5138309168848416 Marvin 03040817483D 8 7 0 0 0 0 999 V2000 1.5341 -0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -0.0041 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 1.8975 -0.0000 1.0277 H 0 0 0 0 0 0 0 0 0 0 0 0 1.8975 -0.8900 -0.5138 H 0 0 0 0 0 0 0 0 0 0 0 0 1.8975 0.8900 -0.5138 H 0 0 0 0 0 0 0 0 0 0 0 0 -0.3675 0.0000 1.0277 H 0 0 0 0 0 0 0 0 0 0 0 0 -0.3675 0.8900 -0.5138 H 0 0 0 0 0 0 0 0 0 0 0 0 -0.3675 -0.8900 -0.5138 H 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 1 3 1 0 0 0 0 1 4 1 0 0 0 0 1 5 1 0 0 0 0 2 6 1 0 0 0 0 2 7 1 0 0 0 0 2 8 1 0 0 0 0 M END $$$$ Marvin 03040817482D 5 4 0 0 0 0 999 V2000 -0.0022 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 0.8219 -0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -0.1969 0.0000 0.5505 H 0 0 0 0 0 0 0 0 0 0 0 0 -0.1969 0.4768 -0.2753 H 0 0 0 0 0 0 0 0 0 0 0 0 -0.1969 -0.4768 -0.2753 H 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 0 0 0 0 1 3 1 0 0 0 0 1 4 1 0 0 0 0 1 5 1 0 0 0 0 M END $$$$ |