Ejemplo n.º 1
0
 public void TestInchi2InchiKey()
 {
     // START SNIPPET: inchi2inchikey
     NInchiOutputKey output = NInchiWrapper.GetInchiKey("InChI=1S/C2H6/c1-2/h1-2H3");
     string          key    = output.Key;
     // END SNIPPET: inchi2inchikey
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculates the InChIKey for an InChI string.
        /// </summary>
        /// <param name="inchi">source InChI string</param>
        /// <returns>InChIKey output</returns>
        /// <exception cref="NInchiException"></exception>
        public static NInchiOutputKey GetInchiKey(string inchi)
        {
            if (inchi == null)
            {
                throw new ArgumentNullException(nameof(inchi), "Null InChI");
            }

            var szINCHIKey = Marshal.AllocHGlobal(28);
            var szXtra1    = Marshal.AllocHGlobal(65);
            var szXtra2    = Marshal.AllocHGlobal(65);
            var ret        = GetINCHIKeyFromINCHI(inchi, 1, 2, szINCHIKey, szXtra1, szXtra2);

            NInchiOutputKey oo = new NInchiOutputKey(ret, Marshal.PtrToStringAnsi(szINCHIKey));

            Marshal.FreeHGlobal(szXtra2);
            Marshal.FreeHGlobal(szXtra1);
            Marshal.FreeHGlobal(szINCHIKey);
            return(oo);
        }