[1648] | 1 | package de.ugoe.cs.autoquest.tasktrees.alignment.algorithms; |
---|
| 2 | |
---|
| 3 | import static org.junit.Assert.*; |
---|
| 4 | |
---|
| 5 | import org.junit.Test; |
---|
| 6 | |
---|
[1649] | 7 | import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.DummySubstitutionMatrix; |
---|
| 8 | |
---|
[1648] | 9 | public class SmithWatermanRepeatedTest { |
---|
| 10 | |
---|
| 11 | @Test |
---|
| 12 | public void testGetMaxScore() { |
---|
[1649] | 13 | int[] seq1 = new int[]{0,1,2,3,4,5,6,7,8,9}; |
---|
| 14 | int[] seq2 = new int[]{0,1,2,3,4,5,6,7,8,9}; |
---|
| 15 | |
---|
| 16 | NumberSequence ns1 = new NumberSequence(10); |
---|
| 17 | NumberSequence ns2 = new NumberSequence(10); |
---|
| 18 | |
---|
| 19 | ns1.setSequence(seq1); |
---|
| 20 | ns2.setSequence(seq2); |
---|
| 21 | |
---|
| 22 | DummySubstitutionMatrix submat = new DummySubstitutionMatrix(); |
---|
| 23 | |
---|
| 24 | AlignmentAlgorithm testalignment1 = AlignmentAlgorithmFactory |
---|
| 25 | .create(); |
---|
[1654] | 26 | |
---|
| 27 | assertNotNull(testalignment1); |
---|
[1649] | 28 | testalignment1.align(ns1, ns2,submat,5); |
---|
| 29 | |
---|
| 30 | assertTrue(testalignment1.getMaxScore()==10); |
---|
[1648] | 31 | } |
---|
| 32 | |
---|
| 33 | @Test |
---|
| 34 | public void testGetAlignmentScore() { |
---|
[1649] | 35 | int[] seq1 = new int[]{0,1,2,3,4,5,6,7,8,9}; |
---|
| 36 | int[] seq2 = new int[]{0,1,2,3,4,5,6,7,8,9}; |
---|
| 37 | |
---|
| 38 | NumberSequence ns1 = new NumberSequence(10); |
---|
| 39 | NumberSequence ns2 = new NumberSequence(10); |
---|
| 40 | |
---|
| 41 | ns1.setSequence(seq1); |
---|
| 42 | ns2.setSequence(seq2); |
---|
| 43 | |
---|
| 44 | DummySubstitutionMatrix submat = new DummySubstitutionMatrix(); |
---|
| 45 | |
---|
| 46 | AlignmentAlgorithm testalignment1 = AlignmentAlgorithmFactory |
---|
| 47 | .create(); |
---|
[1654] | 48 | assertNotNull(testalignment1); |
---|
[1649] | 49 | testalignment1.align(ns1, ns2,submat,5); |
---|
| 50 | assertTrue(testalignment1.getAlignmentScore()==5); |
---|
[1648] | 51 | } |
---|
| 52 | |
---|
| 53 | @Test |
---|
| 54 | public void testGetMatches() { |
---|
[1649] | 55 | int[] seq1 = new int[]{0,1,2,3,4,5,6,7,8,9}; |
---|
| 56 | int[] seq2 = new int[]{3,4,5,6,7}; |
---|
| 57 | |
---|
| 58 | NumberSequence ns1 = new NumberSequence(10); |
---|
| 59 | NumberSequence ns2 = new NumberSequence(10); |
---|
| 60 | |
---|
| 61 | ns1.setSequence(seq1); |
---|
| 62 | ns2.setSequence(seq2); |
---|
| 63 | |
---|
| 64 | DummySubstitutionMatrix submat = new DummySubstitutionMatrix(); |
---|
| 65 | |
---|
| 66 | AlignmentAlgorithm testalignment1 = AlignmentAlgorithmFactory |
---|
| 67 | .create(); |
---|
[1654] | 68 | assertNotNull(testalignment1); |
---|
[1649] | 69 | testalignment1.align(ns1, ns2,submat,4); |
---|
[1656] | 70 | |
---|
[1649] | 71 | |
---|
| 72 | //testalignment1.getMatches().get(0).getFirstSequence().printSequence(); |
---|
| 73 | //testalignment1.getMatches().get(0).getSecondSequence().printSequence(); |
---|
| 74 | |
---|
[1648] | 75 | } |
---|
| 76 | |
---|
| 77 | |
---|
[1649] | 78 | //TODO: Need a better substitution matrix to do proper testing |
---|
[1648] | 79 | @Test |
---|
| 80 | public void testAlign() { |
---|
[1649] | 81 | int[] seq1 = new int[]{0,1,2, 3, 4, 5,6,7,8,9}; |
---|
| 82 | int[] seq2 = new int[]{0,1,2,10,11,12,6,7,8,9}; |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | NumberSequence ns1 = new NumberSequence(10); |
---|
| 86 | NumberSequence ns2 = new NumberSequence(10); |
---|
| 87 | |
---|
| 88 | ns1.setSequence(seq1); |
---|
| 89 | ns2.setSequence(seq2); |
---|
| 90 | |
---|
| 91 | DummySubstitutionMatrix submat = new DummySubstitutionMatrix(); |
---|
| 92 | |
---|
| 93 | AlignmentAlgorithm testalignment1 = AlignmentAlgorithmFactory |
---|
| 94 | .create(); |
---|
[1654] | 95 | assertNotNull(testalignment1); |
---|
[1649] | 96 | testalignment1.align(ns1, ns2,submat,3); |
---|
[1656] | 97 | testalignment1.printDPMatrix(); |
---|
| 98 | testalignment1.printAlignment(); |
---|
| 99 | assertTrue(testalignment1.getAlignmentScore()==4.0); |
---|
[1649] | 100 | |
---|
| 101 | } |
---|
[1648] | 102 | |
---|
| 103 | } |
---|