IAtom atom = crystal.getBuilder().newInstance(IAtom.class, atype); atom.setFractionalPoint3d(new Point3d(frac[0], frac[1], frac[2])); crystal.addAtom(atom); logger.debug("Atom added: ", atom);
IAtom atom = crystal.getBuilder().newInstance(IAtom.class, atype); atom.setFractionalPoint3d(new Point3d(frac[0], frac[1], frac[2])); crystal.addAtom(atom); logger.debug("Atom added: ", atom);
crystal.addAtom(atom);
crystal.addAtom(atom);
crystal.addAtom(atom); logger.debug("Added atom: ", atom);
@Test @Override public void testAddAtom_IAtom() { ICrystal crystal = (ICrystal) newChemObject(); IAtom c1 = crystal.getBuilder().newInstance(IAtom.class, "C"); crystal.addAtom(c1); Assert.assertEquals(1, crystal.getAtomCount()); }
@Test public void testCMLCrystal() throws Exception { StringWriter writer = new StringWriter(); ICrystal crystal = new Crystal(); IAtom silicon = new Atom("Si"); silicon.setFractionalPoint3d(new Point3d(0.0, 0.0, 0.0)); crystal.addAtom(silicon); crystal.setA(new Vector3d(1.5, 0.0, 0.0)); crystal.setB(new Vector3d(0.0, 2.0, 0.0)); crystal.setC(new Vector3d(0.0, 0.0, 1.5)); CMLWriter cmlWriter = new CMLWriter(writer); cmlWriter.write(crystal); cmlWriter.close(); String cmlContent = writer.toString(); logger.debug("****************************** testCMLCrystal()"); logger.debug(cmlContent); logger.debug("******************************"); Assert.assertTrue(cmlContent.indexOf("</crystal>") != -1); // the cystal info has to be present Assert.assertTrue(cmlContent.indexOf("<atom") != -1); // an Atom has to be present }
frac[2] = xred[i][2]; atom.setFractionalPoint3d(new Point3d(frac[0], frac[1], frac[2])); crystal.addAtom(atom);
@Test public void testIsEmpty_Crystal() { IChemModel model = (IChemModel) newChemObject(); IChemObjectBuilder builder = model.getBuilder(); ICrystal crystal = builder.newInstance(ICrystal.class); model.setCrystal(crystal); Assert.assertTrue(model.isEmpty()); crystal.addAtom(builder.newInstance(IAtom.class, "C")); Assert.assertFalse(model.isEmpty()); model.setCrystal(null); Assert.assertTrue(model.isEmpty()); }
@Test public void testRoundTrip() throws Exception { StringWriter sWriter = new StringWriter(); PDBWriter writer = new PDBWriter(sWriter); ICrystal crystal = builder.newInstance(ICrystal.class); crystal.setA(new Vector3d(0, 1, 0)); crystal.setB(new Vector3d(1, 0, 0)); crystal.setC(new Vector3d(0, 0, 2)); IAtom atom = builder.newInstance(IAtom.class, "C"); atom.setPoint3d(new Point3d(0.1, 0.1, 0.3)); crystal.addAtom(atom); writer.write(crystal); writer.close(); String output = sWriter.toString(); Assert.assertNotNull(output); Assert.assertTrue(output.length() > 0); PDBReader reader = new PDBReader(); ChemFile chemFile = (ChemFile) reader.read(new ChemFile()); reader.close(); Assert.assertNotNull(chemFile); Assert.assertEquals(1, chemFile.getChemSequenceCount()); IChemSequence sequence = chemFile.getChemSequence(0); Assert.assertEquals(1, sequence.getChemModelCount()); IChemModel chemModel = sequence.getChemModel(0); Assert.assertNotNull(chemModel); // can't do further testing as the PDBReader does not read // Crystal structures :( }