Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'foo'
  • Loading branch information
rajarshi committed Feb 3, 2012
2 parents 751c1b9 + d9b1b08 commit b1827a7
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 45 deletions.
Expand Up @@ -15,7 +15,7 @@
/**
* Iterate over conformers of a collection of molecules stored in SDF format.
* <p/>
* This class is analogous to the {@link org.openscience.cdk.io.iterator.IteratingMDLReader} except that
* This class is analogous to the {@link org.openscience.cdk.io.iterator.IteratingSDFReader} except that
* rather than return a single {@link org.openscience.cdk.interfaces.IMolecule} at each iteration this
* class will return all the conformers for a given molecule at each iteration.
* <p/>
Expand Down Expand Up @@ -50,7 +50,7 @@
*/
@TestClass("org.openscience.cdk.io.iterator.IteratingMDLConformerReaderTest")
public class IteratingMDLConformerReader implements Iterator {
private IteratingMDLReader imdlr;
private IteratingSDFReader imdlr;
private ConformerContainer container;
private IAtomContainer lastMol = null;

Expand All @@ -59,13 +59,13 @@ public class IteratingMDLConformerReader implements Iterator {

@TestMethod("testSDF")
public IteratingMDLConformerReader(Reader in, IChemObjectBuilder builder) {
imdlr = new IteratingMDLReader(in, builder);
imdlr = new IteratingSDFReader(in, builder);
container = new ConformerContainer();
}

@TestMethod("testSDF")
public IteratingMDLConformerReader(InputStream in, IChemObjectBuilder builder) {
imdlr = new IteratingMDLReader(in, builder);
imdlr = new IteratingSDFReader(in, builder);
container = new ConformerContainer();
}

Expand Down
Expand Up @@ -32,6 +32,7 @@
import java.io.StringReader;
import java.util.NoSuchElementException;

import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtomContainer;
Expand Down Expand Up @@ -81,12 +82,13 @@
* @cdk.keyword file format, MDL molfile
* @cdk.keyword file format, SDF
*/
public class IteratingMDLReader extends DefaultIteratingChemObjectReader<IAtomContainer>
@TestClass("org.openscience.cdk.io.iterator.IteratingSDFReaderTest")
public class IteratingSDFReader extends DefaultIteratingChemObjectReader<IAtomContainer>
implements IChemObjectIOListener {

private BufferedReader input;
private static ILoggingTool logger =
LoggingToolFactory.createLoggingTool(IteratingMDLReader.class);
LoggingToolFactory.createLoggingTool(IteratingSDFReader.class);
private String currentLine;
private IChemFormat currentFormat;
private final ReaderFactory factory = new ReaderFactory();
Expand All @@ -104,7 +106,7 @@ public class IteratingMDLReader extends DefaultIteratingChemObjectReader<IAtomCo
* @param in The Reader to read from
* @param builder The builder
*/
public IteratingMDLReader(Reader in, IChemObjectBuilder builder) {
public IteratingSDFReader(Reader in, IChemObjectBuilder builder) {
this.builder = builder;
setReader(in);
initIOSettings();
Expand All @@ -116,7 +118,8 @@ public IteratingMDLReader(Reader in, IChemObjectBuilder builder) {
* @param in The InputStream to read from
* @param builder The builder
*/
public IteratingMDLReader(InputStream in, IChemObjectBuilder builder) {
@TestMethod("testReadDataItems")
public IteratingSDFReader(InputStream in, IChemObjectBuilder builder) {
this(new InputStreamReader(in), builder);
}

Expand Down
Expand Up @@ -42,7 +42,7 @@
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IRingSet;
import org.openscience.cdk.io.MDLV2000Writer;
import org.openscience.cdk.io.iterator.IteratingMDLReader;
import org.openscience.cdk.io.iterator.IteratingSDFReader;
import org.openscience.cdk.isomorphism.matchers.QueryAtomContainerCreator;
import org.openscience.cdk.ringsearch.AllRingsFinder;
import org.openscience.cdk.ringsearch.RingPartitioner;
Expand All @@ -69,12 +69,12 @@ public TemplateExtractor() {
}

public void cleanDataSet(String dataFile) {
IteratingMDLReader imdl = null;
IteratingSDFReader imdl = null;
IAtomContainerSet som = builder.newInstance(IAtomContainerSet.class);
try {
System.out.println("Start clean dataset...");
BufferedReader fin = new BufferedReader(new FileReader(dataFile));
imdl = new IteratingMDLReader(fin, builder);
imdl = new IteratingSDFReader(fin, builder);
System.out.print("Read File in..");
} catch (Exception exc) {
System.out.println("Could not read Molecules from file " + dataFile
Expand Down Expand Up @@ -106,12 +106,12 @@ public void cleanDataSet(String dataFile) {
}

public void ReadNCISdfFileAsTemplate(String dataFile) {
IteratingMDLReader imdl = null;
IteratingSDFReader imdl = null;
IAtomContainerSet som = builder.newInstance(IAtomContainerSet.class);
try {
System.out.println("Start...");
BufferedReader fin = new BufferedReader(new FileReader(dataFile));
imdl = new IteratingMDLReader(fin, builder);
imdl = new IteratingSDFReader(fin, builder);
System.out.print("Read File in..");
} catch (Exception exc) {
System.out.println("Could not read Molecules from file " + dataFile
Expand All @@ -131,13 +131,13 @@ public void ReadNCISdfFileAsTemplate(String dataFile) {
}

public void PartitionRingsFromComplexRing(String dataFile) {
IteratingMDLReader imdl = null;
IteratingSDFReader imdl = null;
IAtomContainerSet som = builder.newInstance(IAtomContainerSet.class);
IAtomContainer m = null;
try {
System.out.println("Start...");
BufferedReader fin = new BufferedReader(new FileReader(dataFile));
imdl = new IteratingMDLReader(fin, builder);
imdl = new IteratingSDFReader(fin, builder);
System.out.print("Read File in..");
} catch (Exception exc) {
System.out.println("Could not read Molecules from file " + dataFile
Expand Down Expand Up @@ -169,7 +169,7 @@ public void extractUniqueRingSystemsFromFile(String dataFile) {
IAtomContainer m = null;
// RingPartitioner ringPartitioner=new RingPartitioner();
List<IRingSet> ringSystems = null;
IteratingMDLReader imdl = null;
IteratingSDFReader imdl = null;

HashMap<String,String> hashRingSystems = new HashMap<String,String>();
SmilesGenerator smilesGenerator = new SmilesGenerator();
Expand All @@ -196,7 +196,7 @@ public void extractUniqueRingSystemsFromFile(String dataFile) {
try {
System.out.println("Start...");
BufferedReader fin = new BufferedReader(new FileReader(dataFile));
imdl = new IteratingMDLReader(fin, builder);
imdl = new IteratingSDFReader(fin, builder);
System.out.println("Read File in..");
} catch (Exception exc) {
System.out.println("Could not read Molecules from file " + dataFile
Expand Down Expand Up @@ -307,14 +307,14 @@ public void makeCanonicalSmileFromRingSystems(String dataFileIn,
String dataFileOut) {
System.out.println("Start make SMILES...");
IAtomContainer m = null;
IteratingMDLReader imdl = null;
IteratingSDFReader imdl = null;
// QueryAtomContainer query=null;
List<String> data = new ArrayList<String>();
SmilesGenerator smiles = new SmilesGenerator();
try {
System.out.println("Start...");
BufferedReader fin = new BufferedReader(new FileReader(dataFileIn));
imdl = new IteratingMDLReader(fin, builder);
imdl = new IteratingSDFReader(fin, builder);
// fin.close();
System.out.println("Read File in..");
} catch (Exception exc) {
Expand Down Expand Up @@ -378,13 +378,13 @@ public List<BitSet> makeFingerprintsFromSdf(boolean anyAtom, boolean anyAtomAnyB
HybridizationFingerprinter.DEFAULT_SIZE, HybridizationFingerprinter.DEFAULT_SEARCH_DEPTH
);
IAtomContainer m = null;
IteratingMDLReader imdl=null;
IteratingSDFReader imdl=null;
//QueryAtomContainer query=null;
IAtomContainer query = null;
List<BitSet> data = new ArrayList<BitSet>();
try {
System.out.print("Read data file in ...");
imdl = new IteratingMDLReader(fin, builder);
imdl = new IteratingSDFReader(fin, builder);
// fin.close();
System.out.println("ready");
} catch (Exception exc) {
Expand Down
Expand Up @@ -45,7 +45,7 @@
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IRingSet;
import org.openscience.cdk.io.iterator.IteratingMDLReader;
import org.openscience.cdk.io.iterator.IteratingSDFReader;
import org.openscience.cdk.isomorphism.UniversalIsomorphismTester;
import org.openscience.cdk.isomorphism.mcss.RMap;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
Expand Down Expand Up @@ -98,14 +98,14 @@ public static TemplateHandler3D getInstance() throws CDKException {
*/
private void loadTemplates() throws CDKException{
logger.debug("Loading templates...");
IteratingMDLReader imdl;
IteratingSDFReader imdl;
InputStream ins;
BufferedReader fin;

try {
ins = this.getClass().getClassLoader().getResourceAsStream("org/openscience/cdk/modeling/builder3d/data/ringTemplateStructures.sdf.gz");
fin = new BufferedReader(new InputStreamReader(new GZIPInputStream(ins)));
imdl = new IteratingMDLReader(fin, builder);
imdl = new IteratingSDFReader(fin, builder);
} catch (IOException exc1) {
throw new CDKException("Problems loading file ringTemplateStructures.sdf.gz", exc1);
}
Expand Down
Expand Up @@ -53,16 +53,16 @@
* @cdk.module test-io
* @see org.openscience.cdk.io.MDLReader
*/
public class IteratingMDLReaderTest extends CDKTestCase {
public class IteratingSDFReaderTest extends CDKTestCase {

private ILoggingTool logger =
LoggingToolFactory.createLoggingTool(IteratingMDLReaderTest.class);
LoggingToolFactory.createLoggingTool(IteratingSDFReaderTest.class);

@Test public void testSDF() throws Exception {
String filename = "data/mdl/test2.sdf";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(
IteratingSDFReader reader = new IteratingSDFReader(
ins, DefaultChemObjectBuilder.getInstance()
);

Expand Down Expand Up @@ -90,7 +90,7 @@ public boolean ready() throws IOException {
}
};

IteratingMDLReader reader = new IteratingMDLReader(
IteratingSDFReader reader = new IteratingSDFReader(
streamReader, DefaultChemObjectBuilder.getInstance()
);

Expand All @@ -111,7 +111,7 @@ public boolean ready() throws IOException {
String filename = "data/mdl/test.sdf";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(
IteratingSDFReader reader = new IteratingSDFReader(
ins, DefaultChemObjectBuilder.getInstance()
);

Expand All @@ -128,7 +128,7 @@ public boolean ready() throws IOException {
String filename = "data/mdl/test.sdf";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(
IteratingSDFReader reader = new IteratingSDFReader(
ins, DefaultChemObjectBuilder.getInstance()
);

Expand All @@ -145,7 +145,7 @@ public boolean ready() throws IOException {
@Test public void testMultipleEntryFields() throws Exception {
String filename = "data/mdl/test.sdf";
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(
IteratingSDFReader reader = new IteratingSDFReader(
ins, DefaultChemObjectBuilder.getInstance()
);

Expand All @@ -159,7 +159,7 @@ public boolean ready() throws IOException {
String filename = "data/mdl/bug682233.mol";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(
IteratingSDFReader reader = new IteratingSDFReader(
ins, DefaultChemObjectBuilder.getInstance()
);

Expand All @@ -178,7 +178,7 @@ public boolean ready() throws IOException {
String filename = "data/mdl/singleMol.sdf";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(
IteratingSDFReader reader = new IteratingSDFReader(
ins, DefaultChemObjectBuilder.getInstance()
);

Expand All @@ -197,7 +197,7 @@ public boolean ready() throws IOException {
String filename = "data/mdl/emptyStructures.sdf";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(
IteratingSDFReader reader = new IteratingSDFReader(
ins, DefaultChemObjectBuilder.getInstance()
);
int molCount = 0;
Expand Down Expand Up @@ -228,7 +228,7 @@ public boolean ready() throws IOException {
Properties prop = new Properties();
prop.setProperty("ForceReadAs3DCoordinates","true");
PropertiesListener listener = new PropertiesListener(prop);
IteratingMDLReader reader = new IteratingMDLReader(
IteratingSDFReader reader = new IteratingSDFReader(
ins, DefaultChemObjectBuilder.getInstance()
);
reader.addChemObjectIOListener(listener);
Expand All @@ -249,7 +249,7 @@ public boolean ready() throws IOException {
String filename = "data/mdl/no3dStructures.sdf";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(
IteratingSDFReader reader = new IteratingSDFReader(
ins, DefaultChemObjectBuilder.getInstance()
);
int molCount = 0;
Expand All @@ -269,7 +269,7 @@ public boolean ready() throws IOException {
// Now test forced 3D coordinates
logger.info("Testing: " + filename);
ins = this.getClass().getClassLoader().getResourceAsStream(filename);
reader = new IteratingMDLReader(
reader = new IteratingSDFReader(
ins, DefaultChemObjectBuilder.getInstance()
);
reader.addChemObjectIOListener(new MyListener());
Expand Down
4 changes: 2 additions & 2 deletions src/test/org/openscience/cdk/modulesuites/MioTests.java
Expand Up @@ -62,7 +62,7 @@
import org.openscience.cdk.io.XYZWriterTest;
import org.openscience.cdk.io.cml.CMLIOTests;
import org.openscience.cdk.io.iterator.IteratingMDLConformerReaderTest;
import org.openscience.cdk.io.iterator.IteratingMDLReaderTest;
import org.openscience.cdk.io.iterator.IteratingSDFReaderTest;
import org.openscience.cdk.io.iterator.IteratingPCCompoundASNReaderTest;
import org.openscience.cdk.io.iterator.IteratingPCCompoundXMLReaderTest;
import org.openscience.cdk.io.iterator.IteratingPCSubstancesXMLReaderTest;
Expand Down Expand Up @@ -114,7 +114,7 @@
ChemObjectIOInstantionTests.class,

// cdk.io.iterator package
IteratingMDLReaderTest.class,
IteratingSDFReaderTest.class,
IteratingMDLConformerReaderTest.class,
IteratingPCCompoundASNReaderTest.class,
IteratingPCCompoundXMLReaderTest.class,
Expand Down
Expand Up @@ -41,7 +41,7 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.io.iterator.IteratingMDLConformerReader;
import org.openscience.cdk.io.iterator.IteratingMDLReader;
import org.openscience.cdk.io.iterator.IteratingSDFReader;

/**
* @cdk.module test-pcore
Expand Down Expand Up @@ -227,7 +227,7 @@ public void testInvalidQuery() throws CDKException {
public void testCNSPcore() throws FileNotFoundException, CDKException {
String filename = "data/mdl/cnssmarts.sdf";
InputStream ins = PharmacophoreMatcherTest.class.getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(ins,
IteratingSDFReader reader = new IteratingSDFReader(ins,
DefaultChemObjectBuilder.getInstance()
);

Expand Down Expand Up @@ -258,7 +258,7 @@ public void testCNSPcore() throws FileNotFoundException, CDKException {
public void testMatchingBonds() throws FileNotFoundException, CDKException {
String filename = "data/mdl/cnssmarts.sdf";
InputStream ins = PharmacophoreMatcherTest.class.getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(ins,
IteratingSDFReader reader = new IteratingSDFReader(ins,
DefaultChemObjectBuilder.getInstance());

PharmacophoreQuery query = new PharmacophoreQuery();
Expand Down Expand Up @@ -295,7 +295,7 @@ public void testMatchingBonds() throws FileNotFoundException, CDKException {
public void testAngleMatch1() throws Exception {
String filename = "data/mdl/cnssmarts.sdf";
InputStream ins = PharmacophoreMatcherTest.class.getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(ins,
IteratingSDFReader reader = new IteratingSDFReader(ins,
DefaultChemObjectBuilder.getInstance());

PharmacophoreQuery query = new PharmacophoreQuery();
Expand All @@ -321,7 +321,7 @@ public void testAngleMatch1() throws Exception {
public void testAngleMatch2() throws Exception {
String filename = "data/mdl/cnssmarts.sdf";
InputStream ins = PharmacophoreMatcherTest.class.getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(ins,
IteratingSDFReader reader = new IteratingSDFReader(ins,
DefaultChemObjectBuilder.getInstance());

PharmacophoreQuery query = new PharmacophoreQuery();
Expand Down Expand Up @@ -419,7 +419,7 @@ public void multiSmartsQuery() throws IOException, CDKException {

String filename = "data/pcore/multismartpcore.sdf";
InputStream ins = PharmacophoreMatcherTest.class.getClassLoader().getResourceAsStream(filename);
IteratingMDLReader reader = new IteratingMDLReader(ins,
IteratingSDFReader reader = new IteratingSDFReader(ins,
DefaultChemObjectBuilder.getInstance());

IAtomContainer mol = (IAtomContainer) reader.next();
Expand Down

0 comments on commit b1827a7

Please sign in to comment.