Skip to content

Commit

Permalink
Write atom parity
Browse files Browse the repository at this point in the history
Writes the atom stereo parity for MDLV2000 format
  • Loading branch information
johnmay authored and egonw committed Feb 19, 2012
1 parent 8ff4584 commit c7aa428
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/org/openscience/cdk/io/MDLV2000Writer.java
Expand Up @@ -322,7 +322,7 @@ public void writeMolecule(IAtomContainer container) throws Exception {
}else{
line += formatMDLString(container.getAtom(f).getSymbol(), 3);
}
line += " 0 0 0 0 0";
line += String.format(" 0 0 %d 0 0", atom.getStereoParity() == null ? 0 : atom.getStereoParity());
if (writeQueryFormatValencies.isSet() &&
atom.getValency() != (Integer)CDKConstants.UNSET) {
// valence 0 is defined as 15 in mol files - but this writer
Expand Down
21 changes: 20 additions & 1 deletion src/test/org/openscience/cdk/io/MDLV2000WriterTest.java
Expand Up @@ -23,7 +23,7 @@
*/
package org.openscience.cdk.io;


import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.Properties;
Expand Down Expand Up @@ -359,6 +359,25 @@ public void testUnsupportedBondOrder() throws Exception {
mdlWriter.write(benzene);
Assert.assertTrue(writer.toString().indexOf("2 1 4 0 0 0 0") != -1);
}

@Test
public void testAtomParity() throws CDKException, IOException{

InputStream in = ClassLoader.getSystemResourceAsStream("data/mdl/mol_testAtomParity.mol");
MDLV2000Reader reader = new MDLV2000Reader(in);
IAtomContainer molecule = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
reader.read(molecule);
reader.close();

StringWriter sw =new StringWriter();
MDLV2000Writer writer = new MDLV2000Writer(sw);
writer.write(molecule);
writer.close();

Assert.assertTrue(writer.toString().contains(" -1.1749 0.1436 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0"));


}

@Test
public void testWritePseudoAtoms() throws Exception {
Expand Down

0 comments on commit c7aa428

Please sign in to comment.