Code
import requests
import urllib3
urllib3.disable_warnings()
def fetch_uniprot_data(uniprot_id):
= f"https://rest.uniprot.org/uniprotkb/{uniprot_id}.json"
url = requests.get(url, verify=False) # Disable SSL verification
response # Raise an error for bad status codes
response.raise_for_status() return response.json()
def display_uniprot_data(data):
= data.get('primaryAccession', 'N/A')
primary_accession = data.get('proteinDescription', {}).get('recommendedName', {}).get('fullName', {}).get('value', 'N/A')
protein_name = data.get('gene', [{'geneName': {'value': 'N/A'}}])[0]['geneName']['value']
gene_name = data.get('organism', {}).get('scientificName', 'N/A')
organism
= next((comment for comment in data.get('comments', []) if comment['commentType'] == "FUNCTION"), None)
function_comment = function_comment['texts'][0]['value'] if function_comment else 'N/A'
function
# Printing the data
print(f"UniProt ID: {primary_accession}")
print(f"Protein Name: {protein_name}")
print(f"Organism: {organism}")
print(f"Function: {function}")
# Replace this with the UniProt ID you want to fetch
= "Q9UBD6"
uniprot_id = fetch_uniprot_data(uniprot_id)
data display_uniprot_data(data)
UniProt ID: Q9UBD6
Protein Name: Ammonium transporter Rh type C
Organism: Homo sapiens
Function: Ammonium transporter involved in the maintenance of acid-base homeostasis. Transports ammonium and its related derivative methylammonium across the plasma membrane of epithelial cells likely contributing to renal transepithelial ammonia transport and ammonia metabolism. Postulated to primarily mediate an electroneutral bidirectional transport of NH3 ammonia species according to a mechanism that implies interaction of an NH4(+) ion with acidic residues of the pore entry followed by dissociation of NH4(+) into NH3 and H(+). As a result NH3 transits through the central pore and is protonated on the extracellular side reforming NH4(+) (PubMed:11062476, PubMed:14761968, PubMed:15929723, PubMed:16477434, PubMed:16580862, PubMed:24077989). May act as a CO2 channel providing for renal acid secretion (PubMed:24077989)