[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); |
---|
| 70 | testalignment1.printDPMatrix(); |
---|
| 71 | testalignment1.printAlignment(); |
---|
| 72 | |
---|
| 73 | //testalignment1.getMatches().get(0).getFirstSequence().printSequence(); |
---|
| 74 | //testalignment1.getMatches().get(0).getSecondSequence().printSequence(); |
---|
| 75 | |
---|
[1648] | 76 | } |
---|
| 77 | |
---|
| 78 | |
---|
[1649] | 79 | //TODO: Need a better substitution matrix to do proper testing |
---|
[1648] | 80 | @Test |
---|
| 81 | public void testAlign() { |
---|
[1649] | 82 | int[] seq1 = new int[]{0,1,2, 3, 4, 5,6,7,8,9}; |
---|
| 83 | int[] seq2 = new int[]{0,1,2,10,11,12,6,7,8,9}; |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | NumberSequence ns1 = new NumberSequence(10); |
---|
| 87 | NumberSequence ns2 = new NumberSequence(10); |
---|
| 88 | |
---|
| 89 | ns1.setSequence(seq1); |
---|
| 90 | ns2.setSequence(seq2); |
---|
| 91 | |
---|
| 92 | DummySubstitutionMatrix submat = new DummySubstitutionMatrix(); |
---|
| 93 | |
---|
| 94 | AlignmentAlgorithm testalignment1 = AlignmentAlgorithmFactory |
---|
| 95 | .create(); |
---|
[1654] | 96 | assertNotNull(testalignment1); |
---|
[1649] | 97 | testalignment1.align(ns1, ns2,submat,3); |
---|
[1654] | 98 | assertTrue(testalignment1.getAlignmentScore()==1.0); |
---|
[1649] | 99 | |
---|
| 100 | } |
---|
[1648] | 101 | |
---|
| 102 | } |
---|