visualization of molecule with descriptor values attached

User 37df300f74

19-08-2005 14:00:46

Suppose I calculate descriptors for each atom in a molecule, how can I show atom with descriptors values in MViewPane?





Thanks a lot

ChemAxon 9c0afc9aaf

22-08-2005 10:27:46

Hi,





Please provide me some additional information about your question:





1. Do you create Molecular Descriptors with the ChemAxon API (package chemaxon.descriptors) ?





2. You talk about values. Do you want to display some numerical values or do you want to use colors, like in our pharmacophore descriptor example at:





http://www.chemaxon.com/jchem/examples/jsp1_x/initsearch.jsp








Best regards,





Szilard

User 37df300f74

22-08-2005 13:11:53

Szilard, Thanks for your help.





No, I used an third-party descriptor calculator, and each atom in an molecule is given a numerical value.


In your Pka calculation, pka values for some atoms were displayed and associated with atoms in MViewPane. I would like to know which API I need to call in order to do that.

ChemAxon a3d59b832c

22-08-2005 15:13:48

Hello,





The most straightforward is to use methods setExtraLabel(String s) and setExtraLabelColor(long rgbs) of MolAtom:





http://www.chemaxon.com/marvin/doc/api/chemaxon/struc/MolAtom.html#setExtraLabel(java.lang.String)





This value can also be stored in mrv format using attribute mrvExtraLabel:





http://www.chemaxon.com/marvin/doc/user/mrv-doc.html width="90%" cellspacing="0" cellpadding="3" border="0" align="center"> Quote: <?xml version="1.0" encoding="Cp1252" ?>


<MDocument>


<MChemicalStruct>


<molecule molID="m1">


<atomArray


atomID="a1 a2 a3 a4 a5"


elementType="N C C C C"


mrvExtraLabel="18.00 . . . ."


x2="-3.9666666984558105 -5.3003066984558105 -2.6330266984558106 -2.6330266984558106 -5.3003066984558105"


y2="-0.006999976158141408 0.7630000238418582 0.7630000238418582 2.3030000238418573 2.3030000238418573"


/>


<bondArray>


<bond atomRefs2="a1 a2" order="1" />


<bond atomRefs2="a1 a3" order="1" />


<bond atomRefs2="a2 a5" order="2" />


<bond atomRefs2="a5 a4" order="1" />


<bond atomRefs2="a4 a3" order="2" />


</bondArray>


</molecule>


</MChemicalStruct>


</MDocument>


Best regards,





Szabolcs

User 37df300f74

23-08-2005 15:36:07

That do it. Thanks a lot

User 870ab5b546

10-01-2007 20:13:49

Suppose I want to store a number for each atom, but I do not want to show the numbers to the user? Is there a field that I can use?





I can't just make up my own field, because I need the data to be retained when the user modifies the molecule and Marvin sends it back to the server.

ChemAxon a3d59b832c

11-01-2007 10:43:29

bobgr wrote:
Suppose I want to store a number for each atom, but I do not want to show the numbers to the user? Is there a field that I can use?





I can't just make up my own field, because I need the data to be retained when the user modifies the molecule and Marvin sends it back to the server.
I can only think of one such field: atom maps. You can switch off the visualization of these with applet parameter "atomMappingVisible".





http://www.chemaxon.com/marvin/doc/dev/sketchman.html





The atom maps are also stored in most file formats, so they are easy to send for the server.

User 870ab5b546

11-01-2007 12:05:32

We already use atom maps for other purposes, so we are hesitant to use them again for this one. Plus, it is easy for a user to make atom maps visible through the GUI. We want the properties to remain hidden.





May I suggest that you add a field to the MRV specification that allows users to store atom information of any kind that cannot be stored in other fields? Such a field would provide some needed flexibility. We could use such a field, for example, to store the number of unshared electrons held by each atom, or perhaps to store information about the chemical origin of each atom in a synthetic compound. You might even just call it a "comment" field, as long as each atom could have its own field.





It did occur to me that we could use the atomLabel field to store the information, and we could make the label invisible by making it the same color as the background. But the background color can easily be changed, and the presence of the label can be detected if atom numbers or atom maps are turned on because a comma will appear.

ChemAxon 7c2d26e5cf

11-01-2007 20:43:15

We will consider your request.

ChemAxon a3d59b832c

12-01-2007 08:31:44

I suggest to use attached data in this case. You can try this in Marvin by selecting one or more atoms, and then select menu item Edit->Add->Data...





On the upcoming dialog, you can set the field name and value. By default, the data is displayed on the canvas, but if you set the "Displayed lines" on the dialog to -1, it is not. (The data is still highlighted if you move the mouse over the atoms, but we can fix that for example by introducing value -2.)





These attached data are saved as data S-groups in mrv and mol formats.





There are a few problems with editing and highlighting, which we will fix soon.


We prefer this solution over new fields, because it is industry standard and is more general.





I will add some code later about how to create and access these S-groups from the API.

ChemAxon a3d59b832c

12-01-2007 09:21:49

Some code for handling attached data (data sgroups):





Code:



package test;





import chemaxon.struc.Molecule;


import chemaxon.struc.MolAtom;


import chemaxon.struc.Sgroup;


import chemaxon.struc.sgroup.DataSgroup;


import chemaxon.formats.MolImporter;


import chemaxon.formats.MolFormatException;





/**


 * @author Szabolcs Csepregi Date: 12-Jan-2007


 */


public class DataSgroupT {


    static String mol = "C1CCCCC1";





    public static void main(String[] args) throws MolFormatException {


        Molecule m = MolImporter.importMol(mol);





        // Adding data sgroups to each atom:


        for (int i = 0; i < m.getAtomCount(); i++) {


            addSgropToAtom(m, i);


        }//end for(i)





        System.err.println(m.toFormat("mrv"));


        System.err.println(m.toFormat("mol"));





        // Accessing data sgroups:


        for (int i = 0; i < m.getAtomCount(); i++) {


            printData(m, i);


        }//end for(i)





    }//end main





    /**


     * Prints out all data sgroups that atom i is part of.


     */


    private static void printData(Molecule m, int i) {


        MolAtom molatom = m.getAtom(i);


        for (int j = 0; j < m.getSgroupCount(); j++) {// Go through all sgroups


            Sgroup sg = m.getSgroup(j);


            if (sg.getType() == Sgroup.ST_DATA) {// If data sgroup


                DataSgroup dsg = (DataSgroup) sg;


                if (dsg.indexOf(molatom) != -1) {// Is the data attached to molatom?


                    System.err.println("Atom " + i + " has attached data:"


                            + " field name:" + dsg.getFieldName()


                            + " data:" + dsg.getData());


                }


            }


        }//end for(j)


    }





    private static void addSgropToAtom(Molecule m, int i) {


        MolAtom ma = m.getAtom(i);


        DataSgroup ds = new DataSgroup(m);


        ds.setData(Integer.toString(i));


        ds.setFieldName("ATOM_INDEX");


        // To hide the data sgroup:


        ds.setDisplayedLines(-2);


        // This adds ma to ds and puts ds into m, if necessary:


        m.setSgroupParent(ma, ds, true);


    }


}//end class DataSgroupT


User 870ab5b546

12-01-2007 13:34:10

Thanks, Szabolcs! This solution sounds like exactly what we need. We'll play around with it.





One question: Is the displayed lines = -2 option a feature that has already been implemented, or is it something you plan to introduce in the future?

ChemAxon a3d59b832c

12-01-2007 13:37:15

bobgr wrote:
One question: Is the displayed lines = -2 option a feature that has already been implemented, or is it something you plan to introduce in the future?
It is only a plan.

ChemAxon e500b51457

13-02-2007 20:47:00

Dear Bob,





The Marvin features related to Data S-groups (editing, mrv import/export,


"displayed lines = -2" feature) will be available in 4.1.6.





Best regards,


Erika.