Skip to content

Commit 7c37ebe

Browse files
committed
- allow to initialize from sbml str
1 parent 9a4efb4 commit 7c37ebe

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

petab/v1/models/sbml_model.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ def from_file(filepath_or_buffer, model_id: str = None):
8080
sbml_document=sbml_document,
8181
model_id=model_id,
8282
)
83+
84+
@staticmethod
85+
def from_string(sbml_string, model_id: str = None):
86+
sbml_reader, sbml_document, sbml_model = load_sbml_from_string(
87+
sbml_string
88+
)
89+
90+
if not model_id:
91+
model_id = sbml_model.getIdAttribute()
92+
93+
return SbmlModel(
94+
sbml_model=sbml_model,
95+
sbml_reader=sbml_reader,
96+
sbml_document=sbml_document,
97+
model_id=model_id,
98+
)
8399

84100
@property
85101
def model_id(self):

0 commit comments

Comments
 (0)