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

Prepend underscores for tab completion of IDs that start with a number #828

Closed
zakandrewking opened this issue Apr 2, 2019 · 4 comments
Closed

Comments

@zakandrewking
Copy link
Contributor

zakandrewking commented Apr 2, 2019

Tab completion of reaction and metabolite IDs is convenient and widely used in IPython and Jupyter. Falling back on get_by_id for IDs that do not match the Python variable-naming rules is a common annoyance (for me at least, and I imagine many other users).

IDs from existing databases (BiGG, KEGG, etc.) generally use a limited character set that is consistent with Python variable naming, so tab completion works. The main exception is identifiers that start with a number. These are common in BiGG – I'm not sure about other databases – and it would take quite a lot of work to move existing models to new BiGG IDs not starting with numbers. It would also be less intuitive because chemical names commonly begin with numbers ("10-Formyltetrahydrofolate", "1-propanol", etc.).

What if, as a compromise, COBRApy prepended IDs that start with numbers with an underscore, just for tab-completion (and just in the cases were IDs do not conflict with another ID in the model)?

So this would work:

iJO1366.metabolites._10ft<tab>
# completes to:
iJO1366.metabolites._10fthf
# which is equivalent to:
iJO1366.metabolites.get_by_id('10fthf')
@Midnighter
Copy link
Member

Yes, I've been considering that as well. I think the big pro is usability in terms of fast interactive access to objects. The downsides I see, and they do not necessarily outweigh the big pro, are inconsistency between DictList.get_by_id and DictList.<tab> and further inconsistency between the identifier in the SBML and in the cobra.Model.

Alternatively, we could prepend everything with M_, R_ or G_ but suffers from the same problems.

@cdiener
Copy link
Member

cdiener commented Apr 4, 2019

What would you do if there is already another reaction with id _10fthf?

@zakandrewking
Copy link
Contributor Author

In that case, the shortcut would point to the exact match:

iJO1366.metabolites._10ft<tab>
# completes to:
iJO1366.metabolites._10fthf
# which is equivalent to:
iJO1366.metabolites.get_by_id('_10fthf')

I image that's a rare case, and BiGG IDs cannot begin with underscore, but it would be a potential source of confusion.

@cdiener
Copy link
Member

cdiener commented Nov 4, 2022

The preference seems to be to implement along the lines of SBML identifiers.

@cdiener cdiener closed this as completed Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants