logger.info("Adding crystal to file with #atoms: ", crystal.getAtomCount()); model.setCrystal(crystal); seq.addChemModel(model);
logger.info("Adding crystal to file with #atoms: ", crystal.getAtomCount()); model.setCrystal(crystal); seq.addChemModel(model);
/** * Get the total number of atoms inside an IChemModel. * * @param chemModel The IChemModel object. * @return The number of Atom object inside. */ public static int getAtomCount(IChemModel chemModel) { int count = 0; ICrystal crystal = chemModel.getCrystal(); if (crystal != null) { count += crystal.getAtomCount(); } IAtomContainerSet moleculeSet = chemModel.getMoleculeSet(); if (moleculeSet != null) { count += MoleculeSetManipulator.getAtomCount(moleculeSet); } IReactionSet reactionSet = chemModel.getReactionSet(); if (reactionSet != null) { count += ReactionSetManipulator.getAtomCount(reactionSet); } return count; }
@Test public void cod1100784AtomCount() throws IOException, CDKException { InputStream in = getClass().getResourceAsStream("1100784.cif"); CIFReader cifReader = new CIFReader(in); IChemFile chemFile = cifReader.read(new ChemFile()); ICrystal crystal = chemFile.getChemSequence(0).getChemModel(0).getCrystal(); Assert.assertEquals(72, crystal.getAtomCount()); cifReader.close(); }
Assert.assertEquals(4, crystal.getZ().intValue()); Assert.assertEquals("Fm3m", crystal.getSpaceGroup()); Assert.assertEquals(2, crystal.getAtomCount()); Vector3d aaxis = crystal.getA(); Assert.assertEquals(4.5, aaxis.x, 0.1);
Assert.assertEquals(4, crystal.getZ().intValue()); Assert.assertEquals("Fm3m", crystal.getSpaceGroup()); Assert.assertEquals(2, crystal.getAtomCount()); Vector3d aaxis = crystal.getA(); Assert.assertEquals(4.5, aaxis.x, 0.1);
int noatoms = crystal.getAtomCount(); write(Integer.toString(noatoms)); writeln("");
@Test public void testCrystal() { ICrystal crystal = new Crystal(); Assert.assertNotNull(crystal); Assert.assertEquals(0, crystal.getAtomCount()); Assert.assertEquals(0, crystal.getBondCount()); }
@Test public void testCrystal() { ICrystal crystal = new Crystal(); Assert.assertNotNull(crystal); Assert.assertEquals(0, crystal.getAtomCount()); Assert.assertEquals(0, crystal.getBondCount()); }
@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 testDebugCrystal() { ICrystal crystal = new DebugCrystal(); Assert.assertNotNull(crystal); Assert.assertEquals(0, crystal.getAtomCount()); Assert.assertEquals(0, crystal.getBondCount()); }
@Test public void testReading() throws Exception { String filename = "data/vasp/LiMoS2_optimisation_ISIF3.vasp"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); VASPReader reader = new VASPReader(ins); ChemFile chemFile = (ChemFile) reader.read(new ChemFile()); Assert.assertNotNull(chemFile); org.openscience.cdk.interfaces.IChemSequence sequence = chemFile.getChemSequence(0); Assert.assertNotNull(sequence); Assert.assertEquals(6, sequence.getChemModelCount()); org.openscience.cdk.interfaces.IChemModel model = sequence.getChemModel(0); Assert.assertNotNull(model); org.openscience.cdk.interfaces.ICrystal crystal = model.getCrystal(); Assert.assertNotNull(crystal); Assert.assertEquals(16, crystal.getAtomCount()); org.openscience.cdk.interfaces.IAtom atom = crystal.getAtom(0); Assert.assertNotNull(atom); Assert.assertNotNull(atom.getFractionalPoint3d()); } }
@Test public void testTwoAceticAcid() throws Exception { String filename = "data/pmp/two_aceticacid.pmp"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); PMPReader reader = new PMPReader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); reader.close(); Assert.assertNotNull(chemFile); Assert.assertEquals(1, chemFile.getChemSequenceCount()); IChemSequence seq = chemFile.getChemSequence(0); Assert.assertNotNull(seq); Assert.assertEquals(2, seq.getChemModelCount()); IChemModel model = seq.getChemModel(0); Assert.assertNotNull(model); ICrystal crystal = model.getCrystal(); Assert.assertNotNull(crystal); Assert.assertEquals(32, crystal.getAtomCount()); Assert.assertEquals(28, crystal.getBondCount()); model = seq.getChemModel(1); Assert.assertNotNull(model); crystal = model.getCrystal(); Assert.assertNotNull(crystal); Assert.assertEquals(32, crystal.getAtomCount()); Assert.assertEquals(28, crystal.getBondCount()); } }
Assert.assertEquals(4 * 42, crystal.getAtomCount()); Assert.assertTrue(GeometryUtil.has3DCoordinates(crystal));
@Test public void testAceticAcid() throws Exception { String filename = "data/pmp/aceticacid.pmp"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); PMPReader reader = new PMPReader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); reader.close(); Assert.assertNotNull(chemFile); Assert.assertEquals(1, chemFile.getChemSequenceCount()); IChemSequence seq = chemFile.getChemSequence(0); Assert.assertNotNull(seq); Assert.assertEquals(1, seq.getChemModelCount()); IChemModel model = seq.getChemModel(0); Assert.assertNotNull(model); ICrystal crystal = model.getCrystal(); Assert.assertNotNull(crystal); Assert.assertEquals(32, crystal.getAtomCount()); Assert.assertEquals(28, crystal.getBondCount()); Assert.assertEquals("O", crystal.getAtom(6).getSymbol()); Assert.assertEquals(1.4921997, crystal.getAtom(6).getPoint3d().x, 0.00001); Assert.assertEquals("O", crystal.getAtom(7).getSymbol()); Assert.assertEquals(1.4922556, crystal.getAtom(7).getPoint3d().x, 0.00001); }
Assert.assertEquals(42, crystal.getAtomCount()); Assert.assertEquals(1, crystal.getZ().intValue());
@Test @Override public void testAdd_IAtomContainer() { ICrystal crystal = (ICrystal) newChemObject(); IAtomContainer acetone = crystal.getBuilder().newInstance(IAtomContainer.class); IAtom c1 = crystal.getBuilder().newInstance(IAtom.class, "C"); IAtom c2 = crystal.getBuilder().newInstance(IAtom.class, "C"); IAtom o = crystal.getBuilder().newInstance(IAtom.class, "O"); IAtom c3 = crystal.getBuilder().newInstance(IAtom.class, "C"); acetone.addAtom(c1); acetone.addAtom(c2); acetone.addAtom(c3); acetone.addAtom(o); IBond b1 = crystal.getBuilder().newInstance(IBond.class, c1, c2, IBond.Order.SINGLE); IBond b2 = crystal.getBuilder().newInstance(IBond.class, c1, o, IBond.Order.DOUBLE); IBond b3 = crystal.getBuilder().newInstance(IBond.class, c1, c3, IBond.Order.SINGLE); acetone.addBond(b1); acetone.addBond(b2); acetone.addBond(b3); crystal.add(acetone); Assert.assertEquals(4, crystal.getAtomCount()); Assert.assertEquals(3, crystal.getBondCount()); }
@Test public void testCrystal_IAtomContainer() { IAtomContainer acetone = newChemObject().getBuilder().newInstance(IAtomContainer.class); IAtom c1 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom c2 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom o = acetone.getBuilder().newInstance(IAtom.class, "O"); IAtom c3 = acetone.getBuilder().newInstance(IAtom.class, "C"); acetone.addAtom(c1); acetone.addAtom(c2); acetone.addAtom(c3); acetone.addAtom(o); IBond b1 = acetone.getBuilder().newInstance(IBond.class, c1, c2, IBond.Order.SINGLE); IBond b2 = acetone.getBuilder().newInstance(IBond.class, c1, o, IBond.Order.DOUBLE); IBond b3 = acetone.getBuilder().newInstance(IBond.class, c1, c3, IBond.Order.SINGLE); acetone.addBond(b1); acetone.addBond(b2); acetone.addBond(b3); ICrystal crystal = new Crystal(acetone); Assert.assertNotNull(crystal); Assert.assertEquals(4, crystal.getAtomCount()); Assert.assertEquals(3, crystal.getBondCount()); }
@Test public void testCrystal_IAtomContainer() { IChemObject object = newChemObject(); IAtomContainer acetone = object.getBuilder().newInstance(IAtomContainer.class); IAtom c1 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom c2 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom o = acetone.getBuilder().newInstance(IAtom.class, "O"); IAtom c3 = acetone.getBuilder().newInstance(IAtom.class, "C"); acetone.addAtom(c1); acetone.addAtom(c2); acetone.addAtom(c3); acetone.addAtom(o); IBond b1 = acetone.getBuilder().newInstance(IBond.class, c1, c2, IBond.Order.SINGLE); IBond b2 = acetone.getBuilder().newInstance(IBond.class, c1, o, IBond.Order.DOUBLE); IBond b3 = acetone.getBuilder().newInstance(IBond.class, c1, c3, IBond.Order.SINGLE); acetone.addBond(b1); acetone.addBond(b2); acetone.addBond(b3); ICrystal crystal = new Crystal(acetone); Assert.assertNotNull(crystal); Assert.assertEquals(4, crystal.getAtomCount()); Assert.assertEquals(3, crystal.getBondCount()); }
@Test public void testDebugCrystal_IAtomContainer() { IAtomContainer acetone = newChemObject().getBuilder().newInstance(IAtomContainer.class); IAtom c1 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom c2 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom o = acetone.getBuilder().newInstance(IAtom.class, "O"); IAtom c3 = acetone.getBuilder().newInstance(IAtom.class, "C"); acetone.addAtom(c1); acetone.addAtom(c2); acetone.addAtom(c3); acetone.addAtom(o); IBond b1 = acetone.getBuilder().newInstance(IBond.class, c1, c2, IBond.Order.SINGLE); IBond b2 = acetone.getBuilder().newInstance(IBond.class, c1, o, IBond.Order.DOUBLE); IBond b3 = acetone.getBuilder().newInstance(IBond.class, c1, c3, IBond.Order.SINGLE); acetone.addBond(b1); acetone.addBond(b2); acetone.addBond(b3); ICrystal crystal = new DebugCrystal(acetone); Assert.assertNotNull(crystal); Assert.assertEquals(4, crystal.getAtomCount()); Assert.assertEquals(3, crystal.getBondCount()); } }