Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool ok = true;

            try
            {
                peptide.name = textBox1.Text;
                peptide.tau  = int.Parse(textBox2.Text);
                peptide.rho  = int.Parse(textBox3.Text);
                peptide.sMol = double.Parse(textBox4.Text);

                peptide.setMarker(dataGridView1.RowCount - 1);
                for (int i = 0; i < dataGridView1.RowCount - 1; i++)
                {
                    peptide.markers[i].position = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value.ToString());
                    peptide.markers[i].label    = Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value.ToString());
                    if (dataGridView1.Rows[i].Cells[2].Value.ToString() == "True")
                    {
                        peptide.markers[i].check = 1;
                    }
                    else
                    {
                        peptide.markers[i].check = 0;
                    }
                    peptide.markers[i].splitting = Convert.ToDouble(dataGridView1.Rows[i].Cells[3].Value.ToString());
                }

                peptide.setLabel(dataGridView2.RowCount - 1);
                for (int i = 0; i < dataGridView2.RowCount - 1; i++)
                {
                    peptide.labels[i].name  = dataGridView2.Rows[i].Cells[0].Value.ToString();
                    peptide.labels[i].alpha = Convert.ToDouble(dataGridView2.Rows[i].Cells[1].Value.ToString());
                    peptide.labels[i].beta  = Convert.ToDouble(dataGridView2.Rows[i].Cells[2].Value.ToString());
                    peptide.labels[i].psi   = Convert.ToDouble(dataGridView2.Rows[i].Cells[3].Value.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Wrong input!" + ex.Message);
                ok = false;
            }
            finally
            {
                if (ok)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
        }
Beispiel #2
0
        public void directTask()
        {
            Peptide globalbest          = new Peptide();
            Peptide bestvaluewithinsmol = new Peptide();
            Peptide counter             = new Peptide();

            counter.setMarker(markers);
            counter.setLabel(labels);
            globalbest.rmsd = 100.0;
            for (counter.sMol = 0.01; counter.sMol <= 1; counter.sMol += 0.01)                       //fitting smol
            {
                bestvaluewithinsmol.rmsd = 100;
                for (counter.tau = 0; counter.tau < tauRhoPlotDimension; counter.tau++)                           //fitting tau
                {
                    for (counter.rho = 0; counter.rho < tauRhoPlotDimension; counter.rho++)                       //fitting rho
                    {
                        counter.calcrmsd2();
                        if (counter.rmsd < bestvaluewithinsmol.rmsd)
                        {
                            bestvaluewithinsmol.rmsd = counter.rmsd;
                            bestvaluewithinsmol.tau  = counter.tau;
                            bestvaluewithinsmol.rho  = counter.rho;
                        }

                        tauRhoPlot[counter.tau][counter.rho] = counter.rmsd;
                    }
                }
                if (globalbest.rmsd > bestvaluewithinsmol.rmsd)
                {
                    globalbest.rmsd = bestvaluewithinsmol.rmsd;
                    globalbest.tau  = bestvaluewithinsmol.tau;
                    globalbest.rho  = bestvaluewithinsmol.rho;
                    globalbest.sMol = counter.sMol;
                }
            }
            tau  = globalbest.tau;
            rho  = globalbest.rho;
            sMol = globalbest.sMol;
        }
Beispiel #3
0
        private void directTaskToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Stream         fStream         = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //TODO: change ititial directory
            openFileDialog1.InitialDirectory = "d:\\";
            //TODO: design new container
            openFileDialog1.Filter           = "prg files (*.prg)|*.prg|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((fStream = openFileDialog1.OpenFile()) != null)
                    {
                        using (fStream)
                        {
                            //TODO: fix overflow
                            byte[] fReader = new byte[1000];
                            while (fStream.Read(fReader, 0, fReader.Length) > 0)
                            {
                                string   file  = System.Text.Encoding.UTF8.GetString(fReader, 0, fReader.Length);
                                string[] parts = file.Split('&');
                                //TODO: design new container
                                string[] part  = parts[0].Split('|');
                                string[] marks = parts[1].Split('\n');
                                string[] labes = parts[2].Split('\n');

                                peptide.name = part[0];
                                peptide.tau  = int.Parse(part[1]);
                                peptide.rho  = int.Parse(part[2]);
                                peptide.sMol = double.Parse(part[3]);
                                peptide.setMarker(marks.Count());
                                peptide.setLabel(labes.Count());

                                int i = 0;

                                //peptide.markers[0].position = new int();

                                foreach (string mark in marks)
                                {
                                    string[] items = mark.Split('|');
                                    peptide.markers[i].position  = int.Parse(items[0]);
                                    peptide.markers[i].label     = int.Parse(items[1]);
                                    peptide.markers[i].check     = int.Parse(items[2]);
                                    peptide.markers[i].splitting = double.Parse(items[3]);
                                    i++;
                                }
                                i = 0;
                                foreach (string labe in labes)
                                {
                                    string[] items = labe.Split('|');
                                    peptide.labels[i].name  = items[0];
                                    peptide.labels[i].alpha = double.Parse(items[1]);
                                    peptide.labels[i].beta  = double.Parse(items[2]);
                                    peptide.labels[i].psi   = double.Parse(items[3]);
                                    i++;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }