Ejemplo n.º 1
0
        /// <summary>
        /// Convert an InChI string to an IAtomContainer
        /// </summary>
        /// <param name="inchiString"></param>
        /// <returns></returns>

        public static IAtomContainer InChIToAtomContainer(string inchiString)
        {
            string warningMsg, errorMsg;

            InChIGeneratorFactory factory    = InChIGeneratorFactory.Instance;
            InChIToStructure      intostruct = factory.GetInChIToStructure(inchiString, ChemObjectBuilder.Instance);

            InChIReturnCode ret = intostruct.ReturnStatus;

            if (ret == InChIReturnCode.Warning)             // Structure generated, but with warning message
            {
                warningMsg = "InChI warning: " + intostruct.Message;
            }

            else if (ret != InChIReturnCode.Ok)              // Structure generation failed
            {
                errorMsg = "Structure generation failed failed: " + ret.ToString() + " [" + intostruct.Message + "]";
                throw new Exception(errorMsg);
            }

            IAtomContainer mol = intostruct.AtomContainer;


            return(mol);
        }
Ejemplo n.º 2
0
        void Main()
        {
            IAtomContainer container = null;

            #region
            // Generate factory -  if native code does not load
            InChIGeneratorFactory factory = new InChIGeneratorFactory();
            // Get InChIGenerator
            InChIGenerator gen = factory.GetInChIGenerator(container);

            InChIReturnCode ret = gen.ReturnStatus;
            if (ret == InChIReturnCode.Warning)
            {
                // InChI generated, but with warning message
                Console.WriteLine($"InChI warning: {gen.Message}");
            }
            else if (ret != InChIReturnCode.Ok)
            {
                // InChI generation failed
                throw new CDKException($"InChI failed: {ret.ToString()} [{gen.Message}]");
            }

            string inchi   = gen.InChI;
            string auxinfo = gen.AuxInfo;
            #endregion
        }
Ejemplo n.º 3
0
 public NInchiOutput(InChIReturnCode ret, string inchi, string auxInfo, string message, string log)
 {
     ReturnStatus = ret;
     InChI        = inchi;
     AuxInfo      = auxInfo;
     Message      = message;
     Log          = log;
 }
Ejemplo n.º 4
0
 public void TestAuxinfo2Input()
 {
     // START SNIPPET: auxinfo2input
     NInchiInputData data = NInchiWrapper.GetInputFromAuxInfo("AuxInfo=1/1/N:4,1,2,3,5,6/"
                                                              + "E:(5,6)/it:im/rA:6CCNCOO/rB:s1;N1;s1;s2;d2;/rC:264,968,0;295,985,0;233,986,0;"
                                                              + "264,932,0;326,967,0;295,1021,0;");
     InChIReturnCode ret   = data.ReturnStatus;
     NInchiInput     input = data.Input;
     // END SNIPPET: auxinfo2input
 }
Ejemplo n.º 5
0
 public void TestInchi2Structure()
 {
     // START SNIPPET: inchi2structure
     NInchiInputInchi      input  = new NInchiInputInchi("InChI=1/C2H6/c1-2/h1-2H3");
     NInchiOutputStructure output = NInchiWrapper.GetStructureFromInchi(input);
     //
     InChIReturnCode retStatus = output.ReturnStatus;
     int             nat       = output.Atoms.Count;
     int             nbo       = output.Bonds.Count;
     int             nst       = output.Stereos.Count;
     //
     NInchiAtom at0 = output.Atoms[0];
     // END SNIPPET: inchi2structure
 }
Ejemplo n.º 6
0
        static void Main()
        {
            string inchi = "inchi";

            #region
            // Get InChIToStructure
            InChIToStructure intostruct = InChIToStructure.FromInChI(inchi, ChemObjectBuilder.Instance);

            InChIReturnCode ret = intostruct.ReturnStatus;
            if (ret == InChIReturnCode.Warning)
            {
                // Structure generated, but with warning message
                Console.WriteLine($"InChI warning: {intostruct.Message}");
            }
            else if (ret != InChIReturnCode.Ok)
            {
                // Structure generation failed
                throw new CDKException($"Structure generation failed: {ret.ToString()} [{intostruct.Message}]");
            }
            IAtomContainer container = intostruct.AtomContainer;
            #endregion
        }
Ejemplo n.º 7
0
        /// <summary>
        /// SimplifyMolfileForInChIGeneration
        /// </summary>
        /// <param name="molfile"></param>
        /// <returns></returns>

        //static string SimplifyMolfileForInChIGeneration(string molfile)
        //{
        //	string smiles = CdkMol.StructureConverter.MolfileStringToSmilesString(molfile); // convert to smiles
        //	string molfile2 = CdkMol.StructureConverter.SmilesStringToMolfileString(smiles); // and back to V2000 molfile without Sgroups
        //	return molfile2;
        //}

        /// <summary>
        /// IsAcceptableInchiStatus
        /// </summary>
        /// <param name="ig"></param>
        /// <returns></returns>

        static bool IsAcceptableInchiStatus(InChIGenerator ig)
        {
            InChIReturnCode inchiStatus = ig.ReturnStatus;

            if (inchiStatus == InChIReturnCode.Ok)
            {
                return(true);
            }

            string msg     = ig.Message;
            string log     = ig.Log;
            string auxInfo = ig.AuxInfo;

            if (inchiStatus == InChIReturnCode.Warning)
            {
                return(true);
            }

            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
 public NInchiOutputStructure(InChIReturnCode value)
 {
     this.ReturnStatus = value;
 }