@Test public void testWriteValence() throws Exception { StringWriter writer = new StringWriter(); IAtomContainer molecule = TestMoleculeFactory.makeAlphaPinene(); molecule.getAtom(0).setValency(1); molecule.getAtom(1).setValency(0); MDLV2000Writer mdlWriter = new MDLV2000Writer(writer); Properties customSettings = new Properties(); customSettings.setProperty("WriteQueryFormatValencies", "true"); mdlWriter.addChemObjectIOListener(new PropertiesListener(customSettings)); mdlWriter.write(molecule); mdlWriter.close(); String output = writer.toString(); Assert.assertTrue(output.indexOf("0 0 0 0 0 1 0 0 0 0 0 0") != -1); Assert.assertTrue(output.indexOf("0 0 0 0 0 15 0 0 0 0 0 0") != -1); }
@Test public void testForce2DCoordinates() throws Exception { StringWriter writer = new StringWriter(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); IAtom atom = builder.newInstance(IAtom.class, "C"); atom.setPoint2d(new Point2d(1.0, 2.0)); atom.setPoint3d(new Point3d(3.0, 4.0, 5.0)); molecule.addAtom(atom); MDLV2000Writer mdlWriter = new MDLV2000Writer(writer); Properties prop = new Properties(); prop.setProperty("ForceWriteAs2DCoordinates", "true"); PropertiesListener listener = new PropertiesListener(prop); mdlWriter.addChemObjectIOListener(listener); mdlWriter.customizeJob(); mdlWriter.write(molecule); mdlWriter.close(); String output = writer.toString(); // the current behavior is that if both 2D and 3D coordinates // are available, the 3D is outputted, and the 2D not Assert.assertTrue(output.contains("1.0")); Assert.assertTrue(output.contains("2.0")); }
prop.setProperty("WriteAromaticBondTypes", "true"); PropertiesListener listener = new PropertiesListener(prop); mdlWriter.addChemObjectIOListener(listener); mdlWriter.customizeJob(); mdlWriter.write(benzene);