Skip to content

Commit

Permalink
More fixes & Reaction ID autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulocracy committed Feb 1, 2024
1 parent 2cdf0b9 commit 7214753
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cnapy/appdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ def load_scenario_into_model(self, model: cobra.Model):

reaction_ids = [reaction.id for reaction in model.reactions]
for annotation in self.scen_values.annotations:
if "reaction_id" not in annotation.keys():
continue
if annotation["reaction_id"] not in reaction_ids:
continue
reaction: cobra.Reaction = model.reactions.get_by_id(annotation["reaction_id"])
Expand Down
5 changes: 3 additions & 2 deletions cnapy/gui_elements/scenario_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def cell_content_changed(self, row: int, column: int):

@Slot(int, int)
def cell_content_changed_annotations(self, row: int, column: int):
reaction_id: str = self.annotations.item(row, ScenarioAnnotationColumn.Reaction_id).text()
reaction_id: str = self.annotations.cellWidget(row, ScenarioAnnotationColumn.Reaction_id).text().strip()
key: str = self.annotations.item(row, ScenarioAnnotationColumn.Key).text()
value: str = self.annotations.item(row, ScenarioAnnotationColumn.Value).text()
changed_annotation = {
Expand Down Expand Up @@ -411,6 +411,7 @@ def add_scenario_annotation(self):
self.appdata.project.scen_values.annotations.append({})
self.new_annotation_row(row)
self.scenario_changed()
self.annotations.setCurrentCell(row, ScenarioReactionColumn.Id)

def delete_scenario_annotation(self):
row: int = self.annotations.currentRow()
Expand All @@ -421,7 +422,7 @@ def delete_scenario_annotation(self):
self.scenario_changed()

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

0 comments on commit 7214753

Please sign in to comment.