ProSHADE  0.7.6.6 (JUL 2022)
Protein Shape Detection
pyProSHADE_mapManip.cpp
Go to the documentation of this file.
1 
22 //==================================================== Include PyBind11 header
23 #include <pybind11/pybind11.h>
24 #include <pybind11/stl.h>
25 #include <pybind11/numpy.h>
26 
27 //==================================================== Add the ProSHADE_settings and ProSHADE_run classes to the PyBind11 module
28 void add_mapManipNamespace ( pybind11::module& pyProSHADE )
29 {
30  pyProSHADE.def ( "findMAPCOMValues",
31  [] ( ProSHADE_internal_data::ProSHADE_data* dataObj, ProSHADE_settings* settings ) -> pybind11::array_t < proshade_double >
32  {
33  //== Run the detection
34  proshade_double xMapCOM = 0.0, yMapCOM = 0.0, zMapCOM = 0.0;
36  &xMapCOM, &yMapCOM, &zMapCOM,
37  dataObj->xDimSize, dataObj->yDimSize, dataObj->zDimSize,
38  dataObj->xFrom, dataObj->xTo,
39  dataObj->yFrom, dataObj->yTo,
40  dataObj->zFrom, dataObj->zTo, settings->removeNegativeDensity );
41 
42  //== Allocate memory for the numpy values
43  proshade_double* npVals = new proshade_double[3];
44  ProSHADE_internal_misc::checkMemoryAllocation ( npVals, __FILE__, __LINE__, __func__ );
45 
46  //== Copy values
47  npVals[0] = xMapCOM;
48  npVals[1] = yMapCOM;
49  npVals[2] = zMapCOM;
50 
51  //== Create capsules to make sure memory is released properly from the allocating language (C++ in this case)
52  pybind11::capsule pyCapsuleMapCOM ( npVals, []( void *f ) { proshade_double* foo = reinterpret_cast< proshade_double* > ( f ); delete foo; } );
53 
54  //== Copy the value
55  pybind11::array_t < proshade_double > retArr = pybind11::array_t< proshade_double > ( { static_cast<int> ( 3 ) }, // Shape
56  { sizeof(proshade_double) }, // C-stype strides
57  npVals, // Data
58  pyCapsuleMapCOM ); // Capsule
59 
60  //== Done
61  return ( retArr );
62  }, "This function takes the proshade map object and procceds to compute the Centre of Mass of this object in Angstroms in real space.", pybind11::arg ( "dataObj" ), pybind11::arg ( "settings" ) );
63 
64 }
ProSHADE_internal_data::ProSHADE_data::zFrom
proshade_signed zFrom
This is the starting index along the z axis.
Definition: ProSHADE_data.hpp:112
ProSHADE_internal_data::ProSHADE_data
This class contains all inputed and derived data for a single structure.
Definition: ProSHADE_data.hpp:49
ProSHADE_settings::removeNegativeDensity
bool removeNegativeDensity
Should the negative density be removed from input files?
Definition: ProSHADE_settings.hpp:47
ProSHADE_internal_data::ProSHADE_data::zDimSize
proshade_single zDimSize
This is the size of the map cell z dimension in Angstroms.
Definition: ProSHADE_data.hpp:61
ProSHADE_internal_data::ProSHADE_data::zTo
proshade_signed zTo
This is the final index along the z axis.
Definition: ProSHADE_data.hpp:115
ProSHADE_internal_data::ProSHADE_data::xTo
proshade_signed xTo
This is the final index along the x axis.
Definition: ProSHADE_data.hpp:113
ProSHADE_internal_data::ProSHADE_data::yTo
proshade_signed yTo
This is the final index along the y axis.
Definition: ProSHADE_data.hpp:114
ProSHADE_internal_data::ProSHADE_data::xDimSize
proshade_single xDimSize
This is the size of the map cell x dimension in Angstroms.
Definition: ProSHADE_data.hpp:59
ProSHADE_internal_data::ProSHADE_data::internalMap
proshade_double * internalMap
The internal map data representation, which may be amended as the run progresses.
Definition: ProSHADE_data.hpp:56
ProSHADE_internal_data::ProSHADE_data::xFrom
proshade_signed xFrom
This is the starting index along the x axis.
Definition: ProSHADE_data.hpp:110
ProSHADE_settings
This class stores all the settings and is passed to the executive classes instead of a multitude of p...
Definition: ProSHADE_settings.hpp:37
ProSHADE_internal_mapManip::findMAPCOMValues
void findMAPCOMValues(proshade_double *map, proshade_double *xCom, proshade_double *yCom, proshade_double *zCom, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_signed xFrom, proshade_signed xTo, proshade_signed yFrom, proshade_signed yTo, proshade_signed zFrom, proshade_signed zTo, bool removeNegDens)
This function finds the Centre of Mass for a map.
Definition: ProSHADE_mapManip.cpp:243
ProSHADE_internal_misc::checkMemoryAllocation
void checkMemoryAllocation(chVar checkVar, std::string fileP, unsigned int lineP, std::string funcP, std::string infoP="This error may occurs when ProSHADE requests memory to be\n : allocated to it and this operation fails. This could\n : happen when not enough memory is available, either due to\n : other processes using a lot of memory, or when the machine\n : does not have sufficient memory available. Re-run to see\n : if this problem persists.")
Checks if memory was allocated properly.
Definition: ProSHADE_misc.hpp:73
ProSHADE_internal_data::ProSHADE_data::yFrom
proshade_signed yFrom
This is the starting index along the y axis.
Definition: ProSHADE_data.hpp:111
ProSHADE_internal_data::ProSHADE_data::yDimSize
proshade_single yDimSize
This is the size of the map cell y dimension in Angstroms.
Definition: ProSHADE_data.hpp:60