Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct gene.id modification warning message. #1424

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
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)

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