提问人:pippo1980 提问时间:9/18/2023 最后编辑:pippo1980 更新时间:9/18/2023 访问量:106
不明白Python是如何调用这个C函数的
Don't understand how Python calls this C function
问:
请耐心等待,我只是想学习Python,但试图弄清楚一些软件是如何工作的(https://github.com/LBC-LNBio/pyKVFinder/tree/master)。
在 https://github.com/LBC-LNBio/pyKVFinder/blob/master/pyKVFinder/grid.py#L960,我有:grid.py
ncav, cavities = _detect(
nvoxels,
nx,
ny,
nz,
xyzr,
P1,
sincos,
step,
probe_in,
probe_out,
removal_distance,
volume_cutoff,
box_adjustment,
P2,
surface,
nthreads,
verbose,
)
但来自 C 编译库(我相信)及其源代码:https://github.com/LBC-LNBio/pyKVFinder/blob/master/C/pyKVFinder.c#L989C1-L994C2 ,_detect
from _pyKVFinder import _detect, _detect_ladj
pyKVFinder.c
/* Cavity detection */
/*
* Function: _detect
* -----------------
*
* Detect and cluster cavities
*
* PI: 3D grid
* size: number of voxels in 3D grid
* nx: x grid units
* ny: y grid units
* nz: z grid units
* atoms: xyz coordinates and radii of input pdb
* natoms: number of atoms
* xyzr: number of data per atom (4: xyzr)
* reference: xyz coordinates of 3D grid origin
* ndims: number of coordinates (3: xyz)
* sincos: sin and cos of 3D grid angles
* nvalues: number of sin and cos (sina, cosa, sinb, cosb)
* step: 3D grid spacing (A)
* probe_in: Probe In size (A)
* probe_out: Probe Out size (A)
* removal_distance: Length to be removed from the cavity-bulk frontier (A)
* volume_cutoff: Cavities volume filter (A3)
* box_adjustment: Box adjustment mode
* P2: xyz coordinates of x-axis vertice
* nndims: number of coordinates (3: xyz)
* is_ses: surface mode (1: SES or 0: SAS)
* nthreads: number of threads for OpenMP
* verbose: print extra information to standard output
*
* returns: PI[size] (cavities 3D grid) and ncav (number of cavities)
*/
int _detect(int *PI, int size, int nx, int ny, int nz, double *atoms,
int natoms, int xyzr, double *reference, int ndims, double *sincos,
int nvalues, double step, double probe_in, double probe_out,
double removal_distance, double volume_cutoff, int box_adjustment,
double *P2, int nndims, int is_ses, int nthreads, int verbose)
{
关于不同数量的参数和它们的不同顺序,我错过了什么?Python如何在这样的差异下获得正确的结果?我认为 Python C 绑定是由 SWIG 提供的。我应该强调的是,我根本不懂C语言,只是想弄清楚这个非常好的工具的引擎盖下发生了什么。
答: 暂无答案
评论
ctypes
[1,2,3]
int *PI, int size
%apply (int* ARGOUT_ARRAY1, int DIM1) {(int* PI, int size)}
pyKVFinder.i