Skip to content

Commit 9f8de9b

Browse files
johnmayegonw
authored andcommitted
Add a test of the HETATM atom types.
1 parent fc122da commit 9f8de9b

File tree

2 files changed

+5066
-3
lines changed

2 files changed

+5066
-3
lines changed

storage/pdb/src/test/java/org/openscience/cdk/io/PDBReaderTest.java

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424

2525
import java.io.InputStream;
2626
import java.io.StringReader;
27+
import java.util.ArrayList;
2728
import java.util.Collection;
2829
import java.util.Iterator;
30+
import java.util.List;
2931

3032
import org.junit.Assert;
3133
import org.junit.BeforeClass;
@@ -251,18 +253,24 @@ public IChemFile getChemFile(String filename) throws Exception {
251253
}
252254

253255
public IChemFile getChemFile(ISimpleChemObjectReader reader) throws Exception {
254-
return getChemFile(reader, false);
256+
return getChemFile(reader, false, false);
255257
}
256258

257259
public IChemFile getChemFile(String filename, boolean useRebond) throws Exception {
258260
InputStream ins = this.getClass().getResourceAsStream(filename);
259-
return getChemFile(new PDBReader(ins), useRebond);
261+
return getChemFile(new PDBReader(ins), useRebond, false);
260262
}
261263

262-
public IChemFile getChemFile(ISimpleChemObjectReader reader, boolean useRebond) throws Exception {
264+
public IChemFile getChemFile(String filename, boolean useRebond, boolean useHetAtmDict) throws Exception {
265+
InputStream ins = this.getClass().getResourceAsStream(filename);
266+
return getChemFile(new PDBReader(ins), useRebond, useHetAtmDict);
267+
}
268+
269+
public IChemFile getChemFile(ISimpleChemObjectReader reader, boolean useRebond, boolean useHetAtmDict) throws Exception {
263270
Assert.assertNotNull(reader);
264271

265272
reader.getSetting("UseRebondTool").setSetting(String.valueOf(useRebond));
273+
reader.getSetting("UseHetDictionary").setSetting(String.valueOf(useHetAtmDict));
266274

267275
IChemFile chemFile = (IChemFile) reader.read(new ChemFile());
268276
Assert.assertNotNull(chemFile);
@@ -417,6 +425,32 @@ public void test1TOH() throws Exception {
417425
testObjectCountsChemFile(chemFile, 1, 1, 1, 2804, 1, 325, 23);
418426
}
419427

428+
public void assertHetAtmTypes(IChemFile chemFile,
429+
String resName,
430+
String ... expected)
431+
{
432+
List<String> actual = new ArrayList<>();
433+
for (IAtomContainer mol : ChemFileManipulator.getAllAtomContainers(chemFile)) {
434+
for (IAtom atom : mol.atoms()) {
435+
if (((IPDBAtom)atom).getResName().equals(resName))
436+
actual.add(atom.getAtomTypeName());
437+
}
438+
}
439+
Assert.assertArrayEquals("Unexpected HETATOM types for res=" + resName + " was=" + actual,
440+
expected, actual.toArray(new String[0]));
441+
}
442+
443+
@Test
444+
public void test3PTY() throws Exception {
445+
String filename = "3PTY.pdb";
446+
IChemFile chemFile = getChemFile(filename, false, true);
447+
testObjectCountsChemFile(chemFile, 1, 1, 1, 2258, 1, 284, 32);
448+
assertHetAtmTypes(chemFile,
449+
"AFO",
450+
"C.sp3", "O.sp3", "C.sp3", "O.sp3", "C.sp3", "O.sp3", "C.sp3", "O.sp3", "C.sp3", "O.sp3",
451+
"C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3");
452+
}
453+
420454
@Category(SlowTest.class)
421455
@Test
422456
public void test1CKV() throws Exception {

0 commit comments

Comments
 (0)