Create Molecule Object from Database Table

User 49e3cc9e65

17-02-2010 13:44:49

Hello,


Can anybody tell me how to extract chemical entities from a structure table and create molecule objects from them?

ChemAxon e274e1bada

17-02-2010 16:29:41

Hi,


pease describe your chemical softwre envionment (do you use JChem tables, or other structure tables? Which database  server do you use, ...) and your objectives with the chemical entities (you would like to use an API for further processing, or do you want to display the structure, ...).


Regards, Edvard

User 49e3cc9e65

19-02-2010 12:02:39

Hi,


I already got the molecule objects.


I want to use them for MCS commputation and render the molecules in a Java application. I read about the JKlustor class but I cannot find any documentation about it. Even in the Api this class does not appear. What I did so far: I computed the MSCs using the LibraryMCS class.


LibraryMCS libraryMCS = new LibraryMCS();
        DbQueries queries = new DbQueries();
        try {
            for (Entity entity : entities) {
                int curEntId = entity.getCdId();
                byte[] curEntStruc = queries.getEntityStructure(curEntId);
                InputStream inputStream = new ByteArrayInputStream(curEntStruc);
                MolImporter molImporter;
                molImporter = new MolImporter(inputStream);
                Molecule mol = molImporter.read();
                libraryMCS.addMolecule(mol);
            }
            libraryMCS.search();


How can I show the results in a Java Panel?

ChemAxon 9c0afc9aaf

19-02-2010 15:45:14

 


Can anybody tell me how to extract chemical entities from a structure table and create molecule objects from them?

 


In general you have to issue a SELECT statement to fetch the structure source.


(unless you want to display the result of a structure search, JChemSearch provides the molecules in this case colored and aligned if necessary )


In case of jchem tables using the cd_structure column of a jchem table is advised.


A helper function to cope with various column types:


http://www.chemaxon.com/jchem/doc/api/chemaxon/util/DatabaseTools.html#readBytes(java.sql.ResultSet, int)


After this you can use MolImporter to create a Molecule from the byte[] or String. 

User 49e3cc9e65

22-02-2010 09:19:01

Thanks for the reply. That is how I finally did it.


Do you have any hint regarding my second problem of how to render these molecule objects in a Java panel?

ChemAxon a3d59b832c

22-02-2010 12:22:53

Hi Ben,


Have a look at the Marvin Beans examples in the Marvin developers guide:


 


https://www.chemaxon.com/marvin/examples/beans/index.html


 


I am sure you will find the solution there.


 


Best regards,


Szabolcs

User 49e3cc9e65

23-02-2010 10:44:41

Hi,


Unforunately I could not find a solution there.


I just need some assitence of how to use the JKlustor class. There seems to be no API Doc for that class.


 


Here is my code:


        DbQueries dbDocuments = new DbQueries();
        List<Entity> entities = dbDocuments.getAllEntsInDoc(documentId);
        LibraryMCS libraryMCS = new LibraryMCS();
        DbQueries queries = new DbQueries();
        InputStream inputStream = null;
        try {
            for (Entity entity : entities) {
                int curEntId = entity.getCdId();
                byte[] curEntStruc = queries.getEntityStructure(curEntId);
                inputStream = new ByteArrayInputStream(curEntStruc);
                MolImporter molImporter;
                molImporter = new MolImporter(inputStream);
                Molecule mol = molImporter.read();
                libraryMCS.addMolecule(mol);
            }
            libraryMCS.search();
        } catch (MolFormatException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // create frame
        JFrame f = new JFrame();
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        f.setLayout(new FlowLayout());
        f.setBounds(0, 0, 800, 800);
        f.setVisible(true);
        JKlustor jKlustor = new JKlustor(f);
        jKlustor.setLibMCS(libraryMCS);
//        jKlustor.getDataImporter().loadGraph(inputStream);
//        jKlustor.clustering();
        ClusterViewer clusterViewer = jKlustor.getClusterViewer();
        f.setContentPane(clusterViewer);



I got a nullpointer exception if I uncomment the jKlustor.clustering(); line


Exception in thread "main" java.lang.NullPointerException
    at chemaxon.clustering.JKlustorImport.resetLibMCS(JKlustorImport.java:448)
    at chemaxon.clustering.gui.JKlustor.clustering(JKlustor.java:223)
    at Main.testJKlustor(Main.java:108)
    at Main.main(Main.java:154)

Otherwise the shown panel only includes the basic structure of the LibraryMCS tool but no graph is shown.


Can somebody help me?

ChemAxon 8b644e6bf4

23-02-2010 17:18:38

Hi,


 


JKlustor and ClusterViewer classes are for internal use only, they are not part of our public API (see https://www.chemaxon.com/api_land.html). The usage of these classes is not supported.


 


Regards,


Gabor