Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/cobra/core/gene.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ def __init__(self, id: str = None, name: str = "", functional: bool = True) -> N
super().__init__(id=id, name=name)
self._functional = functional

@property
def id(self) -> str:
return super().id

@id.setter
def id(self, new_id) -> None:
warnings.warn(
"Direct modification of gene.id is discouraged and can lead to unexpected gene duplications. "
"Use cobra.manipulation.modify.rename_genes to safely rename genes.",
UserWarning
)
super(Gene, self.__class__).id.fset(self, new_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Moritz said, better not even set it but throw an error with the same message instead of a warning.


@property
def functional(self) -> bool:
"""Flag indicating if the gene is functional.
Expand Down
Loading