private void button1_Click(object sender, EventArgs e) { string[] seq1 = { "A", "C", "G", "T", "A", "C", "A", "G","T","G" }; string[] seq2 = { "T", "A", "C", "A", "C", "G","A","A","G","T" }; string[] res1 = new string[seq1.Length]; string[] res2 = new string[seq1.Length]; for (int i = 0; i <= 4; i++) { res1[i] = seq1[i]; res2[i] = seq2[i]; textBox1.Text +=" "+ res1[i]; textBox2.Text +=" "+ res2[i]; } for(int i = 5; i < seq1.Length; i++) { if (seq1[i] == "T" ) { res1[i] = "A"; } else if (seq1[i] == "A" ) { res1[i] = "T"; } else if (seq1[i] == "C" ) { res1[i] = "G"; } else if (seq1[i] == "G" ) { res1[i] = "C"; } textBox1.Text += res1[i]+" "; } for (int i = 5; i < seq2.Length; i++) { if (seq2[i] == "T") { res2[i] = "A"; } else if (seq2[i] == "A") { res2[i] = "T"; } else if (seq2[i] == "C") { res2[i] = "G"; } else if (seq2[i] == "G") { res2[i] = "C"; } textBox2.Text += res2[i] + " "; } }
// A translates to G, B to B, C to R etcchar[] destTable = { 'G', 'B', 'R' };char source = // wherever this character comes fromchar dest = destTable[source - 'A'];
seq
if else if
switch
char getMatch(char seq) { switch (seq) { case 'T' : return 'A'; case 'A' : return 'T'; // ... } // Error condition (e.g. throw an exception) return ' '; }
res1[i] = getMatch(seq1[i]); res2[i] = getMatch(seq2[i]);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)