2005-11-18 00:53:15 +00:00
|
|
|
%module openbabel
|
|
|
|
|
|
|
|
|
|
%{
|
2006-04-19 15:37:47 +00:00
|
|
|
// used to set import/export for Cygwin DLLs
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
#define USING_OBDLL
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2006-12-10 13:56:00 +00:00
|
|
|
#include <openbabel/obutil.h>
|
|
|
|
|
#include <openbabel/rand.h>
|
|
|
|
|
#include <openbabel/math/vector3.h>
|
|
|
|
|
#include <openbabel/math/matrix3x3.h>
|
|
|
|
|
#include <openbabel/generic.h>
|
|
|
|
|
|
|
|
|
|
#include <openbabel/base.h>
|
|
|
|
|
#include <openbabel/mol.h>
|
|
|
|
|
#include <openbabel/atom.h>
|
|
|
|
|
#include <openbabel/bond.h>
|
|
|
|
|
#include <openbabel/residue.h>
|
|
|
|
|
#include <openbabel/internalcoord.h>
|
|
|
|
|
|
|
|
|
|
#include <openbabel/ring.h>
|
|
|
|
|
#include <openbabel/obconversion.h>
|
|
|
|
|
#include <openbabel/oberror.h>
|
|
|
|
|
|
|
|
|
|
#include <openbabel/fingerprint.h>
|
|
|
|
|
|
|
|
|
|
#include <openbabel/data.h>
|
|
|
|
|
#include <openbabel/parsmart.h>
|
2005-11-18 00:53:15 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
%include "std_list.i"
|
|
|
|
|
%include "std_map.i"
|
|
|
|
|
%include "std_vector.i"
|
|
|
|
|
%include "std_string.i"
|
|
|
|
|
|
2006-03-14 00:47:39 +00:00
|
|
|
namespace std {
|
2006-06-06 16:28:28 +00:00
|
|
|
%template (vectorInt) vector<int>;
|
2006-12-12 12:48:54 +00:00
|
|
|
%template (vectorUnsignedInt) vector<unsigned int>;
|
2006-06-06 16:28:28 +00:00
|
|
|
%template (vvInt) vector< vector<int> >;
|
2006-03-14 00:47:39 +00:00
|
|
|
%template (vectorDouble) vector<double>;
|
2006-06-06 16:28:28 +00:00
|
|
|
%template (vVector3) vector<OpenBabel::vector3>;
|
2006-03-14 00:47:39 +00:00
|
|
|
|
2006-06-06 16:28:28 +00:00
|
|
|
%template (vectorMol) vector<OpenBabel::OBMol>;
|
2006-03-14 00:47:39 +00:00
|
|
|
%template (vectorBond) vector<OpenBabel::OBBond>;
|
|
|
|
|
%template (vectorResidue) vector<OpenBabel::OBResidue>;
|
|
|
|
|
%template (vectorRing) vector<OpenBabel::OBRing>;
|
2006-06-09 10:00:18 +00:00
|
|
|
%template (vectorData) vector<OpenBabel::OBGenericData*>;
|
2006-03-14 00:47:39 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-10 13:56:00 +00:00
|
|
|
%import <openbabel/babelconfig.h>
|
2005-11-18 00:53:15 +00:00
|
|
|
|
2006-10-17 20:36:33 +00:00
|
|
|
%apply std::string &OUTPUT { std::string &to };
|
2006-12-10 13:56:00 +00:00
|
|
|
%include <openbabel/data.h>
|
|
|
|
|
%include <openbabel/rand.h>
|
|
|
|
|
%include <openbabel/obutil.h>
|
|
|
|
|
%include <openbabel/math/vector3.h>
|
|
|
|
|
%import <openbabel/math/matrix3x3.h>
|
|
|
|
|
%include <openbabel/generic.h>
|
|
|
|
|
|
|
|
|
|
%include <openbabel/base.h>
|
|
|
|
|
|
|
|
|
|
%import <openbabel/chains.h>
|
|
|
|
|
%import <openbabel/bitvec.h>
|
|
|
|
|
%import <openbabel/typer.h>
|
|
|
|
|
|
|
|
|
|
%include <openbabel/oberror.h>
|
|
|
|
|
%include <openbabel/obconversion.h>
|
|
|
|
|
%include <openbabel/residue.h>
|
|
|
|
|
%include <openbabel/internalcoord.h>
|
|
|
|
|
%include <openbabel/atom.h>
|
|
|
|
|
%include <openbabel/bond.h>
|
|
|
|
|
%include <openbabel/mol.h>
|
|
|
|
|
%include <openbabel/ring.h>
|
|
|
|
|
%include <openbabel/parsmart.h>
|
|
|
|
|
%include <openbabel/fingerprint.h>
|
2006-10-27 21:10:17 +00:00
|
|
|
|
2006-12-12 12:48:54 +00:00
|
|
|
# The following %ignores avoid warning messages due to shadowed classes.
|
|
|
|
|
# This does not imply a loss of functionality as (in this case)
|
|
|
|
|
# the shadowed class is identical (from the point of view of SWIG) to
|
|
|
|
|
# the shadowing class.
|
|
|
|
|
# This is because C++ references (&) are transformed by SWIG back into
|
|
|
|
|
# pointers, so that OBAtomIter(OBMol &) would be treated the same as
|
|
|
|
|
# OBAtomIter(OBMol *).
|
|
|
|
|
|
|
|
|
|
%ignore OBMolAtomIter(OBMol &);
|
|
|
|
|
%ignore OBMolAtomDFSIter(OBMol &);
|
|
|
|
|
%ignore OBMolAtomBFSIter(OBMol &);
|
|
|
|
|
%ignore OBMolBondIter(OBMol &);
|
|
|
|
|
%ignore OBAtomAtomIter(OBAtom &);
|
|
|
|
|
%ignore OBAtomBondIter(OBAtom &);
|
2006-12-13 13:29:36 +00:00
|
|
|
%ignore OBResidueIter(OBMol &);
|
2006-12-12 12:48:54 +00:00
|
|
|
%ignore OBResidueAtomIter(OBResidue &);
|
|
|
|
|
|
2006-12-13 13:29:36 +00:00
|
|
|
# These classes are renamed so that they can be replaced by Python
|
|
|
|
|
# classes of the same name which provide Pythonic iterators
|
|
|
|
|
# (see %pythoncode section below)
|
|
|
|
|
|
|
|
|
|
%rename(_OBMolAtomIter) OpenBabel::OBMolAtomIter;
|
|
|
|
|
%rename(_OBMolBondIter) OpenBabel::OBMolBondIter;
|
|
|
|
|
%rename(_OBAtomAtomIter) OpenBabel::OBAtomAtomIter;
|
|
|
|
|
%rename(_OBAtomBondIter) OpenBabel::OBAtomBondIter;
|
|
|
|
|
%rename(_OBResidueIter) OpenBabel::OBResidueIter;
|
|
|
|
|
%rename(_OBResidueAtomIter) OpenBabel::OBResidueAtomIter;
|
|
|
|
|
|
|
|
|
|
# These methods are renamed to valid Python method names, as otherwise
|
|
|
|
|
# they cannot be used from Python
|
|
|
|
|
|
2006-10-27 21:10:17 +00:00
|
|
|
%rename(inc) OpenBabel::OBMolAtomIter::operator++;
|
|
|
|
|
%rename(inc) OpenBabel::OBMolBondIter::operator++;
|
|
|
|
|
%rename(inc) OpenBabel::OBAtomAtomIter::operator++;
|
|
|
|
|
%rename(inc) OpenBabel::OBAtomBondIter::operator++;
|
2006-12-13 13:29:36 +00:00
|
|
|
%rename(inc) OpenBabel::OBResidueIter::operator++;
|
|
|
|
|
%rename(inc) OpenBabel::OBResidueAtomIter::operator++;
|
2006-10-27 21:10:17 +00:00
|
|
|
%rename(good) OpenBabel::OBMolAtomIter::operator bool;
|
|
|
|
|
%rename(good) OpenBabel::OBMolBondIter::operator bool;
|
|
|
|
|
%rename(good) OpenBabel::OBAtomAtomIter::operator bool;
|
|
|
|
|
%rename(good) OpenBabel::OBAtomBondIter::operator bool;
|
2006-12-13 13:29:36 +00:00
|
|
|
%rename(good) OpenBabel::OBResidueIter::operator bool;
|
|
|
|
|
%rename(good) OpenBabel::OBResidueAtomIter::operator bool;
|
2006-10-27 21:10:17 +00:00
|
|
|
%rename(deref) OpenBabel::OBMolAtomIter::operator->;
|
|
|
|
|
%rename(deref) OpenBabel::OBMolBondIter::operator->;
|
|
|
|
|
%rename(deref) OpenBabel::OBAtomAtomIter::operator->;
|
|
|
|
|
%rename(deref) OpenBabel::OBAtomBondIter::operator->;
|
2006-12-13 13:29:36 +00:00
|
|
|
%rename(deref) OpenBabel::OBResidueIter::operator->;
|
2006-10-27 21:10:17 +00:00
|
|
|
%rename(deref) OpenBabel::OBResidueAtomIter::operator->;
|
|
|
|
|
|
2006-12-10 13:56:00 +00:00
|
|
|
%include <openbabel/obiter.h>
|
2006-11-29 13:55:16 +00:00
|
|
|
|
2006-12-13 13:29:36 +00:00
|
|
|
# The following class, OBiter, is subclassed to provide Python iterators
|
|
|
|
|
# equivalent to the C++ iterators in obiter.h
|
|
|
|
|
|
|
|
|
|
%pythoncode %{
|
|
|
|
|
class OBIter(object):
|
|
|
|
|
OBiterator = None # This is defined by the subclasses
|
|
|
|
|
|
|
|
|
|
def __init__(self, mol):
|
|
|
|
|
self.iter = self.OBiterator(mol)
|
|
|
|
|
self.finished = False
|
|
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
def next(self):
|
|
|
|
|
if not self.finished:
|
|
|
|
|
b = self.iter.deref()
|
|
|
|
|
self.iter.inc()
|
|
|
|
|
if not self.iter.good():
|
|
|
|
|
# There is nothing left to iterate over
|
|
|
|
|
self.finished = True
|
|
|
|
|
return b
|
|
|
|
|
else:
|
|
|
|
|
raise StopIteration
|
|
|
|
|
|
|
|
|
|
class OBMolAtomIter(OBIter):
|
|
|
|
|
"""Iterator over the atoms in a molecule."""
|
|
|
|
|
OBiterator = _OBMolAtomIter
|
|
|
|
|
class OBMolBondIter(OBIter):
|
|
|
|
|
"""Iterator over the bonds in a molecule."""
|
|
|
|
|
OBiterator = _OBMolBondIter
|
|
|
|
|
class OBAtomAtomIter(OBIter):
|
|
|
|
|
"""Iterator over the atoms attached to an atom."""
|
|
|
|
|
OBiterator = _OBAtomAtomIter
|
|
|
|
|
class OBAtomBondIter(OBIter):
|
|
|
|
|
"""Iterator over the bonds attached to an atom."""
|
|
|
|
|
OBiterator = _OBAtomBondIter
|
|
|
|
|
class OBResidueIter(OBIter):
|
|
|
|
|
"""Iterator over the residues in a molecule."""
|
|
|
|
|
OBiterator = _OBResidueIter
|
|
|
|
|
class OBResidueAtomIter(OBIter):
|
|
|
|
|
"""Iterator over the atoms in a residue."""
|
|
|
|
|
OBiterator = _OBResidueAtomIter
|
|
|
|
|
%}
|
|
|
|
|
|
2006-11-29 13:55:16 +00:00
|
|
|
%include "carrays.i"
|
|
|
|
|
%array_class(double, doubleArray)
|
|
|
|
|
%pythoncode %{
|
|
|
|
|
def double_array(mylist):
|
|
|
|
|
"""Create a C array of doubles from a list."""
|
|
|
|
|
c = doubleArray(len(mylist))
|
|
|
|
|
for i,v in enumerate(mylist):
|
|
|
|
|
c[i] = v
|
|
|
|
|
return c
|
|
|
|
|
%}
|
|
|
|
|
|