コード例 #1
0
ファイル: Form1.cs プロジェクト: hanneshorn/POSRA-SERVER-IBM
 private void sdfRead_Click(object sender, EventArgs e)
 {
     // open SDF file
     sdf = new Scilligence.MolEngine.IO.SDFile(sdfFile.Text, Scilligence.MolEngine.IO.MDLDBBase.OpenMode.Read);
     sdfNext_Click(null, EventArgs.Empty);
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: hanneshorn/POSRA-SERVER-IBM
        private void button16_Click(object sender, EventArgs e)
        {
            // clear reaction table
            combTable.Rows.Clear();

            // prepare the generic reaction
            Reaction rxn = null;
            MolBase s = MolBase.ReadFile(combiRxn.Text);
            if (s as Reaction != null)
                rxn = (Reaction)s;
            else if (s as Sketch != null)
                rxn = ((Sketch)s).AsReaction();
            if (rxn == null)
            {
                MessageBox.Show("Not a valid reaction");
                return;
            }

            // create a combi oject
            Combi combi = new Combi(rxn);

            // add reagents for each R-group reactant component
            int i = 0;
            foreach (Combi.Component c in combi.Components)
            {
                ++i;
                string f = null;
                if (i == 1)
                    f = combiComp1.Text;
                else if (i == 2)
                    f = combiComp2.Text;
                else if (i == 3)
                    f = combiComp3.Text;
                else
                    break;

                using (Scilligence.MolEngine.IO.SDFile sdf = new Scilligence.MolEngine.IO.SDFile(f, Scilligence.MolEngine.IO.MDLDBBase.OpenMode.Read))
                {
                    Scilligence.MolEngine.IO.SDFile.Record r2;
                    while ((r2 = sdf.ReadNext()) != null)
                    {
                        if (r2.m as Molecule != null)
                            c.AddReagent((Molecule)r2.m);
                    }
                }
            }

            // enumerate
            int ri = 0;
            Reaction r;
            // begin to enumerate
            combi.ResetEnum();

            // enumerate one
            while ((r = combi.EnumNext()) != null)
            {
                // display the enumerated reaction
                DataGridViewRow row = new DataGridViewRow();
                row.Height = 200;
                row.Cells.Add(new DataGridViewImageCell());

                MolDrawing md = new MolDrawing(r, new System.Drawing.Rectangle(0, 0, combTable.Columns[0].Width, row.Height), 10);
                row.Cells[0].Value = md.ToImage();
                combTable.Rows.Add(row);
                row.HeaderCell.Value = (++ri).ToString();
            }
        }