GithubHelp home page GithubHelp logo

openbabel-node's Introduction

NPM version npm Travis build status Dependency Status npm npm Gitter

Open Babel Binding for Node.js

Open Babel is a chemical toolbox designed to speak the many languages of chemical data written in C++. Now you can use the Open Babel features in node.js !

Contents

Installation

Linux

First of all you should install openbabel with header files.

sudo apt-get install libopenbabel-dev

Then you can easily install this package using npm

npm install openbabel

OS X

Install openbabel using brew

brew install open-babel
npm install openbabel

Usage

Check the Documentation API for more details.

Use the openbabel module in your project.

var ob = require('openbabel');

Conversion

Read chemical file formats

Create an instance of ob.Conversion :

var conversion = new ob.Conversion();
var mol = conversion.setInFormat('smiles').read('C1CCCC1');
console.log(mol.atomsCount);

And you can use fs to read chimcal data from files :

var fs = require('fs');

var data = readFileSync('methane.smiles');
var conversion = new ob.Conversion();
var mol = conversion.setInFormat('smiles').read(data);
console.log(mol.atomsCount);

Write chemical file formats

Use an ob.Conversion instance :

var str = conversion.setOutFormat('mol').write(mol);
console.log(str);

And also you can export it as a file :

var str = conversion.setOutFormat('mol').write();
fs.writeFileSync('methane.mol', str);

ForceField

Energy Calculation

Create an instance of ob.Conversion using The ob.Conversion.findForceField factory :

var ff = ob.Conversion.findForceField('mmff94');
ff.setup(mol);
console.log(ff.energy);

Call one of systematicRotorSearch, randomRotorSearch, weightedRotorSearch. (Read more in API)

console.log(ff.energy); // Before getting conformer
ff.systematicRotorSearch();
console.log(ff.energy); // After getting conformer

Atom types

You can get data which is set for an atom by calling getData method such as FFAtomType.

ff.prepareAtomTypes();
console.log(mol.atoms[0].getData('FFAtomType'));

openbabel-node's People

Contributors

ahmadina avatar mohebifar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

openbabel-node's Issues

Error adding OpenBabel to a node.js app in visual studio 2015

Using the npm inside node js tools for visual studio installing outputs :

Registry url: https://registry.npmjs.org/
Current Time: 30.8.2015 г. 1:58:52
Last Refreshed: 10.6.2015 г. 1:39:37
Number of Results: 164766
====Executing command 'npm install openbabel --save '====

npm WARN package.json [email protected] No repository field.

[email protected] install c:\users\hristo\documents\visual studio 2015\Projects\NodejsConsoleApp2\NodejsConsoleApp2\node_modules\openbabel
node-gyp rebuild
c:\users\hristo\documents\visual studio 2015\Projects\NodejsConsoleApp2\NodejsConsoleApp2\node_modules\openbabel>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (rebuild)
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(55,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [c:\users\hristo\documents\visual studio 2015\Projects\NodejsConsoleApp2\NodejsConsoleApp2\node_modules\openbabel\build\openbabel.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd c:\users\hristo\documents\visual studio 2015\Projects\NodejsConsoleApp2\NodejsConsoleApp2\node_modules\openbabel
gyp ERR! node -v v0.12.2
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "openbabel" "--save"
npm ERR! node v0.12.2
npm ERR! npm v2.7.4
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the openbabel package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls openbabel
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! c:\users\hristo\documents\visual studio 2015\Projects\NodejsConsoleApp2\NodejsConsoleApp2\npm-debug.log

====npm command completed with exit code 1====

Error Adding openbabel to visual studio

if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\gopin\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\gopin\Desktop\New3202019\New\node_modules\openbabel
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm install fails due to node-gyp rebuild step depending on packages built for old versions of Node

Hi there! I'm extremely interested in using this package (it's the lightest-weight and best looking package out there) but can't install it on a current-ish version of node (e.g. node v15).

npm install openbabel fails due to node-gyp rebuild failing, due to what looks like an outdated version of the nan package built for older versions of node? Not 100% sure as I don't work with C++ builds/compiling to a node package. But I'm guessing you'll have greater insight.

> [email protected] install /Users/xxx/xxx-app/node_modules/openbabel
> node-gyp rebuild

  CXX(target) Release/obj.target/openbabel/src/atom.o
In file included from ../src/atom.cpp:2:
In file included from ../src/mol.h:11:
In file included from ../node_modules/nan/nan.h:111:
../node_modules/nan/nan_new.h:24:43: error: no member named 'Handle' in namespace 'v8'
template <typename T> v8::Local<T> To(v8::Handle<v8::Integer> i);
                                      ~~~~^
../node_modules/nan/nan_new.h:24:61: error: expected '(' for function-style cast or type construction
template <typename T> v8::Local<T> To(v8::Handle<v8::Integer> i);
                                                 ~~~~~~~~~~~^
../node_modules/nan/nan_new.h:24:63: error: use of undeclared identifier 'i'
template <typename T> v8::Local<T> To(v8::Handle<v8::Integer> i);

. . .
. . .
etc.
etc.

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/openbabel/src/atom.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/xxx/.nvm/versions/node/v15.9.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:378:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command "/Users/xxx/.nvm/versions/node/v15.9.0/bin/node" "/Users/adam/.nvm/versions/node/v15.9.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/xxx/xxx-app/node_modules/openbabel
gyp ERR! node -v v15.9.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 

error configure in ubuntu system

$ npm install openbabel -g
/

[email protected] install /home/register/sf_install/node/lib/node_modules/openbabel
node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
make: Entering directory /home/register/sf_install/node/lib/node_modules/openbabel/build' CXX(target) Release/obj.target/openbabel/src/atom.o In file included from ../src/atom.cpp:1:0: /home/register/.node-gyp/0.12.0/deps/v8/include/v8.h: In static member function ‘static void v8::NonCopyablePersistentTraits<T>::Uncompilable() [with O = v8::Object, T = v8::Object]’: /home/register/.node-gyp/0.12.0/deps/v8/include/v8.h:592:5: instantiated from ‘static void v8::NonCopyablePersistentTraits<T>::Copy(const v8::Persistent<S, M>&, v8::NonCopyablePersistentTraits<T>::NonCopyablePersistent*) [with S = v8::Object, M = v8::NonCopyablePersistentTraits<v8::Object>, T = v8::Object, v8::NonCopyablePersistentTraits<T>::NonCopyablePersistent = v8::Persistent<v8::Object>]’ /home/register/.node-gyp/0.12.0/deps/v8/include/v8.h:5826:3: instantiated from ‘void v8::Persistent<T, M>::Copy(const v8::Persistent<S, M>&) [with S = v8::Object, M2 = v8::NonCopyablePersistentTraits<v8::Object>, T = v8::Object, M = v8::NonCopyablePersistentTraits<v8::Object>]’ /home/register/.node-gyp/0.12.0/deps/v8/include/v8.h:657:5: instantiated from ‘v8::Persistent<T, M>::Persistent(const v8::Persistent<T, M>&) [with T = v8::Object, M = v8::NonCopyablePersistentTraits<v8::Object>, v8::Persistent<T, M> = v8::Persistent<v8::Object>]’ ../src/atom.cpp:90:46: instantiated from here /home/register/.node-gyp/0.12.0/deps/v8/include/v8.h:596:5: error: cannot convert ‘v8::Primitive*’ to ‘v8::Object* volatile’ in assignment make: *** [Release/obj.target/openbabel/src/atom.o] Error 1 make: Leaving directory/home/register/sf_install/node/lib/node_modules/openbabel/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/register/sf_install/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Linux 3.5.0-23-generic
gyp ERR! command "node" "/home/register/sf_install/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/register/sf_install/node/lib/node_modules/openbabel
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
npm ERR! Linux 3.5.0-23-generic
npm ERR! argv "/home/register/sf_install/node/bin/node" "/home/register/sf_install/node/bin/npm" "install" "openbabel" "-g"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the openbabel package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls openbabel
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/register/sf_install/node/lib/node_modules/npm/npm-debug.log

How can i fix my mistakes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.