Skip to content

Instantly share code, notes, and snippets.

@edrin
Created May 9, 2009 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edrin/109331 to your computer and use it in GitHub Desktop.
Save edrin/109331 to your computer and use it in GitHub Desktop.
//******************************************************
//* Script to calculate the mass of a chemical structure
//******************************************************
//Connect if not connected (requires JID and password in preferences)
if (!(xmpp.isConnected()))
xmpp.connect();
//Get service and function from xmpp network
var service = xmpp.getService("cdk.ws1.bmc.uu.se");
var func = service.getFunction("calculateMass");
//Get schema from service
var iof;
if (xmpp.existsIoFactory(func)) //Check if binding exists
iof = xmpp.getIoFactory(func); //Try to load generated binding
if (iof==null) {
var ios = func.getIoSchemataSync(90000); //Get schema from service
iof = xmpp.getIoFactory(ios); //Generate binding
}
//Set up input and invoke service
var smiDoc = iof.createSmilesDocument();
smiDoc.setSmiles("CCC(CC)CCNCCO");
var result = func.invokeSync(smiDoc.toString(), 900000);
//Get results and print to console
var obj = iof.getOutputObject(result);
js.print("\n\nMass of molecule: "+ obj.getStringValue());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment