private void btnSchema_Click(object sender, EventArgs e)
        {
            try
            {
                #region Code Commented
                //string strErr_out = "";
                //string strXMLSchema = AppDomain.CurrentDomain.BaseDirectory + "PatentEnhancedPrioritySubstanceIndexing-2.3.xsd";

                //if (Validations.ValidateXmlAgainstSchema(txtXmlFile.Text, strXMLSchema, out strErr_out))
                //{
                //    MessageBox.Show("Validation success");
                //}
                //else
                //{
                //    MessageBox.Show(strErr_out);
                //}
                #endregion

                ParseXMLFile();
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Esempio n. 2
0
        public static DataTable CreateTANDetailsTable()
        {
            DataTable dtStructData = new DataTable();

            try
            {
                dtStructData.Columns.Add("tan_dtl_id", typeof(Int32));
                dtStructData.Columns.Add("structure", typeof(object));
                dtStructData.Columns.Add("mol_weight", typeof(double));
                dtStructData.Columns.Add("mol_formula", typeof(string));
                dtStructData.Columns.Add("iupac_name", typeof(string));
                dtStructData.Columns.Add("page_number", typeof(int));
                dtStructData.Columns.Add("page_label", typeof(string));
                dtStructData.Columns.Add("example_number", typeof(string));
                dtStructData.Columns.Add("en_name", typeof(string));
                dtStructData.Columns.Add("table_number", typeof(string));
                dtStructData.Columns.Add("inchi_key", typeof(string));

                return(dtStructData);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(dtStructData);
        }
Esempio n. 3
0
        public static string GetInchiKeyFromInchiString(string inchistring)
        {
            string strInchikey = "";

            try
            {
                if (inchistring.Trim() != "")
                {
                    string[] splitter    = { "InChIKey=" };
                    string[] strInchiArr = inchistring.Trim().Split(splitter, StringSplitOptions.RemoveEmptyEntries);
                    if (strInchiArr != null)
                    {
                        if (strInchiArr.Length == 2)
                        {
                            strInchikey = strInchiArr[1];
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(strInchikey);
        }
Esempio n. 4
0
 public static ArrayList GetTANListFromTanTable(DataTable _dtTanIds)
 {
     try
     {
         if (_dtTanIds != null)
         {
             ArrayList lstTANIds = new ArrayList();
             if (_dtTanIds.Rows.Count > 0)
             {
                 for (int i = 0; i < _dtTanIds.Rows.Count; i++)
                 {
                     if (!lstTANIds.Contains(_dtTanIds.Rows[i][0].ToString()))
                     {
                         lstTANIds.Add(_dtTanIds.Rows[i][0].ToString());
                     }
                 }
             }
             return(lstTANIds);
         }
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
     return(null);
 }
        private void OpenFile()
        {
            try
            {
                openFileDialog1.Filter      = "XML Files (*.xml)|*.xml|Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                openFileDialog1.FilterIndex = 1;
                openFileDialog1.Title       = "Select a file to open";
                openFileDialog1.FileName    = "";
                openFileDialog1.ShowDialog();

                if (openFileDialog1.FileName != "")
                {
                    xmlFileName = openFileDialog1.FileName;

                    txtXmlFile.Text = xmlFileName.Trim();

                    RichTextBox1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
                    this.Text = "Xml Editor | " + xmlFileName.Substring(xmlFileName.LastIndexOf("\\") + 1);
                }

                Changed = false;
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Esempio n. 6
0
        public static int GetMoleculeCountFromFile(string filename)
        {
            try
            {
                string text = "";

                FileStream   FS = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
                StreamReader SR = new StreamReader(FS);
                text = SR.ReadToEnd();

                SR.Close();
                SR.Dispose();

                FS.Close();
                FS.Dispose();
                Regex           RE         = new Regex("^\\$\\$\\$\\$", RegexOptions.Multiline);
                MatchCollection theMatches = RE.Matches(text);

                return(theMatches.Count);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(0);
        }
Esempio n. 7
0
        public static string RemoveSMILESFromIUPACName(string iupacname)
        {
            string strIUPACName = iupacname;

            try
            {
                if (iupacname.Trim() != "")
                {
                    string[] strSplitter  = { " " };
                    string[] strSplitVals = iupacname.Split(strSplitter, StringSplitOptions.RemoveEmptyEntries);
                    if (strSplitVals != null)
                    {
                        if (strSplitVals.Length > 1)
                        {
                            //strIUPACName = strSplitVals[1].Trim();
                            //return strIUPACName;

                            strSplitVals[0] = "";
                            strIUPACName    = String.Join(" ", strSplitVals);
                            return(strIUPACName.Trim());
                        }
                        else if (strSplitVals.Length == 1)
                        {
                            strIUPACName = String.Join(" ", strSplitVals);
                            return(strIUPACName.Trim());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(strIUPACName);
        }
Esempio n. 8
0
        public static string GetStructureInchiKey(string _molfilestring)
        {
            string strInchiKey = "Inchi Not generated";

            try
            {
                MolHandler mHandler = new MolHandler(_molfilestring);
                Molecule   mol      = mHandler.getMolecule();
                try
                {
                    strInchiKey = mol.toFormat("inchi:key");
                }
                catch //Exception is inchi not generated
                {
                    // if inchi not generated
                    SetMolAbsStereo_Inchi_NotGenerated(ref mol);

                    strInchiKey = mol.toFormat("inchi:key");
                }
                if (strInchiKey != "")
                {
                    strInchiKey = Validations.GetInchiKeyFromInchiString(strInchiKey);
                }

                return(strInchiKey);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(strInchiKey);
        }
Esempio n. 9
0
        private static Molecule StandardizeMolecule(Molecule mol, out bool ischiral_out)
        {
            Molecule molChem    = null;
            bool     blIsChiral = false;

            try
            {
                Standardizer molSdz = new Standardizer("absolutestereo:set");
                molChem = molSdz.standardize(mol);

                blIsChiral = molChem.isAbsStereo();

                #region Code Commented
                //string strDirPath = AppDomain.CurrentDomain.BaseDirectory.ToString();
                //string strXmlPath = strDirPath + "chiral.xml";
                //StandardizerConfiguration sconfing = new StandardizerConfiguration();
                //sconfing.read(strXmlPath);
                //Standardizer sdz = sconfing.getStandardizer();
                //molChem = sdz.standardize(mol);
                //Standardizer sdz = new Standardizer(new File(strXmlPath));
                #endregion

                ischiral_out = blIsChiral;
                return(molChem);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            ischiral_out = blIsChiral;
            return(molChem);
        }
Esempio n. 10
0
 private static void SetMolAbsStereo_Inchi_NotGenerated(ref Molecule _molobj)
 {
     try
     {
         int     atno = 0;
         MolAtom ma   = null;
         for (int i = 0; i < (_molobj.getAtomCount() - 1); i++)
         {
             atno = _molobj.getAtom(i).getAtno();
             if (atno > 109)
             {
                 ma = _molobj.getAtom(i);
                 ma.setAtno(6);
             }
         }
         bool flag1 = _molobj.ungroupSgroups();
         bool flag2 = _molobj.hydrogenize(false);
         if (_molobj.isAbsStereo())
         {
             _molobj.setAbsStereo(true);
         }
         _molobj.aromatize(false);
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 11
0
        private DataTable GetTanDetailsTableFromActiveForm(out string tan_out, out string srcCntrl_out)
        {
            DataTable dtTanDetails = null;
            string    strTanNumber = "";
            string    strSrcCntrl  = "";

            try
            {
                frmCurator              objfrmCurator   = null;
                Forms.frmQryDuplicates  objfrmQueryDups = null;
                Enumeration.frmRGrpEnum objfrmEnum      = null;

                Form objActiveForm = this.ActiveMdiChild;

                if (objActiveForm != null)
                {
                    if (objActiveForm.Name.ToUpper() == "FRMCURATOR")
                    {
                        objfrmCurator = (frmCurator)objActiveForm;
                        dtTanDetails  = objfrmCurator.TANDetailsTbl;
                        strTanNumber  = objfrmCurator.TANNumber;

                        strSrcCntrl = "FRMCURATOR";
                    }
                    else if (objActiveForm.Name.ToUpper() == "FRMQRYDUPLICATES")
                    {
                        objfrmQueryDups = (Forms.frmQryDuplicates)objActiveForm;
                        dtTanDetails    = objfrmQueryDups.ucCheckDuplicates1.SearchResults;
                        strTanNumber    = objfrmQueryDups.ucCheckDuplicates1.TANNumber;

                        strSrcCntrl = "FRMQRYDUPLICATES";
                    }
                    else if (objActiveForm.Name.ToUpper() == "FRMRGRPENUM")
                    {
                        objfrmEnum   = (Enumeration.frmRGrpEnum)objActiveForm;
                        dtTanDetails = objfrmEnum.EnumResultsTbl;
                        strTanNumber = objfrmEnum.TANNumber;

                        string strPageNo    = objfrmEnum.PageNumber;
                        string strPageLabel = objfrmEnum.PageLabel;
                        string strExampleNo = objfrmEnum.ExampleNumber;
                        string strTableNo   = objfrmEnum.TableNumber;

                        strSrcCntrl = "FRMRGRPENUM";

                        RebuildTANDetailsTable_Enum(ref dtTanDetails, strPageNo, strPageLabel, strExampleNo, strTableNo);
                    }
                    tan_out      = strTanNumber;
                    srcCntrl_out = strSrcCntrl;
                    return(dtTanDetails);
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            tan_out      = strTanNumber;
            srcCntrl_out = strSrcCntrl;
            return(dtTanDetails);
        }
Esempio n. 12
0
        private void rGroupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                FormCollection          frmColl     = Application.OpenForms;
                Enumeration.frmRGrpEnum objRgrpEnum = null;
                bool blFrmOpen = false;

                foreach (Form frm in frmColl)
                {
                    if (frm.Name.ToUpper() == "FRMRGRPENUM")
                    {
                        objRgrpEnum = (Enumeration.frmRGrpEnum)frm;
                        blFrmOpen   = true;
                        objRgrpEnum.Show();
                        objRgrpEnum.WindowState = FormWindowState.Maximized;
                    }
                }
                if (!blFrmOpen)
                {
                    objRgrpEnum           = new Enumeration.frmRGrpEnum();
                    objRgrpEnum.MdiParent = this;
                    objRgrpEnum.Show();
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Esempio n. 13
0
        private void openXMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                FormCollection          frmColl       = Application.OpenForms;
                frmXMLViewer_Validation xmlView_Valid = null;
                bool blFrmOpen = false;

                foreach (Form frm in frmColl)
                {
                    if (frm.Name.ToUpper() == "FRMXMLVIEWER_VALIDATION")
                    {
                        xmlView_Valid = (frmXMLViewer_Validation)frm;

                        blFrmOpen = true;
                        xmlView_Valid.Show();
                        xmlView_Valid.WindowState = FormWindowState.Maximized;
                    }
                }
                if (!blFrmOpen)
                {
                    xmlView_Valid           = new frmXMLViewer_Validation();
                    xmlView_Valid.MdiParent = this;
                    xmlView_Valid.Show();
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Esempio n. 14
0
 private void btnBrowseXML_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFile();
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 15
0
 private void frmXMLViewer_Validation_Load(object sender, EventArgs e)
 {
     try
     {
         this.WindowState = FormWindowState.Maximized;
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 16
0
 private void exitToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         this.Close();
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 17
0
 private void frmChemDraw_Load(object sender, EventArgs e)
 {
     try
     {
         AssignMolsToControls();
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 18
0
        public static bool DeleteAllDuplicateStructures(string filename, out int totalreccnt, out int dupreccnt)
        {
            bool blStatus       = false;
            int  intDupRecCnt   = 0;
            int  intTotalRecCnt = 0;

            try
            {
                MolInputStream molInStream = new MolInputStream(new FileInputStream(filename));
                MolImporter    molImp      = new MolImporter(molInStream);
                Molecule       objMol      = new Molecule();

                DataOutputStream dOutStream = new DataOutputStream(new FileOutputStream(filename));
                MolExporter      molExpt    = new MolExporter(dOutStream, "sdf");

                bool   blIsChiral  = false;
                string strInchiKey = "";

                ArrayList molInchiList = new ArrayList();

                while (molImp.read(objMol))
                {
                    objMol = StandardizeMolecule(objMol, out blIsChiral);

                    strInchiKey = objMol.toFormat("inchi:key");
                    strInchiKey = Validations.GetInchiKeyFromInchiString(strInchiKey);

                    if (!molInchiList.Contains(strInchiKey))
                    {
                        molInchiList.Add(strInchiKey);
                        molExpt.write(objMol);
                    }
                    else
                    {
                        intDupRecCnt++;
                    }
                    intTotalRecCnt++;
                }
                //Close all the import & export objects
                molImp.close();
                molInStream.close();
                dOutStream.close();
                molExpt.close();

                blStatus = true;
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            totalreccnt = intTotalRecCnt;
            dupreccnt   = intDupRecCnt;
            return(blStatus);
        }
Esempio n. 19
0
 private void createToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Forms.frmCreateUser objCreateUser = new NameToStructureApplication.Forms.frmCreateUser();
         objCreateUser.Show();
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 20
0
 private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Forms.frmChangePwd objChangePwd = new NameToStructureApplication.Forms.frmChangePwd();
         objChangePwd.ShowDialog();
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 21
0
 private void retrieveDictStripMenuItem1_Click(object sender, EventArgs e)
 {
     try
     {
         Forms.frmRetrieveDict objRetDict = new NameToStructureApplication.Forms.frmRetrieveDict();
         objRetDict.ShowDialog();
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 22
0
        public static string GetConvertedIUPACName(string iupacname)
        {
            string strIUPACName = "";

            try
            {
                if (iupacname.Trim() != "")
                {
                    int intHashCode = 0;
                    foreach (Char c in iupacname.Trim())
                    {
                        intHashCode = c.GetHashCode();
                        switch (intHashCode)
                        {
                        case 913:

                            strIUPACName = strIUPACName + ".alpha.";
                            break;

                        case 914:

                            strIUPACName = strIUPACName + ".beta.";
                            break;

                        case 915:

                            strIUPACName = strIUPACName + ".gamma.";
                            break;

                        case 916:

                            strIUPACName = strIUPACName + ".delta.";
                            break;

                        case 917:

                            strIUPACName = strIUPACName + ".epsilon.";
                            break;

                        default:
                            strIUPACName = strIUPACName + c;
                            break;
                        }
                    }
                    return(strIUPACName);
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(strIUPACName);
        }
Esempio n. 23
0
 private void deleteDictToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     try
     {
         Forms.frmDeleteDict objDeleteDict = new Forms.frmDeleteDict();
         objDeleteDict.ShowDialog();
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 24
0
 private static void ValidationEventHandler(object sender, ValidationEventArgs args)
 {
     try
     {
         blValidateFail = true;
         strErrMSg      = "Validation error: " + args.Message;
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 25
0
 private void SetBehavior()
 {
     try
     {
         bool bFileExists = ((txtFileName.Text.Trim() != string.Empty) && File.Exists(txtFileName.Text));
         xmlGridView1.ViewMode = XmlGridView.VIEW_MODE.XML;
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 26
0
        public static bool CheckForDuplicateStructure(string filename, string qrymolfile, int recindex, out Molecule mol_out)
        {
            bool blStatus = false;

            try
            {
                bool blIsChiral = false;

                MolHandler mHandler = new MolHandler(qrymolfile);
                Molecule   qryMol   = mHandler.getMolecule();
                qryMol = StandardizeMolecule(qryMol, out blIsChiral);

                string strqryMolInchi = qryMol.toFormat("inchi:key");
                strqryMolInchi = Validations.GetInchiKeyFromInchiString(strqryMolInchi);

                //Specify input file to MolInputStream object
                MolInputStream molInStream = new MolInputStream(new FileInputStream(filename));
                MolImporter    molImp      = new MolImporter(molInStream);
                Molecule       objMol      = new Molecule();

                blIsChiral = false;
                string strInchiKey = "";
                int    intRecIndx  = 0;

                Molecule molObj_Stand = null;
                while (molImp.read(objMol))
                {
                    molObj_Stand = StandardizeMolecule(objMol, out blIsChiral);

                    strInchiKey = objMol.toFormat("inchi:key");
                    strInchiKey = Validations.GetInchiKeyFromInchiString(strInchiKey);

                    intRecIndx++;

                    if ((strInchiKey == strqryMolInchi) && (intRecIndx != recindex))
                    {
                        blStatus = true;
                        mol_out  = objMol;
                        return(blStatus);
                    }
                }

                molImp.close();
                molInStream.close();
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            mol_out = null;
            return(blStatus);
        }
Esempio n. 27
0
 private void browsePDFToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         frmCurator frmNToS = new frmCurator();
         frmNToS.MdiParent = this;
         frmNToS.Show();
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 28
0
 static void Main()
 {
     try
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(new frmMain_PepsiLite());//Enumeration.frmRGrpEnum frmMain_PepsiLite
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 29
0
 private void checkDuplicatesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Forms.frmQryDuplicates objfrmQryDups = new Forms.frmQryDuplicates();
         objfrmQryDups.MdiParent = this;
         objfrmQryDups.Show();
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Esempio n. 30
0
        private void OnXmlSyntaxError(object sender, ValidationEventArgs args)
        {
            try
            {
                IsWellFormedXml = false;
                strError        = lineInf.LineNumber.ToString() + ": " + lineInf.LinePosition.ToString() + " " + args.Message;

                ListBox1.Items.Add(strError);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }