
Var atom = mol.GetAtom(i + 1) // note: OpenBabel atom starts with index 1, not 0Ītom.SetIsotope(13) // change mass number to 13 Var atomCount = mol.NumAtoms() // get atom number of molecule
Openbabel zmatrix code#
For example, the following code will change mass number of all C atoms in molecule to 13:

This object holds the structure of a molecule, and you can even manipulate it with OpenBabel API before saving it. It is noticeable that during the conversion, an OBMol object is created. Var outData = conv.writeString(mol, false) // get output data, do not trim white spaces and load it with input dataĬonv.setOutFormat('', 'pdb') // set out format by file extension Var mol = new OpenBabel.OBMol() // create a new molecule object.Ĭonv.readString(mol, inData) //. the input format can also be set by MIME type: Var conv = new OpenBabel.ObConversionWrapper() // create ObConversionWrapper instanceĬonv.setInFormat('', 'mol') // set input format by file extension The dominate use of class ObConversionWrapper is to do conversion between different data formats: Var formatInfo = conv.getFormatInfoById(formatId) // returns detailed format infoĬonsole.log(formatInfo.id, formatInfo.mimeType, formatInfo.specificationURL, scription) You can then extract the id and get more informations from it: var conv = new OpenBabel.ObConversionWrapper() // create ObConversionWrapper instance It can be seen from the demo above that the each item of returned format string of getSupportedInputFormatsStr / getSupportedOutputFormatsStr contains two parts: format id and format description with a delimiter of "-".
Openbabel zmatrix free#
Var sOutputFormats = conv.getSupportedInputFormatsStr('\n') Ĭonv.delete() // free ObConversionWrapper instance Var sInputFormats = conv.getSupportedInputFormatsStr('\n') list all supported input/output formats, use '\n' to separate between each format string To list all of them, the following JavaScript code can be used: var conv = new OpenBabel.ObConversionWrapper() // create ObConversionWrapper instance

OpenBabel supports a lot of different chemical formats (note that not all of them are ported to JavaScript currently). Most of I/O job can be done with this wrapper class. For some reason, in JavaScript compiliation, a wrapper class ObConversionWrapper is created to wrap functions of OBConversion.

In native OpenBabel, the core class to do data format conversion is OBConversion. Now the OpenBabel routines can be calledĪfter initialization, all useful classes can be accessed from that OpenBabel module. OpenBabel.onRuntimeInitialized = function() This is a asynchronous process and a custom event callback should be used to acknowledge the ready of OpenBabel module: var OpenBabel = OpenBabelModule()

The openbabel.js will then load openbabel.wasm, the web assembly compiled from OpenBabel lib, and openbabel.data, the external data file need by Open Babel. The JavaScript file should be included in the HTML file: To use the OpenBabel JS compilation, you need to deploy openbabel.js, openbabel.wasm and openbabel.data all togather in the same directory.
Openbabel zmatrix download#
Overview Demos Download Open Babel Demo Overview OpenBabel Demo - Cheminf-to-web Project Cheminfo-to-web Project Cheminf-to-web Overview Demos Download
