-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Currently, the Pysces thinlayer fits all the parameters that are defined in the EnzymeML document to the measurement data:
PyEnzyme/pyenzyme/thinlayers/psyces.py
Lines 271 to 304 in 5f6cdac
| def _initialize_parameters(self): | |
| """ | |
| Initializes lmfit Parameters instance with model parameters. | |
| Returns: | |
| lmfit.Parameters: Parameters object ready for optimization. | |
| Raises: | |
| ValueError: If a parameter has neither an initial value nor a value attribute. | |
| """ | |
| # Initialize lmfit parameters | |
| parameters = lmfit.Parameters() | |
| # Add global parameters | |
| for param in self.enzmldoc.parameters: | |
| # Build kwargs dictionary with conditional assignments | |
| kwargs = { | |
| **({"min": param.lower_bound} if param.lower_bound is not None else {}), | |
| **({"max": param.upper_bound} if param.upper_bound is not None else {}), | |
| } | |
| # Determine parameter value | |
| if param.value: | |
| kwargs["value"] = param.value | |
| elif param.initial_value: | |
| kwargs["value"] = param.initial_value | |
| else: | |
| raise ValueError( | |
| f"Neither initial_value nor value given for parameter {param.name} in global parameters" | |
| ) | |
| parameters.add(param.symbol, **kwargs) | |
| return parameters |
I have a use case, however, where I only want to fit a subset of the parameters, because some parameters have been previously estimated by another method (plate assay) and the NMR data does not have sufficient information to uniquely fit all of the parameters.
The lmfit parameters dictionary as an option vary which can be assigned to a parameter, setting this to False causes this parameter not to be optimised but kept at its original value. I propose to add another keyword to an enzmldoc.parameter, e.g. vary or fit, set to True by default, but which can be overridden so that that the parameter does not get fitted by lmfit. The code quoted above can then be modified to check for this keyword.
I can work on this once #82 is fixed and the Pysces ThinLayer optimisation works in general.