Created
May 10, 2024 07:25
-
-
Save Stfort52/b7cafecf00d4ebf2152e4a4e993711d5 to your computer and use it in GitHub Desktop.
Simple uniprot interface, not suitable for real querying
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ens2seq(ensembl_id: str) -> str: | |
"""Converts ensembl gene id to protein sequence | |
@ensembl_id: str, ensembl gene id | |
""" | |
uri = f"https://rest.uniprot.org/uniprotkb/stream?" | |
query = f"({ensembl_id}) AND (reviewed:true)" | |
params = { | |
"compressed": "false", | |
"format": "fasta", | |
"query": query | |
} | |
response = requests.get(uri, params=params) | |
fasta = response.text | |
if fasta == "": | |
return "" | |
fasta = fasta.split("\n", 1)[1] | |
return fasta.replace("\n", "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment