Skip to content

Commit 074afb4

Browse files
johnmayegonw
authored andcommitted
First pass at moving from JNA to JNI inchi - some tests need adjusting.
1 parent d3eb48e commit 074afb4

File tree

10 files changed

+527
-458
lines changed

10 files changed

+527
-458
lines changed

storage/inchi/pom.xml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,25 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6-
6+
77
<parent>
88
<artifactId>cdk-storage</artifactId>
99
<groupId>org.openscience.cdk</groupId>
1010
<version>2.7-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>cdk-inchi</artifactId>
14-
14+
1515
<name>cdk-inchi</name>
1616
<dependencies>
1717
<dependency>
1818
<groupId>javax.vecmath</groupId>
1919
<artifactId>vecmath</artifactId>
2020
</dependency>
2121
<dependency>
22-
<groupId>net.sf.jni-inchi</groupId>
23-
<artifactId>jni-inchi</artifactId>
24-
<exclusions>
25-
<exclusion>
26-
<groupId>log4j</groupId>
27-
<artifactId>log4j</artifactId>
28-
</exclusion>
29-
</exclusions>
22+
<groupId>io.github.dan2097</groupId>
23+
<artifactId>jna-inchi-core</artifactId>
24+
<version>1.0.1</version>
3025
</dependency>
3126
<dependency>
3227
<groupId>org.apache.logging.log4j</groupId>
@@ -95,7 +90,7 @@
9590
<artifactId>cdk-data</artifactId>
9691
<version>${project.parent.version}</version>
9792
<type>test-jar</type>
98-
<scope>test</scope>
93+
<scope>test</scope>
9994
</dependency>
10095
<dependency>
10196
<groupId>${project.groupId}</groupId>
@@ -108,7 +103,7 @@
108103
<artifactId>cdk-test</artifactId>
109104
<version>${project.parent.version}</version>
110105
<type>test-jar</type>
111-
<scope>test</scope>
106+
<scope>test</scope>
112107
</dependency>
113108
<dependency>
114109
<groupId>${project.groupId}</groupId>
@@ -127,7 +122,7 @@
127122
<artifactId>cdk-testdata</artifactId>
128123
<version>${project.parent.version}</version>
129124
<type>test-jar</type>
130-
<scope>test</scope>
125+
<scope>test</scope>
131126
</dependency>
132127
</dependencies>
133128

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Copyright (C) 2021 John Mayfield
3+
*
4+
* Contact: cdk-devel@lists.sourceforge.net
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public License
8+
* as published by the Free Software Foundation; either version 2.1
9+
* of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*/
20+
21+
package net.sf.jniinchi;
22+
23+
import io.github.dan2097.jnainchi.InchiFlag;
24+
25+
/**
26+
* This class provides backwards compatibility of JNA-INCHI with JNI-INCHI, this enum was exposed in the CDK API.
27+
* @author John Mayfield
28+
*/
29+
public enum INCHI_OPTION {
30+
SUCF,
31+
ChiralFlagON,
32+
ChiralFlagOFF,
33+
SNon,
34+
SAbs,
35+
SRel,
36+
SRac,
37+
SUU,
38+
NEWPS,
39+
RecMet,
40+
FixedH,
41+
AuxNone,
42+
NoADP,
43+
Compress,
44+
DoNotAddH,
45+
Wnumber,
46+
OutputSDF,
47+
WarnOnEmptyStructure,
48+
FixSp3Bug,
49+
FB,
50+
SPXYZ,
51+
SAsXYZ;
52+
53+
public static INCHI_OPTION wrap(InchiFlag flag) {
54+
switch (flag) {
55+
case SUCF: return SUCF;
56+
case ChiralFlagON: return ChiralFlagON;
57+
case ChiralFlagOFF: return ChiralFlagOFF;
58+
case SNon: return SNon;
59+
case SRel: return SRel;
60+
case SRac: return SRac;
61+
case SUU: return SUU;
62+
case RecMet: return RecMet;
63+
case FixedH: return FixedH;
64+
case AuxNone: return AuxNone;
65+
case DoNotAddH: return DoNotAddH;
66+
case WarnOnEmptyStructure: return WarnOnEmptyStructure;
67+
68+
default: throw new IllegalArgumentException(flag + " not supported?");
69+
}
70+
}
71+
72+
public static InchiFlag wrap(INCHI_OPTION flag) {
73+
switch (flag) {
74+
case SUCF: return InchiFlag.SUCF;
75+
case ChiralFlagON: return InchiFlag.ChiralFlagON;
76+
case ChiralFlagOFF: return InchiFlag.ChiralFlagOFF;
77+
case SNon: return InchiFlag.SNon;
78+
case SRel: return InchiFlag.SRel;
79+
case SRac: return InchiFlag.SRac;
80+
case SUU: return InchiFlag.SUU;
81+
case RecMet: return InchiFlag.RecMet;
82+
case FixedH: return InchiFlag.FixedH;
83+
case AuxNone: return InchiFlag.AuxNone;
84+
case DoNotAddH: return InchiFlag.DoNotAddH;
85+
case WarnOnEmptyStructure: return InchiFlag.WarnOnEmptyStructure;
86+
default:
87+
System.err.println("Unsupported flag: " + flag);
88+
return null;
89+
}
90+
91+
// case SAbs: return SAbs;
92+
// case NEWPS: return NEWPS;
93+
// case NoADP: return NoADP;
94+
// case Compress: return Compress;
95+
// case Wnumber: return Wnumber;
96+
// case OutputSDF: return OutputSDF;
97+
// case FixSp3Bug: return FixSp3Bug;
98+
// case FB: return FB;
99+
// case SPXYZ: return SPXYZ;
100+
// case SAsXYZ: return SAsXYZ;
101+
}
102+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (C) 2021 John Mayfield
3+
*
4+
* Contact: cdk-devel@lists.sourceforge.net
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public License
8+
* as published by the Free Software Foundation; either version 2.1
9+
* of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*/
20+
21+
package net.sf.jniinchi;
22+
23+
import io.github.dan2097.jnainchi.InchiStatus;
24+
25+
/**
26+
* This class provides backwards compatibility of JNA-INCHI with JNI-INCHI, this enum was exposed in the CDK API.
27+
* @author John Mayfield
28+
*/
29+
public enum INCHI_RET {
30+
SKIP,
31+
EOF,
32+
OKAY,
33+
WARNING,
34+
ERROR,
35+
FATAL,
36+
UNKNOWN,
37+
BUSY;
38+
39+
public static INCHI_RET wrap(InchiStatus status) {
40+
switch (status) {
41+
case SUCCESS: return INCHI_RET.OKAY;
42+
case WARNING: return INCHI_RET.WARNING;
43+
case ERROR: return INCHI_RET.ERROR;
44+
default:
45+
throw new IllegalArgumentException("Unexpected status!");
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)