Use of JMSketch class in .java file

User 581eabb90d

02-03-2009 09:09:21

Hi,





 Well, I am trying to read the tag name of .sdf file and .smiles. This is possible in jsp page





where i have the marvin applet integrated into it.





But my requirement is, I want to read tag name using JMSketch class in java code.





i.e I want create its Object and use the api methods such as :





1) 


java.lang.String


getMolProperty(java.lang.String key)









2) 


int


getMolPropertyCount()









3) 


java.lang.String


getMolPropertyKey(int i)















Please suggest me so that I will be able to create the object in java file





and use these api.





ASAP














Thanks





Sumeet Jaju


























 








 


ChemAxon 7c2d26e5cf

05-03-2009 11:19:55

Can you explain why do want to use JMSketch like this way?





JMSketch applet is not a utility class. It is an applet that is instantiated by the browser when the web page is loaded-in where the applet is embedded.





If you would like to read molecule structures from Java code and retrieve a property from the structure, use the MarvinBeans API.





Read structure(s) from any chemical structure file (like sdf or smiles) with MolImporter that builds up a Molecule object from each structure. After then, you can manipulate it or get its properties.

User 581eabb90d

09-04-2009 05:15:54

Thanks Tamas appreciated your help. Well, I had another issue with JMSketch in browser.


I have a for loop where in I set the file to JMSketch using setMol method of JMSketch.


Once I set the file I read the tag name and assign to the varaible. Now next in the loop I set next file to the


JMSketch but what happens here is it takes time to set the next file to the JMSketch so it reads the tag name


of previous file (i.e first file which we have set). As a result I get the duplicate names in the resultant CSV.


So is there any way to clear the JMSketch immediately>Hope this is understandable.


below is the code :


 


    for( cmpCnt = 0; cmpCnt < listSize; cmpCnt++ ) {


         // gets the file data from the hidden text
            var hiddenCmpVal = document.getElementById("hiddenCmp_"+cmpCnt).value;
            var tagName = "";


          //sets the file data to the JMSketch
            document.JMSketch.setMol(hiddenCmpVal,strFileFormat);


           // returns the tag name
            tagName = getTagName(tagHeaderName);
            //alert("tagName : "+tagName);


         // goes>                if (tagName == "" || tagName == undefined) {
                    document.JMSketch.setMol(hiddenCmpVal,strFileFormat);
                    tagName = getTagName(tagHeaderName);
                }else {



           // when you get the first file tag name


           // it takes time to set another file so it reads the tag name of previous file


           //and comes into else and breaks


                    break ;
                }
            }
   



            iupacNamesCSV = iupacNamesCSV + tagName + "_~~_";
           
        }


 


 


 


 




your help would be appreciated.




Thanks


Sumit Jaju






 

ChemAxon 7c2d26e5cf

10-04-2009 14:35:23

Actually, setMol starts a new thread for molecule loading and return immediatelly. You can ask notification about finishing of molecule loading. To do this,specify the "molLoaderFinishedEvent" applet parameter to be able to catch the event. The value of this parameter is a name of a javascript function which is evaluated when the molecule loading is completed.


Here is an example:


msketch_name="MSketch";
msketch_mayscript="true";
msketch_begin("/marvin", 460, 445);
msketch_param("mol","C1=CNC=C1");
msketch_param("molLoaderFinishedEvent","js:loadFinished()");
msketch_end();

function loadFinished() {
alert("Molecule is loaded");
}
You can try out this example by visitting to the following URL: Example for "molLoaderFinishedEvent".