Skip to content

Commit 0d07e69

Browse files
committed
New test to demonstrate issue with cloning
1 parent 2a6ff38 commit 0d07e69

1 file changed

Lines changed: 40 additions & 6 deletions

File tree

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/StructureToolsTest.java

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,28 @@
2222
*/
2323
package org.biojava.nbio.structure.test;
2424

25-
import junit.framework.TestCase;
26-
2725
import org.biojava.nbio.structure.*;
2826
import org.biojava.nbio.structure.align.util.AtomCache;
2927
import org.biojava.nbio.structure.io.FileParsingParameters;
3028
import org.biojava.nbio.structure.io.PDBFileParser;
3129
import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory;
3230
import org.biojava.nbio.structure.io.mmcif.ChemCompProvider;
3331
import org.biojava.nbio.structure.io.mmcif.DownloadChemCompProvider;
32+
import org.junit.Before;
33+
import org.junit.Test;
3434

3535
import java.io.IOException;
3636
import java.io.InputStream;
3737

3838
import static org.junit.Assume.assumeNoException;
39+
import static org.junit.Assert.*;
3940

40-
public class StructureToolsTest extends TestCase {
41+
public class StructureToolsTest {
4142

4243
Structure structure, structure2, structure3, structure4;
4344

44-
@Override
45-
protected void setUp() throws IOException
45+
@Before
46+
public void setUp() throws IOException
4647
{
4748
InputStream inStream = this.getClass().getResourceAsStream("/5pti.pdb");
4849
assertNotNull(inStream);
@@ -85,12 +86,13 @@ protected void setUp() throws IOException
8586
inStream.close();
8687
}
8788

88-
89+
@Test
8990
public void testGetCAAtoms(){
9091
Atom[] cas = StructureTools.getRepresentativeAtomArray(structure);
9192
assertEquals("did not find the expected number of Atoms (58), but got " + cas.length,58,cas.length);
9293
}
9394

95+
@Test
9496
public void testGetAtomsConsistency() throws IOException, StructureException{
9597

9698
//Save the existing ChemCompProvider
@@ -120,11 +122,13 @@ public void testGetAtomsConsistency() throws IOException, StructureException{
120122
ChemCompGroupFactory.setChemCompProvider(provider);
121123
}
122124

125+
@Test
123126
public void testGetNrAtoms(){
124127
int length = StructureTools.getNrAtoms(structure);
125128
assertEquals("did not find the expected number of Atoms (1087), but got " + length,1087,length);
126129
}
127130

131+
@Test
128132
@SuppressWarnings("deprecation")
129133
public void testGetSubRanges() throws StructureException {
130134
String range;
@@ -239,6 +243,7 @@ public void testGetSubRanges() throws StructureException {
239243
} catch(IllegalArgumentException ex) {} //expected
240244
}
241245

246+
@Test
242247
public void testRevisedConvention() throws IOException, StructureException{
243248

244249
AtomCache cache = new AtomCache();
@@ -319,6 +324,7 @@ public void testRevisedConvention() throws IOException, StructureException{
319324
* Test some subranges that we used to have problems with
320325
* @throws StructureException
321326
*/
327+
@Test
322328
@SuppressWarnings("deprecation")
323329
public void testGetSubRangesExtended() throws StructureException {
324330
String range;
@@ -380,6 +386,7 @@ public void testGetSubRangesExtended() throws StructureException {
380386
* Test insertion codes
381387
* @throws StructureException
382388
*/
389+
@Test
383390
@SuppressWarnings("deprecation")
384391
public void testGetSubRangesInsertionCodes() throws StructureException {
385392
String range;
@@ -437,6 +444,7 @@ public void testGroupsWithinShell() {
437444
//TODO
438445
}
439446

447+
@Test
440448
public void testCAmmCIF() throws StructureException {
441449

442450
//Save the existing ChemCompProvider
@@ -473,5 +481,31 @@ public void testCAmmCIF() throws StructureException {
473481

474482
ChemCompGroupFactory.setChemCompProvider(provider);
475483
}
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+
}
476496

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+
}
477511
}

0 commit comments

Comments
 (0)