11from loguru import logger
2+ from mdmodels .units .unit_definition import UnitDefinition
23
3- import pyenzyme as pe
44import pyenzyme .tools as tools
5+ from pyenzyme .versions .v2 import (
6+ EnzymeMLDocument ,
7+ EquationType ,
8+ MeasurementData ,
9+ Parameter ,
10+ ReactionElement ,
11+ )
512
613
7- def validate_sbml_export (doc : pe . EnzymeMLDocument ) -> bool :
14+ def validate_sbml_export (doc : EnzymeMLDocument ) -> bool :
815 """This function validates the SBML export of an EnzymeML document.
916
1017 Args:
@@ -26,7 +33,7 @@ def validate_sbml_export(doc: pe.EnzymeMLDocument) -> bool:
2633 return result
2734
2835
29- def _check_consistent_vessel_ids (doc : pe . EnzymeMLDocument ) -> bool :
36+ def _check_consistent_vessel_ids (doc : EnzymeMLDocument ) -> bool :
3037 """This validator checks whether all species have a vessel id that exists in the document.
3138
3239 SBML documents require that all species have a vessel id that exists in the document and
@@ -62,7 +69,7 @@ def _check_consistent_vessel_ids(doc: pe.EnzymeMLDocument) -> bool:
6269 return all (result )
6370
6471
65- def _check_equation_either_rule_or_reaction (doc : pe . EnzymeMLDocument ) -> bool :
72+ def _check_equation_either_rule_or_reaction (doc : EnzymeMLDocument ) -> bool :
6673 """This validator checks whether there are either rules or reactions in the document.
6774
6875 SBML documents require that there are either rules or reactions in the document. For instance,
@@ -78,10 +85,10 @@ def _check_equation_either_rule_or_reaction(doc: pe.EnzymeMLDocument) -> bool:
7885 """
7986
8087 species_w_rate = {
81- eq .species_id for eq in doc .equations if eq .equation_type == pe . EquationType .ODE
88+ eq .species_id for eq in doc .equations if eq .equation_type == EquationType .ODE
8289 }
8390
84- all_reaction_elements = tools .extract (obj = doc , target = pe . ReactionElement )
91+ all_reaction_elements = tools .extract (obj = doc , target = ReactionElement )
8592 result , validated = [], set ()
8693
8794 for element in all_reaction_elements :
@@ -98,7 +105,7 @@ def _check_equation_either_rule_or_reaction(doc: pe.EnzymeMLDocument) -> bool:
98105 return all (result )
99106
100107
101- def _check_units_exist (doc : pe . EnzymeMLDocument ) -> bool :
108+ def _check_units_exist (doc : EnzymeMLDocument ) -> bool :
102109 """This validator checks whether all units in the document are defined in the SBML standard.
103110
104111 Args:
@@ -109,26 +116,26 @@ def _check_units_exist(doc: pe.EnzymeMLDocument) -> bool:
109116 """
110117
111118 mandatory_unit_objects = [
112- * tools .extract (obj = doc , target = pe . MeasurementData ),
119+ * tools .extract (obj = doc , target = MeasurementData ),
113120 ]
114121
115122 optional_unit_objects = [
116- * tools .extract (obj = doc , target = pe . Parameter ),
123+ * tools .extract (obj = doc , target = Parameter ),
117124 ]
118125
119126 result = []
120127
121128 for unit_obj in mandatory_unit_objects :
122- units = tools .extract (obj = unit_obj , target = pe . UnitDefinition )
129+ units = tools .extract (obj = unit_obj , target = UnitDefinition )
123130
124131 if len (units ) == 0 :
125132 logger .error (
126- f"Object of type '{ type (unit_obj ).__name__ } ' with id '{ unit_obj .id } ' does not have a unit defined."
133+ f"Object of type '{ type (unit_obj ).__name__ } ' with id '{ unit_obj .species_id } ' does not have a unit defined."
127134 )
128135 result .append (False )
129136
130137 for unit_obj in optional_unit_objects :
131- units = tools .extract (obj = unit_obj , target = pe . UnitDefinition )
138+ units = tools .extract (obj = unit_obj , target = UnitDefinition )
132139
133140 if len (units ) == 0 :
134141 logger .warning (
@@ -140,7 +147,7 @@ def _check_units_exist(doc: pe.EnzymeMLDocument) -> bool:
140147 return all (result )
141148
142149
143- def _check_assigned_params_are_not_constant (doc : pe . EnzymeMLDocument ) -> bool :
150+ def _check_assigned_params_are_not_constant (doc : EnzymeMLDocument ) -> bool :
144151 """This validator checks whether all assigned parameters are not constant.
145152
146153 If a parameter is assigned a value through an assignment rule, it should not be constant.
@@ -154,7 +161,7 @@ def _check_assigned_params_are_not_constant(doc: pe.EnzymeMLDocument) -> bool:
154161 bool: True if all assigned parameters are valid, False otherwise.
155162 """
156163
157- assignments = doc .filter_equations (equation_type = pe . EquationType .ASSIGNMENT )
164+ assignments = doc .filter_equations (equation_type = EquationType .ASSIGNMENT )
158165 result = []
159166
160167 for assignment in assignments :
0 commit comments