|
23 | 23 | package org.openscience.cdk.io; |
24 | 24 |
|
25 | 25 | import java.io.InputStream; |
| 26 | +import java.io.StringReader; |
26 | 27 | import java.util.Iterator; |
27 | 28 |
|
28 | 29 | import org.junit.Assert; |
|
32 | 33 | import org.openscience.cdk.ChemModel; |
33 | 34 | import org.openscience.cdk.Reaction; |
34 | 35 | import org.openscience.cdk.interfaces.IAtomContainer; |
| 36 | +import org.openscience.cdk.interfaces.IChemObjectBuilder; |
35 | 37 | import org.openscience.cdk.interfaces.IMapping; |
36 | 38 | import org.openscience.cdk.interfaces.IReaction; |
37 | 39 | import org.openscience.cdk.io.IChemObjectReader.Mode; |
| 40 | +import org.openscience.cdk.silent.SilentChemObjectBuilder; |
38 | 41 | import org.openscience.cdk.tools.ILoggingTool; |
39 | 42 | import org.openscience.cdk.tools.LoggingToolFactory; |
40 | 43 |
|
@@ -143,4 +146,36 @@ public void testAgentParts() throws Exception { |
143 | 146 | assertThat(reaction.getAgents().getAtomContainerCount(), is(1)); |
144 | 147 | } |
145 | 148 | } |
| 149 | + |
| 150 | + @Test public void optionalSdfSeparator() throws Exception { |
| 151 | + String dummyRecord = "ethanol\n" + |
| 152 | + " Mrv1810 09251921392D \n" + |
| 153 | + "\n" + |
| 154 | + " 3 2 0 0 0 0 999 V2000\n" + |
| 155 | + " 1.9520 -1.1270 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n" + |
| 156 | + " 1.2375 -0.7145 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n" + |
| 157 | + " 2.6664 -0.7145 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n" + |
| 158 | + " 1 2 1 0 0 0 0\n" + |
| 159 | + " 1 3 1 0 0 0 0\n" + |
| 160 | + "M END\n" + |
| 161 | + "$$$$\n"; |
| 162 | + StringBuilder sb = new StringBuilder(); |
| 163 | + sb.append("$RXN\n"); |
| 164 | + sb.append("Test\n\n\n 2 1\n"); |
| 165 | + sb.append("$MOL\n"); |
| 166 | + sb.append(dummyRecord); |
| 167 | + sb.append("$MOL\n"); |
| 168 | + sb.append(dummyRecord); |
| 169 | + sb.append("$MOL\n"); |
| 170 | + sb.append(dummyRecord); |
| 171 | + |
| 172 | + IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); |
| 173 | + try (MDLRXNV2000Reader reader = new MDLRXNV2000Reader(new StringReader(sb.toString()))) { |
| 174 | + IReaction rxn = reader.read(bldr.newInstance(IReaction.class)); |
| 175 | + assertThat(rxn.getReactants().getAtomContainerCount(), is(2)); |
| 176 | + assertThat(rxn.getProducts().getAtomContainerCount(), is(1)); |
| 177 | + assertThat(rxn.getReactants().getAtomContainer(0).getAtomCount(), is(3)); |
| 178 | + assertThat(rxn.getReactants().getAtomContainer(1).getAtomCount(), is(3)); |
| 179 | + } |
| 180 | + } |
146 | 181 | } |
0 commit comments