From f34e29a0c0dac869fa7e43f64e3cacabb8d5f070 Mon Sep 17 00:00:00 2001 From: Ali Sinan Saglam Date: Tue, 21 Sep 2021 13:14:55 -0400 Subject: [PATCH] change to allow for "<" in observable blocks to be read by standard XML readers --- bionetgen/modelapi/bngparser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bionetgen/modelapi/bngparser.py b/bionetgen/modelapi/bngparser.py index 8c266f2..f52ea00 100644 --- a/bionetgen/modelapi/bngparser.py +++ b/bionetgen/modelapi/bngparser.py @@ -62,14 +62,18 @@ def _parse_model_bngpl(self, model_obj) -> None: with TemporaryFile("w+") as xml_file: if self.bngfile.generate_xml(xml_file): # TODO: Add verbosity option to the library - # print("Parsing") - self.parse_xml(xml_file.read(), model_obj) + xmlstr = xml_file.read() + # < is not a valid XML character, we need to replace it + xmlstr = xmlstr.replace('relation="<', 'relation="<') + self.parse_xml(xmlstr, model_obj) model_obj.reset_compilation_tags() else: raise ValueError("XML file couldn't be generated") elif model_file.endswith(".xml"): with open(model_file, "r") as f: xml_str = f.read() + # < is not a valid XML character, we need to replace it + xmlstr = xml_str.replace('relation="<', 'relation="<') self.parse_xml(xml_str, model_obj) model_obj.reset_compilation_tags() else: