|
9 | 9 | import org.json.simple.JSONValue; |
10 | 10 |
|
11 | 11 | import java.io.File; |
| 12 | +import java.nio.file.Path; |
12 | 13 | import java.util.concurrent.ConcurrentHashMap; |
13 | 14 |
|
14 | 15 | import static org.vcell.libvcell.SolverUtils.sbmlToFiniteVolumeInput; |
15 | 16 | import static org.vcell.libvcell.SolverUtils.vcmlToFiniteVolumeInput; |
| 17 | +import static org.vcell.libvcell.ModelUtils.vcml_to_sbml; |
| 18 | +import static org.vcell.libvcell.ModelUtils.sbml_to_vcml; |
| 19 | +import static org.vcell.libvcell.ModelUtils.vcml_to_vcml; |
16 | 20 |
|
17 | 21 |
|
18 | 22 | public class Entrypoints { |
@@ -52,6 +56,7 @@ public String toJson() { |
52 | 56 | documentation = """ |
53 | 57 | Converts VCML file into Finite Volume Input files. |
54 | 58 | vcml_content: text of VCML XML document |
| 59 | + simulation_name: name of the simulation to convert |
55 | 60 | output_dir_path: path to the output directory (expected to be subdirectory of the workspace) |
56 | 61 | Returns a JSON string with success status and message""" |
57 | 62 | ) |
@@ -106,4 +111,92 @@ public static CCharPointer entrypoint_sbmlToFiniteVolumeInput( |
106 | 111 | logger.info("Returning from sbmlToFiniteVolumeInput: " + json); |
107 | 112 | return createString(json); |
108 | 113 | } |
109 | | - } |
| 114 | + |
| 115 | + @CEntryPoint( |
| 116 | + name = "vcmlToSbml", |
| 117 | + documentation = """ |
| 118 | + Converts VCML file into an SBML file. |
| 119 | + vcml_content: text of VCML XML document |
| 120 | + application_name: name of the application to export |
| 121 | + sbml_file_path: path to the SBML file to write |
| 122 | + Returns a JSON string with success status and message""" |
| 123 | + ) |
| 124 | + public static CCharPointer entrypoint_vcmlToSbml( |
| 125 | + IsolateThread ignoredThread, |
| 126 | + CCharPointer vcml_content, |
| 127 | + CCharPointer application_name, |
| 128 | + CCharPointer sbml_file_path) { |
| 129 | + ReturnValue returnValue; |
| 130 | + try { |
| 131 | + String vcmlContentStr = CTypeConversion.toJavaString(vcml_content); |
| 132 | + String applicationName = CTypeConversion.toJavaString(application_name); |
| 133 | + Path sbmlFilePath = new File(CTypeConversion.toJavaString(sbml_file_path)).toPath(); |
| 134 | + vcml_to_sbml(vcmlContentStr, applicationName, sbmlFilePath); |
| 135 | + returnValue = new ReturnValue(true, "Success"); |
| 136 | + }catch (Throwable t) { |
| 137 | + logger.error("Error translating vcml application to sbml", t); |
| 138 | + returnValue = new ReturnValue(false, t.getMessage()); |
| 139 | + } |
| 140 | + // return result as a json string |
| 141 | + String json = returnValue.toJson(); |
| 142 | + logger.info("Returning from vcellToSbml: " + json); |
| 143 | + return createString(json); |
| 144 | + } |
| 145 | + |
| 146 | + @CEntryPoint( |
| 147 | + name = "sbmlToVcml", |
| 148 | + documentation = """ |
| 149 | + Converts SBML file into a VCML file. |
| 150 | + sbml_content: text of SBML XML document |
| 151 | + vcml_file_path: path to the VCML file to write |
| 152 | + Returns a JSON string with success status and message""" |
| 153 | + ) |
| 154 | + public static CCharPointer entrypoint_sbmlToVcml( |
| 155 | + IsolateThread ignoredThread, |
| 156 | + CCharPointer sbml_content, |
| 157 | + CCharPointer vcml_file_path) { |
| 158 | + ReturnValue returnValue; |
| 159 | + try { |
| 160 | + String sbmlContentStr = CTypeConversion.toJavaString(sbml_content); |
| 161 | + Path vcmlFilePath = new File(CTypeConversion.toJavaString(vcml_file_path)).toPath(); |
| 162 | + sbml_to_vcml(sbmlContentStr, vcmlFilePath); |
| 163 | + returnValue = new ReturnValue(true, "Success"); |
| 164 | + }catch (Throwable t) { |
| 165 | + logger.error("Error translating sbml to vcml", t); |
| 166 | + returnValue = new ReturnValue(false, t.getMessage()); |
| 167 | + } |
| 168 | + // return result as a json string |
| 169 | + String json = returnValue.toJson(); |
| 170 | + logger.info("Returning from sbmlToVcell: " + json); |
| 171 | + return createString(json); |
| 172 | + } |
| 173 | + |
| 174 | + @CEntryPoint( |
| 175 | + name = "vcmlToVcml", |
| 176 | + documentation = """ |
| 177 | + Updates a VCML file into a fully populated VCML file. |
| 178 | + vcml_content: text of VCML XML document |
| 179 | + vcml_file_path: path to the VCML file to write |
| 180 | + Returns a JSON string with success status and message""" |
| 181 | + ) |
| 182 | + public static CCharPointer entrypoint_vcmlToVcml( |
| 183 | + IsolateThread ignoredThread, |
| 184 | + CCharPointer vcml_content, |
| 185 | + CCharPointer vcml_file_path) { |
| 186 | + ReturnValue returnValue; |
| 187 | + try { |
| 188 | + String vcmlContentStr = CTypeConversion.toJavaString(vcml_content); |
| 189 | + Path vcmlFilePath = new File(CTypeConversion.toJavaString(vcml_file_path)).toPath(); |
| 190 | + vcml_to_vcml(vcmlContentStr, vcmlFilePath); |
| 191 | + returnValue = new ReturnValue(true, "Success"); |
| 192 | + }catch (Throwable t) { |
| 193 | + logger.error("Error refreshing vcml", t); |
| 194 | + returnValue = new ReturnValue(false, t.getMessage()); |
| 195 | + } |
| 196 | + // return result as a json string |
| 197 | + String json = returnValue.toJson(); |
| 198 | + logger.info("Returning from vcellToVcml: " + json); |
| 199 | + return createString(json); |
| 200 | + } |
| 201 | + |
| 202 | +} |
0 commit comments