Beispiel #1
0
        /// <summary>
        /// Public method to get tautomers for an input molecule, based on the InChI which will be calculated by .NET prot of JNI-InChI.
        /// </summary>
        /// <param name="mol">molecule for which to generate tautomers</param>
        /// <returns>a list of tautomers, if any</returns>
        /// <exception cref="CDKException"></exception>
        public ICollection <IAtomContainer> GetTautomers(IAtomContainer mol)
        {
            string opt = "";

            if ((flags & Options.KetoEnol) != 0)
            {
                opt += " -KET";
            }
            if ((flags & Options.OneFiveShift) != 0)
            {
                opt += " -15T";
            }

            InChIGenerator gen   = InChIGeneratorFactory.Instance.GetInChIGenerator(mol, opt);
            string         inchi = gen.InChI;
            string         aux   = gen.AuxInfo;

            long[] amap = new long[mol.Atoms.Count];
            InChINumbersTools.ParseAuxInfo(aux, amap);

            if (inchi == null)
            {
                throw new CDKException($"{typeof(InChIGenerator)} failed to create an InChI for the provided molecule, InChI -> null.");
            }
            return(GetTautomers(mol, inchi, amap));
        }
Beispiel #2
0
        /// <summary>
        /// Obtain the InChI numbering for canonising SMILES. The cdk-smiles module
        /// does not and should not depend on cdk-inchi and so the numbers are loaded
        /// via reflection. If the class cannot be found on the path an
        /// exception is thrown.
        /// </summary>
        /// <param name="container">a structure</param>
        /// <returns>the inchi numbers</returns>
        /// <exception cref="CDKException">the inchi numbers could not be obtained</exception>
        private static long[] InChINumbers(IAtomContainer container)
        {
            var rgrps = GetRgrps(container, AtomicNumbers.Rutherfordium);

            foreach (var rgrp in rgrps)
            {
                rgrp.AtomicNumber = AtomicNumbers.Rutherfordium;
                rgrp.Symbol       = ChemicalElement.Rf.Symbol;
            }

            var numbers = InChINumbersTools.GetUSmilesNumbers(container);

            foreach (var rgrp in rgrps)
            {
                rgrp.AtomicNumber = AtomicNumbers.Unknown;
                rgrp.Symbol       = "*";
            }
            return(numbers);
        }