private void button1_Click(object sender, EventArgs e) { // remove whitespace and prepend a - to contents of seq char[] first = ("-" + Regex.Replace(seq1.Text, @"\s+", "").ToUpper()).ToCharArray(); char[] second = ("-" + Regex.Replace(seq2.Text, @"\s+", "").ToUpper()).ToCharArray(); int[] scoreSystem = new int[3]; if (countGaps.Checked) { scoreSystem[0] = 1; scoreSystem[1] = -1; scoreSystem[2] = -2; } else if (countNoGaps.Checked) { scoreSystem[0] = 1; scoreSystem[1] = -1; scoreSystem[2] = 0; } else { // gap options not selected results.Text = "Please select if this alignment should count gaps or not" + "\r\n"; return; } ScoringMatrix simon = new ScoringMatrix(first, second, scoreSystem); OptimumMatrix jack = new OptimumMatrix(first, second); if (isGlobal.Checked) { for (int i = 1; i < first.Length; i++) { for (int j = 1; j < second.Length; j++) { jack.setScore(i, j, simon.calcCell(i, j)); } } } else if (isLocal.Checked) { for (int i = 1; i < first.Length; i++) { for (int j = 1; j < second.Length; j++) { jack.setScore(i, j, simon.calcCellLocal(i, j)); } } } else { // alignment type options not selected results.Text = "Please select if this alignment should be global or local" + "\r\n"; return; } int[] maxPos = simon.getMaxScorePos(); string[] paul = jack.calcOptPathFrom(maxPos[0], maxPos[1]); results.Text += paul[0] + "\r\n" + paul[1] + "\r\n\r\n"; }
static void Main(string[] args) { char[] first = { '-', 'A', 'G', 'C' }; char[] second = { '-', 'A', 'A', 'A', 'C' }; ScoringMatrix simon = new ScoringMatrix(first,second); OptimumMatrix jack = new OptimumMatrix(first, second); for (int i = 1; i < first.Length; i++) { for (int j = 1; j < second.Length; j++) { jack.setScore(i, j, simon.calcCell(i, j)); } } int[] maxPos = simon.getMaxScorePos(); string[] paul = jack.calcOptPathFrom(maxPos[0],maxPos[1]); Console.WriteLine(paul[0]); Console.WriteLine(paul[1]); }
static void Main(string[] args) { char[] first = { '-', 'A', 'G', 'C' }; char[] second = { '-', 'A', 'A', 'A', 'C' }; ScoringMatrix simon = new ScoringMatrix(first, second); OptimumMatrix jack = new OptimumMatrix(first, second); for (int i = 1; i < first.Length; i++) { for (int j = 1; j < second.Length; j++) { jack.setScore(i, j, simon.calcCell(i, j)); } } int[] maxPos = simon.getMaxScorePos(); string[] paul = jack.calcOptPathFrom(maxPos[0], maxPos[1]); Console.WriteLine(paul[0]); Console.WriteLine(paul[1]); }