Thanks this is great, just found it when needed again after those few years
;-)
On 29 August 2014 at 19:35, Greg Landrum <[email protected]> wrote:
> Hi Jan,
>
> On Friday, August 29, 2014, Jan Domanski <[email protected]> wrote:
>
>> Hi there,
>>
>> I'm trying to wrap the very handy method getPositions from
>> rdkit/Code/GraphMol/Wrap/Conformer.cpp to return coordinates of a
>> conformer as a numpy array.
>>
>> So far I was able to return a tuple of tuples, as below
>>
>> PyObject *convertPoint(RDGeom::Point3D &point){
>> PyObject *res = PyTuple_New(3);
>> PyTuple_SetItem(res,0,PyFloat_FromDouble(point.x));
>> PyTuple_SetItem(res,1,PyFloat_FromDouble(point.y));
>> PyTuple_SetItem(res,2,PyFloat_FromDouble(point.z));
>> return res;
>> }
>>
>> PyObject* GetPos(const Conformer *conf) {
>> RDGeom::POINT3D_VECT pos=conf->getPositions();
>> PyObject *res = PyTuple_New(pos.size());
>> for(int idx=0;idx<pos.size();idx++){
>> PyTuple_SetItem(res,idx,convertPoint(pos[idx]));
>> }
>> return res;
>> }
>>
>> Getting the PyArray_SimpleNew was a little tricky in my hands, but I
>> assume that's what I need to use somehow. Does anybody have any pointers?
>>
>
> There are some examples in the RDKit source that may be helpful. Here's
> one of them:
> https://github.com/rdkit/rdkit/blob/master/Code/Numerics/Alignment/Wrap/
> rdAlignment.cpp#L134
>
> -greg
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss