private void Principal_Load(object sender, EventArgs e) { makefba = new MakeFba(); doc = new XmlDocument(); fba2 = false; yaabri = false; txt = false; abierto = false; objetivefuntion = ""; yaabriconstraint = false; }
private void button1_Click(object sender, EventArgs e) { if (reactionObjetiveComboBox.Text.Length > 0 && comboreactionexchange.Text.Length > 0) { if (Sbml.There(reactionObjetiveComboBox, reactionObjetiveComboBox.Text) && Sbml.There(comboreactionexchange, comboreactionexchange.Text)) { if ((aNumericUpDown.Value != bNumericUpDown.Value) && (aNumericUpDown.Value < bNumericUpDown.Value)) { makefba = new MakeFba(); int i = 0; bool find = false; foreach (Reaction item in sbml.ListReaction) { if (item.Id == reactionObjetiveComboBox.Text) { reactionoptimize = reactionObjetiveComboBox.Text; find = true; break; } i++; } if (find) { if (radiomax.Checked) { pd = OptimisationDirection.MAXIMISE; } else { pd = OptimisationDirection.MINIMISE; } pointresult = makefba.Rna(sbml, i, pd, (int)aNumericUpDown.Value, (int)bNumericUpDown.Value, comboreactionexchange.Text); resultlist.Items.Clear(); string[] str; ListViewItem list; for (int k = 0; k < pointresult.Length; k++) { int kaux = k + 1; str = new string[3] { kaux.ToString(), pointresult[k].X.ToString(), pointresult[k].Y.ToString() }; list = new ListViewItem(str); resultlist.Items.Add(list); } results = true; button3.Enabled = true; } else { results = false; button3.Enabled = false; MessageBox.Show("This reaction not exist in the model", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("The values of A and B must be different, and A less than B", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Select the objective functions to optimize and to be varied", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Select the objective functions to optimize and to be varied", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button2_Click(object sender, EventArgs e) { if (reactionObjetiveComboBox.Text.Length > 0) { makefba = new MakeFba(); int i = 0; bool find = false; foreach (Reaction item in sbml.ListReaction) { if (item.Id == reactionObjetiveComboBox.Text) { reactionoptimize = reactionObjetiveComboBox.Text; find = true; break; } i++; } if (find) { if (radiomax.Checked) { pd = OptimisationDirection.MAXIMISE; } else { pd = OptimisationDirection.MINIMISE; } Funcion_obj = i; makefba.Fba(sbml, i, pd); double z = makefba.Lp.GetObjectiveValue(); resultlist.Items.Clear(); string[] str = new string[2] { "Z = " + reactionObjetiveComboBox.Text, z.ToString() }; ListViewItem list = new ListViewItem(str); resultlist.Items.Add(list); for (int k = 0; k < sbml.ListReaction.Length; k++) { str = new string[2] { sbml.ListReaction[k].Id, makefba.Lp.GetColPrimal(k + 1).ToString() }; list = new ListViewItem(str); resultlist.Items.Add(list); } results = true; button5.Enabled = true; button3.Enabled = true; } else { results = false; button3.Enabled = false; MessageBox.Show("This reaction not exist in the model", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Select the function to optimize", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button5_Click(object sender, EventArgs e) { double flujo_r = 0; makefba.Fba(sbml, Funcion_obj, pd); z = makefba.Lp.GetObjectiveValue(); string[] aux_flujos = new String[sbml.ListReaction.Length]; for (int j = 0; j < sbml.ListReaction.Length; j++) { aux_flujos[j] = makefba.Lp.GetColPrimal(j + 1).ToString(); } int pos = 1; for (int i = 0; i < sbml.ListReaction.Length; i++)// { if (makefba.Lp.GetColPrimal(i + 1) < 9000 && makefba.Lp.GetColPrimal(i + 1) > -9000) { flujo_r = makefba.Lp.GetColPrimal(i + 1); pos = i; double viejo_low = sbml.ListReaction[i].LowerBound; // double viejo_up = sbml.ListReaction[i].UpperBound; // double nuevo_low = 0; double nuevo_up = 0; if (flujo_r == 0) { nuevo_low = 0.002; nuevo_up = 0.003; } else { nuevo_low = flujo_r * 1 / 100; nuevo_low = flujo_r - nuevo_low; nuevo_up = flujo_r * 1.1 / 100; nuevo_up = flujo_r - nuevo_up; } sbml.ListReaction[i].LowerBound = nuevo_low; // sbml.ListReaction[i].UpperBound = nuevo_up; // MakeFba makefba_shadows = new MakeFba(); makefba_shadows.Fba(sbml, Funcion_obj, pd); // double z_prima = makefba_shadows.Lp.GetObjectiveValue(); double aux = makefba_shadows.Lp.GetColPrimal(pos + 1); double shadows = (z - z_prima) / (flujo_r - makefba_shadows.Lp.GetColPrimal(pos + 1)); if (flujo_r - makefba_shadows.Lp.GetColPrimal(pos + 1) != 0) { string[] str = new string[3] { sbml.ListReaction[i].Id, aux_flujos[i], shadows.ToString() }; ListViewItem list = new ListViewItem(str); resultlist.Items[pos + 1] = list; } else { string[] str = new string[3] { sbml.ListReaction[i].Id, aux_flujos[i], "Infinito." }; ListViewItem list = new ListViewItem(str); resultlist.Items[pos + 1] = list; } sbml.ListReaction[i].LowerBound = viejo_low; sbml.ListReaction[i].UpperBound = viejo_up; } } }
private void button1_Click(object sender, EventArgs e) { if (reactionObjetiveComboBox.Text.Length > 0 && reactionObjetiveComboBox2.Text.Length > 0) { if (Sbml.There(reactionObjetiveComboBox, reactionObjetiveComboBox.Text) && Sbml.There(reactionObjetiveComboBox2, reactionObjetiveComboBox2.Text)) { makefba = new MakeFba(); int i = 0; int j = 0; int ii = 0; int jj = 0; int find = 0; foreach (Reaction item in sbml.ListReaction) { if (item.Id == reactionObjetiveComboBox.Text) { reactionoptimize1 = reactionObjetiveComboBox.Text; find++; ii = i; } if (item.Id == reactionObjetiveComboBox2.Text) { reactionoptimize2 = reactionObjetiveComboBox2.Text; find++; jj = j; } if (find == 2) { break; } j++; i++; } if (find == 2) { if (radiomax.Checked) { pd = OptimisationDirection.MAXIMISE; } else { pd = OptimisationDirection.MINIMISE; } fva = makefba.Fva(sbml, ii, jj, pd); double z1 = fva.Lp1.GetObjectiveValue(); double z2 = fva.Lp2.GetObjectiveValue(); resultlist.Items.Clear(); string[] str = new string[3] { "Z1,Z2", "Z1 = " + z1.ToString(), "Z2 = " + z2.ToString() }; ListViewItem list = new ListViewItem(str, 0, Color.Black, Color.YellowGreen, new Font("Arial", 12)); resultlist.Items.Add(list); for (int k = 0; k < sbml.ListReaction.Length; k++) { str = new string[3] { sbml.ListReaction[k].Id, fva.Lp1.GetColPrimal(k + 1).ToString(), fva.Lp2.GetColPrimal(k + 1).ToString() }; if (fva.Lp1.GetColPrimal(k + 1) == fva.Lp2.GetColPrimal(k + 1)) { list = new ListViewItem(str); resultlist.Items.Add(list); } else { list = new ListViewItem(str, 0, Color.Black, Color.YellowGreen, new Font("Arial", 12)); resultlist.Items.Add(list); } } results = true; button3.Enabled = true; } else { results = false; button3.Enabled = false; MessageBox.Show("This reaction not exist in the model", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("One of the functions not exist in the model", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Select the functions to optimize", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }