Code
import requests
import urllib3
urllib3.disable_warnings()
def fetch_uniprot_data(uniprot_id):
url = f"https://rest.uniprot.org/uniprotkb/{uniprot_id}.json"
response = requests.get(url, verify=False) # Disable SSL verification
response.raise_for_status() # Raise an error for bad status codes
return response.json()
def display_uniprot_data(data):
primary_accession = data.get('primaryAccession', 'N/A')
protein_name = data.get('proteinDescription', {}).get('recommendedName', {}).get('fullName', {}).get('value', 'N/A')
gene_name = data.get('gene', [{'geneName': {'value': 'N/A'}}])[0]['geneName']['value']
organism = data.get('organism', {}).get('scientificName', 'N/A')
function_comment = next((comment for comment in data.get('comments', []) if comment['commentType'] == "FUNCTION"), None)
function = function_comment['texts'][0]['value'] if function_comment else 'N/A'
# 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
uniprot_id = "Q8WWT9"
data = fetch_uniprot_data(uniprot_id)
display_uniprot_data(data)UniProt ID: Q8WWT9
Protein Name: Na(+)/dicarboxylate cotransporter 3
Organism: Homo sapiens
Function: High-affinity sodium-dicarboxylate cotransporter that accepts a range of substrates with 4-6 carbon atoms, such as the citric acid cycle intermediates succinate and alpha-ketoglutarate (2-oxoglutarate), as well as other compounds including N-acetyl-L-aspartate (PubMed:10794676, PubMed:10992006, PubMed:15561973, PubMed:17356845, PubMed:17426067, PubMed:24247155, PubMed:30635937). Transports the dicarboxylate into the cell with a probable stoichiometry of 3 Na(+) for 1 divalent dicarboxylate, rendering the process electrogenic (PubMed:10794676, PubMed:10992006). Can transport citrate in a Na(+)-dependent manner, recognizing the divalent form of citrate rather than the trivalent form which is normally found in blood (PubMed:10794676)