/// <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.getInstance(); InChIToStructure intostruct = factory.getInChIToStructure(inchiString, DefaultChemObjectBuilder); INCHI_RET ret = intostruct.getReturnStatus(); if (ret == INCHI_RET.WARNING) // Structure generated, but with warning message { warningMsg = "InChI warning: " + intostruct.getMessage(); } else if (ret != INCHI_RET.OKAY) // Structure generation failed { errorMsg = "Structure generation failed failed: " + ret.toString() + " [" + intostruct.getMessage() + "]"; throw new Exception(errorMsg); } IAtomContainer mol = intostruct.getAtomContainer(); return(mol); }
/// <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) { INCHI_RET inchiStatus = ig.getReturnStatus(); if (inchiStatus == INCHI_RET.OKAY) { return(true); } string msg = ig.getMessage(); string log = ig.getLog(); string auxInfo = ig.getAuxInfo(); if (inchiStatus == INCHI_RET.WARNING) { return(true); } else { return(false); } }