Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Weird SDF output

View foo.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
package net.sf.cdk.tools;
 
import org.openscience.cdk.ChemFile;
import org.openscience.cdk.MoleculeSet;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.io.MDLV2000Reader;
import org.openscience.cdk.io.SDFWriter;
import org.openscience.cdk.io.listener.PropertiesListener;
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
 
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
 
/**
* A one line summary.
*
* @author Rajarshi Guha
*/
public class foo {
public static void main(String[] args) throws CDKException, IOException {
MDLV2000Reader reader = new MDLV2000Reader(new FileReader("/Users/guhar/tmp/nci10_original.sdf"));
ChemFile chemFile = reader.read(new ChemFile());
List<IAtomContainer> mols = ChemFileManipulator.getAllAtomContainers(chemFile);
 
for (int i = 0; i < mols.size(); i++) {
try {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mols.get(i));
} catch (CDKException e) {
 
}
}
 
SDFWriter writer = new SDFWriter(new FileWriter("foo.sdf"));
 
Properties sdfWriterProps = new Properties();
sdfWriterProps.put("writeProperties", "false");
writer.addChemObjectIOListener(
new PropertiesListener(sdfWriterProps)
);
writer.customizeJob();
 
IMoleculeSet molset = new MoleculeSet();
for (IAtomContainer mol : mols) molset.addAtomContainer(mol);
writer.write(molset);
writer.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.