Esempio n. 1
0
        private void chemRenditor_Results_StructureChanged(object sender, EventArgs e)
        {
            try
            {
                chemaxon.util.MolHandler molHandler = new MolHandler(chemRenditor_Results.MolfileString);
                Molecule molObj = molHandler.getMolecule();

                txtMolWeight.Text  = molObj.getMass().ToString();
                txtMolFormula.Text = molObj.getFormula();

                string strMolfile   = molObj.toFormat("mol");
                string strIUPACName = "";
                string strErrMsg    = "";
                if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg))
                {
                    strIUPACName = Validations.GetConvertedIUPACName(strIUPACName);
                }
                else
                {
                    strIUPACName = "IUPAC name not provided";
                }
                txtIUPACName.Text = strIUPACName;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        private void chemRenditor_Trgt_StructureChanged(object sender, EventArgs e)
        {
            try
            {
                if (chemRenditor_Trgt.MolfileString != null)
                {
                    MolHandler molHandler1 = new MolHandler(chemRenditor_Trgt.MolfileString);
                    Molecule   molObj1     = molHandler1.getMolecule();

                    txtMolWeight.Text  = "";
                    txtMolFormula.Text = "";

                    txtMolWeight.Text  = molObj1.getMass().ToString();
                    txtMolFormula.Text = molObj1.getFormula();

                    if (molObj1.isAbsStereo())
                    {
                        lblChiral.Visible = true;
                    }
                    else
                    {
                        lblChiral.Visible = false;
                    }

                    string strMolfile   = molObj1.toFormat("mol");
                    string strIUPACName = "";
                    string strErrMsg    = "";
                    if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg))
                    {
                        //strIUPACName = Validations.RemoveSMILESFromIUPACName(strIUPACName);
                        strIUPACName = Validations.GetConvertedIUPACName(strIUPACName);
                    }
                    else
                    {
                        strIUPACName = "IUPAC name not provided";
                    }
                    txtIUPACName.Text = strIUPACName;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        private void chemRenditor_Results_StructureChanged(object sender, EventArgs e)
        {
            try
            {
                if (chemRenditor_Results.MolfileString != null)
                {
                    chemaxon.util.MolHandler molHandler = new MolHandler(chemRenditor_Results.MolfileString);
                    Molecule molObj = molHandler.getMolecule();

                    txtMolWeight.Text  = molObj.getMass().ToString();
                    txtMolFormula.Text = molObj.getFormula();

                    string strMolfile   = molObj.toFormat("mol");
                    string strIUPACName = "";
                    string strErrMsg    = "";
                    if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg))
                    {
                        strIUPACName = Validations.GetConvertedIUPACName(strIUPACName);
                    }
                    else
                    {
                        strIUPACName = "IUPAC name not provided";
                    }
                    txtIUPACName.Text = strIUPACName;

                    if (molObj.isAbsStereo())
                    {
                        lblChiral.Visible = true;
                    }
                    else
                    {
                        lblChiral.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Esempio n. 4
0
        private void GetStructureFromImage()
        {
            try
            {
                IDataObject clipData = Clipboard.GetDataObject();
                if (clipData.GetDataPresent(DataFormats.Bitmap))
                {
                    Cursor = Cursors.WaitCursor;

                    Image imgChemistry = Clipboard.GetImage();

                    string strMol_out     = "";
                    bool   blIsChiral_out = false;
                    string strErrMsg_out  = "";

                    if (ImageToStructure.GetStructureFromImage(imgChemistry, out strMol_out, out blIsChiral_out, out strErrMsg_out))
                    {
                        ChemRenditor.MolfileString = strMol_out;

                        try
                        {
                            chemaxon.util.MolHandler molHandler_Trgt = new MolHandler(ChemRenditor.MolfileString);
                            Molecule molObj = molHandler_Trgt.getMolecule();

                            txtMolWeight.Text  = molObj.getMass().ToString();
                            txtMolFormula.Text = molObj.getFormula();

                            string strMolfile   = molObj.toFormat("mol");
                            string strIUPACName = "";
                            string strErrMsg    = "";
                            if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg))
                            {
                                strIUPACName = ChemistryOperations.RemoveSMILESFromIUPACName(strIUPACName);
                                strIUPACName = ChemistryOperations.GetConvertedIUPACName(strIUPACName);
                            }
                            else
                            {
                                strIUPACName = "IUPAC name not provided";
                            }
                        }
                        catch
                        {
                        }

                        //if (molObj.isAbsStereo())
                        //{
                        //    lblChiral.Visible = true;
                        //}
                        //else
                        //{
                        //    lblChiral.Visible = false;
                        //}


                        //txtIUPACName.Text = strIUPACName;

                        Cursor = Cursors.Default;
                    }
                    else
                    {
                        Cursor = Cursors.Default;
                        MessageBox.Show(strErrMsg_out);
                    }

                    Clipboard.Clear();
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.WriteErrorLog(ex.ToString());
            }
            Cursor = Cursors.Default;
        }
        private void chemRenditor_StructureChanged(object sender, EventArgs e)
        {
            try
            {
                if (chemRenditor.MolfileString != null)
                {
                    if (chemRenditor.MolfileString.Trim() != "" && strInchi_Before != "")
                    {
                        chemaxon.util.MolHandler molHandler = new MolHandler(chemRenditor.MolfileString);
                        Molecule objMol = molHandler.getMolecule();

                        string strInchi_After = objMol.toFormat("inchi:key");

                        strInchi_After = Validations.GetInchiKeyFromInchiString(strInchi_After);

                        if (strInchi_After != strInchi_Before)
                        {
                            txtMolWeight.Text  = objMol.getMass().ToString();
                            txtMolFormula.Text = objMol.getFormula();

                            if (objMol.isAbsStereo())
                            {
                                lblChiral.Visible = true;
                            }
                            else
                            {
                                lblChiral.Visible = false;
                            }

                            string strMolfile   = objMol.toFormat("mol");
                            string strIUPACName = "";
                            string strErrMsg    = "";
                            if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg))
                            {
                                //strIUPACName = Validations.RemoveSMILESFromIUPACName(strIUPACName);
                                strIUPACName = Validations.GetConvertedIUPACName(strIUPACName);
                            }
                            else
                            {
                                strIUPACName = "IUPAC name not provided";
                            }
                            txtIUPACName.Text = strIUPACName;
                        }
                    }
                }

                #region Code Commented
                //if (chemRenditor.MolfileString.Trim() != "")
                //{
                //    string strChem = MolDataTbl.Rows[currRecIndex - 1]["Structure"].ToString();
                //    chemaxon.util.MolHandler molHandler_Qry = new MolHandler(chemRenditor.MolfileString.Trim());
                //    Molecule molObj_Qry = molHandler_Qry.getMolecule();

                //    chemaxon.util.MolHandler molHandler_Trgt = new MolHandler(strChem);
                //    Molecule molObj_Trgt = molHandler_Trgt.getMolecule();

                //    string strInchi_Qry = molObj_Qry.toFormat("inchi:key");
                //    string strInchi_Trgt = molObj_Trgt.toFormat("inchi:key");

                //    strInchi_Qry = Validations.GetInchiKeyFromInchiString(strInchi_Qry);
                //    strInchi_Trgt = Validations.GetInchiKeyFromInchiString(strInchi_Trgt);

                //    if (!strInchi_Qry.Equals(strInchi_Trgt))
                //    {
                //       txtMolWeight.Text = molObj_Qry.getMass().ToString();
                //       txtMolFormula.Text = molObj_Qry.getFormula();

                //       if (molObj_Qry.isAbsStereo())
                //       {
                //           lblChiral.Visible = true;
                //       }
                //       else
                //       {
                //           lblChiral.Visible = false;
                //       }

                //        string strMolfile = molObj_Qry.toFormat("mol");
                //        string strIUPACName = "";
                //        string strErrMsg = "";
                //        if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg))
                //        {
                //            strIUPACName = Validations.RemoveSMILESFromIUPACName(strIUPACName);
                //            strIUPACName = Validations.GetConvertedIUPACName(strIUPACName);
                //        }
                //        else
                //        {
                //            strIUPACName = "IUPAC name not provided";
                //        }
                //        lblIUPACName.Text = strIUPACName;
                //    }
                //}
                #endregion
            }
            catch (Exception ex)
            {
                ErrorHandling_NTS.WriteErrorLog(ex.ToString());
            }
        }
Esempio n. 6
0
        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);
        }