Commits

Sam Adams  committed 2fe3468

Fixed to InChI bond order

  • Participants
  • Parent commits b8d0892

Comments (0)

Files changed (6)

File chemistry-common/src/main/java/uk/ac/cam/ch/wwmm/chempound/chemistry/inchi/InchiTool.java

 	 */
 	private static INCHI_BOND_TYPE getBondType(CMLBond bond) {
 		String order = bond.getOrder();
-		if ("1".equals(order)) {
+		if ("1".equals(order) || "S".equals(order)) {
 			return INCHI_BOND_TYPE.SINGLE;
-		} else if ("2".equals(order)) {
+		} else if ("2".equals(order) || "D".equals(order)) {
 			return INCHI_BOND_TYPE.DOUBLE;
-		} else if ("3".equals(order)) {
+		} else if ("3".equals(order) || "T".equals(order)) {
 			return INCHI_BOND_TYPE.TRIPLE;
 		} else {
 			return INCHI_BOND_TYPE.ALTERN;

File chemistry-common/src/test/java/uk/ac/cam/ch/wwmm/chempound/chemistry/inchi/InchiToolTest.java

 public class InchiToolTest {
 
     @Test
-    public void testCH2() throws IOException, ParsingException {
-        CMLMolecule molecule = loadMol365();
+    public void testCH4() throws Exception {
+        CMLMolecule molecule = load("/ch4.cml");
+        String inchi = InchiTool.generateInchi(molecule, "");
+        assertEquals("InChI=1S/CH4/h1H4", inchi);
+    }
+
+    @Test
+    public void testCH2() throws Exception {
+        CMLMolecule molecule = load("/ch2.cml");
         String inchi = InchiTool.generateInchi(molecule, "");
         assertEquals("InChI=1S/CH2/h1H2", inchi);
     }
 
-    private CMLMolecule loadMol365() throws ParsingException, IOException {
+    private CMLMolecule load(String filepath) throws ParsingException, IOException {
         Document doc;
         CMLBuilder builder = new CMLBuilder();
-        InputStream in = getClass().getResourceAsStream("/mol365.cml");
+        InputStream in = getClass().getResourceAsStream(filepath);
         try {
             doc = builder.build(in);
         } finally {

File chemistry-common/src/test/resources/ch2.cml

+<?xml version="1.0" encoding="UTF-8"?>
+<molecule xmlns="http://www.xml-cml.org/schema">
+    <atomArray>
+        <atom id="a1" elementType="C" x3="-0.1346097616" y3="0.0" z3="-0.1096357002" />
+        <atom id="a2" elementType="H" x3="-0.1374606571" y3="0.0" z3="0.9934981956" />
+        <atom id="a3" elementType="H" x3="0.9451192268" y3="0.0" z3="-0.3356839941" />
+    </atomArray>
+    <bondArray>
+        <bond atomRefs2="a1 a2" id="a1_a2" order="S"/>
+        <bond atomRefs2="a1 a3" id="a1_a3" order="S"/>
+    </bondArray>
+</molecule>

File chemistry-common/src/test/resources/ch4.cml

+<?xml version="1.0" encoding="UTF-8"?>
+<molecule xmlns="http://www.xml-cml.org/schema">
+    <atomArray>
+        <atom id="a1" elementType="C" x3="3.875" y3="0.678" z3="-8.417" />
+        <atom id="a2" elementType="H" x3="3.800" y3="1.690" z3="-8.076" />
+        <atom id="a3" elementType="H" x3="4.907" y3="0.410" z3="-8.516" />
+        <atom id="a4" elementType="H" x3="3.406" y3="0.026" z3="-7.711" />
+        <atom id="a5" elementType="H" x3="3.389" y3="0.583" z3="-9.366" />
+    </atomArray>
+    <bondArray>
+        <bond atomRefs2="a1 a2" id="a1_a2" order="S"/>
+        <bond atomRefs2="a1 a3" id="a1_a3" order="S"/>
+        <bond atomRefs2="a1 a4" id="a1_a4" order="S"/>
+        <bond atomRefs2="a1 a5" id="a1_a5" order="S"/>
+    </bondArray>
+</molecule>

File chemistry-common/src/test/resources/mol365.cml

-<?xml version="1.0" encoding="UTF-8"?>
-<molecule xmlns="http://www.xml-cml.org/schema">
-    <atomArray>
-        <atom id="a1" elementType="C" x3="-0.1346097616" y3="0.0" z3="-0.1096357002" />
-        <atom id="a2" elementType="H" x3="-0.1374606571" y3="0.0" z3="0.9934981956" />
-        <atom id="a3" elementType="H" x3="0.9451192268" y3="0.0" z3="-0.3356839941" />
-    </atomArray>
-    <bondArray>
-        <bond atomRefs2="a1 a2" id="a1_a2" order="S"/>
-        <bond atomRefs2="a1 a3" id="a1_a3" order="S"/>
-    </bondArray>
-</molecule>
     <repositories>
         <repository>
             <id>ucc-repo</id>
-            <url>https://maven.ch.cam.ac.uk/m2repo</url>
+            <url>http://maven.ch.cam.ac.uk/m2repo</url>
         </repository>
     </repositories>