Skip to content

Commit a56d30b

Browse files
committed
New test to demonstrate issue with cloning
1 parent f73c9e6 commit a56d30b

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);
@@ -86,12 +87,13 @@ protected void setUp() throws IOException
8687
inStream.close();
8788
}
8889

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

96+
@Test
9597
public void testGetAtomsConsistency() throws IOException, StructureException{
9698

9799
//Save the existing ChemCompProvider
@@ -121,11 +123,13 @@ public void testGetAtomsConsistency() throws IOException, StructureException{
121123
ChemCompGroupFactory.setChemCompProvider(provider);
122124
}
123125

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

132+
@Test
129133
@SuppressWarnings("deprecation")
130134
public void testGetSubRanges() throws StructureException {
131135
String range;
@@ -263,6 +267,7 @@ public void testGetSubRanges() throws StructureException {
263267
} catch(IllegalArgumentException ex) {} //expected
264268
}
265269

270+
@Test
266271
public void testRevisedConvention() throws IOException, StructureException{
267272

268273
AtomCache cache = new AtomCache();
@@ -348,6 +353,7 @@ public void testRevisedConvention() throws IOException, StructureException{
348353
* Test some subranges that we used to have problems with
349354
* @throws StructureException
350355
*/
356+
@Test
351357
@SuppressWarnings("deprecation")
352358
public void testGetSubRangesExtended() throws StructureException {
353359
String range;
@@ -444,6 +450,7 @@ public void testGetSubRangesExtended() throws StructureException {
444450
* Test insertion codes
445451
* @throws StructureException
446452
*/
453+
@Test
447454
@SuppressWarnings("deprecation")
448455
public void testGetSubRangesInsertionCodes() throws StructureException {
449456
String range;
@@ -501,6 +508,7 @@ public void testGroupsWithinShell() {
501508
//TODO
502509
}
503510

511+
@Test
504512
public void testCAmmCIF() throws StructureException {
505513

506514
//Save the existing ChemCompProvider
@@ -537,5 +545,31 @@ public void testCAmmCIF() throws StructureException {
537545

538546
ChemCompGroupFactory.setChemCompProvider(provider);
539547
}
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+
}
540560

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

0 commit comments

Comments
 (0)