public static double GetStructureMolWeight_MolFormula(string _molfilestring, out string _molformula) { double dblMolWeight = 0.0; string strMolFormula = ""; try { MolHandler mHandler = new MolHandler(_molfilestring); dblMolWeight = mHandler.calcMolWeight(); strMolFormula = mHandler.calcMolFormula(); _molformula = strMolFormula; return(dblMolWeight); } catch (Exception ex) { } _molformula = strMolFormula; return(dblMolWeight); }
public static string GetMoleculeWeightAndMolFormula(string molstring, out string molformula_out) { string strMolWeight = ""; string strMolFormula = ""; try { MolHandler mHandler = new MolHandler(molstring); float fltMolWeight = mHandler.calcMolWeight(); strMolFormula = mHandler.calcMolFormula(); strMolWeight = fltMolWeight.ToString(); molformula_out = strMolFormula; return(strMolWeight); } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } molformula_out = strMolFormula; return(strMolWeight); }
public static bool WriteXmlFileUsingDataTable(DataTable _dtTandetails, string _tannumber, string outxmlfile) { bool blStatus = false; try { if (_dtTandetails != null) { if (_dtTandetails.Rows.Count > 0) { patentInfo patentInfo_Obj = new patentInfo(); patentInfo_Obj.tan = _tannumber; patentInfo_Obj.language = languageType.en; int intMolCnt = _dtTandetails.Rows.Count; patentLocation patLoc = null; name[] name_Arr = null; name name_obj = null; names names_Arr = null; nameType namType = null; structureDataType structDtype = null; string[] strIUpacName = null; propheticSubstance propSubstance_Obj = null; propheticSubstance[] propSubstance_Arr = new propheticSubstance[intMolCnt]; propheticSubstances propSubstances_Obj = null; patent patent_Obj = new patent(); int intCntr = 0; string strMol = ""; byte[] barr_Mol = null; int v3000 = 0; double nullMol = 0.0; MolHandler objMHandler = null; for (int i = 0; i < _dtTandetails.Rows.Count; i++) { objMHandler = new MolHandler(_dtTandetails.Rows[i]["structure"].ToString()); v3000 = 0; v3000 = objMHandler.toFormat("mol").IndexOf("V3000"); nullMol = 0.0; nullMol = objMHandler.calcMolWeight(); barr_Mol = null; if (v3000 == -1 && nullMol != 0) { patLoc = new patentLocation(); patLoc.pageLabel = _dtTandetails.Rows[i]["page_label"].ToString(); patLoc.pageNumber = _dtTandetails.Rows[i]["page_number"].ToString(); patLoc.exampleLabel = _dtTandetails.Rows[i]["example_number"].ToString(); name_obj = new name(); name_obj.lang = languageType.en; string[] strArr_EnName = new string[1]; strArr_EnName[0] = _dtTandetails.Rows[i]["en_name"].ToString(); name_obj.Text = strArr_EnName; name_Arr = new name[1]; name_Arr[0] = name_obj; strIUpacName = new string[1]; strIUpacName[0] = _dtTandetails.Rows[i]["iupac_name"].ToString(); namType = new nameType(); namType.Text = strIUpacName; names_Arr = new names(); names_Arr.IUPACName = namType; names_Arr.name = name_Arr; strMol = _dtTandetails.Rows[i]["structure"].ToString(); barr_Mol = null; barr_Mol = System.Text.ASCIIEncoding.ASCII.GetBytes(strMol); structDtype = new structureDataType(); structDtype.Value = barr_Mol; propSubstance_Obj = new propheticSubstance(); propSubstance_Obj.structureData = structDtype; propSubstance_Obj.patentLocation = patLoc; propSubstance_Obj.names = names_Arr; propSubstance_Arr[intCntr] = propSubstance_Obj; intCntr++; } } propSubstances_Obj = new propheticSubstances(); propSubstances_Obj.propheticSubstance = propSubstance_Arr; patent_Obj.patentInfo = patentInfo_Obj; patent_Obj.propheticSubstances = propSubstances_Obj; // Serialization XmlSerializer xmlSer = new XmlSerializer(typeof(patent)); TextWriter txtWriter = new StreamWriter(outxmlfile); xmlSer.Serialize(txtWriter, patent_Obj); txtWriter.Close(); txtWriter.Dispose(); blStatus = true; return(blStatus); } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(blStatus); }
public static DataTable GetRGroupEnumerationResults(DataTable _enumDataTbl, string _qryRCore) { DataTable dtEnumResData = new DataTable(); try { dtEnumResData.Columns.Add("id", typeof(string)); dtEnumResData.Columns.Add("structure", typeof(object)); dtEnumResData.Columns.Add("mol_weight", typeof(double)); dtEnumResData.Columns.Add("mol_formula", typeof(string)); dtEnumResData.Columns.Add("iupac_name", typeof(string)); dtEnumResData.Columns.Add("inchi_key", typeof(string)); int rgrpNum = 1; Molecule molEnum = null; MolHandler mHandler = null; Molecule rCoreMol = null; RgMolecule rgMol = null; MolHandler mHand_Result = null; DataRow dtRow = null; string strMolFile = ""; string strIUPACName = ""; string strErrMsg = ""; if (_enumDataTbl != null) { if (_enumDataTbl.Rows.Count > 0) { for (int rowindx = 0; rowindx < _enumDataTbl.Rows.Count; rowindx++) { molEnum = new Molecule(); mHandler = new MolHandler(_qryRCore); rCoreMol = mHandler.getMolecule(); try { for (int colindx = 1; colindx < _enumDataTbl.Columns.Count; colindx++) { rgrpNum = GetRgroupNumFromRGroupName(_enumDataTbl.Columns[colindx].ColumnName); rgMol = ReturnRGroupMolecule(_enumDataTbl.Rows[rowindx][colindx].ToString(), rgrpNum); //molEnum = AddRGrpMolToCoreMolecule(rgMol, rCoreMol, rgrpNum); AddRGrpMolToCoreMolecule(ref rCoreMol, rgMol, rgrpNum); } //Set Radical Empty to Result Mol SetRadicalEmptyToResultMol(ref rCoreMol); mHand_Result = new MolHandler(rCoreMol); strMolFile = ""; strMolFile = mHand_Result.toFormat("mol"); } catch { } dtRow = dtEnumResData.NewRow(); dtRow["id"] = _enumDataTbl.Rows[rowindx][0].ToString(); dtRow["structure"] = strMolFile; if (strMolFile != "") { dtRow["mol_weight"] = mHand_Result.calcMolWeight(); dtRow["mol_formula"] = mHand_Result.calcMolFormula(); dtRow["inchi_key"] = ChemistryOperations.GetStructureInchiKey(strMolFile); strIUPACName = ""; strErrMsg = ""; if (ChemistryOperations.GetIUPACNameFromStructure(strMolFile, out strIUPACName, out strErrMsg)) { strIUPACName = Validations.GetConvertedIUPACName(strIUPACName); } else { strIUPACName = "IUPAC name not provided"; } dtRow["iupac_name"] = strIUPACName; } dtEnumResData.Rows.Add(dtRow); } return(dtEnumResData); } } } catch (Exception ex) { PepsiLiteErrorHandling.WriteErrorLog(ex.ToString()); } return(dtEnumResData); }