|
22 | 22 | */ |
23 | 23 | package org.biojava.nbio.structure.test; |
24 | 24 |
|
25 | | -import junit.framework.TestCase; |
26 | | - |
27 | 25 | import org.biojava.nbio.structure.*; |
28 | 26 | import org.biojava.nbio.structure.align.util.AtomCache; |
29 | 27 | import org.biojava.nbio.structure.io.FileParsingParameters; |
30 | 28 | import org.biojava.nbio.structure.io.PDBFileParser; |
31 | 29 | import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory; |
32 | 30 | import org.biojava.nbio.structure.io.mmcif.ChemCompProvider; |
33 | 31 | import org.biojava.nbio.structure.io.mmcif.DownloadChemCompProvider; |
| 32 | +import org.junit.Before; |
| 33 | +import org.junit.Test; |
34 | 34 |
|
35 | 35 | import java.io.IOException; |
36 | 36 | import java.io.InputStream; |
37 | 37 |
|
38 | 38 | import static org.junit.Assume.assumeNoException; |
| 39 | +import static org.junit.Assert.*; |
39 | 40 |
|
40 | | -public class StructureToolsTest extends TestCase { |
| 41 | +public class StructureToolsTest { |
41 | 42 |
|
42 | 43 | Structure structure, structure2, structure3, structure4; |
43 | 44 |
|
44 | | - @Override |
45 | | - protected void setUp() throws IOException |
| 45 | + @Before |
| 46 | + public void setUp() throws IOException |
46 | 47 | { |
47 | 48 | InputStream inStream = this.getClass().getResourceAsStream("/5pti.pdb"); |
48 | 49 | assertNotNull(inStream); |
@@ -85,12 +86,13 @@ protected void setUp() throws IOException |
85 | 86 | inStream.close(); |
86 | 87 | } |
87 | 88 |
|
88 | | - |
| 89 | + @Test |
89 | 90 | public void testGetCAAtoms(){ |
90 | 91 | Atom[] cas = StructureTools.getRepresentativeAtomArray(structure); |
91 | 92 | assertEquals("did not find the expected number of Atoms (58), but got " + cas.length,58,cas.length); |
92 | 93 | } |
93 | 94 |
|
| 95 | + @Test |
94 | 96 | public void testGetAtomsConsistency() throws IOException, StructureException{ |
95 | 97 |
|
96 | 98 | //Save the existing ChemCompProvider |
@@ -120,11 +122,13 @@ public void testGetAtomsConsistency() throws IOException, StructureException{ |
120 | 122 | ChemCompGroupFactory.setChemCompProvider(provider); |
121 | 123 | } |
122 | 124 |
|
| 125 | + @Test |
123 | 126 | public void testGetNrAtoms(){ |
124 | 127 | int length = StructureTools.getNrAtoms(structure); |
125 | 128 | assertEquals("did not find the expected number of Atoms (1087), but got " + length,1087,length); |
126 | 129 | } |
127 | 130 |
|
| 131 | + @Test |
128 | 132 | @SuppressWarnings("deprecation") |
129 | 133 | public void testGetSubRanges() throws StructureException { |
130 | 134 | String range; |
@@ -239,6 +243,7 @@ public void testGetSubRanges() throws StructureException { |
239 | 243 | } catch(IllegalArgumentException ex) {} //expected |
240 | 244 | } |
241 | 245 |
|
| 246 | + @Test |
242 | 247 | public void testRevisedConvention() throws IOException, StructureException{ |
243 | 248 |
|
244 | 249 | AtomCache cache = new AtomCache(); |
@@ -319,6 +324,7 @@ public void testRevisedConvention() throws IOException, StructureException{ |
319 | 324 | * Test some subranges that we used to have problems with |
320 | 325 | * @throws StructureException |
321 | 326 | */ |
| 327 | + @Test |
322 | 328 | @SuppressWarnings("deprecation") |
323 | 329 | public void testGetSubRangesExtended() throws StructureException { |
324 | 330 | String range; |
@@ -380,6 +386,7 @@ public void testGetSubRangesExtended() throws StructureException { |
380 | 386 | * Test insertion codes |
381 | 387 | * @throws StructureException |
382 | 388 | */ |
| 389 | + @Test |
383 | 390 | @SuppressWarnings("deprecation") |
384 | 391 | public void testGetSubRangesInsertionCodes() throws StructureException { |
385 | 392 | String range; |
@@ -437,6 +444,7 @@ public void testGroupsWithinShell() { |
437 | 444 | //TODO |
438 | 445 | } |
439 | 446 |
|
| 447 | + @Test |
440 | 448 | public void testCAmmCIF() throws StructureException { |
441 | 449 |
|
442 | 450 | //Save the existing ChemCompProvider |
@@ -473,5 +481,31 @@ public void testCAmmCIF() throws StructureException { |
473 | 481 |
|
474 | 482 | ChemCompGroupFactory.setChemCompProvider(provider); |
475 | 483 | } |
| 484 | + |
| 485 | + @Test |
| 486 | + public void testGetRepresentativeAtomsProtein() throws StructureException, IOException { |
| 487 | + Structure s = StructureIO.getStructure("1smt"); |
| 488 | + Chain c = s.getChain(0); |
| 489 | + Atom[] atoms = StructureTools.getRepresentativeAtomArray(c); |
| 490 | + assertEquals(98,atoms.length); |
| 491 | + |
| 492 | + Chain clonedChain = (Chain)c.clone(); |
| 493 | + atoms = StructureTools.getRepresentativeAtomArray(clonedChain); |
| 494 | + assertEquals(98,atoms.length); |
| 495 | + } |
476 | 496 |
|
| 497 | + @Test |
| 498 | + public void testGetRepresentativeAtomsDna() throws StructureException, IOException { |
| 499 | + |
| 500 | + Structure s = StructureIO.getStructure("2pvi"); |
| 501 | + Chain c = s.getChainByPDB("C"); |
| 502 | + Atom[] atoms = StructureTools.getRepresentativeAtomArray(c); // chain C (1st nucleotide chain) |
| 503 | + // actually it should be 13, but at the moment one of the nucleotides is not caught correctly because it's non-standard |
| 504 | + assertEquals(12,atoms.length); |
| 505 | + |
| 506 | + Chain clonedChain = (Chain)c.clone(); |
| 507 | + atoms = StructureTools.getRepresentativeAtomArray(clonedChain); // chain C (1st nucleotide chain) |
| 508 | + assertEquals(12,atoms.length); |
| 509 | + |
| 510 | + } |
477 | 511 | } |
0 commit comments