diff --git a/src/PAModelpy/Enzyme.py b/src/PAModelpy/Enzyme.py index f754708..860be25 100644 --- a/src/PAModelpy/Enzyme.py +++ b/src/PAModelpy/Enzyme.py @@ -250,7 +250,7 @@ def change_kcat_values(self, rxn2kcat: Dict): else: catalytic_event_id = f"CE_{CatalyticEvent._extract_reaction_id_from_catalytic_reaction_id(rxn_id, self.enzyme_id_regex)}" # change rxn2kcat dictionary - self.rxn2kcat[rxn_id] = {**self.rxn2kcat[rxn_id],**kcats} + self.rxn2kcat.setdefault(catalytic_event_id, {}).update(kcats) # is there already a link between enzyme and reaction? if catalytic_event_id not in self.catalytic_events: warn(f"Reaction {rxn_id} is not associated with enzyme {self.id}. Skip") diff --git a/src/PAModelpy/EnzymeSectors.py b/src/PAModelpy/EnzymeSectors.py index 1d796ec..016eab6 100644 --- a/src/PAModelpy/EnzymeSectors.py +++ b/src/PAModelpy/EnzymeSectors.py @@ -380,9 +380,7 @@ def _get_model_genes_from_enzyme(self, enzyme_id: str, model: Model) -> list: def change_kcat_values(self, rxn_id:str, enzyme_id:str, kcat_f_b:dict[Literal['f', 'b'], float] ) -> None: - rxnid2protein = defaultdict(dict ,self.rxn2protein[rxn_id]) - rxnid2protein[enzyme_id] = {**rxnid2protein[enzyme_id],**kcat_f_b} - self.rxn2protein[rxn_id] = dict(rxnid2protein) + self.rxn2protein.setdefault(rxn_id, {}).update(kcat_f_b) def __setstate__(self, state): # Restore state from the unpickled state diff --git a/src/PAModelpy/__init__.py b/src/PAModelpy/__init__.py index 590c7bf..aafae96 100644 --- a/src/PAModelpy/__init__.py +++ b/src/PAModelpy/__init__.py @@ -1,4 +1,4 @@ -print('Loading PAModelpy modules version 0.0.4.1') +print('Loading PAModelpy modules version 0.0.4.2') from .Enzyme import * from .EnzymeSectors import * diff --git a/src/flux_analysis/__init__.py b/src/PAModelpy/flux_analysis/__init__.py similarity index 100% rename from src/flux_analysis/__init__.py rename to src/PAModelpy/flux_analysis/__init__.py diff --git a/src/flux_analysis/recombinant_protein_expression.py b/src/PAModelpy/flux_analysis/recombinant_protein_expression.py similarity index 100% rename from src/flux_analysis/recombinant_protein_expression.py rename to src/PAModelpy/flux_analysis/recombinant_protein_expression.py diff --git a/src/utils/__init__.py b/src/PAModelpy/utils/__init__.py similarity index 100% rename from src/utils/__init__.py rename to src/PAModelpy/utils/__init__.py diff --git a/src/utils/pam_generation.py b/src/PAModelpy/utils/pam_generation.py similarity index 96% rename from src/utils/pam_generation.py rename to src/PAModelpy/utils/pam_generation.py index 36d7985..6222bb7 100644 --- a/src/utils/pam_generation.py +++ b/src/PAModelpy/utils/pam_generation.py @@ -9,9 +9,9 @@ from dataclasses import dataclass, field -from src.PAModelpy.PAModel import PAModel -from src.PAModelpy.EnzymeSectors import ActiveEnzymeSector, UnusedEnzymeSector, TransEnzymeSector -from src.PAModelpy.configuration import Config +from ..PAModel import PAModel +from ..EnzymeSectors import ActiveEnzymeSector, UnusedEnzymeSector, TransEnzymeSector +from ..configuration import Config DEFAULT_MOLMASS = 39959.4825 #kDa DEFAULT_KCAT = 11 #s-1 @@ -80,7 +80,7 @@ def parse_gpr_information(gpr_info:str, gene2protein: dict[str, str] = None) -> tuple[list,list]: #filter out nan entries if not isinstance(gpr_info, str): - return None + return None, None # #only get the genes associated with this enzyme gpr_list = _parse_gpr(gpr_info) @@ -191,11 +191,13 @@ def _check_if_all_model_reactions_are_in_rxn_info2protein(model: cobra.Model, protein2gpr:defaultdict[str,list] ) -> Tuple[dict[str, ReactionInformation],defaultdict[str,list]]: for rxn in model.reactions: + rxn_id = _extract_reaction_id( + rxn.id) # some reactions ids are associated with copy numbers, only filter for the actual reaction id if not ( - rxn.id not in rxn_info2protein.keys() - and 'EX'.lower() not in rxn.id.lower()#is the reaction an exchange with the environment? - and 'BIOMASS' not in rxn.id#is the reaction a pseudoreaction? - and len(rxn._genes) > 0 #is the reaction associated with enzymes? + rxn_id not in rxn_info2protein.keys() + and 'EX'.lower() not in rxn.id.lower() # is the reaction an exchange with the environment? + and 'BIOMASS' not in rxn.id # is the reaction a pseudoreaction? + and len(rxn._genes) > 0 # is the reaction associated with enzymes? and list(rxn._genes)[0].id != 's0001' ): continue diff --git a/src/__init__.py b/src/__init__.py index f3435d1..2043616 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1 +1,2 @@ -from PAModelpy import * \ No newline at end of file +from PAModelpy.src.PAModelpy.flux_analysis import * +from PAModelpy.src.PAModelpy.utils import * \ No newline at end of file diff --git a/src/pyproject.toml b/src/pyproject.toml index 6f84e28..4f9e34d 100644 --- a/src/pyproject.toml +++ b/src/pyproject.toml @@ -5,11 +5,11 @@ requires = [ build-backend = "setuptools.build_meta" [tool.setuptools.packages] -find = {} # Scan the project directory with the default parameters +find = { where = ["src"] } # Scan the project directory with the default parameters [project] name = 'PAModelpy' -version = '0.0.4.1' +version = '0.0.4.2' authors = [{name='Samira van den Bogaard', email = 'samira.vandenbogaard@rwth-aachen.de'}] description = 'Python framework for building and analysing protein allocation models' readme = 'README.md'