| 1 |
/** |
| 2 |
* JNA-RInChI - Library for calling RInChI from Java |
| 3 |
* Copyright © 2022 Nikolay Kochev |
| 4 |
* <p> |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* <p> |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU Lesser General Public License for more details. |
| 14 |
* <p> |
| 15 |
* You should have received a copy of the GNU Lesser General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
package io.github.dan2097.jnarinchi; |
| 19 |
|
| 20 |
import com.sun.jna.Library; |
| 21 |
import com.sun.jna.Native; |
| 22 |
import com.sun.jna.NativeLibrary; |
| 23 |
import com.sun.jna.ptr.PointerByReference; |
| 24 |
|
| 25 |
/** |
| 26 |
* JNA Wrapper for library <b>rinchi</b>. |
| 27 |
* |
| 28 |
* @author nick |
| 29 |
*/ |
| 30 |
public class RinchiLibrary implements Library { |
| 31 |
public static final String JNA_LIBRARY_NAME = "rinchi"; |
| 32 |
public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(RinchiLibrary.JNA_LIBRARY_NAME); |
| 33 |
|
| 34 |
static { |
| 35 |
Native.register(RinchiLibrary.class, RinchiLibrary.JNA_NATIVE_LIB); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Returns the latest error message of the native rinchi library. |
| 40 |
* |
| 41 |
* @return the string of error message |
| 42 |
*/ |
| 43 |
public static native String rinchilib_latest_err_msg(); |
| 44 |
|
| 45 |
/** |
| 46 |
* Generates RInChI and RAuxInfo from a text file in MDL RXN/RDFile format. |
| 47 |
* <br> |
| 48 |
* Original signature: |
| 49 |
* <code>int rinchilib_rinchi_from_file_text( |
| 50 |
* const char* input_format, const char* in_file_text, bool in_force_equilibrium, |
| 51 |
* const char** out_rinchi_string, const char** out_rinchi_auxinfo)</code><br> |
| 52 |
* |
| 53 |
* @param input_format reaction file format as a string ("RXN", "RD" or "AUTO") |
| 54 |
* @param in_file_text input reaction as a text in MDL RXN/RDFile format |
| 55 |
* @param in_force_equilibrium determines whether to force equilibrium in RInChI generation |
| 56 |
* @param out_rinchi_string_p the result RInChI wrapped by a PointerByReference object |
| 57 |
* @param out_rinchi_auxinfo_p the result RAuxInfo wrapped by a PointerByReference object |
| 58 |
* @return the exit code |
| 59 |
*/ |
| 60 |
public static native int rinchilib_rinchi_from_file_text( |
| 61 |
String input_format, |
| 62 |
String in_file_text, |
| 63 |
boolean in_force_equilibrium, |
| 64 |
PointerByReference out_rinchi_string_p, |
| 65 |
PointerByReference out_rinchi_auxinfo_p); |
| 66 |
|
| 67 |
/** |
| 68 |
* Generates RInChIKey from a text file in MDL RXN/RDFile format. |
| 69 |
* <br> |
| 70 |
* Original signature: |
| 71 |
* <code> int rinchilib_rinchikey_from_file_text(const char* input_format, const char* in_file_text, |
| 72 |
* const char* key_type, bool in_force_equilibrium, const char** out_rinchi_key) </code><br> |
| 73 |
* |
| 74 |
* @param input_format reaction file format as a string ("RXN", "RD" or "AUTO") |
| 75 |
* @param in_file_text input reaction as a text in MDL RXN/RDFile format |
| 76 |
* @param key_type RInChIKey type as a string ("L", "S" or "W") |
| 77 |
* @param in_force_equilibrium determines whether to force equilibrium in RInChI generation |
| 78 |
* @param out_rinchi_key_p the result RInChIKey wrapped by a PointerByReference object |
| 79 |
* @return the exit code |
| 80 |
*/ |
| 81 |
public static native int rinchilib_rinchikey_from_file_text( |
| 82 |
String input_format, |
| 83 |
String in_file_text, |
| 84 |
String key_type, |
| 85 |
boolean in_force_equilibrium, |
| 86 |
PointerByReference out_rinchi_key_p |
| 87 |
); |
| 88 |
|
| 89 |
/** |
| 90 |
* Converts RInChI and RAuxInfo into a reaction represented as text file in MDL RXN/RDFile format. |
| 91 |
* <br> |
| 92 |
* Original signature: |
| 93 |
* <code> int rinchilib_file_text_from_rinchi(const char* rinchi_string, const char* rinchi_auxinfo, |
| 94 |
* const char* output_format, const char** out_file_text) </code><br> |
| 95 |
* |
| 96 |
* @param rinchi_string RInChI string |
| 97 |
* @param rinchi_auxinfo RAuxInfo string |
| 98 |
* @param output_format reaction file format as a string ("RXN", "RD" or "AUTO") |
| 99 |
* @param out_file_text_p the result reaction file text wrapped by a PointerByReference object |
| 100 |
* @return the exit code |
| 101 |
*/ |
| 102 |
public static native int rinchilib_file_text_from_rinchi( |
| 103 |
String rinchi_string, |
| 104 |
String rinchi_auxinfo, |
| 105 |
String output_format, |
| 106 |
PointerByReference out_file_text_p); |
| 107 |
|
| 108 |
/** |
| 109 |
* Extracts InChIs and AuxInfo for all reaction components from a RInChI and RAuxInfo strings. |
| 110 |
* <br> |
| 111 |
* Original signature: |
| 112 |
* <code> int rinchilib_inchis_from_rinchi(const char* rinchi_string, const char* rinchi_auxinfo, |
| 113 |
* const char** out_inchis_text) </code><br> |
| 114 |
* |
| 115 |
* The result from this function must be parsed as it is a single multi-line string |
| 116 |
* containing reaction direction, inchi, auxinfo and role for every component. |
| 117 |
* |
| 118 |
* @param rinchi_string RInChI string |
| 119 |
* @param rinchi_auxinfo RAuxInfo string |
| 120 |
* @param out_inchis_text_p output information wrapped by a PointerByReference object |
| 121 |
* @return the exit code |
| 122 |
*/ |
| 123 |
public static native int rinchilib_inchis_from_rinchi( |
| 124 |
String rinchi_string, |
| 125 |
String rinchi_auxinfo, |
| 126 |
PointerByReference out_inchis_text_p |
| 127 |
); |
| 128 |
|
| 129 |
/** |
| 130 |
* Generates RInChIKey from a RInChI string. |
| 131 |
* <br> |
| 132 |
* Original signature: |
| 133 |
* <code> int rinchilib_rinchikey_from_rinchi(const char* rinchi_string, const char* key_type, |
| 134 |
* const char** out_rinchi_key) </code><br> |
| 135 |
* |
| 136 |
* @param rinchi_string RInChI string |
| 137 |
* @param key_type RInChIKey type as a string ("L", "S" or "W") |
| 138 |
* @param out_rinchi_key_p the result RInChIKey wrapped by a PointerByReference object |
| 139 |
* @return the exit code |
| 140 |
*/ |
| 141 |
public static native int rinchilib_rinchikey_from_rinchi( |
| 142 |
String rinchi_string, |
| 143 |
String key_type, |
| 144 |
PointerByReference out_rinchi_key_p); |
| 145 |
} |