| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.analysis; |
| 22 |
|
|
| 23 |
|
import static org.testng.AssertJUnit.assertEquals; |
| 24 |
|
import static org.testng.AssertJUnit.assertNull; |
| 25 |
|
|
| 26 |
|
import jalview.datamodel.Alignment; |
| 27 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 28 |
|
import jalview.datamodel.Sequence; |
| 29 |
|
import jalview.datamodel.SequenceI; |
| 30 |
|
import jalview.gui.AlignFrame; |
| 31 |
|
import jalview.gui.JvOptionPane; |
| 32 |
|
|
| 33 |
|
import java.util.List; |
| 34 |
|
|
| 35 |
|
import org.testng.annotations.BeforeClass; |
| 36 |
|
import org.testng.annotations.BeforeMethod; |
| 37 |
|
import org.testng.annotations.Test; |
| 38 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (86) |
Complexity: 5 |
Complexity Density: 0.06 |
|
| 39 |
|
public class ParsePropertiesTest |
| 40 |
|
{ |
| 41 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 42 |
1 |
@BeforeClass(alwaysRun = true)... |
| 43 |
|
public void setUpJvOptionPane() |
| 44 |
|
{ |
| 45 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 46 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
private Alignment al; |
| 50 |
|
|
| 51 |
|
private ParseProperties pp; |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 56 |
3 |
@BeforeMethod(alwaysRun = true)... |
| 57 |
|
public void setUp() |
| 58 |
|
{ |
| 59 |
3 |
SequenceI[] seqs = new SequenceI[] { |
| 60 |
|
new Sequence("sq1", "THISISAPLACEHOLDER"), |
| 61 |
|
new Sequence("sq2", "THISISAPLACEHOLDER"), |
| 62 |
|
new Sequence("sq3", "THISISAPLACEHOLDER"), |
| 63 |
|
new Sequence("sq4", "THISISAPLACEHOLDER") }; |
| 64 |
3 |
seqs[0].setDescription("1 mydescription1"); |
| 65 |
3 |
seqs[1].setDescription("mydescription2"); |
| 66 |
3 |
seqs[2].setDescription("2. 0.1 mydescription+3"); |
| 67 |
3 |
seqs[3].setDescription("3 0.01 mydescription4"); |
| 68 |
3 |
al = new Alignment(seqs); |
| 69 |
|
|
| 70 |
3 |
pp = new ParseProperties(al); |
| 71 |
|
|
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 79 |
1 |
@Test(groups = { "Functional" })... |
| 80 |
|
public void testGetScoresFromDescription() |
| 81 |
|
{ |
| 82 |
1 |
String regex = ".*([-0-9.+]+)"; |
| 83 |
1 |
final int count = pp.getScoresFromDescription("my Score", |
| 84 |
|
"my Score Description", regex, true); |
| 85 |
1 |
System.out.println("Matched " + count + " for " + regex); |
| 86 |
1 |
assertEquals(4, count); |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
1 |
AlignmentAnnotation[] anns = al.getSequenceAt(0).getAnnotation(); |
| 92 |
1 |
assertEquals(1, anns.length); |
| 93 |
1 |
assertEquals(1d, anns[0].getScore(), 0.001d); |
| 94 |
1 |
assertEquals("my Score Description", anns[0].description); |
| 95 |
1 |
assertEquals("my Score", anns[0].label); |
| 96 |
1 |
anns = al.getSequenceAt(1).getAnnotation(); |
| 97 |
1 |
assertEquals(1, anns.length); |
| 98 |
1 |
assertEquals(2d, anns[0].getScore(), 0.001d); |
| 99 |
1 |
assertEquals("my Score Description", anns[0].description); |
| 100 |
1 |
assertEquals("my Score", anns[0].label); |
| 101 |
1 |
anns = al.getSequenceAt(2).getAnnotation(); |
| 102 |
1 |
assertEquals(1, anns.length); |
| 103 |
1 |
assertEquals(3d, anns[0].getScore(), 0.001d); |
| 104 |
1 |
anns = al.getSequenceAt(3).getAnnotation(); |
| 105 |
1 |
assertEquals(1, anns.length); |
| 106 |
1 |
assertEquals(4d, anns[0].getScore(), 0.001d); |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
| 115 |
1 |
@Test(groups = { "Functional" })... |
| 116 |
|
public void testGetScoresFromDescription_twoScores() |
| 117 |
|
{ |
| 118 |
1 |
String regex = ".*([-0-9.+]+).+([-0-9.+]+).*"; |
| 119 |
1 |
final int count = pp.getScoresFromDescription("my Score", |
| 120 |
|
"my Score Description", regex, true); |
| 121 |
1 |
System.out.println("Matched " + count + " for " + regex); |
| 122 |
1 |
assertEquals(3, count); |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
1 |
AlignmentAnnotation[] anns = al.getSequenceAt(0).getAnnotation(); |
| 128 |
1 |
assertEquals(2, anns.length); |
| 129 |
1 |
assertEquals(1d, anns[0].getScore(), 0.001d); |
| 130 |
1 |
assertEquals("my Score Description", anns[0].description); |
| 131 |
1 |
assertEquals("my Score", anns[0].label); |
| 132 |
1 |
assertEquals(1d, anns[1].getScore(), 0.001d); |
| 133 |
1 |
assertEquals("my Score Description (column 1)", anns[1].description); |
| 134 |
1 |
assertEquals("my Score_1", anns[1].label); |
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
1 |
assertNull(al.getSequenceAt(1).getAnnotation()); |
| 140 |
|
|
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
1 |
anns = al.getSequenceAt(2).getAnnotation(); |
| 148 |
1 |
assertEquals(2, anns.length); |
| 149 |
1 |
assertEquals(1d, anns[0].getScore(), 0.001d); |
| 150 |
1 |
assertEquals("my Score Description", anns[0].description); |
| 151 |
1 |
assertEquals("my Score", anns[0].label); |
| 152 |
1 |
assertEquals(3d, anns[1].getScore(), 0.001d); |
| 153 |
1 |
assertEquals("my Score Description (column 1)", anns[1].description); |
| 154 |
1 |
assertEquals("my Score_1", anns[1].label); |
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
1 |
anns = al.getSequenceAt(3).getAnnotation(); |
| 162 |
1 |
assertEquals(2, anns.length); |
| 163 |
1 |
assertEquals(1d, anns[0].getScore(), 0.001d); |
| 164 |
1 |
assertEquals("my Score Description", anns[0].description); |
| 165 |
1 |
assertEquals("my Score", anns[0].label); |
| 166 |
1 |
assertEquals(4d, anns[1].getScore(), 0.001d); |
| 167 |
1 |
assertEquals("my Score Description (column 1)", anns[1].description); |
| 168 |
1 |
assertEquals("my Score_1", anns[1].label); |
| 169 |
|
} |
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
@see |
| 176 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 177 |
1 |
@Test(groups = { "Functional" })... |
| 178 |
|
public void testGetScoresFromDescription_wordBoundaries() |
| 179 |
|
{ |
| 180 |
1 |
String regex = "\\W*([-+eE0-9.]+)"; |
| 181 |
1 |
List<SequenceI> seqs = al.getSequences(); |
| 182 |
1 |
seqs.get(0).setDescription("Ferredoxin"); |
| 183 |
1 |
seqs.get(1).setDescription(" Ferredoxin-1, chloroplast precursor"); |
| 184 |
1 |
seqs.get(2).setDescription("GH28E30p"); |
| 185 |
1 |
seqs.get(3).setDescription("At1g10960/T19D16_12"); |
| 186 |
1 |
final int count = pp.getScoresFromDescription("description column", |
| 187 |
|
"score in description column ", regex, true); |
| 188 |
1 |
assertEquals(3, count); |
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
1 |
AlignmentAnnotation[] anns = al.getSequenceAt(0).getAnnotation(); |
| 194 |
1 |
assertNull(anns); |
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
1 |
anns = al.getSequenceAt(1).getAnnotation(); |
| 200 |
1 |
assertEquals(1, anns.length); |
| 201 |
1 |
assertEquals(1d, anns[0].getScore(), 0.001d); |
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
1 |
anns = al.getSequenceAt(2).getAnnotation(); |
| 209 |
1 |
assertEquals(1, anns.length); |
| 210 |
1 |
assertEquals(2.8E31d, anns[0].getScore(), 0.001d); |
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
1 |
anns = al.getSequenceAt(3).getAnnotation(); |
| 216 |
1 |
assertEquals(5, anns.length); |
| 217 |
1 |
assertEquals(1d, anns[0].getScore(), 0.001d); |
| 218 |
1 |
assertEquals(10960d, anns[1].getScore(), 0.001d); |
| 219 |
1 |
assertEquals(19d, anns[2].getScore(), 0.001d); |
| 220 |
1 |
assertEquals(16d, anns[3].getScore(), 0.001d); |
| 221 |
1 |
assertEquals(12d, anns[4].getScore(), 0.001d); |
| 222 |
|
} |
| 223 |
|
} |