Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp12
- {
- public partial class Form1 : Form
- {
- protected static int GenomNum;
- protected static int A;
- protected static int G;
- protected static int C;
- protected static int T;
- protected static char x;
- protected static string DNA;
- protected static string DNA_2;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- string l6 = "Плюс - конец";
- label3.Text = l6;
- string l7 = "Минус - конец";
- label4.Text = l7;
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- DNA = Box1.Text;
- }
- private void Math()
- {
- switch (x)
- {
- case 'A':
- A = A + 1;
- break;
- case 'G':
- G = G + 1;
- break;
- case 'T':
- T = T + 1;
- break;
- case 'C':
- C = C + 1;
- break;
- case 'a':
- A = A + 1;
- break;
- case 'g':
- G = G + 1;
- break;
- case 't':
- T = T + 1;
- break;
- case 'c':
- C = C + 1;
- break;
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- DNA_2 = null;
- try
- {
- char[] n = new char[DNA.Length];
- GenomNum = DNA.Length;
- for (int i = 0; i < GenomNum; i++)
- {
- //Алгоритм создания комплиментароной цепочки ДНК
- n[i] = DNA[i];
- x = n[i];
- Complementarity();
- }
- Kompli.Visible = true;
- }
- catch
- {
- Form3 error = new Form3();
- error.ShowDialog();
- }
- Kompli.Text = DNA_2;
- }
- private void Complementarity()
- {
- string Base;
- switch (x)
- {
- case 'a':
- Base = "T";
- DNA_2 = DNA_2 + Base;
- break;
- case 'c':
- Base = "G";
- DNA_2 = DNA_2 + Base;
- break;
- case 't':
- Base = "A";
- DNA_2 = DNA_2 + Base;
- break;
- case 'g':
- Base = "C";
- DNA_2 = DNA_2 + Base;
- break;
- case 'A':
- Base = "T";
- DNA_2 = DNA_2 + Base;
- break;
- case 'C':
- Base = "G";
- DNA_2 = DNA_2 + Base;
- break;
- case 'T':
- Base = "A";
- DNA_2 = DNA_2 + Base;
- break;
- case 'G':
- Base = "C";
- DNA_2 = DNA_2 + Base;
- break;
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (String.IsNullOrWhiteSpace(DNA))
- {
- label1.Visible = true;
- A = 0;
- G = 0;
- C = 0;
- T = 0;
- label4.Text = ($"Значения на минус - конце молекулы: Аденин - {A} Гуанин - {G} Тимин - {T} Цитозин - {C}");
- label3.Text = ($"Значения на плюс - конце молекулы: Аденин - {A} Гуанин - {G} Тимин - {T} Цитозин - {C}");
- }
- else
- {
- A = 0;
- G = 0;
- C = 0;
- T = 0;
- label1.Visible = false;
- char[] n = new char[DNA.Length];
- GenomNum = DNA.Length;
- GenomNum = GenomNum / 2;
- for (int i = 0; i < GenomNum; i++)
- {
- n[i] = DNA[i];
- x = n[i];
- Math();
- }
- label4.Text = ($"Значения на минус - конце молекулы: Аденин - {A} Гуанин - {G} Тимин - {T} Цитозин - {C}");
- A = 0;
- G = 0;
- C = 0;
- T = 0;
- for (int i = GenomNum; i < DNA.Length; i++)
- {
- n[i] = DNA[i];
- x = n[i];
- Math();
- }
- label3.Text = ($"Значения на плюс - конце молекулы: Аденин - {A} Гуанин - {G} Тимин - {T} Цитозин - {C}");
- }
- }
- private void RNA_Click(object sender, EventArgs e)
- {
- DNA_2 = null;
- try
- {
- char[] count = new char[DNA.Length];
- GenomNum = DNA.Length / 2;
- for (int i = 0; i < GenomNum; i++)
- {
- count[i] = DNA[i];
- x = count[i];
- RNA_Create();
- }
- Kompli.Visible = true;
- }
- catch
- {
- Form3 error = new Form3();
- error.ShowDialog();
- }
- Kompli.Text = DNA_2;
- }
- private void RNA_Create()
- {
- string Base;
- switch (x)
- {
- case 'a':
- Base = "U";
- DNA_2 = DNA_2 + Base;
- break;
- case 'c':
- Base = "G";
- DNA_2 = DNA_2 + Base;
- break;
- case 't':
- Base = "A";
- DNA_2 = DNA_2 + Base;
- break;
- case 'g':
- Base = "C";
- DNA_2 = DNA_2 + Base;
- break;
- case 'A':
- Base = "U";
- DNA_2 = DNA_2 + Base;
- break;
- case 'C':
- Base = "G";
- DNA_2 = DNA_2 + Base;
- break;
- case 'T':
- Base = "A";
- DNA_2 = DNA_2 + Base;
- break;
- case 'G':
- Base = "C";
- DNA_2 = DNA_2 + Base;
- break;
- }
- }
- private void DNA_1_Click(object sender, EventArgs e)
- {
- try
- {
- DNA_2 = null;
- char[] countDNA = new char[DNA.Length];
- GenomNum = DNA.Length;
- for (int i = 0; i < GenomNum; i++)
- {
- x = countDNA[i];
- DNA_Create();
- }
- Kompli.Visible = true;
- Kompli.Text = DNA_2;
- }
- catch
- {
- Form3 error = new Form3();
- error.ShowDialog();
- }
- }
- private void DNA_Create()
- {
- string Base;
- switch (x)
- {
- case 'u':
- Base = "T";
- x = Convert.ToChar(Base);
- break;
- case 'U':
- Base = "T";
- x = Convert.ToChar(Base);
- break;
- }
- DNA_2 = DNA_2 + Convert.ToString(x);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement