|
|
@@ -14,17 +14,9 @@ public class NucleotideCounterTest {
|
|
14
|
14
|
public ExpectedException expectedException = ExpectedException.none();
|
|
15
|
15
|
|
|
16
|
16
|
@Test
|
|
17
|
|
- public void testEmptyDnaStringHasNoAdenine() {
|
|
18
|
|
- NucleotideCounter nucleotideCounter = new NucleotideCounter("");
|
|
19
|
|
- assertThat(nucleotideCounter.count('A'), is(0));
|
|
20
|
|
- }
|
|
21
|
|
-
|
|
22
|
|
- @Ignore("Remove to run test")
|
|
23
|
|
- @Test
|
|
24
|
17
|
public void testEmptyDnaStringHasNoNucleotides() {
|
|
25
|
18
|
NucleotideCounter nucleotideCounter = new NucleotideCounter("");
|
|
26
|
19
|
Map<Character, Integer> counts = nucleotideCounter.nucleotideCounts();
|
|
27
|
|
- assertThat(counts.size(), is(4));
|
|
28
|
20
|
assertThat(counts, allOf(
|
|
29
|
21
|
hasEntry('A', 0),
|
|
30
|
22
|
hasEntry('C', 0),
|
|
|
@@ -35,70 +27,36 @@ public class NucleotideCounterTest {
|
|
35
|
27
|
|
|
36
|
28
|
@Ignore("Remove to run test")
|
|
37
|
29
|
@Test
|
|
38
|
|
- public void testRepetitiveCytosineGetsCounted() {
|
|
39
|
|
- NucleotideCounter nucleotideCounter = new NucleotideCounter("CCCCC");
|
|
40
|
|
- assertThat(nucleotideCounter.count('C'), is(5));
|
|
41
|
|
- }
|
|
42
|
|
-
|
|
43
|
|
- @Ignore("Remove to run test")
|
|
44
|
|
- @Test
|
|
45
|
|
- public void testRepetitiveSequenceWithOnlyGuanine() {
|
|
46
|
|
- NucleotideCounter nucleotideCounter = new NucleotideCounter("GGGGGGGG");
|
|
|
30
|
+ public void testDnaStringHasOneNucleotide() {
|
|
|
31
|
+ NucleotideCounter nucleotideCounter = new NucleotideCounter("G");
|
|
47
|
32
|
Map<Character, Integer> counts = nucleotideCounter.nucleotideCounts();
|
|
48
|
|
- assertThat(counts.size(), is(4));
|
|
49
|
33
|
assertThat(counts, allOf(
|
|
50
|
34
|
hasEntry('A', 0),
|
|
51
|
35
|
hasEntry('C', 0),
|
|
52
|
|
- hasEntry('G', 8),
|
|
|
36
|
+ hasEntry('G', 1),
|
|
53
|
37
|
hasEntry('T', 0)
|
|
54
|
38
|
));
|
|
55
|
39
|
}
|
|
56
|
40
|
|
|
57
|
41
|
@Ignore("Remove to run test")
|
|
58
|
42
|
@Test
|
|
59
|
|
- public void testCountsOnlyThymine() {
|
|
60
|
|
- NucleotideCounter nucleotideCounter = new NucleotideCounter("GGGGGTAACCCGG");
|
|
61
|
|
- assertThat(nucleotideCounter.count('T'), is(1));
|
|
62
|
|
- }
|
|
63
|
|
-
|
|
64
|
|
- @Ignore("Remove to run test")
|
|
65
|
|
- @Test
|
|
66
|
|
- public void testCountsANucleotideOnlyOnce() {
|
|
67
|
|
- NucleotideCounter nucleotideCounter = new NucleotideCounter("CGATTGGG");
|
|
68
|
|
- nucleotideCounter.count('T');
|
|
69
|
|
- assertThat(nucleotideCounter.count('T'), is(2));
|
|
70
|
|
- }
|
|
71
|
|
-
|
|
72
|
|
- @Ignore("Remove to run test")
|
|
73
|
|
- @Test
|
|
74
|
|
- public void testDnaCountsDoNotChangeAfterCountingAdenine() {
|
|
75
|
|
- NucleotideCounter nucleotideCounter = new NucleotideCounter("GATTACA");
|
|
76
|
|
- nucleotideCounter.count('A');
|
|
|
43
|
+ public void testRepetitiveSequenceWithOnlyGuanine() {
|
|
|
44
|
+ NucleotideCounter nucleotideCounter = new NucleotideCounter("GGGGGGG");
|
|
77
|
45
|
Map<Character, Integer> counts = nucleotideCounter.nucleotideCounts();
|
|
78
|
|
- assertThat(counts.size(), is(4));
|
|
79
|
46
|
assertThat(counts, allOf(
|
|
80
|
|
- hasEntry('A', 3),
|
|
81
|
|
- hasEntry('C', 1),
|
|
82
|
|
- hasEntry('G', 1),
|
|
83
|
|
- hasEntry('T', 2)
|
|
|
47
|
+ hasEntry('A', 0),
|
|
|
48
|
+ hasEntry('C', 0),
|
|
|
49
|
+ hasEntry('G', 7),
|
|
|
50
|
+ hasEntry('T', 0)
|
|
84
|
51
|
));
|
|
85
|
52
|
}
|
|
86
|
53
|
|
|
87
|
54
|
@Ignore("Remove to run test")
|
|
88
|
55
|
@Test
|
|
89
|
|
- public void testValidatesNucleotides() {
|
|
90
|
|
- expectedException.expect(IllegalArgumentException.class);
|
|
91
|
|
- NucleotideCounter nucleotideCounter = new NucleotideCounter("GACT");
|
|
92
|
|
- nucleotideCounter.count('X');
|
|
93
|
|
- }
|
|
94
|
|
-
|
|
95
|
|
- @Ignore("Remove to run test")
|
|
96
|
|
- @Test
|
|
97
|
|
- public void testCountsAllNucleotides() {
|
|
98
|
|
- String s = "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC";
|
|
99
|
|
- NucleotideCounter nucleotideCounter = new NucleotideCounter(s);
|
|
|
56
|
+ public void testDnaStringHasMultipleNucleotide() {
|
|
|
57
|
+ NucleotideCounter nucleotideCounter
|
|
|
58
|
+ = new NucleotideCounter("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC");
|
|
100
|
59
|
Map<Character, Integer> counts = nucleotideCounter.nucleotideCounts();
|
|
101
|
|
- assertThat(counts.size(), is(4));
|
|
102
|
60
|
assertThat(counts, allOf(
|
|
103
|
61
|
hasEntry('A', 20),
|
|
104
|
62
|
hasEntry('C', 12),
|
|
|
@@ -106,4 +64,11 @@ public class NucleotideCounterTest {
|
|
106
|
64
|
hasEntry('T', 21)
|
|
107
|
65
|
));
|
|
108
|
66
|
}
|
|
|
67
|
+
|
|
|
68
|
+ @Ignore("Remove to run test")
|
|
|
69
|
+ @Test
|
|
|
70
|
+ public void testDnaStringHasInvalidNucleotides() {
|
|
|
71
|
+ expectedException.expect(IllegalArgumentException.class);
|
|
|
72
|
+ NucleotideCounter nucleotideCounter = new NucleotideCounter("AGXXACT");
|
|
|
73
|
+ }
|
|
109
|
74
|
}
|