biothings / mygene.info

MyGene.info: A BioThings API for gene annotations
http://mygene.info
Other
113 stars 20 forks source link

Retrieve full table given two fields #82

Closed ilibarra closed 4 years ago

ilibarra commented 4 years ago

Dear MyGene team,

I have a user question: Is it possible to retrieve one complete mapping table between any two identifiers without having to submit gene names each time? E.g. get the full ensembl gene IDs for all symbols in mouse, or all symbols/ensembl ID pairs in human.

Something like mg.querymany, but without names as input. Maybe mg.queryall.

mg = mygene.MyGeneInfo()
out = mg.queryall(scopes='symbol', fields='ensembl.gene', species='mouse', as_dataframe=True, returnall=True)

Thank you for your consideration, Ignacio

kevinxin90 commented 4 years ago

You can do:

mg = mygene.MyGeneInfo()
mg.query('taxid:10090', fields='symbol, ensembl.gene',fetch_all=True)

This will fetch you symbols and ensemble gene ids for all mouse genes as a Python Generator.

You can then manipulate the generator as you wish.

ilibarra commented 4 years ago

Thank you for the prompt reply!