[f2d6445] | 1 | // -*- C++ -*- |
---|
| 2 | #include <Python.h> |
---|
| 3 | |
---|
| 4 | #include <vector> |
---|
| 5 | #include <cstring> |
---|
| 6 | #include <stdexcept> |
---|
| 7 | #include "Point3D.h" |
---|
| 8 | #include "misc.h" |
---|
| 9 | #include "lores_model.h" |
---|
| 10 | #include "pdb_model.h" |
---|
| 11 | #include "complex_model.h" |
---|
| 12 | #include "geo_shape.h" |
---|
| 13 | #include "iq.h" |
---|
| 14 | |
---|
| 15 | // copyright |
---|
| 16 | |
---|
| 17 | char pypointsmodelpy_copyright__doc__[] = ""; |
---|
| 18 | char pypointsmodelpy_copyright__name__[] = "copyright"; |
---|
| 19 | |
---|
| 20 | static char pypointsmodelpy_copyright_note[] = |
---|
| 21 | "pointsmodelpy python module: Copyright (c) 2007 University of Tennessee"; |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | PyObject * pypointsmodelpy_copyright(PyObject *, PyObject *) |
---|
| 25 | { |
---|
| 26 | return Py_BuildValue("s", pypointsmodelpy_copyright_note); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | // new_loresmodel |
---|
| 30 | //wrapper for LORESModel constructor LORESModel(double density) |
---|
| 31 | |
---|
| 32 | char pypointsmodelpy_new_loresmodel__doc__[] = "Low-resolution shapes:real space geometric complex models"; |
---|
| 33 | char pypointsmodelpy_new_loresmodel__name__[] = "new_loresmodel"; |
---|
| 34 | |
---|
| 35 | PyObject * pypointsmodelpy_new_loresmodel(PyObject *, PyObject *args) |
---|
| 36 | { |
---|
| 37 | double density = 0; |
---|
| 38 | |
---|
| 39 | int ok = PyArg_ParseTuple(args, "d",&density); |
---|
| 40 | if(!ok) return NULL; |
---|
| 41 | |
---|
| 42 | LORESModel *newlores = new LORESModel(density); |
---|
| 43 | return PyCObject_FromVoidPtr(newlores, PyDelLores); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | void PyDelLores(void *ptr){ |
---|
| 47 | LORESModel * oldlores = static_cast<LORESModel *>(ptr); |
---|
| 48 | delete oldlores; |
---|
| 49 | return; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | //LORESModel methods add(GeoShape &, double sld) |
---|
| 53 | char pypointsmodelpy_lores_add__name__[] = "lores_add"; |
---|
| 54 | char pypointsmodelpy_lores_add__doc__[] = "loresmodel method:add(Geoshape &,sld)"; |
---|
| 55 | |
---|
| 56 | PyObject * pypointsmodelpy_lores_add(PyObject *, PyObject *args){ |
---|
| 57 | double sld = 1; |
---|
| 58 | PyObject *pyloresmodel = 0, *pyshape = 0; |
---|
| 59 | int ok = PyArg_ParseTuple(args, "OOd", &pyloresmodel, &pyshape, &sld); |
---|
| 60 | if(!ok) return NULL; |
---|
| 61 | |
---|
| 62 | void *temp = PyCObject_AsVoidPtr(pyloresmodel); |
---|
| 63 | void *temp2 = PyCObject_AsVoidPtr(pyshape); |
---|
| 64 | |
---|
| 65 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 66 | GeoShape * thisshape = static_cast<GeoShape *>(temp2); |
---|
| 67 | |
---|
| 68 | thislores->Add(*thisshape, sld); |
---|
| 69 | |
---|
| 70 | return Py_BuildValue("i", 0); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | //LORESModel methods GetPoints(vector<Point3D> &) |
---|
| 74 | char pypointsmodelpy_get_lorespoints__name__[] = "get_lorespoints"; |
---|
| 75 | char pypointsmodelpy_get_lorespoints__doc__[] = "get the points from the lores model"; |
---|
| 76 | |
---|
| 77 | PyObject * pypointsmodelpy_get_lorespoints(PyObject *, PyObject *args){ |
---|
| 78 | PyObject *pyloresmodel = 0, *pypoint3dvec = 0; |
---|
| 79 | int ok = PyArg_ParseTuple(args, "OO", &pyloresmodel, &pypoint3dvec); |
---|
| 80 | if(!ok) return NULL; |
---|
| 81 | |
---|
| 82 | void *temp = PyCObject_AsVoidPtr(pyloresmodel); |
---|
| 83 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 84 | |
---|
| 85 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 86 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 87 | |
---|
| 88 | int npts = thislores->GetPoints(*thisvec); |
---|
| 89 | //temporary |
---|
| 90 | thislores->WritePoints2File(*thisvec); |
---|
| 91 | return Py_BuildValue("i", npts); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | // new_pdbmodel |
---|
| 95 | //wrapper for PDBModel constructor PDBModel() |
---|
| 96 | |
---|
| 97 | char pypointsmodelpy_new_pdbmodel__doc__[] = "PDB model: contain atomic coordinate from PDB file & Scattering length density"; |
---|
| 98 | char pypointsmodelpy_new_pdbmodel__name__[] = "new_pdbmodel"; |
---|
| 99 | |
---|
| 100 | PyObject * pypointsmodelpy_new_pdbmodel(PyObject *, PyObject *args) |
---|
| 101 | { |
---|
| 102 | PDBModel *newpdb = new PDBModel(); |
---|
| 103 | return PyCObject_FromVoidPtr(newpdb, PyDelPDB); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | void PyDelPDB(void *ptr){ |
---|
| 107 | PDBModel * oldpdb = static_cast<PDBModel *>(ptr); |
---|
| 108 | delete oldpdb; |
---|
| 109 | return; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | //PDBModel methods AddPDB(char * pdbfile) |
---|
| 113 | char pypointsmodelpy_pdbmodel_add__name__[] = "pdbmodel_add"; |
---|
| 114 | char pypointsmodelpy_pdbmodel_add__doc__[] = "Add a structure from PDB"; |
---|
| 115 | |
---|
| 116 | PyObject * pypointsmodelpy_pdbmodel_add(PyObject *, PyObject *args){ |
---|
| 117 | PyObject *pypdbmodel = 0; |
---|
| 118 | char * pdbfile; |
---|
| 119 | |
---|
| 120 | int ok = PyArg_ParseTuple(args, "Os", &pypdbmodel, &pdbfile); |
---|
| 121 | if(!ok) return NULL; |
---|
| 122 | |
---|
| 123 | void *temp = PyCObject_AsVoidPtr(pypdbmodel); |
---|
| 124 | |
---|
| 125 | PDBModel * thispdb = static_cast<PDBModel *>(temp); |
---|
| 126 | |
---|
| 127 | thispdb->AddPDB(pdbfile); |
---|
| 128 | |
---|
| 129 | return Py_BuildValue("i", 0); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | //PDBModel methods GetPoints(Point3DVector &) |
---|
| 133 | char pypointsmodelpy_get_pdbpoints__name__[] = "get_pdbpoints"; |
---|
| 134 | char pypointsmodelpy_get_pdbpoints__doc__[] = "Get atomic points from pdb with SLD"; |
---|
| 135 | |
---|
| 136 | PyObject * pypointsmodelpy_get_pdbpoints(PyObject *, PyObject *args){ |
---|
| 137 | PyObject *pypdbmodel = 0, *pypoint3dvec = 0; |
---|
| 138 | int ok = PyArg_ParseTuple(args, "OO", &pypdbmodel, &pypoint3dvec); |
---|
| 139 | if(!ok) return NULL; |
---|
| 140 | |
---|
| 141 | void *temp = PyCObject_AsVoidPtr(pypdbmodel); |
---|
| 142 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 143 | |
---|
| 144 | PDBModel * thispdb = static_cast<PDBModel *>(temp); |
---|
| 145 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 146 | |
---|
| 147 | int npts = thispdb->GetPoints(*thisvec); |
---|
| 148 | |
---|
| 149 | return Py_BuildValue("i", npts); |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | // new_complexmodel |
---|
| 153 | //wrapper for ComplexModel constructor ComplexModel() |
---|
| 154 | |
---|
| 155 | char pypointsmodelpy_new_complexmodel__doc__[] = "COMPLEX model: contain LORES and PDB models"; |
---|
| 156 | char pypointsmodelpy_new_complexmodel__name__[] = "new_complexmodel"; |
---|
| 157 | |
---|
| 158 | PyObject * pypointsmodelpy_new_complexmodel(PyObject *, PyObject *args) |
---|
| 159 | { |
---|
| 160 | ComplexModel *newcomplex = new ComplexModel(); |
---|
| 161 | return PyCObject_FromVoidPtr(newcomplex, PyDelComplex); |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | void PyDelComplex(void *ptr){ |
---|
| 165 | ComplexModel * oldcomplex = static_cast<ComplexModel *>(ptr); |
---|
| 166 | delete oldcomplex; |
---|
| 167 | return; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | //ComplexModel methods Add(PointsModel *) |
---|
| 171 | char pypointsmodelpy_complexmodel_add__name__[] = "complexmodel_add"; |
---|
| 172 | char pypointsmodelpy_complexmodel_add__doc__[] = "Add LORES model or PDB Model,type has to be specified (either PDB or LORES)"; |
---|
| 173 | |
---|
| 174 | PyObject * pypointsmodelpy_complexmodel_add(PyObject *, PyObject *args){ |
---|
| 175 | PyObject *pycomplexmodel = 0, *pymodel = 0; |
---|
| 176 | char * modeltype; |
---|
| 177 | |
---|
| 178 | int ok = PyArg_ParseTuple(args, "OOs", &pycomplexmodel,&pymodel, &modeltype); |
---|
| 179 | if(!ok) return NULL; |
---|
| 180 | |
---|
| 181 | void *temp2 = PyCObject_AsVoidPtr(pycomplexmodel); |
---|
| 182 | ComplexModel *thiscomplex = static_cast<ComplexModel *>(temp2); |
---|
| 183 | |
---|
| 184 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 185 | if (strcmp(modeltype,"LORES") == 0){ |
---|
| 186 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 187 | thiscomplex->Add(thislores); |
---|
| 188 | } |
---|
| 189 | else if (strcmp(modeltype,"PDB") == 0){ |
---|
| 190 | PDBModel * thispdb = static_cast<PDBModel *>(temp); |
---|
| 191 | thiscomplex->Add(thispdb); |
---|
| 192 | } |
---|
| 193 | else{ |
---|
| 194 | throw runtime_error("The model type is either PDB or LORES"); |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | return Py_BuildValue("i", 0); |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | //ComplexModel methods GetPoints(Point3DVector &) |
---|
| 201 | char pypointsmodelpy_get_complexpoints__name__[] = "get_complexpoints"; |
---|
| 202 | char pypointsmodelpy_get_complexpoints__doc__[] = "Get points from complex model (container for LORES & PDB model)"; |
---|
| 203 | |
---|
| 204 | PyObject * pypointsmodelpy_get_complexpoints(PyObject *, PyObject *args){ |
---|
| 205 | PyObject *pycomplexmodel = 0, *pypoint3dvec = 0; |
---|
| 206 | int ok = PyArg_ParseTuple(args, "OO", &pycomplexmodel, &pypoint3dvec); |
---|
| 207 | if(!ok) return NULL; |
---|
| 208 | |
---|
| 209 | void *temp = PyCObject_AsVoidPtr(pycomplexmodel); |
---|
| 210 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 211 | |
---|
| 212 | ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp); |
---|
| 213 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 214 | |
---|
| 215 | int npts = thiscomplex->GetPoints(*thisvec); |
---|
| 216 | |
---|
| 217 | return Py_BuildValue("i", npts); |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | //create a new vector that holds of class Point3D objects |
---|
| 221 | char pypointsmodelpy_new_point3dvec__doc__[] = ""; |
---|
| 222 | char pypointsmodelpy_new_point3dvec__name__[] = "new_point3dvec"; |
---|
| 223 | |
---|
| 224 | PyObject * pypointsmodelpy_new_point3dvec(PyObject *, PyObject *args) |
---|
| 225 | { |
---|
| 226 | PyObject *pyvec = 0; |
---|
| 227 | |
---|
| 228 | vector<Point3D> *newvec = new vector<Point3D>(); |
---|
| 229 | |
---|
| 230 | return PyCObject_FromVoidPtr(newvec, PyDelPoint3DVec); |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | void PyDelPoint3DVec(void *ptr) |
---|
| 234 | { |
---|
| 235 | vector<Point3D> * oldvec = static_cast<vector<Point3D> *>(ptr); |
---|
| 236 | delete oldvec; |
---|
| 237 | return; |
---|
| 238 | |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | //LORESModel method distribution(point3dvec) |
---|
| 242 | char pypointsmodelpy_get_lores_pr__name__[] = "get_lores_pr"; |
---|
| 243 | char pypointsmodelpy_get_lores_pr__doc__[] = "calculate distance distribution function"; |
---|
| 244 | |
---|
| 245 | PyObject * pypointsmodelpy_get_lores_pr(PyObject *, PyObject *args) |
---|
| 246 | { |
---|
| 247 | PyObject *pymodel = 0, *pypoint3dvec = 0; |
---|
| 248 | int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pypoint3dvec); |
---|
| 249 | if(!ok) return NULL; |
---|
| 250 | |
---|
| 251 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 252 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 253 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 254 | |
---|
| 255 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 256 | double rmax = thislores->DistDistribution(*thisvec); |
---|
| 257 | |
---|
| 258 | return Py_BuildValue("d", rmax); |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | //LORESModel method distribution_xy(point3dvec) |
---|
| 262 | char pypointsmodelpy_distdistribution_xy__name__[] = "distdistribution_xy"; |
---|
| 263 | char pypointsmodelpy_distdistribution_xy__doc__[] = "calculate distance distribution function on XY plane"; |
---|
| 264 | |
---|
| 265 | PyObject * pypointsmodelpy_distdistribution_xy(PyObject *, PyObject *args) |
---|
| 266 | { |
---|
| 267 | PyObject *pymodel = 0, *pypoint3dvec = 0; |
---|
| 268 | int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pypoint3dvec); |
---|
| 269 | if(!ok) return NULL; |
---|
| 270 | |
---|
| 271 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 272 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 273 | |
---|
| 274 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 275 | |
---|
[bbfad0a] | 276 | Py_BEGIN_ALLOW_THREADS |
---|
[f2d6445] | 277 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 278 | thislores->DistDistributionXY(*thisvec); |
---|
[bbfad0a] | 279 | Py_END_ALLOW_THREADS |
---|
| 280 | |
---|
[f2d6445] | 281 | return Py_BuildValue("i", 0); |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | //PDBModel method distribution_xy(point3dvec) |
---|
| 285 | char pypointsmodelpy_get_pdb_pr_xy__name__[] = "get_pdb_pr_xy"; |
---|
| 286 | char pypointsmodelpy_get_pdb_pr_xy__doc__[] = "calculate distance distribution function on XY plane"; |
---|
| 287 | |
---|
| 288 | PyObject * pypointsmodelpy_get_pdb_pr_xy(PyObject *, PyObject *args) |
---|
| 289 | { |
---|
| 290 | PyObject *pymodel = 0, *pypoint3dvec = 0; |
---|
| 291 | int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pypoint3dvec); |
---|
| 292 | if(!ok) return NULL; |
---|
| 293 | |
---|
| 294 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 295 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 296 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 297 | |
---|
| 298 | PDBModel * thispdb = static_cast<PDBModel *>(temp); |
---|
| 299 | thispdb->DistDistributionXY(*thisvec); |
---|
| 300 | |
---|
| 301 | return Py_BuildValue("i", 0); |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | //PDBModel method distribution(point3dvec) |
---|
| 305 | char pypointsmodelpy_get_pdb_pr__name__[] = "get_pdb_pr"; |
---|
| 306 | char pypointsmodelpy_get_pdb_pr__doc__[] = "calculate distance distribution function"; |
---|
| 307 | |
---|
| 308 | PyObject * pypointsmodelpy_get_pdb_pr(PyObject *, PyObject *args) |
---|
| 309 | { |
---|
| 310 | PyObject *pymodel = 0, *pypoint3dvec = 0; |
---|
| 311 | int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pypoint3dvec); |
---|
| 312 | if(!ok) return NULL; |
---|
| 313 | |
---|
| 314 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 315 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 316 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 317 | |
---|
[bbfad0a] | 318 | Py_BEGIN_ALLOW_THREADS |
---|
[f2d6445] | 319 | PDBModel * thispdb = static_cast<PDBModel *>(temp); |
---|
| 320 | thispdb->DistDistribution(*thisvec); |
---|
[bbfad0a] | 321 | Py_END_ALLOW_THREADS |
---|
| 322 | |
---|
[f2d6445] | 323 | return Py_BuildValue("i", 0); |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | //ComplexModel method distribution(point3dvec) |
---|
| 327 | char pypointsmodelpy_get_complex_pr__name__[] = "get_complex_pr"; |
---|
| 328 | char pypointsmodelpy_get_complex_pr__doc__[] = "calculate distance distribution function"; |
---|
| 329 | |
---|
| 330 | PyObject * pypointsmodelpy_get_complex_pr(PyObject *, PyObject *args) |
---|
| 331 | { |
---|
| 332 | PyObject *pymodel = 0, *pypoint3dvec = 0; |
---|
| 333 | int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pypoint3dvec); |
---|
| 334 | if(!ok) return NULL; |
---|
| 335 | |
---|
| 336 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 337 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 338 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 339 | |
---|
| 340 | ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp); |
---|
[bbfad0a] | 341 | Py_BEGIN_ALLOW_THREADS |
---|
[f2d6445] | 342 | thiscomplex->DistDistribution(*thisvec); |
---|
[bbfad0a] | 343 | Py_END_ALLOW_THREADS |
---|
[f2d6445] | 344 | return Py_BuildValue("i", 0); |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | //LORESModel method CalculateIQ(iq) |
---|
| 348 | char pypointsmodelpy_get_lores_iq__name__[] = "get_lores_iq"; |
---|
| 349 | char pypointsmodelpy_get_lores_iq__doc__[] = "calculate scattering intensity"; |
---|
| 350 | |
---|
| 351 | PyObject * pypointsmodelpy_get_lores_iq(PyObject *, PyObject *args) |
---|
| 352 | { |
---|
| 353 | PyObject *pylores = 0, *pyiq = 0; |
---|
| 354 | int ok = PyArg_ParseTuple(args, "OO", &pylores, &pyiq); |
---|
| 355 | if(!ok) return NULL; |
---|
| 356 | |
---|
| 357 | void *temp = PyCObject_AsVoidPtr(pylores); |
---|
| 358 | void *temp2 = PyCObject_AsVoidPtr(pyiq); |
---|
| 359 | |
---|
| 360 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 361 | IQ * thisiq = static_cast<IQ *>(temp2); |
---|
| 362 | |
---|
[bbfad0a] | 363 | Py_BEGIN_ALLOW_THREADS |
---|
[f2d6445] | 364 | thislores->CalculateIQ(thisiq); |
---|
[bbfad0a] | 365 | Py_END_ALLOW_THREADS |
---|
| 366 | |
---|
[f2d6445] | 367 | return Py_BuildValue("i",0); |
---|
| 368 | } |
---|
| 369 | |
---|
| 370 | //LORESModel method CalculateIQ(q) |
---|
| 371 | char pypointsmodelpy_get_lores_i__name__[] = "get_lores_i"; |
---|
| 372 | char pypointsmodelpy_get_lores_i__doc__[] = "calculate averaged scattering intensity from a single q"; |
---|
| 373 | |
---|
| 374 | PyObject * pypointsmodelpy_get_lores_i(PyObject *, PyObject *args) |
---|
| 375 | { |
---|
| 376 | PyObject *pylores = 0; |
---|
| 377 | double q = 0; |
---|
| 378 | int ok = PyArg_ParseTuple(args, "Od", &pylores, &q); |
---|
| 379 | if(!ok) return NULL; |
---|
| 380 | |
---|
| 381 | void *temp = PyCObject_AsVoidPtr(pylores); |
---|
| 382 | |
---|
| 383 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
[bbfad0a] | 384 | |
---|
| 385 | double I = 0.0; |
---|
| 386 | Py_BEGIN_ALLOW_THREADS |
---|
| 387 | I = thislores->CalculateIQ(q); |
---|
| 388 | Py_END_ALLOW_THREADS |
---|
| 389 | |
---|
[f2d6445] | 390 | return Py_BuildValue("d",I); |
---|
| 391 | } |
---|
| 392 | |
---|
| 393 | // method calculateIQ_2D(iq) |
---|
| 394 | char pypointsmodelpy_calculateIQ_2D__name__[] = "calculateIQ_2D"; |
---|
| 395 | char pypointsmodelpy_calculateIQ_2D__doc__[] = "calculate scattering intensity"; |
---|
| 396 | |
---|
| 397 | PyObject * pypointsmodelpy_calculateIQ_2D(PyObject *, PyObject *args) |
---|
| 398 | { |
---|
| 399 | PyObject *pylores = 0, *pyiq = 0; |
---|
| 400 | double theta = 0; |
---|
| 401 | int ok = PyArg_ParseTuple(args, "OOd", &pylores, &pyiq,&theta); |
---|
| 402 | if(!ok) return NULL; |
---|
| 403 | |
---|
| 404 | void *temp = PyCObject_AsVoidPtr(pylores); |
---|
| 405 | void *temp2 = PyCObject_AsVoidPtr(pyiq); |
---|
| 406 | |
---|
| 407 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 408 | IQ * thisiq = static_cast<IQ *>(temp2); |
---|
[bbfad0a] | 409 | |
---|
| 410 | Py_BEGIN_ALLOW_THREADS |
---|
[f2d6445] | 411 | thislores->CalculateIQ_2D(thisiq,theta); |
---|
[bbfad0a] | 412 | Py_END_ALLOW_THREADS |
---|
| 413 | |
---|
[f2d6445] | 414 | return Py_BuildValue("i",0); |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | // method calculateI_Qxy(Qx,Qy) |
---|
| 418 | char pypointsmodelpy_calculateI_Qxy__name__[] = "calculateI_Qxy"; |
---|
| 419 | char pypointsmodelpy_calculateI_Qxy__doc__[] = "calculate scattering intensity on a 2D pixel"; |
---|
| 420 | |
---|
| 421 | PyObject * pypointsmodelpy_calculateI_Qxy(PyObject *, PyObject *args) |
---|
| 422 | { |
---|
| 423 | PyObject *pylores = 0; |
---|
| 424 | double qx = 0, qy = 0; |
---|
| 425 | double I = 0; |
---|
| 426 | |
---|
| 427 | int ok = PyArg_ParseTuple(args, "Odd", &pylores, &qx,&qy); |
---|
| 428 | if(!ok) return NULL; |
---|
| 429 | |
---|
| 430 | void *temp = PyCObject_AsVoidPtr(pylores); |
---|
| 431 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
[bbfad0a] | 432 | |
---|
| 433 | Py_BEGIN_ALLOW_THREADS |
---|
[f2d6445] | 434 | I = thislores->CalculateIQ_2D(qx,qy); |
---|
[bbfad0a] | 435 | Py_END_ALLOW_THREADS |
---|
| 436 | |
---|
[f2d6445] | 437 | return Py_BuildValue("d",I); |
---|
| 438 | } |
---|
| 439 | |
---|
[2bb0b26] | 440 | // method calculateI_Qxy(poitns, Qx,Qy) |
---|
| 441 | char pypointsmodelpy_calculateI_Qvxy__name__[] = "calculateI_Qvxy"; |
---|
| 442 | char pypointsmodelpy_calculateI_Qvxy__doc__[] = "calculate scattering intensity on a 2D pixel"; |
---|
| 443 | |
---|
| 444 | PyObject * pypointsmodelpy_calculateI_Qvxy(PyObject *, PyObject *args) |
---|
| 445 | { |
---|
| 446 | PyObject *pylores = 0, *pypoint3dvec = 0; |
---|
| 447 | double qx = 0, qy = 0; |
---|
| 448 | double I = 0; |
---|
| 449 | |
---|
| 450 | int ok = PyArg_ParseTuple(args, "OOdd", &pylores, &pypoint3dvec, &qx,&qy); |
---|
| 451 | if(!ok) return NULL; |
---|
| 452 | |
---|
| 453 | void *temp = PyCObject_AsVoidPtr(pylores); |
---|
| 454 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 455 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 456 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 457 | |
---|
[bbfad0a] | 458 | Py_BEGIN_ALLOW_THREADS |
---|
[2bb0b26] | 459 | I = thislores->CalculateIQ_2D(*thisvec, qx,qy); |
---|
[bbfad0a] | 460 | Py_END_ALLOW_THREADS |
---|
| 461 | |
---|
[2bb0b26] | 462 | return Py_BuildValue("d",I); |
---|
| 463 | } |
---|
| 464 | |
---|
[f2d6445] | 465 | // PDBModel method calculateIQ(iq) |
---|
| 466 | char pypointsmodelpy_get_pdb_iq__name__[] = "get_pdb_iq"; |
---|
| 467 | char pypointsmodelpy_get_pdb_iq__doc__[] = "calculate scattering intensity for PDB model"; |
---|
| 468 | |
---|
| 469 | PyObject * pypointsmodelpy_get_pdb_iq(PyObject *, PyObject *args) |
---|
| 470 | { |
---|
| 471 | PyObject *pymodel = 0, *pyiq = 0; |
---|
| 472 | int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pyiq); |
---|
| 473 | if(!ok) return NULL; |
---|
| 474 | |
---|
| 475 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 476 | void *temp2 = PyCObject_AsVoidPtr(pyiq); |
---|
| 477 | |
---|
| 478 | PDBModel * thispdb = static_cast<PDBModel *>(temp); |
---|
| 479 | IQ * thisiq = static_cast<IQ *>(temp2); |
---|
| 480 | |
---|
[bbfad0a] | 481 | Py_BEGIN_ALLOW_THREADS |
---|
[f2d6445] | 482 | thispdb->CalculateIQ(thisiq); |
---|
[bbfad0a] | 483 | Py_END_ALLOW_THREADS |
---|
| 484 | |
---|
[f2d6445] | 485 | return Py_BuildValue("i",0); |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | // PDBModel method calculateIQ_2D(qx,qy) |
---|
| 489 | char pypointsmodelpy_get_pdb_Iqxy__name__[] = "get_pdb_Iqxy"; |
---|
| 490 | char pypointsmodelpy_get_pdb_Iqxy__doc__[] = "calculate scattering intensity by a given (qx,qy) for PDB model"; |
---|
| 491 | |
---|
| 492 | PyObject * pypointsmodelpy_get_pdb_Iqxy(PyObject *, PyObject *args) |
---|
| 493 | { |
---|
| 494 | PyObject *pypdb = 0; |
---|
| 495 | double qx = 0, qy = 0; |
---|
| 496 | double I = 0; |
---|
| 497 | |
---|
| 498 | int ok = PyArg_ParseTuple(args, "Odd", &pypdb, &qx,&qy); |
---|
| 499 | if(!ok) return NULL; |
---|
| 500 | |
---|
| 501 | void *temp = PyCObject_AsVoidPtr(pypdb); |
---|
| 502 | PDBModel * thispdb = static_cast<PDBModel *>(temp); |
---|
| 503 | |
---|
[bbfad0a] | 504 | Py_BEGIN_ALLOW_THREADS |
---|
[f2d6445] | 505 | I = thispdb->CalculateIQ_2D(qx,qy); |
---|
[bbfad0a] | 506 | Py_END_ALLOW_THREADS |
---|
| 507 | |
---|
[f2d6445] | 508 | return Py_BuildValue("d",I); |
---|
| 509 | } |
---|
| 510 | |
---|
[2bb0b26] | 511 | // PDBModel method calculateIQ_2Dv(points,qx,qy) |
---|
| 512 | char pypointsmodelpy_get_pdb_Iqvxy__name__[] = "get_pdb_Iqvxy"; |
---|
| 513 | char pypointsmodelpy_get_pdb_Iqvxy__doc__[] = "calculate scattering intensity by a given (qx,qy) for PDB model"; |
---|
| 514 | |
---|
| 515 | PyObject * pypointsmodelpy_get_pdb_Iqvxy(PyObject *, PyObject *args) |
---|
| 516 | { |
---|
| 517 | PyObject *pypdb = 0, *pypoint3dvec = 0; |
---|
| 518 | double qx = 0, qy = 0; |
---|
| 519 | double I = 0; |
---|
| 520 | |
---|
| 521 | int ok = PyArg_ParseTuple(args, "OOdd", &pypdb, &pypoint3dvec, &qx,&qy); |
---|
| 522 | if(!ok) return NULL; |
---|
| 523 | |
---|
| 524 | void *temp = PyCObject_AsVoidPtr(pypdb); |
---|
| 525 | PDBModel * thispdb = static_cast<PDBModel *>(temp); |
---|
| 526 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 527 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 528 | |
---|
[bbfad0a] | 529 | Py_BEGIN_ALLOW_THREADS |
---|
[2bb0b26] | 530 | I = thispdb->CalculateIQ_2D(*thisvec,qx,qy); |
---|
[bbfad0a] | 531 | Py_END_ALLOW_THREADS |
---|
| 532 | |
---|
[2bb0b26] | 533 | return Py_BuildValue("d",I); |
---|
| 534 | } |
---|
| 535 | |
---|
[f2d6445] | 536 | // ComplexModel method calculateIQ(iq) |
---|
| 537 | char pypointsmodelpy_get_complex_iq__name__[] = "get_complex_iq"; |
---|
| 538 | char pypointsmodelpy_get_complex_iq__doc__[] = "calculate scattering intensity for COMPLEX model"; |
---|
| 539 | |
---|
| 540 | PyObject * pypointsmodelpy_get_complex_iq(PyObject *, PyObject *args) |
---|
| 541 | { |
---|
| 542 | PyObject *pymodel = 0, *pyiq = 0; |
---|
| 543 | int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pyiq); |
---|
| 544 | if(!ok) return NULL; |
---|
| 545 | |
---|
| 546 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 547 | void *temp2 = PyCObject_AsVoidPtr(pyiq); |
---|
| 548 | |
---|
| 549 | ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp); |
---|
| 550 | IQ * thisiq = static_cast<IQ *>(temp2); |
---|
| 551 | |
---|
[bbfad0a] | 552 | Py_BEGIN_ALLOW_THREADS |
---|
[f2d6445] | 553 | thiscomplex->CalculateIQ(thisiq); |
---|
[bbfad0a] | 554 | Py_END_ALLOW_THREADS |
---|
| 555 | |
---|
[f2d6445] | 556 | return Py_BuildValue("i",0); |
---|
| 557 | } |
---|
| 558 | |
---|
[2bb0b26] | 559 | //LORESModel method CalculateIQ_2D(points,qx,qy) |
---|
| 560 | char pypointsmodelpy_get_complex_Iqxy__name__[] = "get_complex_iq_2D"; |
---|
| 561 | char pypointsmodelpy_get_complex_Iqxy__doc__[] = "calculate averaged scattering intensity from a single q"; |
---|
| 562 | |
---|
| 563 | PyObject * pypointsmodelpy_get_complex_Iqxy(PyObject *, PyObject *args) |
---|
| 564 | { |
---|
| 565 | PyObject *pylores = 0, *pypoint3dvec = 0; |
---|
| 566 | double qx = 0, qy = 0; |
---|
| 567 | int ok = PyArg_ParseTuple(args, "OOdd", &pylores, &pypoint3dvec, &qx, &qy); |
---|
| 568 | if(!ok) return NULL; |
---|
| 569 | |
---|
| 570 | void *temp = PyCObject_AsVoidPtr(pylores); |
---|
| 571 | ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp); |
---|
| 572 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 573 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 574 | |
---|
[bbfad0a] | 575 | double I = 0.0; |
---|
| 576 | Py_BEGIN_ALLOW_THREADS |
---|
| 577 | I = thiscomplex->CalculateIQ_2D(*thisvec,qx,qy); |
---|
| 578 | Py_END_ALLOW_THREADS |
---|
| 579 | |
---|
[2bb0b26] | 580 | return Py_BuildValue("d",I); |
---|
| 581 | } |
---|
| 582 | |
---|
[41e8114] | 583 | //LORESModel method CalculateIQ_2D_Error(points,qx,qy) |
---|
| 584 | char pypointsmodelpy_get_complex_Iqxy_err__name__[] = "get_complex_iq_2D_err"; |
---|
| 585 | char pypointsmodelpy_get_complex_Iqxy_err__doc__[] = "calculate averaged scattering intensity from a single q"; |
---|
| 586 | |
---|
| 587 | PyObject * pypointsmodelpy_get_complex_Iqxy_err(PyObject *, PyObject *args) |
---|
| 588 | { |
---|
| 589 | PyObject *pylores = 0, *pypoint3dvec = 0; |
---|
| 590 | double qx = 0, qy = 0; |
---|
| 591 | int ok = PyArg_ParseTuple(args, "OOdd", &pylores, &pypoint3dvec, &qx, &qy); |
---|
| 592 | if(!ok) return NULL; |
---|
| 593 | |
---|
| 594 | void *temp = PyCObject_AsVoidPtr(pylores); |
---|
| 595 | ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp); |
---|
| 596 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 597 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 598 | |
---|
[bbfad0a] | 599 | double I = 0.0; |
---|
| 600 | Py_BEGIN_ALLOW_THREADS |
---|
| 601 | I = thiscomplex->CalculateIQ_2D_Error(*thisvec,qx,qy); |
---|
| 602 | Py_END_ALLOW_THREADS |
---|
| 603 | |
---|
[41e8114] | 604 | return Py_BuildValue("d",I); |
---|
| 605 | } |
---|
| 606 | |
---|
[f2d6445] | 607 | //LORESModel method CalculateIQ(q) |
---|
| 608 | char pypointsmodelpy_get_complex_i__name__[] = "get_complex_i"; |
---|
| 609 | char pypointsmodelpy_get_complex_i__doc__[] = "calculate averaged scattering intensity from a single q"; |
---|
| 610 | |
---|
| 611 | PyObject * pypointsmodelpy_get_complex_i(PyObject *, PyObject *args) |
---|
| 612 | { |
---|
| 613 | PyObject *pylores = 0; |
---|
| 614 | double q = 0; |
---|
| 615 | int ok = PyArg_ParseTuple(args, "Od", &pylores, &q); |
---|
| 616 | if(!ok) return NULL; |
---|
| 617 | |
---|
| 618 | void *temp = PyCObject_AsVoidPtr(pylores); |
---|
| 619 | |
---|
| 620 | ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp); |
---|
[bbfad0a] | 621 | |
---|
| 622 | double I = 0.0; |
---|
| 623 | Py_BEGIN_ALLOW_THREADS |
---|
| 624 | I = thiscomplex->CalculateIQ(q); |
---|
| 625 | Py_END_ALLOW_THREADS |
---|
| 626 | |
---|
[f2d6445] | 627 | return Py_BuildValue("d",I); |
---|
| 628 | } |
---|
| 629 | |
---|
| 630 | char pypointsmodelpy_get_complex_i_error__name__[] = "get_complex_i_error"; |
---|
| 631 | char pypointsmodelpy_get_complex_i_error__doc__[] = "calculate error on averaged scattering intensity from a single q"; |
---|
| 632 | |
---|
| 633 | PyObject * pypointsmodelpy_get_complex_i_error(PyObject *, PyObject *args) |
---|
| 634 | { |
---|
| 635 | PyObject *pylores = 0; |
---|
| 636 | double q = 0; |
---|
| 637 | int ok = PyArg_ParseTuple(args, "Od", &pylores, &q); |
---|
| 638 | if(!ok) return NULL; |
---|
| 639 | |
---|
| 640 | void *temp = PyCObject_AsVoidPtr(pylores); |
---|
| 641 | |
---|
| 642 | ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp); |
---|
| 643 | |
---|
[bbfad0a] | 644 | double I = 0.0; |
---|
| 645 | Py_BEGIN_ALLOW_THREADS |
---|
| 646 | I = thiscomplex->CalculateIQError(q); |
---|
| 647 | Py_END_ALLOW_THREADS |
---|
| 648 | |
---|
[f2d6445] | 649 | return Py_BuildValue("d",I); |
---|
| 650 | } |
---|
| 651 | |
---|
| 652 | |
---|
| 653 | |
---|
| 654 | |
---|
| 655 | //method outputPR(string filename) |
---|
| 656 | char pypointsmodelpy_outputPR__name__[] = "outputPR"; |
---|
| 657 | char pypointsmodelpy_outputPR__doc__[] = "print out P(R) to a file"; |
---|
| 658 | |
---|
| 659 | PyObject * pypointsmodelpy_outputPR(PyObject *, PyObject *args) |
---|
| 660 | { |
---|
| 661 | PyObject *pymodel = 0; |
---|
| 662 | char *outfile; |
---|
| 663 | int ok = PyArg_ParseTuple(args, "Os", &pymodel, &outfile); |
---|
| 664 | if(!ok) return NULL; |
---|
| 665 | |
---|
| 666 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 667 | |
---|
| 668 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 669 | |
---|
| 670 | thislores->OutputPR(outfile); |
---|
| 671 | |
---|
| 672 | return Py_BuildValue("i", 0); |
---|
| 673 | } |
---|
| 674 | |
---|
| 675 | //method outputPR_xy(string filename) |
---|
| 676 | char pypointsmodelpy_outputPR_xy__name__[] = "outputPR_xy"; |
---|
| 677 | char pypointsmodelpy_outputPR_xy__doc__[] = "print out P(R) to a file"; |
---|
| 678 | |
---|
| 679 | PyObject * pypointsmodelpy_outputPR_xy(PyObject *, PyObject *args) |
---|
| 680 | { |
---|
| 681 | PyObject *pyloresmodel = 0; |
---|
| 682 | char *outfile; |
---|
| 683 | int ok = PyArg_ParseTuple(args, "Os", &pyloresmodel, &outfile); |
---|
| 684 | if(!ok) return NULL; |
---|
| 685 | |
---|
| 686 | void *temp = PyCObject_AsVoidPtr(pyloresmodel); |
---|
| 687 | |
---|
| 688 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 689 | |
---|
| 690 | thislores->OutputPR_XY(outfile); |
---|
| 691 | |
---|
| 692 | return Py_BuildValue("i", 0); |
---|
| 693 | } |
---|
| 694 | |
---|
| 695 | //PDBModel method outputPR(string filename) |
---|
| 696 | char pypointsmodelpy_save_pdb_pr__name__[] = "save_pdb_pr"; |
---|
| 697 | char pypointsmodelpy_save_pdb_pr__doc__[] = "print out P(R) to a file"; |
---|
| 698 | |
---|
| 699 | PyObject * pypointsmodelpy_save_pdb_pr(PyObject *, PyObject *args) |
---|
| 700 | { |
---|
| 701 | PyObject *pymodel = 0; |
---|
| 702 | char *outfile; |
---|
| 703 | int ok = PyArg_ParseTuple(args, "Os", &pymodel, &outfile); |
---|
| 704 | if(!ok) return NULL; |
---|
| 705 | |
---|
| 706 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 707 | |
---|
| 708 | PDBModel * thispdb = static_cast<PDBModel *>(temp); |
---|
| 709 | |
---|
| 710 | thispdb->OutputPR(outfile); |
---|
| 711 | |
---|
| 712 | return Py_BuildValue("i", 0); |
---|
| 713 | } |
---|
| 714 | |
---|
| 715 | //ComplexModel method outputPR(string filename) |
---|
| 716 | char pypointsmodelpy_save_complex_pr__name__[] = "save_complex_pr"; |
---|
| 717 | char pypointsmodelpy_save_complex_pr__doc__[] = "print out P(R) to a file"; |
---|
| 718 | |
---|
| 719 | PyObject * pypointsmodelpy_save_complex_pr(PyObject *, PyObject *args) |
---|
| 720 | { |
---|
| 721 | PyObject *pymodel = 0; |
---|
| 722 | char *outfile; |
---|
| 723 | int ok = PyArg_ParseTuple(args, "Os", &pymodel, &outfile); |
---|
| 724 | if(!ok) return NULL; |
---|
| 725 | |
---|
| 726 | void *temp = PyCObject_AsVoidPtr(pymodel); |
---|
| 727 | |
---|
| 728 | ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp); |
---|
| 729 | |
---|
| 730 | thiscomplex->OutputPR(outfile); |
---|
| 731 | |
---|
| 732 | return Py_BuildValue("i", 0); |
---|
| 733 | } |
---|
| 734 | |
---|
| 735 | |
---|
| 736 | //method outputPDB(string filename) |
---|
| 737 | char pypointsmodelpy_outputPDB__name__[] = "outputPDB"; |
---|
| 738 | char pypointsmodelpy_outputPDB__doc__[] = "save the monte-carlo distributed points of the geomodel into a PDB format file.\ |
---|
| 739 | a .pdb extension will be automatically added"; |
---|
| 740 | |
---|
| 741 | PyObject * pypointsmodelpy_outputPDB(PyObject *, PyObject *args) |
---|
| 742 | { |
---|
| 743 | PyObject *pyloresmodel = 0, *pypoint3dvec=0; |
---|
| 744 | char *outfile; |
---|
| 745 | int ok = PyArg_ParseTuple(args, "OOs", &pyloresmodel, &pypoint3dvec,&outfile); |
---|
| 746 | if(!ok) return NULL; |
---|
| 747 | |
---|
| 748 | void *temp = PyCObject_AsVoidPtr(pyloresmodel); |
---|
| 749 | |
---|
| 750 | LORESModel * thislores = static_cast<LORESModel *>(temp); |
---|
| 751 | |
---|
| 752 | void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); |
---|
| 753 | vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); |
---|
| 754 | |
---|
| 755 | thislores->OutputPDB(*thisvec,outfile); |
---|
| 756 | |
---|
| 757 | return Py_BuildValue("i", 0); |
---|
| 758 | } |
---|
| 759 | |
---|
| 760 | // version |
---|
| 761 | // $Id$ |
---|
| 762 | |
---|
| 763 | // End of file |
---|