public AlignmentTestCase(double timeLimit, string v, string w, AlignmentFinder af, int expectedResult, bool subsequence = false) : base(timeLimit, null) { this.expectedResult = expectedResult; this.v = v; this.w = w; this.af = af; this.subsequence = subsequence; }
static void Main(string[] args) { AlignmentFinder af1 = new AlignmentFinder(); AlignmentFinder af2 = new AlignmentFinder(ScoringMatrix.PAM250, -5); TestSet unweightedTests = new TestSet(); unweightedTests.TestCases.Add(new AlignmentTestCase(1, "AGT", "AGT", af1, 0)); unweightedTests.TestCases.Add(new AlignmentTestCase(1, "CCCP", "AAAACCCPAAAAAAAAAA", af1, -14)); unweightedTests.TestCases.Add(new AlignmentTestCase(1, "AAACAC", "CACA", af1, -3)); unweightedTests.TestCases.Add(new AlignmentTestCase(1, "AGGCTACTTTCA", "GGCTACTATATCA", af1, -3)); unweightedTests.TestCases.Add(new AlignmentTestCase(1, "CCGCCT", "AGTGGGGTAAGA", af1, -10)); unweightedTests.TestCases.Add(new AlignmentTestCase(1, "AAAAAAAAAAAAAAAAAAAA", "AAGAAGAAGAAGAGAA", af1, -9)); unweightedTests.TestCases.Add(new AlignmentTestCase(1, "AAAAWWW", "WWWAAAA", af1, -6)); unweightedTests.TestCases.Add(new AlignmentTestCase(1, "WWSRWWW", "EWWW", af1, -4)); unweightedTests.TestCases.Add(new AlignmentTestCase(2, PheA, Dhv, af1, -397)); unweightedTests.TestCases.Add(new AlignmentTestCase(3, Yp0, Yp5, af1, -1137)); TestSet weightedTests = new TestSet(); weightedTests.TestCases.Add(new AlignmentTestCase(1, "AGT", "AGT", af2, 10)); weightedTests.TestCases.Add(new AlignmentTestCase(1, "CCCP", "AAAACCCPAAAAAAAAAA", af2, -28)); weightedTests.TestCases.Add(new AlignmentTestCase(1, "AAACAC", "CACA", af2, 6)); weightedTests.TestCases.Add(new AlignmentTestCase(1, "AGGCTACTTTCA", "GGCTACTATATCA", af2, 47)); weightedTests.TestCases.Add(new AlignmentTestCase(1, "CCGCCT", "AGTGGGGTAAGA", af2, -32)); weightedTests.TestCases.Add(new AlignmentTestCase(1, "AAAAAAAAAAAAAAAAAAAA", "AAGAAGAAGAAGAGAA", af2, 7)); weightedTests.TestCases.Add(new AlignmentTestCase(1, "AAAAWWW", "WWWAAAA", af2, 11)); weightedTests.TestCases.Add(new AlignmentTestCase(1, "WWSRWWW", "EWWW", af2, 36)); weightedTests.TestCases.Add(new AlignmentTestCase(2, PheA, Dhv, af2, 464)); weightedTests.TestCases.Add(new AlignmentTestCase(5, Yp0, Yp5, af2, 1062)); TestSet subsequenceTests = new TestSet(); subsequenceTests.TestCases.Add(new AlignmentTestCase(1, "AGT", "AGT", af2, 10, true)); subsequenceTests.TestCases.Add(new AlignmentTestCase(1, "CCCP", "AAAACCCPAAAAAAAAAA", af2, 42, true)); subsequenceTests.TestCases.Add(new AlignmentTestCase(1, "AAACAC", "CACA", af2, 26, true)); subsequenceTests.TestCases.Add(new AlignmentTestCase(1, "AGGCTACTTTCA", "CTAACT", af2, 30, true)); subsequenceTests.TestCases.Add(new AlignmentTestCase(1, "AGGCTACTTTCA", "CTCT", af2, 25, true)); subsequenceTests.TestCases.Add(new AlignmentTestCase(1, "AGGCTCTTTCA", "CTACT", af2, 25, true)); subsequenceTests.TestCases.Add(new AlignmentTestCase(1, "AAAAWWW", "WWWAAAA", af2, 51, true)); subsequenceTests.TestCases.Add(new AlignmentTestCase(1, "WSRWW", "EWWW", af2, 41, true)); subsequenceTests.TestCases.Add(new AlignmentTestCase(2, PheA, Dhv, af2, 658, true)); subsequenceTests.TestCases.Add(new AlignmentTestCase(5, Yp0, Yp5, af2, 1344, true)); Console.WriteLine("Część 1: bez wag dopasowań"); unweightedTests.PreformTests(true, false); Console.WriteLine("Część 2: z wagami dopasowań"); weightedTests.PreformTests(true, false); Console.WriteLine("Część 3: dopasowanie podciągów"); subsequenceTests.PreformTests(true, false); }
private static void DebugTest(string v, string w, AlignmentFinder af, bool subsequence) { Console.WriteLine("------------------------"); Console.WriteLine($"v={v}"); Console.WriteLine($"w={w}"); Alignment al; int sc; if (!subsequence) { sc = af.FindAlignment(v, w, out al); } else { sc = af.FindSubsequenceAlignment(v, w, out al); } Console.WriteLine($"av={al.AlignedV}"); Console.WriteLine($"aw={al.AlignedW}"); Console.WriteLine($"returned={sc}"); int score = 0; int n = al.AlignedV.Length; for (int i = 0; i < n; ++i) { if (al.AlignedV[i] != '-' && al.AlignedW[i] != '-') { score += af.Matrix[al.AlignedV[i], al.AlignedW[i]]; } else if (al.AlignedV[i] == '-' && al.AlignedW[i] == '-') { throw new ArgumentException("aligned gaps found"); } else { score += af.Epsilon; } } Console.WriteLine($"computed={score}"); }