Exemplo n.º 1
0
        private void btnWellFormNess_Click(object sender, EventArgs e)
        {
            try
            {
                ListBox1.Items.Clear();

                RichTextBox1.SaveFile(xmlFileName, RichTextBoxStreamType.PlainText);

                IsWellFormedXml = true;

                using (FileStream stream = File.OpenRead(AppDomain.CurrentDomain.BaseDirectory + "PatentEnhancedPrioritySubstanceIndexing-2.3.xsd"))
                {
                    XmlReaderSettings settings = new XmlReaderSettings();

                    XmlSchema schema = XmlSchema.Read(stream, OnXmlSyntaxError);
                    settings.ValidationType = ValidationType.Schema;
                    settings.Schemas.Add(schema);
                    settings.ValidationEventHandler += OnXmlSyntaxError;

                    string strError = "";
                    using (XmlReader validator = XmlReader.Create(txtXmlFile.Text.Trim(), settings))
                    {
                        try
                        {
                            // Validate the entire xml file
                            while (validator.Read())
                            {
                                lineInf = (IXmlLineInfo)validator;
                            }
                        }
                        catch (Exception ex)
                        {
                            if (lineInf.HasLineInfo())
                            {
                                strError = lineInf.LineNumber.ToString() + ": " + lineInf.LinePosition.ToString() + " " + ex.Message;
                            }
                            ListBox1.Items.Add(strError);
                        }
                    }
                }
                if (IsWellFormedXml)
                {
                    MessageBox.Show("Wellformed XML", "Wellformed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Exemplo n.º 2
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());
            }
        }
Exemplo n.º 3
0
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string    strTanNumber = "";
                string    strSrcCntrl  = "";
                DataTable dtTanDetails = GetTanDetailsTableFromActiveForm(out strTanNumber, out strSrcCntrl);

                if (dtTanDetails != null)
                {
                    if (dtTanDetails.Rows.Count > 0)
                    {
                        if (strTanNumber.Trim() != "")
                        {
                            Forms.frmExportOpts objfrmExp = new Forms.frmExportOpts();

                            ArrayList availProplst = GetExportListOnSourceControl(strSrcCntrl);

                            objfrmExp.AvailProps = availProplst;

                            if (objfrmExp.ShowDialog() == DialogResult.OK)
                            {
                                string strFilepath = objfrmExp.FolderPath + "\\" + strTanNumber + ".sdf";
                                if (Export.PepsiLite_Export.EmportToSdFile(strFilepath, dtTanDetails, objfrmExp.SelectedProps))
                                {
                                    MessageBox.Show("Data exported to sd file successfully", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please specify TAN Number", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("No data is available to export", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("No data is available to export", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Exemplo n.º 4
0
        private void frmReviewer_Load(object sender, EventArgs e)
        {
            try
            {
                ucChemProps_Navigation1.FileName  = FileName;
                ucChemProps_Navigation1.TANNumber = TANNumber;
                ucChemProps_Navigation1.LoadMolecules();

                this.WindowState = FormWindowState.Maximized;
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Exemplo n.º 5
0
        public static bool SetChemaxonLicenseFilePath(string licFilePath)
        {
            bool blStatus = false;

            try
            {
                LicenseManager.setLicenseFile(licFilePath);
                return(blStatus = true);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(blStatus);
        }
Exemplo n.º 6
0
 private void TabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (TabControl1.SelectedIndex == 1)
         {
             RichTextBox1.SaveFile(xmlFileName, RichTextBoxStreamType.PlainText);
             webBrowser1.Navigate(xmlFileName);
         }
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Exemplo n.º 7
0
        public static bool ValidateXmlAgainstSchema(string xmlFilename, string schemaFilename, out string errmsg)
        {
            bool blStatus = false;
            XmlValidatingReader validator = null;

            try
            {
                XmlTextReader xmlTRdr = new XmlTextReader(xmlFilename);
                validator = new XmlValidatingReader(xmlTRdr);
                validator.ValidationType = ValidationType.Schema;

                XmlSchemaCollection xmlSchColl = new XmlSchemaCollection();
                xmlSchColl.Add(null, schemaFilename);
                validator.Schemas.Add(xmlSchColl);

                blValidateFail = false;

                validator.ValidationEventHandler += new ValidationEventHandler(ValidationEventHandler);

                while (validator.Read())
                {
                    if (blValidateFail)
                    {
                        break;
                    }
                }
                if (blValidateFail)
                {
                    blStatus = false;
                }
                else
                {
                    blStatus = true;
                }
            }
            catch (XmlException ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            finally
            {
                validator.Close();
            }
            errmsg = strErrMSg;
            return(blStatus);
        }
Exemplo n.º 8
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         if (rbnOpenEye.Checked)
         {
             if (renditor_OpenEye.MolfileString != null)
             {
                 SelectedMol = renditor_OpenEye.MolfileString;
                 this.Close();
             }
             else
             {
                 MessageBox.Show("No Molecule in the OpenEye");
             }
         }
         else if (rbnChemDraw.Checked)
         {
             if (renditor_ChemDraw.MolfileString != null)
             {
                 SelectedMol = renditor_ChemDraw.MolfileString;
                 this.Close();
             }
             else
             {
                 MessageBox.Show("No Molecule in the ChemDraw");
             }
         }
         else if (rbnChemAxon.Checked)
         {
             if (renditor_ChemAxon.MolfileString != null)
             {
                 SelectedMol = renditor_ChemAxon.MolfileString;
                 this.Close();
             }
             else
             {
                 MessageBox.Show("No Molecule in the ChemAxon");
             }
         }
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Exemplo n.º 9
0
 private void DisableMenuItems()
 {
     try
     {
         browsePDFToolStripMenuItem.Enabled  = false;
         exportToolStripMenuItem.Enabled     = false;
         XMLToolStripMenuItem.Enabled        = false;
         queryToolStripMenuItem.Enabled      = false;
         EnumtoolStripMenuItem.Enabled       = false;
         setttingsToolStripMenuItem.Enabled  = false;
         dictionaryToolStripMenuItem.Enabled = false;
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Exemplo n.º 10
0
        private void frmMain_PepsiLite_Load(object sender, EventArgs e)
        {
            try
            {
                CheckAndSetEnvironVariable.SetEnvironmentVariableEx(strEnvVarName, strEnvVarVal);
                CheckAndSetEnvironVariable.SetChemaxonLicenseFilePath(AppDomain.CurrentDomain.BaseDirectory + "license.cxl");

                //Disable menu Items
                DisableMenuItems();

                //Open Login form
                loginToolStripMenuItem_Click(null, null);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Exemplo n.º 11
0
        private void frmXMLViewer_Load(object sender, EventArgs e)
        {
            try
            {
                txtFileName.Text = _filename;

                xmlGridView1.DataFilePath      = txtFileName.Text;
                xmlGridView1.DataSetTableIndex = 0;

                SetBehavior();

                this.WindowState = FormWindowState.Maximized;
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Exemplo n.º 12
0
        public static int GetDuplicateRecordsCount(string filename, out int totalreccnt)
        {
            int intDupRecCnt   = 0;
            int intTotalRecCnt = 0;

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

                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);
                    }
                    else
                    {
                        intDupRecCnt++;
                    }
                    intTotalRecCnt++;
                }

                molImp.close();
                molInStream.close();
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            totalreccnt = intTotalRecCnt;
            return(intDupRecCnt);
        }
Exemplo n.º 13
0
        private void AssignMolsToControls()
        {
            try
            {
                if (OpenEyeMol.Trim() != "")
                {
                    txtError_OpenEye.Visible       = false;
                    renditor_OpenEye.MolfileString = OpenEyeMol;
                }
                else
                {
                    txtError_OpenEye.Visible = true;
                    txtError_OpenEye.Text    = Error_OpenEye;
                }

                if (ChemDrawMol.Trim() != "")
                {
                    txtError_ChemDraw.Visible       = false;
                    renditor_ChemDraw.MolfileString = ChemDrawMol;
                }
                else
                {
                    txtError_ChemDraw.Visible = true;
                    txtError_ChemDraw.Text    = Error_ChemDraw;
                }

                if (ChemAxonMol.Trim() != "")
                {
                    txtError_ChemAxon.Visible       = false;
                    renditor_ChemAxon.MolfileString = ChemAxonMol;
                }
                else
                {
                    txtError_ChemAxon.Visible = true;
                    txtError_ChemAxon.Text    = Error_ChemAxon;
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Exemplo n.º 14
0
        private void RebuildTANDetailsTable_Enum(ref DataTable _dtEnumdetails, string _pageno, string _pagelabel, string _exampleno, string _tableno)
        {
            try
            {
                if (_dtEnumdetails != null)
                {
                    if (_dtEnumdetails.Rows.Count > 0)
                    {
                        if (!_dtEnumdetails.Columns.Contains("page_number"))
                        {
                            _dtEnumdetails.Columns.Add("page_number", typeof(int));
                        }
                        if (!_dtEnumdetails.Columns.Contains("page_label"))
                        {
                            _dtEnumdetails.Columns.Add("page_label", typeof(string));
                        }
                        if (!_dtEnumdetails.Columns.Contains("example_number"))
                        {
                            _dtEnumdetails.Columns.Add("example_number", typeof(string));
                        }
                        if (!_dtEnumdetails.Columns.Contains("table_number"))
                        {
                            _dtEnumdetails.Columns.Add("table_number", typeof(string));
                        }

                        for (int rowindx = 0; rowindx < _dtEnumdetails.Rows.Count; rowindx++)
                        {
                            _dtEnumdetails.Rows[rowindx]["page_number"]    = Convert.ToInt32(_pageno);
                            _dtEnumdetails.Rows[rowindx]["page_label"]     = _pagelabel;
                            _dtEnumdetails.Rows[rowindx]["example_number"] = _exampleno;
                            _dtEnumdetails.Rows[rowindx]["table_number"]   = _tableno;
                        }
                        _dtEnumdetails.AcceptChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Exemplo n.º 15
0
        private void loginToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Forms.frmLogin objLogin = new Forms.frmLogin();
                if (objLogin.ShowDialog() != DialogResult.OK)
                {
                    if (objLogin.SubmitClick)
                    {
                        EnableMenuItems(objLogin.UserRole);

                        statStripLbl_User.Visible = true;
                        statStripLbl_User.Text    = Classes.Generic_PepsiLite.UserRole + ": " + Classes.Generic_PepsiLite.UserName;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Exemplo n.º 16
0
        private ArrayList GetExportListOnSourceControl(string _srcCntrl)
        {
            ArrayList availProplst = new ArrayList();

            try
            {
                if (_srcCntrl.Trim() != "")
                {
                    if (_srcCntrl.Trim().ToUpper() == "FRMCURATOR" || _srcCntrl.Trim().ToUpper() == "FRMQRYDUPLICATES")
                    {
                        availProplst.Add("Structure");
                        availProplst.Add("Mol Weight");
                        availProplst.Add("Mol Formula");
                        availProplst.Add("IUPAC Name");
                        availProplst.Add("Page Number");
                        availProplst.Add("Page Label");
                        availProplst.Add("Example Number");
                        availProplst.Add("En Name");
                        availProplst.Add("Table Number");
                    }
                    else if (_srcCntrl.Trim().ToUpper() == "FRMRGRPENUM")
                    {
                        availProplst.Add("Structure");
                        availProplst.Add("Mol Weight");
                        availProplst.Add("Mol Formula");
                        availProplst.Add("IUPAC Name");
                        availProplst.Add("Page Number");
                        availProplst.Add("Page Label");
                        availProplst.Add("Example Number");
                        availProplst.Add("Table Number");
                    }
                    return(availProplst);
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(availProplst);
        }
Exemplo n.º 17
0
        public static bool CheckForV3000Format(string molfilestring)
        {
            bool blIsV3000 = false;

            try
            {
                if (molfilestring != "")
                {
                    int v3000 = molfilestring.IndexOf("V3000");
                    if (v3000 == -1)
                    {
                        blIsV3000 = false;
                    }
                    else
                    {
                        blIsV3000 = true;
                    }

                    #region Code Commented
                    //MolHandler mHandler = new MolHandler(molfilestring);
                    //int atomCnt = mHandler.getAtomCount();
                    //if (atomCnt > 999)
                    //{
                    //    blIsV3000 = true;
                    //}
                    //else
                    //{
                    //    blIsV3000 = false;
                    //}
                    #endregion
                }
                return(blIsV3000);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(blIsV3000);
        }
Exemplo n.º 18
0
        private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string SelItem = null;
                int    linN    = 0;
                int    colN    = 0;
                SelItem = ListBox1.SelectedItem.ToString();

                if (!string.IsNullOrEmpty(SelItem))
                {
                    linN = Convert.ToInt16(Regex.Replace(SelItem, "([0-9]+): ([0-9]+)(.*)", "$1"));
                    colN = Convert.ToInt16(Regex.Replace(SelItem, "([0-9]+): ([0-9]+)(.*)", "$2"));


                    MatchCollection mc   = default(MatchCollection);
                    int             i    = 0;
                    int             totc = 0;

                    mc = Regex.Matches(RichTextBox1.Text, "\\n", RegexOptions.Singleline);

                    try
                    {
                        RichTextBox1.Select(mc[linN - 2].Index + colN, 2);
                        RichTextBox1.SelectionColor = Color.Blue;

                        RichTextBox1.Focus();
                    }
                    catch (Exception ex)
                    {
                        RichTextBox1.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Exemplo n.º 19
0
        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)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            _molformula = strMolFormula;
            return(dblMolWeight);
        }
Exemplo n.º 20
0
        public static string GetConvertedMolString(string MolString)
        {
            string strConv64 = "";

            try
            {
                if (MolString != "")
                {
                    byte[] byteArr = StringToByteArray(MolString);
                    if (byteArr != null)
                    {
                        strConv64 = Convert.ToBase64String(byteArr);
                    }
                }
                return(strConv64);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(strConv64);
        }
Exemplo n.º 21
0
 private void btnBrowsePDFFile_Click(object sender, EventArgs e)
 {
     try
     {
         openFileDialog1.Filter = "PDF|*.pdf";
         if (openFileDialog1.ShowDialog() == DialogResult.OK)
         {
             string strFileName = openFileDialog1.FileName;
             if (strFileName.Trim() != "")
             {
                 txtFileName.Text        = strFileName;
                 pdfDocBrow.IsAccessible = true;
                 pdfDocBrow.LoadFile(strFileName);
                 pdfDocBrow.Visible = true;
             }
         }
     }
     catch (Exception ex)
     {
         ErrorHandling_NTS.WriteErrorLog(ex.ToString());
     }
 }
Exemplo n.º 22
0
        public static bool SetEnvironmentVariableEx(string environmentVariable, string variableValue)
        {
            bool blStatus = false;

            try
            {
                string strEnv = Environment.GetEnvironmentVariable(environmentVariable);
                if (strEnv == null)
                {
                    // Get the write permission to set the environment variable.
                    EnvironmentPermission environmentPermission = new EnvironmentPermission(EnvironmentPermissionAccess.Write, environmentVariable);
                    environmentPermission.Demand();
                    blStatus = SetEnvironmentVariable(environmentVariable, variableValue);
                    return(blStatus);
                }
            }
            catch (SecurityException ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(blStatus);
        }
Exemplo n.º 23
0
        public static string GetStandardizedMolecule(string strMolFile, out bool isChiral_Out)
        {
            string strStandMol = "";
            bool   blIsChiral  = false;

            try
            {
                chemaxon.util.MolHandler molHandler = new MolHandler(strMolFile);
                Molecule molObj       = molHandler.getMolecule();
                Molecule molObj_Stand = StandardizeMolecule(molObj, out blIsChiral);
                strStandMol = molObj_Stand.toFormat("mol");

                isChiral_Out = blIsChiral;
                return(strStandMol);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }

            isChiral_Out = blIsChiral;
            return(strStandMol);
        }
Exemplo n.º 24
0
        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_NTS.WriteErrorLog(ex.ToString());
            }
            molformula_out = strMolFormula;
            return(strMolWeight);
        }
Exemplo n.º 25
0
        private void EnableMenuItems(string _userrole)
        {
            try
            {
                loginToolStripMenuItem.Enabled = false;

                browsePDFToolStripMenuItem.Enabled = true;
                exportToolStripMenuItem.Enabled    = true;

                queryToolStripMenuItem.Enabled = true;
                EnumtoolStripMenuItem.Enabled  = true;

                setttingsToolStripMenuItem.Enabled = true;

                if (_userrole.Trim().ToUpper() == "REVIEWER")
                {
                    XMLToolStripMenuItem.Enabled          = true;
                    userAccountsToolStripMenuItem.Enabled = false;
                }
                else if (_userrole.Trim().ToUpper() == "ADMINISTRATOR")
                {
                    XMLToolStripMenuItem.Enabled          = true;
                    userAccountsToolStripMenuItem.Enabled = true;
                    dictionaryToolStripMenuItem.Enabled   = true;
                }
                else if (_userrole.Trim().ToUpper() == "CURATOR")
                {
                    XMLToolStripMenuItem.Enabled          = false;
                    userAccountsToolStripMenuItem.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Exemplo n.º 26
0
        public static bool IsValidTanNumber(string tanNumString)
        {
            bool blStatus = false;

            try
            {
                Regex           regExp    = new Regex("[0-9]{8}[A-Z]{1}$", RegexOptions.Singleline);
                MatchCollection matchColl = regExp.Matches(tanNumString);

                if (matchColl.Count > 0)
                {
                    blStatus = true;
                }
                else
                {
                    blStatus = false;
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(blStatus);
        }
Exemplo n.º 27
0
        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);
        }
Exemplo n.º 28
0
        public static bool WriteXmlFile(string infilename, string tannumber, string outputfilepath)
        {
            System.IO.StreamWriter sWriter = null;
            try
            {
                sWriter = new System.IO.StreamWriter(outputfilepath);

                //xml file header information
                sWriter.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
                sWriter.WriteLine("<patent xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"PatentEnhancedPrioritySubstanceIndexing-2.3.xsd\">");
                sWriter.WriteLine("<patentInfo>");
                sWriter.WriteLine("<tan>" + tannumber + "</tan>");
                sWriter.WriteLine("<language>en</language>");
                sWriter.WriteLine("</patentInfo>");
                sWriter.WriteLine("<propheticSubstances>");

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

                //Declare mol property variables
                string strPage_No     = "";
                string strPage_Lbl    = "";
                string strExample_Lbl = "";
                string strEn_name     = "";
                string strIUPAC_Name  = "";
                string strStandMol    = "";
                string strMolBase64   = "";

                //Read molecules from molImporter
                while (molImp.read(mol))
                {
                    sWriter.WriteLine("<propheticSubstance>");
                    sWriter.WriteLine("<patentLocation>");

                    //Page No
                    strPage_No = "";
                    strPage_No = mol.getProperty("Page Number").Trim();
                    sWriter.WriteLine("<pageNumber>" + strPage_No + "</pageNumber>");

                    //Page Label
                    strPage_Lbl = "";
                    strPage_Lbl = mol.getProperty("Page Label").Trim();
                    sWriter.WriteLine("<pageLabel>" + strPage_Lbl + "</pageLabel>");

                    //Example label
                    strExample_Lbl = "";
                    strExample_Lbl = mol.getProperty("Example Number").Trim();
                    sWriter.WriteLine("<exampleLabel>" + strExample_Lbl + "</exampleLabel>");

                    sWriter.WriteLine("</patentLocation>");
                    sWriter.WriteLine("<names>");

                    //en Name
                    strEn_name = "";
                    strEn_name = mol.getProperty("en name").Trim();//En Name
                    sWriter.WriteLine("<name lang=\"en\">" + strEn_name + "</name>");

                    //IUPAC Name
                    strIUPAC_Name = "";
                    strIUPAC_Name = mol.getProperty("IUPAC Name").Trim();
                    sWriter.WriteLine("<IUPACName>" + strIUPAC_Name + "</IUPACName>");
                    sWriter.WriteLine("</names>");

                    //Check here for V2000 format, if not write in error log
                    string mol2d = mol.toFormat("mol");

                    int v3000 = mol2d.IndexOf("V3000");
                    if (v3000 != -1)
                    {
                        //System.out.println("V3000 Error has occured! at Molecule Number: " + molCount + " in SDF file " + fileName);
                        //System.exit(0);
                    }

                    double nullMol = mol.getExactMass();
                    if (nullMol == 0)
                    {
                        //System.out.println("NULL Mol Error has occured! at Molecule Number: " + molCount + " in SDF file " + fileName);
                        //System.exit(0);
                    }


                    strStandMol = "";
                    strStandMol = mol.toFormat("mol");//MoleculeStandardizer.GetStandardizedMolecule(mol.toFormat("mol"));

                    strMolBase64 = "";
                    strMolBase64 = ConvertToBase64.GetConvertedMolString(strStandMol);

                    sWriter.WriteLine("<structureData encoding=\"Base64\" type=\"MDL Molfile V2000\">" + strMolBase64 + "</structureData>");//Base64 Molstring
                    sWriter.WriteLine("</propheticSubstance>");
                }

                sWriter.WriteLine("</propheticSubstances>");
                sWriter.WriteLine("</patent>");
                sWriter.Close();
                sWriter.Dispose();

                return(true);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            finally
            {
                sWriter.Close();
                sWriter.Dispose();
            }
            return(true);
        }
Exemplo n.º 29
0
        public static bool WriteXmlFileUsingXSD(string infilename, string tannumber, string outputfilepath)
        {
            bool blStatus = false;

            try
            {
                patentInfo patentInfo_Obj = new patentInfo();
                patentInfo_Obj.tan      = tannumber;
                patentInfo_Obj.language = languageType.en;

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

                //int intMolCnt = molImp.getRecordCount();
                int intMolCnt = ChemistryOperations.GetMoleculeCountFromFile(infilename);

                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;

                //Read molecules from molImporter
                while (molImp.read(mol))
                {
                    patLoc              = new patentLocation();
                    patLoc.pageLabel    = mol.getProperty("Page Label");
                    patLoc.pageNumber   = mol.getProperty("Page Number");
                    patLoc.exampleLabel = mol.getProperty("Example Number");

                    name_Arr = new name[1];

                    name_obj      = new name();
                    name_obj.lang = languageType.en;

                    string[] strArr_EnName = new string[1];
                    strArr_EnName[0] = mol.getProperty("en name").Trim();
                    name_obj.Text    = strArr_EnName;

                    name_Arr[0] = name_obj;

                    strIUpacName    = new string[1];
                    strIUpacName[0] = mol.getProperty("IUPAC Name").Trim();

                    namType      = new nameType();
                    namType.Text = strIUpacName;

                    names_Arr           = new names();
                    names_Arr.IUPACName = namType;
                    names_Arr.name      = name_Arr;

                    string strMol = mol.toFormat("mol");

                    int    v3000   = strMol.IndexOf("V3000");
                    double nullMol = mol.getExactMass();

                    byte[] barr_Mol = null;

                    if (v3000 == -1 && nullMol != 0)
                    {
                        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(outputfilepath);
                xmlSer.Serialize(txtWriter, patent_Obj);

                txtWriter.Close();
                txtWriter.Dispose();

                molInStream.close();
                molImp.close();

                blStatus = true;
                return(blStatus);
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            return(blStatus);
        }
Exemplo n.º 30
0
        public static bool GetStructureFromCompoundName(string strCompName, out string molstring_out, out bool ischiral_out, out string errmessage_out)
        {
            bool   blStatus      = false;
            string strMolString  = "";
            string strErrMessage = "";
            bool   blIsChiral    = false;

            try
            {
                string strDirPath = AppDomain.CurrentDomain.BaseDirectory.ToString();
                string strExePath = strDirPath + "nam2mol.exe";

                string strInputFileName  = "CompName.txt";
                string strOutputFileName = "CompStructure.mol";

                if (System.IO.File.Exists(strDirPath + strInputFileName))
                {
                    System.IO.File.Delete(strDirPath + strInputFileName);
                }
                System.IO.StreamWriter sWriter = new System.IO.StreamWriter(strDirPath + strInputFileName);
                sWriter.WriteLine(strCompName.Trim());
                sWriter.Close();
                sWriter.Dispose();

                if (System.IO.File.Exists(strDirPath + strOutputFileName))
                {
                    System.IO.File.Delete(strDirPath + strOutputFileName);
                }

                //ProcessStartInfo class
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.CreateNoWindow        = true;
                startInfo.UseShellExecute       = false;
                startInfo.RedirectStandardError = true;
                startInfo.FileName    = @"" + strExePath + "";
                startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                startInfo.Arguments   = @"-in """ + strDirPath + strInputFileName + @"""  -out """ + strDirPath + strOutputFileName + @""" -depict true";
                //startInfo.Arguments = @"-in """ + strDirPath + strInputFileName + @""" -depict true";

                string strErrMsg = "";
                try
                {
                    using (Process exeProcess = Process.Start(startInfo))
                    {
                        strErrMsg = exeProcess.StandardError.ReadToEnd();
                        exeProcess.WaitForExit();
                    }
                }
                catch (Exception ex)
                {
                    ErrorHandling_NTS.WriteErrorLog(ex.ToString());
                }
                //Read Output molecule from outputfile
                StreamReader sReader = new StreamReader(strDirPath + strOutputFileName);
                string       newMolfileString;
                newMolfileString = sReader.ReadToEnd();

                //Standardize the molecule
                string strStandMol = GetStandardizedMolecule(newMolfileString, out blIsChiral);

                sReader.Close();
                sReader.Dispose();

                if (newMolfileString != "")
                {
                    strMolString   = strStandMol;
                    molstring_out  = strMolString;
                    errmessage_out = "";
                    ischiral_out   = blIsChiral;
                    blStatus       = true;
                    return(blStatus);
                }
                else
                {
                    strErrMessage  = strErrMsg;
                    molstring_out  = "";
                    ischiral_out   = blIsChiral;
                    errmessage_out = strErrMessage;
                    blStatus       = false;
                    return(blStatus);
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
            molstring_out  = "";
            ischiral_out   = blIsChiral;
            errmessage_out = strErrMessage;
            return(blStatus);
        }