rdkit-rs / rdkit

RDKit Made Idiomatic for Rust
12 stars 9 forks source link

Add bonds #16

Open pstjohn opened 7 months ago

pstjohn commented 7 months ago

It would be great to have access to bond-level information: https://www.rdkit.org/docs/cppapi/classRDKit_1_1Bond.html along with associated methods in molecule structures that get bonds.

Would that be as simple as adding the necessary items to ro_mol.rs?

Related, did you look into autocxx to help build out some of the boilerplate wrapper code?

xrl commented 7 months ago

@pstjohn unfortunately I did not get autocxx working. I would love to get away from manually setting up bindings for every little thing -- it's terribly error prone and for the most part I'm just smart enough to be dangerous on C++ vs Rust.

I did start this issue: https://github.com/google/autocxx/issues/1334 . I'd gladly accept help on using autocxx, manually setting up bindings isn't a great use of anyone's time.

xrl commented 7 months ago

To your original point, yes, it sounds like you'll want to expose something like bonds(ptr: SharedPtr<ROMol> -> CxxVector<Bond> and introduce a type Bond in ro_mol.rs. Unfortunately I never figured out how to expose a CXX iter in Rust, so I instead just drain the iterator in to a vector and return the vector -- but passing around vectors with complex interior types is a bit of a game in cxx.

Getting autocxx working might be more efficient.