Skip to content

Commit 9ad1872

Browse files
committed
improved package structure: utils and flux_analysis are now available as well
1 parent 0d4c597 commit 9ad1872

File tree

9 files changed

+17
-16
lines changed

9 files changed

+17
-16
lines changed

src/PAModelpy/Enzyme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def change_kcat_values(self, rxn2kcat: Dict):
250250
else:
251251
catalytic_event_id = f"CE_{CatalyticEvent._extract_reaction_id_from_catalytic_reaction_id(rxn_id, self.enzyme_id_regex)}"
252252
# change rxn2kcat dictionary
253-
self.rxn2kcat[rxn_id] = {**self.rxn2kcat[rxn_id],**kcats}
253+
self.rxn2kcat.setdefault(catalytic_event_id, {}).update(kcats)
254254
# is there already a link between enzyme and reaction?
255255
if catalytic_event_id not in self.catalytic_events:
256256
warn(f"Reaction {rxn_id} is not associated with enzyme {self.id}. Skip")

src/PAModelpy/EnzymeSectors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,7 @@ def _get_model_genes_from_enzyme(self, enzyme_id: str, model: Model) -> list:
380380
def change_kcat_values(self, rxn_id:str, enzyme_id:str,
381381
kcat_f_b:dict[Literal['f', 'b'], float]
382382
) -> None:
383-
rxnid2protein = defaultdict(dict ,self.rxn2protein[rxn_id])
384-
rxnid2protein[enzyme_id] = {**rxnid2protein[enzyme_id],**kcat_f_b}
385-
self.rxn2protein[rxn_id] = dict(rxnid2protein)
383+
self.rxn2protein.setdefault(rxn_id, {}).update(kcat_f_b)
386384

387385
def __setstate__(self, state):
388386
# Restore state from the unpickled state

src/PAModelpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
print('Loading PAModelpy modules version 0.0.4.1')
1+
print('Loading PAModelpy modules version 0.0.4.2')
22

33
from .Enzyme import *
44
from .EnzymeSectors import *
File renamed without changes.

src/utils/pam_generation.py renamed to src/PAModelpy/utils/pam_generation.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from dataclasses import dataclass, field
1010

1111

12-
from src.PAModelpy.PAModel import PAModel
13-
from src.PAModelpy.EnzymeSectors import ActiveEnzymeSector, UnusedEnzymeSector, TransEnzymeSector
14-
from src.PAModelpy.configuration import Config
12+
from ..PAModel import PAModel
13+
from ..EnzymeSectors import ActiveEnzymeSector, UnusedEnzymeSector, TransEnzymeSector
14+
from ..configuration import Config
1515

1616
DEFAULT_MOLMASS = 39959.4825 #kDa
1717
DEFAULT_KCAT = 11 #s-1
@@ -80,7 +80,7 @@ def parse_gpr_information(gpr_info:str,
8080
gene2protein: dict[str, str] = None) -> tuple[list,list]:
8181
#filter out nan entries
8282
if not isinstance(gpr_info, str):
83-
return None
83+
return None, None
8484

8585
# #only get the genes associated with this enzyme
8686
gpr_list = _parse_gpr(gpr_info)
@@ -191,11 +191,13 @@ def _check_if_all_model_reactions_are_in_rxn_info2protein(model: cobra.Model,
191191
protein2gpr:defaultdict[str,list]
192192
) -> Tuple[dict[str, ReactionInformation],defaultdict[str,list]]:
193193
for rxn in model.reactions:
194+
rxn_id = _extract_reaction_id(
195+
rxn.id) # some reactions ids are associated with copy numbers, only filter for the actual reaction id
194196
if not (
195-
rxn.id not in rxn_info2protein.keys()
196-
and 'EX'.lower() not in rxn.id.lower()#is the reaction an exchange with the environment?
197-
and 'BIOMASS' not in rxn.id#is the reaction a pseudoreaction?
198-
and len(rxn._genes) > 0 #is the reaction associated with enzymes?
197+
rxn_id not in rxn_info2protein.keys()
198+
and 'EX'.lower() not in rxn.id.lower() # is the reaction an exchange with the environment?
199+
and 'BIOMASS' not in rxn.id # is the reaction a pseudoreaction?
200+
and len(rxn._genes) > 0 # is the reaction associated with enzymes?
199201
and list(rxn._genes)[0].id != 's0001'
200202
): continue
201203

src/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from PAModelpy import *
1+
from PAModelpy.src.PAModelpy.flux_analysis import *
2+
from PAModelpy.src.PAModelpy.utils import *

src/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ requires = [
55
build-backend = "setuptools.build_meta"
66

77
[tool.setuptools.packages]
8-
find = {} # Scan the project directory with the default parameters
8+
find = { where = ["src"] } # Scan the project directory with the default parameters
99

1010
[project]
1111
name = 'PAModelpy'
12-
version = '0.0.4.1'
12+
version = '0.0.4.2'
1313
authors = [{name='Samira van den Bogaard', email = 'samira.vandenbogaard@rwth-aachen.de'}]
1414
description = 'Python framework for building and analysing protein allocation models'
1515
readme = 'README.md'

0 commit comments

Comments
 (0)