Skip to content

Commit fd8eb71

Browse files
committed
remove validation boolean, validate always
1 parent a0aab6a commit fd8eb71

File tree

8 files changed

+22
-32
lines changed

8 files changed

+22
-32
lines changed

libvcell/_internal/native_calls.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def sbml_to_finite_volume_input(self, sbml_content: str, output_dir_path: Path)
6060
raise
6161

6262
def vcml_to_sbml(
63-
self, vcml_content: str, application_name: str, sbml_file_path: Path, validate: bool
63+
self, vcml_content: str, application_name: str, sbml_file_path: Path
6464
) -> ReturnValue:
6565
try:
6666
with IsolateManager(self.lib) as isolate_thread:
@@ -69,7 +69,6 @@ def vcml_to_sbml(
6969
ctypes.c_char_p(vcml_content.encode("utf-8")),
7070
ctypes.c_char_p(application_name.encode("utf-8")),
7171
ctypes.c_char_p(str(sbml_file_path).encode("utf-8")),
72-
ctypes.c_int(1 if validate else 0),
7372
)
7473

7574
value: bytes | None = ctypes.cast(json_ptr, ctypes.c_char_p).value
@@ -83,14 +82,13 @@ def vcml_to_sbml(
8382
logging.exception("Error in vcml_to_sbml()", exc_info=e)
8483
raise
8584

86-
def sbml_to_vcml(self, sbml_content: str, vcml_file_path: Path, validate: bool) -> ReturnValue:
85+
def sbml_to_vcml(self, sbml_content: str, vcml_file_path: Path) -> ReturnValue:
8786
try:
8887
with IsolateManager(self.lib) as isolate_thread:
8988
json_ptr: ctypes.c_char_p = self.lib.sbmlToVcml(
9089
isolate_thread,
9190
ctypes.c_char_p(sbml_content.encode("utf-8")),
9291
ctypes.c_char_p(str(vcml_file_path).encode("utf-8")),
93-
ctypes.c_int(1 if validate else 0),
9492
)
9593

9694
value: bytes | None = ctypes.cast(json_ptr, ctypes.c_char_p).value

libvcell/_internal/native_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def _define_entry_points(self) -> None:
3939
self.lib.sbmlToFiniteVolumeInput.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p]
4040

4141
self.lib.sbmlToVcml.restype = ctypes.c_char_p
42-
self.lib.sbmlToVcml.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int]
42+
self.lib.sbmlToVcml.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
4343

4444
self.lib.vcmlToSbml.restype = ctypes.c_char_p
45-
self.lib.vcmlToSbml.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int]
45+
self.lib.vcmlToSbml.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p]
4646

4747
self.lib.vcmlToVcml.restype = ctypes.c_char_p
4848
self.lib.vcmlToVcml.argtypes = [ctypes.c_void_p, ctypes.c_char_p]

libvcell/model_utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,36 @@
33
from libvcell._internal.native_calls import ReturnValue, VCellNativeCalls
44

55

6-
def vcml_to_sbml(vcml_content: str, application_name: str, sbml_file_path: Path, validate: bool) -> tuple[bool, str]:
6+
def vcml_to_sbml(vcml_content: str, application_name: str, sbml_file_path: Path) -> tuple[bool, str]:
77
"""
88
Convert VCML content to SBML file
99
1010
Args:
1111
vcml_content (str): VCML content
1212
application_name (str): VCell Biomodel application name
1313
sbml_file_path (Path): path to resulting SBML file
14-
validate (bool): whether to validate SBML file
1514
1615
Returns:
1716
tuple[bool, str]: A tuple containing the success status and a message
1817
"""
1918
native = VCellNativeCalls()
20-
return_value: ReturnValue = native.vcml_to_sbml(vcml_content, application_name, sbml_file_path, validate)
19+
return_value: ReturnValue = native.vcml_to_sbml(vcml_content, application_name, sbml_file_path)
2120
return return_value.success, return_value.message
2221

2322

24-
def sbml_to_vcml(sbml_content: str, vcml_file_path: Path, validate: bool) -> tuple[bool, str]:
23+
def sbml_to_vcml(sbml_content: str, vcml_file_path: Path) -> tuple[bool, str]:
2524
"""
2625
Convert SBML content to finite volume input files
2726
2827
Args:
2928
sbml_content (str): SBML content
3029
vcml_file_path (Path): path to resulting VCML file
31-
validate (bool): whether to validate SBML import with round trip test
3230
3331
Returns:
3432
tuple[bool, str]: A tuple containing the success status and a message
3533
"""
3634
native = VCellNativeCalls()
37-
return_value: ReturnValue = native.sbml_to_vcml(sbml_content, vcml_file_path, validate)
35+
return_value: ReturnValue = native.sbml_to_vcml(sbml_content, vcml_file_path)
3836
return return_value.success, return_value.message
3937

4038

tests/test_libvcell.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_sbml_to_finite_volume_input(temp_output_dir: Path, sbml_file_path: Path
2424
def test_sbml_to_vcml(temp_output_dir: Path, sbml_file_path: Path) -> None:
2525
sbml_content = sbml_file_path.read_text()
2626
vcml_file_path = temp_output_dir / "test.vcml"
27-
success, msg = sbml_to_vcml(sbml_content=sbml_content, vcml_file_path=vcml_file_path, validate=False)
27+
success, msg = sbml_to_vcml(sbml_content=sbml_content, vcml_file_path=vcml_file_path)
2828
assert vcml_file_path.exists()
2929
assert success is True
3030
assert msg == "Success"
@@ -34,7 +34,7 @@ def test_vcml_to_sbml(temp_output_dir: Path, vcml_file_path: Path, vcml_app_name
3434
vcml_content = vcml_file_path.read_text()
3535
sbml_file_path = temp_output_dir / "test.sbml"
3636
success, msg = vcml_to_sbml(
37-
vcml_content=vcml_content, application_name=vcml_app_name, sbml_file_path=sbml_file_path, validate=False
37+
vcml_content=vcml_content, application_name=vcml_app_name, sbml_file_path=sbml_file_path
3838
)
3939
assert sbml_file_path.exists()
4040
assert success is True

vcell-native/src/main/java/org/vcell/libvcell/Entrypoints.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,19 @@ public static CCharPointer entrypoint_sbmlToFiniteVolumeInput(
119119
vcml_content: text of VCML XML document
120120
application_name: name of the application to export
121121
sbml_file_path: path to the SBML file to write
122-
validate_sbml: whether to validate the SBML file
123122
Returns a JSON string with success status and message"""
124123
)
125124
public static CCharPointer entrypoint_vcmlToSbml(
126125
IsolateThread ignoredThread,
127126
CCharPointer vcml_content,
128127
CCharPointer application_name,
129-
CCharPointer sbml_file_path,
130-
int validate_sbml) {
128+
CCharPointer sbml_file_path) {
131129
ReturnValue returnValue;
132130
try {
133131
String vcmlContentStr = CTypeConversion.toJavaString(vcml_content);
134132
String applicationName = CTypeConversion.toJavaString(application_name);
135133
Path sbmlFilePath = new File(CTypeConversion.toJavaString(sbml_file_path)).toPath();
136-
vcml_to_sbml(vcmlContentStr, applicationName, sbmlFilePath, CTypeConversion.toBoolean(validate_sbml));
134+
vcml_to_sbml(vcmlContentStr, applicationName, sbmlFilePath);
137135
returnValue = new ReturnValue(true, "Success");
138136
}catch (Throwable t) {
139137
logger.error("Error translating vcml application to sbml", t);
@@ -151,19 +149,17 @@ public static CCharPointer entrypoint_vcmlToSbml(
151149
Converts SBML file into a VCML file.
152150
sbml_content: text of SBML XML document
153151
vcml_file_path: path to the VCML file to write
154-
validate_sbml: whether to validate the SBML file
155152
Returns a JSON string with success status and message"""
156153
)
157154
public static CCharPointer entrypoint_sbmlToVcml(
158155
IsolateThread ignoredThread,
159156
CCharPointer sbml_content,
160-
CCharPointer vcml_file_path,
161-
int validate_sbml) {
157+
CCharPointer vcml_file_path) {
162158
ReturnValue returnValue;
163159
try {
164160
String sbmlContentStr = CTypeConversion.toJavaString(sbml_content);
165161
Path vcmlFilePath = new File(CTypeConversion.toJavaString(vcml_file_path)).toPath();
166-
sbml_to_vcml(sbmlContentStr, vcmlFilePath, CTypeConversion.toBoolean(validate_sbml));
162+
sbml_to_vcml(sbmlContentStr, vcmlFilePath);
167163
returnValue = new ReturnValue(true, "Success");
168164
}catch (Throwable t) {
169165
logger.error("Error translating sbml to vcml", t);

vcell-native/src/main/java/org/vcell/libvcell/MainRecorder.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public static void main(String[] args) {
5454

5555
// create a temporary file for the VCML output
5656
File temp_vcml_file = new File(output_dir, "temp.vcml");
57-
boolean validateSBML = true;
58-
sbml_to_vcml(sbml_str, temp_vcml_file.toPath(), validateSBML);
57+
sbml_to_vcml(sbml_str, temp_vcml_file.toPath());
5958
// remove temporary file
6059
if (temp_vcml_file.exists()) {
6160
boolean deleted = temp_vcml_file.delete();
@@ -71,8 +70,7 @@ public static void main(String[] args) {
7170

7271
// create a temporary file for the SBML output
7372
File temp_sbml_file = new File(output_dir, "temp.vcml");
74-
boolean validateSBML = true;
75-
vcml_to_sbml(vcml_str, vcml_app_name, temp_sbml_file.toPath(), validateSBML);
73+
vcml_to_sbml(vcml_str, vcml_app_name, temp_sbml_file.toPath());
7674
// remove temporary file
7775
if (temp_sbml_file.exists()) {
7876
boolean deleted = temp_sbml_file.delete();

vcell-native/src/main/java/org/vcell/libvcell/ModelUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
public class ModelUtils {
2424

25-
public static void sbml_to_vcml(String sbml_content, Path vcmlPath, boolean validateSBML)
25+
public static void sbml_to_vcml(String sbml_content, Path vcmlPath)
2626
throws VCLoggerException, XmlParseException, IOException, MappingException {
2727

2828
record LoggerMessage(VCLogger.Priority priority, VCLogger.ErrorType errorType, String message) {};
@@ -40,6 +40,7 @@ record LoggerMessage(VCLogger.Priority priority, VCLogger.ErrorType errorType, S
4040
final BioModel bioModel;
4141
try (InputStream inputStream = new ByteArrayInputStream(sbml_content.getBytes())) {
4242
// create a SBMLImporter from the XMLSource
43+
boolean validateSBML = true;
4344
SBMLImporter sbmlImporter = new SBMLImporter(inputStream, vclogger, validateSBML);
4445
bioModel = sbmlImporter.getBioModel();
4546
}
@@ -60,12 +61,13 @@ record LoggerMessage(VCLogger.Priority priority, VCLogger.ErrorType errorType, S
6061
}
6162

6263

63-
public static void vcml_to_sbml(String vcml_content, String applicationName, Path sbmlPath, boolean validateSBML)
64+
public static void vcml_to_sbml(String vcml_content, String applicationName, Path sbmlPath)
6465
throws XmlParseException, IOException, XMLStreamException, SbmlException, MappingException {
6566

6667
BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(vcml_content));
6768
bioModel.updateAll(false);
6869
SimulationContext simContext = bioModel.getSimulationContext(applicationName);
70+
boolean validateSBML = true;
6971
SBMLExporter sbmlExporter = new SBMLExporter(simContext, 3, 1, validateSBML);
7072
String sbml_string = sbmlExporter.getSBMLString();
7173
XmlUtil.writeXMLStringToFile(sbml_string, sbmlPath.toFile().getAbsolutePath(), true);

vcell-native/src/test/java/org/vcell/libvcell/EntrypointsTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ public void test_sbml_to_vcml() throws MappingException, IOException, XmlParseEx
117117
String sbmlContent = getFileContentsAsString("/TinySpatialProject_Application0.xml");
118118
File parent_dir = Files.createTempDirectory("sbmlToVcml").toFile();
119119
File vcml_temp_file = new File(parent_dir, "temp.vcml");
120-
boolean validate = true;
121-
sbml_to_vcml(sbmlContent, vcml_temp_file.toPath(), validate);
120+
sbml_to_vcml(sbmlContent, vcml_temp_file.toPath());
122121
assert(vcml_temp_file.exists());
123122
}
124123

@@ -128,8 +127,7 @@ public void test_vcml_to_sbml() throws MappingException, IOException, XmlParseEx
128127
File parent_dir = Files.createTempDirectory("vcmlToSbml").toFile();
129128
File sbml_temp_file = new File(parent_dir, "temp.sbml");
130129
String applicationName = "unnamed_spatialGeom";
131-
boolean validate = true;
132-
vcml_to_sbml(vcmlContent, applicationName, sbml_temp_file.toPath(), validate);
130+
vcml_to_sbml(vcmlContent, applicationName, sbml_temp_file.toPath());
133131
assert(sbml_temp_file.exists());
134132
}
135133

0 commit comments

Comments
 (0)