// compile: gcc -shared -Wall -fPIC `/cluster/user/armin/bin/modeller9.10/bin/mod9.10 --cflags --libs` `pkg-config --cflags glib-2.0` -I/usr/include/python2.4 cuser_form56.c cuser_form56_wrap.c -o _cuser_form56.so -lm // this is a reimplemtation of MODELLER's multiple Gaussian distance restraints // there is an additional parameter W which sets the weight for all restraints explicity (instead of the physical_schedule in python file) #include #include "modeller.h" #include "cuser_form56.h" #include #include #include static const float RT = 6.0; static const float W = 1; float get_p(float stdev, float x, float delta) { return exp(-0.5 * delta * delta / (stdev*stdev)) / x; } /////////////////////// /* Evaluate the form */ /////////////////////// static int myform_eval(void *data, const float *feat, const int *iftyp, const int *modal, int n_feat, const float *pcsr, int n_pcsr, gboolean deriv, float *fderv, float *val) { const int numComp = *modal; double w[numComp]; double mean[numComp]; double sd[numComp]; double p[numComp]; double v[numComp]; int i; // fill in values from rsr file for (i=0; i rgauss2) { v[i] = rgauss2 - 1E-10; } if (v[i] > rgauss1 && v[i] <= rgauss2) { double M = 37; // maximal exponent for exp double A = (rgauss2 - M) / (M * (rgauss2 - rgauss1)); double B = (rgauss2 / M) * ((M - rgauss1) / (rgauss2 - rgauss1)); v[i] = v[i] / (A*abs(v[i]) + B); } } double sum = 0; for (i=0; i