creating fragments with 3D information

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





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


$$$$


ChemAxon 8b644e6bf4

06-03-2008 17:47:59

Dear Lorenz,





As far as I know the sdf export do changes the coordinates by changing the location of the exported structure, but leaves the geometry intact. I have compared the original structure and the fragments from Your post (see attached out.sdf), and the geometry seemed to be intact.





Btw, I recommend to use System.out.print( Molecule.toFormat() ) instead of println (when exporting formats different from SMILES) and use System.err to other verbose info. Doing this, the structures can be collected in a single file by redirecting the output. (This works for mol, sdf but does not for mrv.)





For such structure manipulations, btab, ctab can help a lot (see: http://chemaxon.com/marvin/help/developer/beans/api/chemaxon/struc/CGraph.html#getBtab() and http://chemaxon.com/marvin/help/developer/beans/api/chemaxon/struc/CGraph.html#getCtab() ) (btab can help to walk all connected atoms, ctab helps identify bonds between central and connected atoms) It is also possible to use cloneMolecule() to make copies and remove unwanted atoms/bonds from the clones.





bye,


Gabor

User 568550d85a

11-03-2008 17:13:10

Hello





If I look at your (and mine) output I see:


Code:



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





  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








So obviously the carbon - carbon distance is not the same for the original and the first fragment. I think it is shrunk by the factor of 2. The same phenomenon appears when you open the file in mview: The fragments have much shorter C-C Bonds than the original molecules...





lorenz

ChemAxon 8b644e6bf4

12-03-2008 01:36:31

Dear Lorenz,





You are right, the exported fragments are scaled down. It seems that fragment dimensionality must be set explicitly. Adding frag.setDim( 3 ); before exporting will solve this issue.





btw, i recommend to use [prehydrogenize] instead of [hydrogenize]. The first one adds explicit H atoms before the coordinate generation process (so Clean3D will generate their coordinates), producing lower energy conformers. [hydrogenize], which invoked explicit H addition after the coordinate generation process produced eclipsed conformation in this example.





bye,


Gabor