public static DataTable GetDuplicateRecords(string filename, string qrymolstring, out int totalrecs_out) { DataTable dtDupRecs = null; int totalRecCnt = 0; try { dtDupRecs = CreateTANDetailsTable(); dtDupRecs.Columns.Add("OrigRecIndex", typeof(Int32)); bool blIsChiral = false; string InchiKey_Qry = ""; string InchiKey_Trgt = ""; MolHandler mHandler = new MolHandler(qrymolstring); Molecule qryMol = mHandler.getMolecule(); StandardizeMolecule(qryMol, out blIsChiral); InchiKey_Qry = qryMol.toFormat("inchi:key"); InchiKey_Qry = Validations.GetInchiKeyFromInchiString(InchiKey_Qry); MolInputStream molInStream = new MolInputStream(new FileInputStream(filename)); MolImporter molImp = new MolImporter(molInStream); Molecule objMol = new Molecule(); DataRow dtRow = null; while (molImp.read(objMol)) { objMol = StandardizeMolecule(objMol, out blIsChiral); InchiKey_Trgt = objMol.toFormat("inchi:key"); InchiKey_Trgt = Validations.GetInchiKeyFromInchiString(InchiKey_Trgt); if (InchiKey_Qry == InchiKey_Trgt) { dtRow = dtDupRecs.NewRow(); //Mol Structure dtRow["Structure"] = objMol.toFormat("mol"); //Mol Weight dtRow["MolWeight"] = objMol.getMass().ToString(); //Mol Formula dtRow["MolFormula"] = objMol.getFormula(); //Page No dtRow["PageNumber"] = objMol.getProperty("Page Number").Trim(); //Page Label dtRow["PageLabel"] = objMol.getProperty("Page Label").Trim(); //Example Number dtRow["ExampleNumber"] = objMol.getProperty("Example Number").Trim(); //IUPAC Name dtRow["IupacName"] = objMol.getProperty("IUPAC Name").Trim(); //en name dtRow["EnName"] = objMol.getProperty("en name").Trim(); //Is Chiral if (objMol.isAbsStereo()) { dtRow["IsChiral"] = "True"; } else { dtRow["IsChiral"] = "False"; } dtRow["OrigRecIndex"] = totalRecCnt; dtDupRecs.Rows.Add(dtRow); } totalRecCnt++; } molImp.close(); molInStream.close(); totalrecs_out = totalRecCnt; return(dtDupRecs); } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } totalrecs_out = totalRecCnt; return(dtDupRecs); }
private void fromDatabaseToolStripMenuItem_Click(object sender, EventArgs e) { try { //DataTable dtTANs = PepsiLiteDataAccess.DataOperations.RetrieveTANIDS_All(); DataTable dtTANs = PepsiLiteDataAccess.DataOperations.GetCompletedTANs(); if (dtTANs != null) { if (dtTANs.Rows.Count > 0) { ArrayList lstTans = Validations.GetArrayListFromDataTable(dtTANs, 0); if (lstTans != null) { if (lstTans.Count > 0) { Forms.frmSelectTAN_Xml objSelTan_Xml = new Forms.frmSelectTAN_Xml(); objSelTan_Xml.AvailTANs = lstTans; if (objSelTan_Xml.ShowDialog() == DialogResult.OK) { Cursor = Cursors.WaitCursor; DataTable dtTanDetails = null; bool blWriteStatus = false; string strXmlFilePath = ""; for (int i = 0; i < objSelTan_Xml.SelectedTANs.Count; i++) { if (objSelTan_Xml.SelectedTANs.Count == 1) { dtTanDetails = PepsiLiteDataAccess.DataOperations.RetrieveTANDetails(objSelTan_Xml.SelectedTANs[i].ToString()); if (dtTanDetails != null) { if (dtTanDetails.Rows.Count > 0) { strXmlFilePath = objSelTan_Xml.FolderName + "\\" + objSelTan_Xml.SelectedTANs[i].ToString() + ".xml"; WriteOutPutXMLFile.WriteXmlFileUsingDataTable(dtTanDetails, objSelTan_Xml.SelectedTANs[i].ToString(), strXmlFilePath); frmXMLViewer xmlView = new frmXMLViewer(); xmlView.FileName = strXmlFilePath; xmlView.MdiParent = this; xmlView.Show(); } else { MessageBox.Show("No data found", "No Data", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("No data found", "No Data", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { dtTanDetails = PepsiLiteDataAccess.DataOperations.RetrieveTANDetails(objSelTan_Xml.SelectedTANs[i].ToString()); strXmlFilePath = objSelTan_Xml.FolderName + "\\" + objSelTan_Xml.SelectedTANs[i].ToString() + ".xml"; WriteOutPutXMLFile.WriteXmlFileUsingDataTable(dtTanDetails, objSelTan_Xml.SelectedTANs[i].ToString(), strXmlFilePath); blWriteStatus = true; } } if (blWriteStatus) { openFileDialog1.FileName = strXmlFilePath; openFileDialog1.ShowDialog(); } Cursor = Cursors.Default; } } } } else { MessageBox.Show("No TANs are available"); } } else { MessageBox.Show("No TANs are available"); } } catch (Exception ex) { PepsiLiteErrorHandling.WriteErrorLog(ex.ToString()); } }
private void openFileToolStripMenuItem_Click(object sender, EventArgs e) { try { openFileDialog1.Filter = "SDF|*.sdf|TXT|*.txt"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { string strFileName = openFileDialog1.FileName; if (strFileName.Trim() != "") { System.IO.FileInfo finfo = new System.IO.FileInfo(strFileName); if (finfo.Length > 0) { string strFileName_TAN = System.IO.Path.GetFileNameWithoutExtension(strFileName); if (Validations.IsValidTanNumber(strFileName_TAN.Trim())) { FormCollection frmColl = Application.OpenForms; frmReviewer frmReview = null; bool blFrmOpen = false; foreach (Form frm in frmColl) { if (frm.Name.ToUpper() == "FRMREVIEWER") { frmReview = (frmReviewer)frm; if (frmReview.FileName == strFileName) { blFrmOpen = true; frmReview.Show(); frmReview.WindowState = FormWindowState.Maximized; } } } if (!blFrmOpen) { #region Code Commented //DialogResult diares = MessageBox.Show("Do you want to check duplicate records?","Check duplicates",MessageBoxButtons.YesNo,MessageBoxIcon.Question); //if (diares == DialogResult.Yes) //{ // int intDupRCnt = 0; // int intTotalRCnt = 0; // intDupRCnt = ChemistryOperations.GetDuplicateRecordsCount(strFileName.Trim(), out intTotalRCnt); // if (intDupRCnt > 0) // { // diares = MessageBox.Show(intDupRCnt + " duplicate records found out of " + intTotalRCnt + " record(s). \r\n Do you want to delete duplicates?", "Delete duplicates", MessageBoxButtons.YesNo, MessageBoxIcon.Question); // if (diares == DialogResult.Yes) // { // if (ChemistryOperations.DeleteAllDuplicateStructures(strFileName.Trim(), out intTotalRCnt, out intDupRCnt)) // { // MessageBox.Show(intDupRCnt + " duplicate records deleted out of " + intTotalRCnt + "record(s)"); // } // } // } // else // { // MessageBox.Show("No duplicate records found out of " + intTotalRCnt + " record(s)"); // } // frmReview = new frmReviewer(); // frmReview.FileName = strFileName.Trim(); // frmReview.TANNumber = strFileName_TAN.Trim(); // frmReview.MdiParent = this; // frmReview.Show(); //} #endregion frmReview = new frmReviewer(); frmReview.FileName = strFileName.Trim(); frmReview.TANNumber = strFileName_TAN.Trim(); frmReview.MdiParent = this; frmReview.Show(); } } else { MessageBox.Show("Not a valid file name with TAN Number", "In valid file", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Can not read empty file", "Empty file", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch (Exception ex) { PepsiLiteErrorHandling.WriteErrorLog(ex.ToString()); } }
private void fromFileToolStripMenuItem_Click(object sender, EventArgs e) { try { openFileDialog1.Filter = "SDF|*.sdf|TXT|*.txt"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { string strFilePath = openFileDialog1.FileName; if (strFilePath.Trim() != "") { System.IO.FileInfo finfo = new System.IO.FileInfo(strFilePath); if (finfo.Length > 0) { string strFileName_TAN = System.IO.Path.GetFileNameWithoutExtension(strFilePath); string strDirPath = System.IO.Path.GetDirectoryName(strFilePath); if (Validations.IsValidTanNumber(strFileName_TAN.Trim())) { string strXmlPath = strDirPath + "\\" + strFileName_TAN + ".xml"; FormCollection frmColl = Application.OpenForms; frmXMLViewer xmlView = null; bool blFrmOpen = false; foreach (Form frm in frmColl) { if (frm.Name.ToUpper() == "FRMXMLVIEWER") { xmlView = (frmXMLViewer)frm; if (xmlView.FileName == strXmlPath) { blFrmOpen = true; xmlView.Show(); xmlView.WindowState = FormWindowState.Maximized; } } } if (!blFrmOpen) { //statStripLbl_User.Text = "Generating XML, please wait..."; toolSProgBar.Visible = true; if (WriteOutPutXMLFile.WriteXmlFileUsingXSD(strFilePath, strFileName_TAN, strXmlPath)) { //statStripLbl_User.Text = "Validating XML..."; string strXMLSchema = AppDomain.CurrentDomain.BaseDirectory + "PatentEnhancedPrioritySubstanceIndexing-2.3.xsd";// "PEPSILiteSchema.xsd"; string strErr_out = ""; if (Validations.ValidateXmlAgainstSchema(strXmlPath, strXMLSchema, out strErr_out)) { toolSProgBar.Visible = false; xmlView = new frmXMLViewer(); xmlView.FileName = strXmlPath; xmlView.MdiParent = this; xmlView.Show(); } else { toolSProgBar.Visible = false; MessageBox.Show(strErr_out, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //statStripLbl_User.Text = ""; toolSProgBar.Visible = false; MessageBox.Show("Error in writing Xml file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { toolSProgBar.Visible = false; MessageBox.Show("Not a valid file name with TAN Number"); } } else { MessageBox.Show("Can not read empty file", "Empty file", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch (Exception ex) { PepsiLiteErrorHandling.WriteErrorLog(ex.ToString()); } }