|
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); |
@@ -86,12 +87,13 @@ protected void setUp() throws IOException |
86 | 87 | inStream.close(); |
87 | 88 | } |
88 | 89 |
|
89 | | - |
| 90 | + @Test |
90 | 91 | public void testGetCAAtoms(){ |
91 | 92 | Atom[] cas = StructureTools.getRepresentativeAtomArray(structure); |
92 | 93 | assertEquals("did not find the expected number of Atoms (58), but got " + cas.length,58,cas.length); |
93 | 94 | } |
94 | 95 |
|
| 96 | + @Test |
95 | 97 | public void testGetAtomsConsistency() throws IOException, StructureException{ |
96 | 98 |
|
97 | 99 | //Save the existing ChemCompProvider |
@@ -121,11 +123,13 @@ public void testGetAtomsConsistency() throws IOException, StructureException{ |
121 | 123 | ChemCompGroupFactory.setChemCompProvider(provider); |
122 | 124 | } |
123 | 125 |
|
| 126 | + @Test |
124 | 127 | public void testGetNrAtoms(){ |
125 | 128 | int length = StructureTools.getNrAtoms(structure); |
126 | 129 | assertEquals("did not find the expected number of Atoms (1087), but got " + length,1087,length); |
127 | 130 | } |
128 | 131 |
|
| 132 | + @Test |
129 | 133 | @SuppressWarnings("deprecation") |
130 | 134 | public void testGetSubRanges() throws StructureException { |
131 | 135 | String range; |
@@ -263,6 +267,7 @@ public void testGetSubRanges() throws StructureException { |
263 | 267 | } catch(IllegalArgumentException ex) {} //expected |
264 | 268 | } |
265 | 269 |
|
| 270 | + @Test |
266 | 271 | public void testRevisedConvention() throws IOException, StructureException{ |
267 | 272 |
|
268 | 273 | AtomCache cache = new AtomCache(); |
@@ -348,6 +353,7 @@ public void testRevisedConvention() throws IOException, StructureException{ |
348 | 353 | * Test some subranges that we used to have problems with |
349 | 354 | * @throws StructureException |
350 | 355 | */ |
| 356 | + @Test |
351 | 357 | @SuppressWarnings("deprecation") |
352 | 358 | public void testGetSubRangesExtended() throws StructureException { |
353 | 359 | String range; |
@@ -444,6 +450,7 @@ public void testGetSubRangesExtended() throws StructureException { |
444 | 450 | * Test insertion codes |
445 | 451 | * @throws StructureException |
446 | 452 | */ |
| 453 | + @Test |
447 | 454 | @SuppressWarnings("deprecation") |
448 | 455 | public void testGetSubRangesInsertionCodes() throws StructureException { |
449 | 456 | String range; |
@@ -501,6 +508,7 @@ public void testGroupsWithinShell() { |
501 | 508 | //TODO |
502 | 509 | } |
503 | 510 |
|
| 511 | + @Test |
504 | 512 | public void testCAmmCIF() throws StructureException { |
505 | 513 |
|
506 | 514 | //Save the existing ChemCompProvider |
@@ -537,5 +545,31 @@ public void testCAmmCIF() throws StructureException { |
537 | 545 |
|
538 | 546 | ChemCompGroupFactory.setChemCompProvider(provider); |
539 | 547 | } |
| 548 | + |
| 549 | + @Test |
| 550 | + public void testGetRepresentativeAtomsProtein() throws StructureException, IOException { |
| 551 | + Structure s = StructureIO.getStructure("1smt"); |
| 552 | + Chain c = s.getChain(0); |
| 553 | + Atom[] atoms = StructureTools.getRepresentativeAtomArray(c); |
| 554 | + assertEquals(98,atoms.length); |
| 555 | + |
| 556 | + Chain clonedChain = (Chain)c.clone(); |
| 557 | + atoms = StructureTools.getRepresentativeAtomArray(clonedChain); |
| 558 | + assertEquals(98,atoms.length); |
| 559 | + } |
540 | 560 |
|
| 561 | + @Test |
| 562 | + public void testGetRepresentativeAtomsDna() throws StructureException, IOException { |
| 563 | + |
| 564 | + Structure s = StructureIO.getStructure("2pvi"); |
| 565 | + Chain c = s.getChainByPDB("C"); |
| 566 | + Atom[] atoms = StructureTools.getRepresentativeAtomArray(c); // chain C (1st nucleotide chain) |
| 567 | + // actually it should be 13, but at the moment one of the nucleotides is not caught correctly because it's non-standard |
| 568 | + assertEquals(12,atoms.length); |
| 569 | + |
| 570 | + Chain clonedChain = (Chain)c.clone(); |
| 571 | + atoms = StructureTools.getRepresentativeAtomArray(clonedChain); // chain C (1st nucleotide chain) |
| 572 | + assertEquals(12,atoms.length); |
| 573 | + |
| 574 | + } |
541 | 575 | } |
0 commit comments