PDBReader extends DefaultChemObjectReader { @Override public <T extends IChemObject> T read(T oObj) throws CDKException { if (oObj instanceof IChemFile) { return (T) readChemFile((IChemFile) oObj); } else { throw new CDKException("Only supported is reading of ChemFile objects."); } } PDBReader(InputStream oIn);  PDBReader(Reader oIn);  PDBReader(); @Override IResourceFormat getFormat(); @Override void setReader(Reader input); @Override void setReader(InputStream input); @Override boolean accepts(Class<? extends IChemObject> classObject); @Override T read(T oObj); @Override void close(); void customizeJob();  }
@Test public void testPDBFileCoffein() throws Exception { String filename = "data/pdb/coffeine.pdb"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader oReader = new PDBReader(ins); Assert.assertNotNull(oReader); IChemFile oChemFile = (IChemFile) oReader.read(new ChemFile()); Assert.assertNotNull(oChemFile); Assert.assertEquals(oChemFile.getChemSequenceCount(), 1); IChemSequence oSeq = oChemFile.getChemSequence(0); Assert.assertNotNull(oSeq); Assert.assertEquals(oSeq.getChemModelCount(), 1); IChemModel oModel = oSeq.getChemModel(0); Assert.assertNotNull(oModel); Assert.assertEquals(1, oModel.getMoleculeSet().getAtomContainerCount()); IAtomContainer container = oModel.getMoleculeSet().getAtomContainer(0); Assert.assertFalse(container instanceof IBioPolymer); Assert.assertTrue(container instanceof IAtomContainer); IAtomContainer oMol = (IAtomContainer) container; Assert.assertNotNull(oMol); Assert.assertEquals(oMol.getAtomCount(), 14); IAtom nAtom = oMol.getAtom(0); Assert.assertNotNull(nAtom); Assert.assertTrue(nAtom instanceof IPDBAtom); IPDBAtom oAtom = (IPDBAtom) nAtom; Assert.assertEquals(new String("C"), oAtom.getSymbol()); Assert.assertEquals(1, oAtom.getSerial().intValue()); Assert.assertEquals("C1", oAtom.getName()); Assert.assertEquals("MOL", oAtom.getResName()); Assert.assertEquals("1", oAtom.getResSeq()); Assert.assertEquals(1.0, oAtom.getOccupancy(), 0); Assert.assertEquals(0.0, oAtom.getTempFactor(), 0); nAtom = oMol.getAtom(3); Assert.assertNotNull(nAtom); Assert.assertTrue(nAtom instanceof IPDBAtom); oAtom = (IPDBAtom) nAtom; Assert.assertEquals("O", oAtom.getSymbol()); Assert.assertEquals(4, oAtom.getSerial().intValue()); Assert.assertEquals("O4", oAtom.getName()); Assert.assertEquals("MOL", oAtom.getResName()); Assert.assertEquals("1", oAtom.getResSeq()); Assert.assertEquals(1.0, oAtom.getOccupancy(), 0); Assert.assertEquals(0.0, oAtom.getTempFactor(), 0); nAtom = oMol.getAtom(oMol.getAtomCount()-1); Assert.assertNotNull(nAtom); Assert.assertTrue(nAtom instanceof IPDBAtom); oAtom = (IPDBAtom) nAtom; Assert.assertEquals("N", oAtom.getSymbol()); Assert.assertEquals(14, oAtom.getSerial().intValue()); Assert.assertEquals("N14", oAtom.getName()); Assert.assertEquals("MOL", oAtom.getResName()); Assert.assertEquals("1", oAtom.getResSeq()); Assert.assertEquals(1.0, oAtom.getOccupancy(), 0); Assert.assertEquals(0.0, oAtom.getTempFactor(), 0); }
@Test public void testProtein() throws Exception { String filename = "data/pdb/Test-1crn.pdb"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new PDBReader(ins); Assert.assertNotNull(reader); ChemFile chemFile = (ChemFile) reader.read(new ChemFile()); Assert.assertNotNull(chemFile); Assert.assertEquals(1, chemFile.getChemSequenceCount()); org.openscience.cdk.interfaces.IChemSequence seq = chemFile.getChemSequence(0); Assert.assertNotNull(seq); Assert.assertEquals(1, seq.getChemModelCount()); IChemModel model = seq.getChemModel(0); Assert.assertNotNull(model); Assert.assertEquals(1, model.getMoleculeSet().getAtomContainerCount()); IAtomContainer container = model.getMoleculeSet().getAtomContainer(0); Assert.assertTrue(container instanceof IBioPolymer); IBioPolymer mol = (IBioPolymer) container; Assert.assertNotNull(mol); Assert.assertEquals(327, mol.getAtomCount()); Assert.assertEquals(46, mol.getMonomerCount()); Assert.assertNotNull(mol.getMonomer("THRA1", "A")); Assert.assertEquals(7, mol.getMonomer("THRA1", "A").getAtomCount()); Assert.assertNotNull(mol.getMonomer("ILEA7", "A")); Assert.assertEquals(8, mol.getMonomer("ILEA7", "A").getAtomCount()); IAtom nAtom = mol.getAtom(94); Assert.assertNotNull(nAtom); Assert.assertTrue(nAtom instanceof PDBAtom); PDBAtom atom = (PDBAtom) nAtom; Assert.assertEquals("C", atom.getSymbol()); Assert.assertEquals(95, atom.getSerial().intValue()); Assert.assertEquals("CZ", atom.getName()); Assert.assertEquals("PHE", atom.getResName()); Assert.assertEquals("13", atom.getResSeq()); Assert.assertEquals(1.0, atom.getOccupancy(), 0.001); Assert.assertEquals(6.84, atom.getTempFactor(), 0.001); }
@Test public void test114D() throws Exception { String filename = "data/pdb/114D.pdb"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new PDBReader(ins); Assert.assertNotNull(reader); IChemFile chemFile = (IChemFile) reader.read(new ChemFile()); Assert.assertNotNull(chemFile); Assert.assertEquals(1, chemFile.getChemSequenceCount()); org.openscience.cdk.interfaces.IChemSequence seq = chemFile.getChemSequence(0); Assert.assertNotNull(seq); Assert.assertEquals(1, seq.getChemModelCount()); IChemModel model = seq.getChemModel(0); Assert.assertNotNull(model); Assert.assertEquals(1, model.getMoleculeSet().getAtomContainerCount()); IAtomContainer container = model.getMoleculeSet().getAtomContainer(0); Assert.assertTrue(container instanceof IBioPolymer); IBioPolymer polymer = (IBioPolymer) container; Assert.assertTrue("Strand A is not a PDBStrand", polymer.getStrand("A") instanceof PDBStrand); PDBStrand strandA = (PDBStrand) polymer.getStrand("A"); Iterator<String> lst = strandA.getMonomerNamesInSequentialOrder().iterator(); String monomer1 = lst.next(); IMonomer mono1 = strandA.getMonomer(monomer1); Assert.assertNotNull(mono1); Assert.assertNotNull(mono1.getMonomerName()); Assert.assertTrue("Monomer is not a PDBMonomer", mono1 instanceof PDBMonomer); PDBMonomer pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals(pdbMonomer.getResSeq(), "1"); String monomer2 = lst.next(); IMonomer mono2 = strandA.getMonomer(monomer2); Assert.assertTrue("Monomer is not a PDBMonomer", mono2 instanceof PDBMonomer); PDBMonomer pdbMonomer2 = (PDBMonomer) mono2; Assert.assertEquals(pdbMonomer2.getResSeq(), "2"); Assert.assertEquals(552, ChemFileManipulator.getAtomCount(chemFile)); Assert.assertEquals(2, polymer.getStrandCount()); Assert.assertEquals(24, polymer.getMonomerCount()); Assert.assertTrue(polymer.getStrandNames().contains("A")); Assert.assertTrue(polymer.getStrandNames().contains("B")); Assert.assertFalse(polymer.getStrandNames().contains("C")); Assert.assertEquals(24, polymer.getMonomerCount()); Assert.assertTrue(polymer instanceof PDBPolymer); PDBPolymer pdb = (PDBPolymer) polymer; Assert.assertEquals(0, pdb.getStructures().size()); }
@Test public void test1D66() throws Exception { String filename = "data/pdb/1D66.pdb"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new PDBReader(ins); Assert.assertNotNull(reader); IChemFile chemFile = (IChemFile) reader.read(new ChemFile()); Assert.assertNotNull(chemFile); Assert.assertEquals(1, chemFile.getChemSequenceCount()); org.openscience.cdk.interfaces.IChemSequence seq = chemFile.getChemSequence(0); Assert.assertNotNull(seq); Assert.assertEquals(1, seq.getChemModelCount()); IChemModel model = seq.getChemModel(0); Assert.assertNotNull(model); Assert.assertEquals(1, model.getMoleculeSet().getAtomContainerCount()); IAtomContainer container = model.getMoleculeSet().getAtomContainer(0); Assert.assertTrue(container instanceof IBioPolymer); IBioPolymer polymer = (IBioPolymer) container; Assert.assertTrue(polymer instanceof PDBPolymer); PDBPolymer pdb = (PDBPolymer) polymer; Assert.assertEquals(4, pdb.getStrandCount()); Assert.assertTrue(polymer.getStrandNames().contains("D")); Assert.assertTrue("Strand D is not a PDBStrand", polymer.getStrand("D") instanceof PDBStrand); Assert.assertTrue(polymer.getStrandNames().contains("E")); Assert.assertTrue("Strand E is not a PDBStrand", polymer.getStrand("E") instanceof PDBStrand); Assert.assertTrue(polymer.getStrandNames().contains("A")); Assert.assertTrue("Strand A is not a PDBStrand", polymer.getStrand("A") instanceof PDBStrand); Assert.assertTrue(polymer.getStrandNames().contains("B")); Assert.assertTrue("Strand B is not a PDBStrand", polymer.getStrand("B") instanceof PDBStrand); Assert.assertEquals(polymer.getStrands().size(), 4); PDBStrand strandA = (PDBStrand) polymer.getStrand("A"); Collection<String> lst = strandA.getMonomerNamesInSequentialOrder(); Assert.assertEquals(57, lst.size()); Iterator<String> lstIter = lst.iterator(); String monomer1 = lstIter.next(); IMonomer mono1 = strandA.getMonomer(monomer1); Assert.assertNotNull(mono1); Assert.assertNotNull(mono1.getMonomerName()); Assert.assertTrue("Monomer is not a PDBMonomer", mono1 instanceof PDBMonomer); PDBMonomer pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("A", pdbMonomer.getChainID()); Assert.assertEquals("8", pdbMonomer.getResSeq()); monomer1 = lstIter.next(); mono1 = strandA.getMonomer(monomer1); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("A", pdbMonomer.getChainID()); Assert.assertEquals("9", pdbMonomer.getResSeq()); monomer1 = lstIter.next(); mono1 = strandA.getMonomer(monomer1); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("A", pdbMonomer.getChainID()); Assert.assertEquals("10", pdbMonomer.getResSeq()); PDBStrand strandB = (PDBStrand) polymer.getStrand("B"); lst = strandB.getMonomerNamesInSequentialOrder(); Assert.assertEquals(57, lst.size()); lstIter = lst.iterator(); monomer1 = lstIter.next(); mono1 = strandB.getMonomer(monomer1); Assert.assertNotNull(mono1); Assert.assertNotNull(mono1.getMonomerName()); Assert.assertTrue("Monomer is not a PDBMonomer", mono1 instanceof PDBMonomer); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("B", pdbMonomer.getChainID()); Assert.assertEquals("8", pdbMonomer.getResSeq()); monomer1 = lstIter.next(); mono1 = strandB.getMonomer(monomer1); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("B", pdbMonomer.getChainID()); Assert.assertEquals("9", pdbMonomer.getResSeq()); monomer1 = lstIter.next(); mono1 = strandB.getMonomer(monomer1); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("B", pdbMonomer.getChainID()); Assert.assertEquals("10", pdbMonomer.getResSeq()); PDBStrand strandE = (PDBStrand) polymer.getStrand("E"); lst = strandE.getMonomerNamesInSequentialOrder(); Assert.assertEquals(19, lst.size()); lstIter = lst.iterator(); monomer1 = lstIter.next(); mono1 = strandE.getMonomer(monomer1); Assert.assertNotNull(mono1); Assert.assertNotNull(mono1.getMonomerName()); Assert.assertTrue("Monomer is not a PDBMonomer", mono1 instanceof PDBMonomer); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("E", pdbMonomer.getChainID()); Assert.assertEquals("20", pdbMonomer.getResSeq()); monomer1 = lstIter.next(); mono1 = strandE.getMonomer(monomer1); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("E", pdbMonomer.getChainID()); Assert.assertEquals("21", pdbMonomer.getResSeq()); monomer1 = lstIter.next(); mono1 = strandE.getMonomer(monomer1); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("E", pdbMonomer.getChainID()); Assert.assertEquals("22", pdbMonomer.getResSeq()); PDBStrand strandD = (PDBStrand) polymer.getStrand("D"); lst = strandD.getMonomerNamesInSequentialOrder(); Assert.assertEquals(19, lst.size()); lstIter = lst.iterator(); monomer1 = lstIter.next(); mono1 = strandD.getMonomer(monomer1); Assert.assertNotNull(mono1); Assert.assertNotNull(mono1.getMonomerName()); Assert.assertTrue("Monomer is not a PDBMonomer", mono1 instanceof PDBMonomer); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("D", pdbMonomer.getChainID()); Assert.assertEquals("1", pdbMonomer.getResSeq()); monomer1 = lstIter.next(); mono1 = strandD.getMonomer(monomer1); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("D", pdbMonomer.getChainID()); Assert.assertEquals("2", pdbMonomer.getResSeq()); monomer1 = lstIter.next(); mono1 = strandD.getMonomer(monomer1); pdbMonomer = (PDBMonomer) mono1; Assert.assertEquals("D", pdbMonomer.getChainID()); Assert.assertEquals("3", pdbMonomer.getResSeq()); Assert.assertEquals(6, pdb.getStructures().size()); }
@Category(SlowTest.class) @Test public void readFinalPump() throws Exception { IChemFile chemFile = new PDBReader(getClass().getResourceAsStream("finalPump96.09.06.pdb")).read(new ChemFile()); }