Skip to content

@rajarshi /foo.java
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Weird SDF output
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.