mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
* wip * - avoid leaking memory after instantiating UChar_Vect - fix some indentation - make it easier to read/write pickles as native byte arrays from Java and C# - add tests --------- Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
30 lines
776 B
C#
30 lines
776 B
C#
// Linux:
|
|
// compile with
|
|
// mcs -platform:x64 -r:../RDKit2DotNet.dll -out:MolToFromByteArray.exe MolToFromByteArray.cs
|
|
// and run with
|
|
// LD_LIBRARY_PATH=..:$RDBASE/lib:$LD_LIBRARY_PATH MONO_PATH=.. mono MolToFromByteArray.exe
|
|
|
|
using System.IO;
|
|
using System.Diagnostics;
|
|
using GraphMolWrap;
|
|
|
|
public class MolToFromByteArrayTest
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
string smi = "CN(C)c1ccc2c(=O)cc[nH]c2c1";
|
|
string pklFileName = "quinolone.pkl";
|
|
{
|
|
ROMol mol = RWMol.MolFromSmiles(smi);
|
|
byte[] pkl = mol.ToByteArray();
|
|
File.WriteAllBytes(pklFileName, pkl);
|
|
mol.Dispose();
|
|
}
|
|
{
|
|
byte[] pkl = File.ReadAllBytes(pklFileName);
|
|
ROMol mol = ROMol.FromByteArray(pkl);
|
|
Debug.Assert(mol.MolToSmiles() == smi);
|
|
mol.Dispose();
|
|
}
|
|
}
|
|
} |