I was trying to use the Perl interface to OpenBabel to do some RMSD calculations and found I couldn't since key functionality seemed to be missing. Specifically, the ability to manipulate SWIG C arrays in perl and access to a couple functions. Here are the changes I made to get things to work:
include/openbabel/obutil.h
156,164d155
< #ifndef __KCC
< extern "C" {
< OBAPI void rotate_coords(double,double m[3][3],unsigned int);
< OBAPI double calc_rms(double,double,unsigned int);
< }
< #else
< OBAPI void rotate_coords(double,double m[3][3],unsigned int);
< OBAPI double calc_rms(double,double,unsigned int);
< #endif
165a157,159
OBAPI void rotate_coords(double,double m[3][3],int);
OBAPI double calc_rms(double,double*,unsigned int);
scripts/openbabel-perl.i
163,188d162
< // Add some helper functions for C arrays
< %inline %{
< double double_array(int size) {
< return (double ) malloc(sizeof(double)size);
< }
< void double_destroy(int a) {
< free(a);
< }
< void double_set(double a, int i, double val) {
< a[i] = val;
< }
< double double_get(double a, int i) {
< return a[i];
< }
<
< double (rotation_matrix())[3] {
< return (double ()[3]) malloc(9sizeof(double));
< }
<
< void rotation_matrix_free(double (m)[3])
< {
< free(m);
< }
<
< %}
<
I don't know what version you've used for the patch -- it's definitely not SVN trunk. Could you e-mail me a patch for SVN trunk?
Thanks very much,
-Geoff
That was comparing against 2.2.3. Here's the diff for the trunk (note that rotate_coord had the wrong prototype, this is a subtle bug that is also fixed):
Index: include/openbabel/obutil.h
--- include/openbabel/obutil.h (revision 4112)
+++ include/openbabel/obutil.h (working copy)
@@ -153,10 +153,17 @@
};
//RMS helper methods/
+#ifndef __KCC
+ extern "C" {
+ OBAPI void rotate_coords(double,double m[3][3],unsigned);
+ OBAPI double calc_rms(double,double,unsigned int);
+ }
+#else
+ OBAPI void rotate_coords(double,double m[3][3],unsigned);
+ OBAPI double calc_rms(double,double,unsigned int);
+#endif
+
#ifndef SWIG
- OBAPI void rotate_coords(double,double m[3][3],int);
- OBAPI double calc_rms(double,double*,unsigned int);
-
//! \name String conversion utilities
//@{
// Documentation in obutil.cpp
Index: scripts/openbabel-perl.i
===================================================================
--- scripts/openbabel-perl.i (revision 4112)
+++ scripts/openbabel-perl.i (working copy)
@@ -276,6 +276,30 @@
}
%}
+// Add some helper functions for C arrays
+%inline %{
+double double_array(int size) {
+ return (double ) malloc(sizeof(double)size);
+}
+void double_destroy(int a) {
+ free(a);
+}
+void double_set(double a, int i, double val) {
+ a[i] = val;
+}
+double double_get(double a, int i) {
+ return a[i];
+}
+
+double (rotation_matrix())[3] {
+ return (double ()[3]) malloc(9sizeof(double));
+ }
+
+void rotation_matrix_free(double (m)[3]) {
+ free(m);
+}
+%}
+
%define MAKE_ITER_CLASS(itername, renamediter)
%rename itername renamediter;
%perlcode %{