| 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.AlignmentAnnotation; |
| 27 |
|
import jalview.datamodel.Annotation; |
| 28 |
|
import jalview.datamodel.HiddenMarkovModel; |
| 29 |
|
import jalview.datamodel.Profile; |
| 30 |
|
import jalview.datamodel.ProfileI; |
| 31 |
|
import jalview.datamodel.Profiles; |
| 32 |
|
import jalview.datamodel.ProfilesI; |
| 33 |
|
import jalview.datamodel.ResidueCount; |
| 34 |
|
import jalview.datamodel.Sequence; |
| 35 |
|
import jalview.datamodel.SequenceGroup; |
| 36 |
|
import jalview.datamodel.SequenceI; |
| 37 |
|
import jalview.gui.JvOptionPane; |
| 38 |
|
import jalview.io.DataSourceType; |
| 39 |
|
import jalview.io.FileParse; |
| 40 |
|
import jalview.io.HMMFile; |
| 41 |
|
|
| 42 |
|
import java.io.IOException; |
| 43 |
|
import java.net.MalformedURLException; |
| 44 |
|
|
| 45 |
|
import java.util.Hashtable; |
| 46 |
|
|
| 47 |
|
import org.testng.annotations.BeforeClass; |
| 48 |
|
import org.testng.annotations.Test; |
| 49 |
|
|
| |
|
| 94.7% |
Uncovered Elements: 15 (282) |
Complexity: 20 |
Complexity Density: 0.08 |
|
| 50 |
|
public class AAFrequencyTest |
| 51 |
|
{ |
| 52 |
|
HiddenMarkovModel hmm; |
| 53 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 54 |
1 |
@BeforeClass(alwaysRun = true)... |
| 55 |
|
public void setUpJvOptionPane() |
| 56 |
|
{ |
| 57 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 58 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 59 |
|
} |
| 60 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 61 |
1 |
@BeforeClass(alwaysRun = true)... |
| 62 |
|
public void setUp() throws IOException, MalformedURLException |
| 63 |
|
{ |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
1 |
HMMFile hmmFile = new HMMFile(new FileParse( |
| 68 |
|
"test/jalview/io/test_MADE1_hmm.txt", DataSourceType.FILE)); |
| 69 |
1 |
hmm = hmmFile.getHMM(); |
| 70 |
|
} |
| 71 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
| 72 |
1 |
@Test(groups = { "Functional" })... |
| 73 |
|
public void testCalculate_noProfile() |
| 74 |
|
{ |
| 75 |
1 |
SequenceI seq1 = new Sequence("Seq1", "CAG-T"); |
| 76 |
1 |
SequenceI seq2 = new Sequence("Seq2", "CAC-T"); |
| 77 |
1 |
SequenceI seq3 = new Sequence("Seq3", "C---G"); |
| 78 |
1 |
SequenceI seq4 = new Sequence("Seq4", "CA--t"); |
| 79 |
1 |
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 }; |
| 80 |
1 |
int width = seq1.getLength(); |
| 81 |
1 |
ProfilesI result = AAFrequency.calculate(seqs, width, 0, width, false); |
| 82 |
|
|
| 83 |
|
|
| 84 |
1 |
ProfileI col = result.get(0); |
| 85 |
1 |
assertEquals(100f, col.getPercentageIdentity(false)); |
| 86 |
1 |
assertEquals(100f, col.getPercentageIdentity(true)); |
| 87 |
1 |
assertEquals(4, col.getMaxCount()); |
| 88 |
1 |
assertEquals("C", col.getModalResidue()); |
| 89 |
1 |
assertNull(col.getCounts()); |
| 90 |
|
|
| 91 |
|
|
| 92 |
1 |
col = result.get(1); |
| 93 |
1 |
assertEquals(75f, col.getPercentageIdentity(false)); |
| 94 |
1 |
assertEquals(100f, col.getPercentageIdentity(true)); |
| 95 |
1 |
assertEquals(3, col.getMaxCount()); |
| 96 |
1 |
assertEquals("A", col.getModalResidue()); |
| 97 |
|
|
| 98 |
|
|
| 99 |
1 |
col = result.get(2); |
| 100 |
1 |
assertEquals(25f, col.getPercentageIdentity(false)); |
| 101 |
1 |
assertEquals(50f, col.getPercentageIdentity(true)); |
| 102 |
1 |
assertEquals(1, col.getMaxCount()); |
| 103 |
1 |
assertEquals("CG", col.getModalResidue()); |
| 104 |
|
|
| 105 |
|
|
| 106 |
1 |
col = result.get(3); |
| 107 |
1 |
assertEquals(0f, col.getPercentageIdentity(false)); |
| 108 |
1 |
assertEquals(0f, col.getPercentageIdentity(true)); |
| 109 |
1 |
assertEquals(0, col.getMaxCount()); |
| 110 |
1 |
assertEquals("", col.getModalResidue()); |
| 111 |
|
|
| 112 |
|
|
| 113 |
1 |
col = result.get(4); |
| 114 |
1 |
assertEquals(75f, col.getPercentageIdentity(false)); |
| 115 |
1 |
assertEquals(75f, col.getPercentageIdentity(true)); |
| 116 |
1 |
assertEquals(3, col.getMaxCount()); |
| 117 |
1 |
assertEquals("T", col.getModalResidue()); |
| 118 |
|
} |
| 119 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 120 |
1 |
@Test(groups = { "Functional" })... |
| 121 |
|
public void testCalculate_withProfile() |
| 122 |
|
{ |
| 123 |
1 |
SequenceI seq1 = new Sequence("Seq1", "CAGT"); |
| 124 |
1 |
SequenceI seq2 = new Sequence("Seq2", "CACT"); |
| 125 |
1 |
SequenceI seq3 = new Sequence("Seq3", "C--G"); |
| 126 |
1 |
SequenceI seq4 = new Sequence("Seq4", "CA-t"); |
| 127 |
1 |
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 }; |
| 128 |
1 |
int width = seq1.getLength(); |
| 129 |
1 |
ProfilesI result = AAFrequency.calculate(seqs, width, 0, width, true); |
| 130 |
|
|
| 131 |
1 |
ProfileI profile = result.get(0); |
| 132 |
1 |
assertEquals(4, profile.getCounts().getCount('C')); |
| 133 |
1 |
assertEquals(4, profile.getHeight()); |
| 134 |
1 |
assertEquals(4, profile.getNonGapped()); |
| 135 |
|
|
| 136 |
1 |
profile = result.get(1); |
| 137 |
1 |
assertEquals(3, profile.getCounts().getCount('A')); |
| 138 |
1 |
assertEquals(4, profile.getHeight()); |
| 139 |
1 |
assertEquals(3, profile.getNonGapped()); |
| 140 |
|
|
| 141 |
1 |
profile = result.get(2); |
| 142 |
1 |
assertEquals(1, profile.getCounts().getCount('C')); |
| 143 |
1 |
assertEquals(1, profile.getCounts().getCount('G')); |
| 144 |
1 |
assertEquals(4, profile.getHeight()); |
| 145 |
1 |
assertEquals(2, profile.getNonGapped()); |
| 146 |
|
|
| 147 |
1 |
profile = result.get(3); |
| 148 |
1 |
assertEquals(3, profile.getCounts().getCount('T')); |
| 149 |
1 |
assertEquals(1, profile.getCounts().getCount('G')); |
| 150 |
1 |
assertEquals(4, profile.getHeight()); |
| 151 |
1 |
assertEquals(4, profile.getNonGapped()); |
| 152 |
|
} |
| 153 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
1PASS
|
|
| 154 |
0 |
@Test(groups = { "Functional" }, enabled = false)... |
| 155 |
|
public void testCalculate_withProfileTiming() |
| 156 |
|
{ |
| 157 |
0 |
SequenceI seq1 = new Sequence("Seq1", "CAGT"); |
| 158 |
0 |
SequenceI seq2 = new Sequence("Seq2", "CACT"); |
| 159 |
0 |
SequenceI seq3 = new Sequence("Seq3", "C--G"); |
| 160 |
0 |
SequenceI seq4 = new Sequence("Seq4", "CA-t"); |
| 161 |
0 |
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 }; |
| 162 |
|
|
| 163 |
|
|
| 164 |
0 |
int width = seq1.getLength(); |
| 165 |
0 |
AAFrequency.calculate(seqs, width, 0, width, true); |
| 166 |
|
|
| 167 |
0 |
int reps = 100000; |
| 168 |
0 |
long start = System.currentTimeMillis(); |
| 169 |
0 |
for (int i = 0; i < reps; i++) |
| 170 |
|
{ |
| 171 |
0 |
AAFrequency.calculate(seqs, width, 0, width, true); |
| 172 |
|
} |
| 173 |
0 |
System.out.println(System.currentTimeMillis() - start); |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 182 |
1 |
@Test(groups = { "Functional" })... |
| 183 |
|
public void testCompleteConsensus_includeGaps_showLogo() |
| 184 |
|
{ |
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
1 |
SequenceI seq1 = new Sequence("Seq1", "CAG-T"); |
| 189 |
1 |
SequenceI seq2 = new Sequence("Seq2", "CAC-T"); |
| 190 |
1 |
SequenceI seq3 = new Sequence("Seq3", "C---G"); |
| 191 |
1 |
SequenceI seq4 = new Sequence("Seq4", "CA--t"); |
| 192 |
1 |
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 }; |
| 193 |
1 |
int width = seq1.getLength(); |
| 194 |
1 |
ProfilesI profiles = AAFrequency.calculate(seqs, width, 0, width, true); |
| 195 |
|
|
| 196 |
1 |
AlignmentAnnotation consensus = new AlignmentAnnotation("Consensus", |
| 197 |
|
"PID", new Annotation[width]); |
| 198 |
1 |
AAFrequency.completeConsensus(consensus, profiles, 0, 5, false, true, |
| 199 |
|
4); |
| 200 |
|
|
| 201 |
1 |
Annotation ann = consensus.annotations[0]; |
| 202 |
1 |
assertEquals("C 100%", ann.description); |
| 203 |
1 |
assertEquals("C", ann.displayCharacter); |
| 204 |
1 |
ann = consensus.annotations[1]; |
| 205 |
1 |
assertEquals("A 75%", ann.description); |
| 206 |
1 |
assertEquals("A", ann.displayCharacter); |
| 207 |
1 |
ann = consensus.annotations[2]; |
| 208 |
1 |
assertEquals("C 25%; G 25%", ann.description); |
| 209 |
1 |
assertEquals("+", ann.displayCharacter); |
| 210 |
1 |
ann = consensus.annotations[3]; |
| 211 |
1 |
assertEquals("", ann.description); |
| 212 |
1 |
assertEquals("-", ann.displayCharacter); |
| 213 |
1 |
ann = consensus.annotations[4]; |
| 214 |
1 |
assertEquals("T 75%; G 25%", ann.description); |
| 215 |
1 |
assertEquals("T", ann.displayCharacter); |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 223 |
1 |
@Test(groups = { "Functional" })... |
| 224 |
|
public void testCompleteConsensus_ignoreGaps_noLogo() |
| 225 |
|
{ |
| 226 |
|
|
| 227 |
|
|
| 228 |
|
|
| 229 |
1 |
SequenceI seq1 = new Sequence("Seq1", "CAG-T"); |
| 230 |
1 |
SequenceI seq2 = new Sequence("Seq2", "CAC-T"); |
| 231 |
1 |
SequenceI seq3 = new Sequence("Seq3", "C---G"); |
| 232 |
1 |
SequenceI seq4 = new Sequence("Seq4", "CA--t"); |
| 233 |
1 |
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 }; |
| 234 |
1 |
int width = seq1.getLength(); |
| 235 |
1 |
ProfilesI profiles = AAFrequency.calculate(seqs, width, 0, width, true); |
| 236 |
|
|
| 237 |
1 |
AlignmentAnnotation consensus = new AlignmentAnnotation("Consensus", |
| 238 |
|
"PID", new Annotation[width]); |
| 239 |
1 |
AAFrequency.completeConsensus(consensus, profiles, 0, 5, true, false, |
| 240 |
|
4); |
| 241 |
|
|
| 242 |
1 |
Annotation ann = consensus.annotations[0]; |
| 243 |
1 |
assertEquals("C 100%", ann.description); |
| 244 |
1 |
assertEquals("C", ann.displayCharacter); |
| 245 |
1 |
ann = consensus.annotations[1]; |
| 246 |
1 |
assertEquals("A 100%", ann.description); |
| 247 |
1 |
assertEquals("A", ann.displayCharacter); |
| 248 |
1 |
ann = consensus.annotations[2]; |
| 249 |
1 |
assertEquals("[CG] 50%", ann.description); |
| 250 |
1 |
assertEquals("+", ann.displayCharacter); |
| 251 |
1 |
ann = consensus.annotations[3]; |
| 252 |
1 |
assertEquals("", ann.description); |
| 253 |
1 |
assertEquals("-", ann.displayCharacter); |
| 254 |
1 |
ann = consensus.annotations[4]; |
| 255 |
1 |
assertEquals("T 75%", ann.description); |
| 256 |
1 |
assertEquals("T", ann.displayCharacter); |
| 257 |
|
} |
| 258 |
|
|
| 259 |
|
|
| 260 |
|
|
| 261 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 262 |
1 |
@Test(groups = { "Functional" })... |
| 263 |
|
public void testExtractProfile() |
| 264 |
|
{ |
| 265 |
|
|
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
| 269 |
1 |
ProfileI profile = new Profile(200, 30, 70, "G"); |
| 270 |
1 |
ResidueCount counts = new ResidueCount(); |
| 271 |
1 |
counts.put('G', 70); |
| 272 |
1 |
counts.put('R', 60); |
| 273 |
1 |
counts.put('L', 38); |
| 274 |
1 |
counts.put('H', 2); |
| 275 |
1 |
profile.setCounts(counts); |
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 280 |
|
|
| 281 |
|
|
| 282 |
|
|
| 283 |
|
|
| 284 |
|
|
| 285 |
1 |
int[] extracted = AAFrequency.extractProfile(profile, true); |
| 286 |
1 |
int[] expected = new int[] { 0, 4, 99, 'G', 41, 'R', 35, 'L', 22, 'H', |
| 287 |
|
1 }; |
| 288 |
1 |
org.testng.Assert.assertEquals(extracted, expected); |
| 289 |
|
|
| 290 |
|
|
| 291 |
|
|
| 292 |
|
|
| 293 |
1 |
counts.put('G', 68); |
| 294 |
1 |
counts.put('Q', 1); |
| 295 |
1 |
counts.put('K', 1); |
| 296 |
1 |
extracted = AAFrequency.extractProfile(profile, true); |
| 297 |
1 |
expected = new int[] { 0, 4, 98, 'G', 40, 'R', 35, 'L', 22, 'H', 1 }; |
| 298 |
1 |
org.testng.Assert.assertEquals(extracted, expected); |
| 299 |
|
|
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
|
| 303 |
|
|
| 304 |
|
|
| 305 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 306 |
1 |
@Test(groups = { "Functional" })... |
| 307 |
|
public void testExtractProfile_countGaps() |
| 308 |
|
{ |
| 309 |
|
|
| 310 |
|
|
| 311 |
|
|
| 312 |
|
|
| 313 |
1 |
ProfileI profile = new Profile(200, 30, 70, "G"); |
| 314 |
1 |
ResidueCount counts = new ResidueCount(); |
| 315 |
1 |
counts.put('G', 70); |
| 316 |
1 |
counts.put('R', 60); |
| 317 |
1 |
counts.put('L', 38); |
| 318 |
1 |
counts.put('H', 2); |
| 319 |
1 |
profile.setCounts(counts); |
| 320 |
|
|
| 321 |
|
|
| 322 |
|
|
| 323 |
|
|
| 324 |
|
|
| 325 |
|
|
| 326 |
|
|
| 327 |
|
|
| 328 |
|
|
| 329 |
1 |
int[] extracted = AAFrequency.extractProfile(profile, false); |
| 330 |
1 |
int[] expected = new int[] { AlignmentAnnotation.SEQUENCE_PROFILE, 4, |
| 331 |
|
85, 'G', 35, 'R', 30, 'L', 19, 'H', 1 }; |
| 332 |
1 |
org.testng.Assert.assertEquals(extracted, expected); |
| 333 |
|
|
| 334 |
|
|
| 335 |
|
|
| 336 |
|
|
| 337 |
1 |
counts.put('G', 68); |
| 338 |
1 |
counts.put('Q', 1); |
| 339 |
1 |
counts.put('K', 1); |
| 340 |
1 |
extracted = AAFrequency.extractProfile(profile, false); |
| 341 |
1 |
expected = new int[] { AlignmentAnnotation.SEQUENCE_PROFILE, 4, 84, 'G', |
| 342 |
|
34, 'R', 30, 'L', 19, 'H', 1 }; |
| 343 |
1 |
org.testng.Assert.assertEquals(extracted, expected); |
| 344 |
|
|
| 345 |
|
} |
| 346 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 347 |
1 |
@Test(groups = { "Functional" })... |
| 348 |
|
public void testExtractCdnaProfile() |
| 349 |
|
{ |
| 350 |
|
|
| 351 |
|
|
| 352 |
|
|
| 353 |
|
|
| 354 |
1 |
Hashtable profile = new Hashtable(); |
| 355 |
|
|
| 356 |
|
|
| 357 |
|
|
| 358 |
|
|
| 359 |
|
|
| 360 |
|
|
| 361 |
1 |
int[] codonCounts = new int[66]; |
| 362 |
1 |
char[] codon1 = new char[] { 'G', 'C', 'A' }; |
| 363 |
1 |
char[] codon2 = new char[] { 'c', 'C', 'A' }; |
| 364 |
1 |
char[] codon3 = new char[] { 't', 'g', 'A' }; |
| 365 |
1 |
char[] codon4 = new char[] { 'G', 'C', 't' }; |
| 366 |
1 |
int encoded1 = CodingUtils.encodeCodon(codon1); |
| 367 |
1 |
int encoded2 = CodingUtils.encodeCodon(codon2); |
| 368 |
1 |
int encoded3 = CodingUtils.encodeCodon(codon3); |
| 369 |
1 |
int encoded4 = CodingUtils.encodeCodon(codon4); |
| 370 |
1 |
codonCounts[2 + encoded1] = 30; |
| 371 |
1 |
codonCounts[2 + encoded2] = 70; |
| 372 |
1 |
codonCounts[2 + encoded3] = 9; |
| 373 |
1 |
codonCounts[2 + encoded4] = 1; |
| 374 |
1 |
codonCounts[0] = 120; |
| 375 |
1 |
codonCounts[1] = 110; |
| 376 |
1 |
profile.put(AAFrequency.PROFILE, codonCounts); |
| 377 |
|
|
| 378 |
|
|
| 379 |
|
|
| 380 |
|
|
| 381 |
|
|
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
|
| 386 |
1 |
int[] extracted = AAFrequency.extractCdnaProfile(profile, true); |
| 387 |
1 |
int[] expected = new int[] { AlignmentAnnotation.CDNA_PROFILE, 3, 98, |
| 388 |
|
encoded2, 63, encoded1, 27, encoded3, 8 }; |
| 389 |
1 |
org.testng.Assert.assertEquals(extracted, expected); |
| 390 |
|
} |
| 391 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 392 |
1 |
@Test(groups = { "Functional" })... |
| 393 |
|
public void testExtractCdnaProfile_countGaps() |
| 394 |
|
{ |
| 395 |
|
|
| 396 |
|
|
| 397 |
|
|
| 398 |
|
|
| 399 |
1 |
Hashtable profile = new Hashtable(); |
| 400 |
|
|
| 401 |
|
|
| 402 |
|
|
| 403 |
|
|
| 404 |
|
|
| 405 |
|
|
| 406 |
1 |
int[] codonCounts = new int[66]; |
| 407 |
1 |
char[] codon1 = new char[] { 'G', 'C', 'A' }; |
| 408 |
1 |
char[] codon2 = new char[] { 'c', 'C', 'A' }; |
| 409 |
1 |
char[] codon3 = new char[] { 't', 'g', 'A' }; |
| 410 |
1 |
char[] codon4 = new char[] { 'G', 'C', 't' }; |
| 411 |
1 |
int encoded1 = CodingUtils.encodeCodon(codon1); |
| 412 |
1 |
int encoded2 = CodingUtils.encodeCodon(codon2); |
| 413 |
1 |
int encoded3 = CodingUtils.encodeCodon(codon3); |
| 414 |
1 |
int encoded4 = CodingUtils.encodeCodon(codon4); |
| 415 |
1 |
codonCounts[2 + encoded1] = 30; |
| 416 |
1 |
codonCounts[2 + encoded2] = 70; |
| 417 |
1 |
codonCounts[2 + encoded3] = 9; |
| 418 |
1 |
codonCounts[2 + encoded4] = 1; |
| 419 |
1 |
codonCounts[0] = 120; |
| 420 |
1 |
codonCounts[1] = 110; |
| 421 |
1 |
profile.put(AAFrequency.PROFILE, codonCounts); |
| 422 |
|
|
| 423 |
|
|
| 424 |
|
|
| 425 |
|
|
| 426 |
|
|
| 427 |
|
|
| 428 |
|
|
| 429 |
|
|
| 430 |
|
|
| 431 |
1 |
int[] extracted = AAFrequency.extractCdnaProfile(profile, false); |
| 432 |
1 |
int[] expected = new int[] { AlignmentAnnotation.CDNA_PROFILE, 3, 90, |
| 433 |
|
encoded2, 58, encoded1, 25, encoded3, 7 }; |
| 434 |
1 |
org.testng.Assert.assertEquals(extracted, expected); |
| 435 |
|
} |
| |
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 436 |
1 |
@Test(groups= {"Functional"})... |
| 437 |
|
public void testExtractSSProfileForSequenceGroup() |
| 438 |
|
{ |
| 439 |
1 |
Sequence sq = new Sequence("ASD","ASD"); |
| 440 |
1 |
Annotation h=new Annotation("H","",'H',0f),e=new Annotation("E","",'E',0f); |
| 441 |
1 |
AlignmentAnnotation aa_allh = new AlignmentAnnotation("Secondary Structure","Foo h", new Annotation[] {h,h,h}); |
| 442 |
1 |
AlignmentAnnotation aa_allh2 = new AlignmentAnnotation("Secondary Structure","Foo h2", new Annotation[] {h,h,h}); |
| 443 |
1 |
AlignmentAnnotation aa_alle = new AlignmentAnnotation("Secondary Structure","Foo e", new Annotation[] {e,e,e}); |
| 444 |
1 |
AlignmentAnnotation aa_allc = new AlignmentAnnotation("Secondary Structure","Foo c", new Annotation[] {null,null,null}); |
| 445 |
|
|
| 446 |
1 |
SequenceGroup sg = new SequenceGroup(); |
| 447 |
1 |
sq.addAlignmentAnnotation(aa_allc); |
| 448 |
1 |
sq.addAlignmentAnnotation(aa_alle); |
| 449 |
1 |
sq.addAlignmentAnnotation(aa_allh); |
| 450 |
1 |
sq.addAlignmentAnnotation(aa_allh2); |
| 451 |
|
|
| 452 |
|
|
| 453 |
1 |
sg.addSequence(sq, false); |
| 454 |
1 |
sg.addAnnotationFromTree(aa_alle); |
| 455 |
|
|
| 456 |
1 |
ProfilesI profile; |
| 457 |
|
|
| 458 |
1 |
profile = AAFrequency.calculateSS(new SequenceI[] {sq}, 3, 1, 3, false, "All", sg); |
| 459 |
1 |
assertEquals("E",profile.get(1).getModalSS()); |
| 460 |
1 |
assertEquals(1,profile.getCount()); |
| 461 |
1 |
assertEquals(1,profile.get(1).getSeqWithSSCount()); |
| 462 |
|
|
| 463 |
|
|
| 464 |
1 |
profile = AAFrequency.calculateSS(new SequenceI[] {sq}, 3, 1, 3, false, null, sg); |
| 465 |
1 |
assertEquals("E",profile.get(1).getModalSS()); |
| 466 |
|
|
| 467 |
|
|
| 468 |
1 |
profile = AAFrequency.calculateSS(new SequenceI[] {sq}, 3, 1, 3, false, "All", null); |
| 469 |
1 |
assertEquals("H",profile.get(1).getModalSS()); |
| 470 |
1 |
assertEquals(4,profile.getCount()); |
| 471 |
1 |
assertEquals(1,profile.get(1).getSeqWithSSCount()); |
| 472 |
|
|
| 473 |
|
|
| 474 |
1 |
profile = AAFrequency.calculateSS(new SequenceI[] {sq}, 3, 1, 3, false, null, null); |
| 475 |
1 |
assertEquals("H",profile.get(1).getModalSS()); |
| 476 |
|
} |
| 477 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 5 |
Complexity Density: 0.38 |
1PASS
|
|
| 478 |
1 |
@Test(groups = { "Functional" })... |
| 479 |
|
public void testExtractHMMProfile() |
| 480 |
|
throws MalformedURLException, IOException |
| 481 |
|
{ |
| 482 |
1 |
int[] expected = { 0, 4, 100, 'T', 71, 'C', 12, 'G', 9, 'A', 9 }; |
| 483 |
1 |
int[] actual = AAFrequency.extractHMMProfile(hmm, 17, false, false); |
| 484 |
12 |
for (int i = 0; i < actual.length; i++) |
| 485 |
|
{ |
| 486 |
11 |
if (i == 2) |
| 487 |
|
{ |
| 488 |
1 |
assertEquals(actual[i], expected[i]); |
| 489 |
|
} |
| 490 |
|
else |
| 491 |
|
{ |
| 492 |
10 |
assertEquals(actual[i], expected[i]); |
| 493 |
|
} |
| 494 |
|
} |
| 495 |
|
|
| 496 |
1 |
int[] expected2 = { 0, 4, 100, 'A', 85, 'C', 0, 'G', 0, 'T', 0 }; |
| 497 |
1 |
int[] actual2 = AAFrequency.extractHMMProfile(hmm, 2, true, false); |
| 498 |
12 |
for (int i = 0; i < actual2.length; i++) |
| 499 |
|
{ |
| 500 |
11 |
if (i == 2) |
| 501 |
|
{ |
| 502 |
1 |
assertEquals(actual[i], expected[i]); |
| 503 |
|
} |
| 504 |
|
else |
| 505 |
|
{ |
| 506 |
10 |
assertEquals(actual[i], expected[i]); |
| 507 |
|
} |
| 508 |
|
} |
| 509 |
|
|
| 510 |
1 |
assertNull(AAFrequency.extractHMMProfile(null, 98978867, true, false)); |
| 511 |
|
} |
| 512 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
| 513 |
1 |
@Test(groups = { "Functional" })... |
| 514 |
|
public void testGetAnalogueCount() |
| 515 |
|
{ |
| 516 |
|
|
| 517 |
|
|
| 518 |
|
|
| 519 |
1 |
int count = AAFrequency.getAnalogueCount(hmm, 0, 'T', false, false); |
| 520 |
1 |
assertEquals(7859, count); |
| 521 |
|
|
| 522 |
|
|
| 523 |
|
|
| 524 |
|
|
| 525 |
|
|
| 526 |
|
|
| 527 |
|
|
| 528 |
1 |
count = AAFrequency.getAnalogueCount(hmm, 0, 'T', false, true); |
| 529 |
1 |
assertEquals(12987, count); |
| 530 |
|
|
| 531 |
|
|
| 532 |
|
|
| 533 |
|
|
| 534 |
1 |
count = AAFrequency.getAnalogueCount(hmm, 20, 'G', false, false); |
| 535 |
1 |
assertEquals(7546, count); |
| 536 |
|
|
| 537 |
|
|
| 538 |
|
|
| 539 |
|
|
| 540 |
|
|
| 541 |
1 |
count = AAFrequency.getAnalogueCount(hmm, 1077, 'G', true, false); |
| 542 |
1 |
assertEquals(0, count); |
| 543 |
|
} |
| 544 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 545 |
1 |
@Test(groups = { "Functional" })... |
| 546 |
|
public void testCompleteInformation() |
| 547 |
|
{ |
| 548 |
1 |
ProfileI prof1 = new Profile(1, 0, 100, "A"); |
| 549 |
1 |
ProfileI prof2 = new Profile(1, 0, 100, "-"); |
| 550 |
|
|
| 551 |
1 |
ProfilesI profs = new Profiles(1,new ProfileI[] { prof1, prof2 }); |
| 552 |
1 |
Annotation ann1 = new Annotation(6.5f); |
| 553 |
1 |
Annotation ann2 = new Annotation(0f); |
| 554 |
1 |
Annotation[] annots = new Annotation[] { ann1, ann2 }; |
| 555 |
1 |
SequenceI seq = new Sequence("", "AA", 0, 0); |
| 556 |
1 |
seq.setHMM(hmm); |
| 557 |
1 |
AlignmentAnnotation annot = new AlignmentAnnotation("", "", annots); |
| 558 |
1 |
annot.setSequenceRef(seq); |
| 559 |
1 |
AAFrequency.completeInformation(annot, profs, 0, 1); |
| 560 |
1 |
float ic = annot.annotations[0].value; |
| 561 |
1 |
assertEquals(0.91532f, ic, 0.0001f); |
| 562 |
1 |
ic = annot.annotations[1].value; |
| 563 |
1 |
assertEquals(0f, ic, 0.0001f); |
| 564 |
1 |
int i = 0; |
| 565 |
|
} |
| 566 |
|
} |