File: simple.py

package info (click to toggle)
rdkit 202209.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 203,880 kB
  • sloc: cpp: 334,239; python: 80,247; ansic: 24,579; java: 7,667; sql: 2,123; yacc: 1,884; javascript: 1,358; lex: 1,260; makefile: 576; xml: 229; fortran: 183; cs: 181; sh: 101
file content (13 lines) | stat: -rw-r--r-- 454 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
import ctypes
rdk = ctypes.cdll.LoadLibrary('./lib/librdkitcffi.so')
rdk.get_smiles.argtypes = [ctypes.c_void_p, ctypes.c_size_t, ctypes.c_char_p]
rdk.get_smiles.restype = ctypes.c_char_p
rdk.get_mol.restype = ctypes.c_void_p
rdk.free_ptr.argtypes = [ctypes.c_void_p]

sz = ctypes.c_size_t()
mol = rdk.get_mol(b'CCC(O)C(C(=O)O)C', ctypes.byref(sz), b'')
smi = rdk.get_smiles(mol, sz, b'')
assert (smi == b'CCC(O)C(C)C(=O)O')
print(smi)
rdk.free_ptr(mol)