Skip to content

Commit

Permalink
Fixes and small code refurbishment
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulocracy committed Feb 1, 2024
1 parent 1754fc7 commit 2cdf0b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cnapy/appdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ def load_scenario_into_model(self, model: cobra.Model):
for (reaction, coeff) in zip(reactions, expression.values()):
constr.set_linear_coefficients({reaction.forward_variable: coeff, reaction.reverse_variable: -coeff})

reac_ids = [x.id for x in model.reactions]
reaction_ids = [reaction.id for reaction in model.reactions]
for annotation in self.scen_values.annotations:
if annotation["key"] not in reac_ids:
if annotation["reaction_id"] not in reaction_ids:
continue
reaction: cobra.Reaction = model.reactions.get_by_id(annotation["key"])
reaction: cobra.Reaction = model.reactions.get_by_id(annotation["reaction_id"])
reaction.annotation[annotation["key"]] = annotation["value"]

def collect_default_scenario_values(self) -> Tuple[List[str], List[Tuple[float, float]]]:
Expand Down
12 changes: 6 additions & 6 deletions cnapy/gui_elements/scenario_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ScenarioReactionColumn(IntEnum):
UB = 3

class ScenarioAnnotationColumn(IntEnum):
Id = 0
Reaction_id = 0
Key = 1
Value = 2

Expand Down Expand Up @@ -131,7 +131,7 @@ def __init__(self, central_widget):

scenario_annotations = QWidget()
annotations_layout = QVBoxLayout(scenario_annotations)
label = QLabel("Scenario annotations")
label = QLabel("Scenario reaction annotations")
label.setToolTip("The IDs of the scenario annotations are the affected reaction ID.")
hbox = QHBoxLayout()
hbox.addWidget(label)
Expand Down Expand Up @@ -273,15 +273,15 @@ def cell_content_changed(self, row: int, column: int):

@Slot(int, int)
def cell_content_changed_annotations(self, row: int, column: int):
reac_id: str = self.annotations.item(row, ScenarioAnnotationColumn.Id).text()
reaction_id: str = self.annotations.item(row, ScenarioAnnotationColumn.Reaction_id).text()
key: str = self.annotations.item(row, ScenarioAnnotationColumn.Key).text()
value: str = self.annotations.item(row, ScenarioAnnotationColumn.Value).text()
changed_annotation = {
"id": reac_id,
"reaction_id": reaction_id,
"key": key,
"value": value,
}
self.appdata.project.scen_values[row] = changed_annotation
self.appdata.project.scen_values.annotations[row] = changed_annotation
self.scenario_changed()

def verify_bound(self, item: QTableWidgetItem):
Expand Down Expand Up @@ -421,7 +421,7 @@ def delete_scenario_annotation(self):
self.scenario_changed()

def new_annotation_row(self, row: int):
self.annotations.setItem(row, ScenarioAnnotationColumn.Id, QTableWidgetItem())
self.annotations.setItem(row, ScenarioAnnotationColumn.Reaction_id, QTableWidgetItem())
self.annotations.setItem(row, ScenarioAnnotationColumn.Key, QTableWidgetItem())
self.annotations.setItem(row, ScenarioAnnotationColumn.Value, QTableWidgetItem())
self.scenario_changed()
Expand Down

0 comments on commit 2cdf0b9

Please sign in to comment.