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 = "Q13586"
data = fetch_uniprot_data(uniprot_id)
display_uniprot_data(data)UniProt ID: Q13586
Protein Name: Stromal interaction molecule 1
Organism: Homo sapiens
Function: Acts as a Ca(2+) sensor that gates two major inward rectifying Ca(2+) channels at the plasma membrane: Ca(2+) release-activated Ca(2+) (CRAC) channels and arachidonate-regulated Ca(2+)-selective (ARC) channels (PubMed:15866891, PubMed:16005298, PubMed:16208375, PubMed:16537481, PubMed:16733527, PubMed:16766533, PubMed:16807233, PubMed:18854159, PubMed:19182790, PubMed:19249086, PubMed:19622606, PubMed:19706554, PubMed:22464749, PubMed:24069340, PubMed:24351972, PubMed:24591628, PubMed:25326555, PubMed:26322679, PubMed:28219928, PubMed:32415068). Plays a role in mediating store-operated Ca(2+) entry (SOCE), a Ca(2+) influx following depletion of intracellular Ca(2+) stores. Upon Ca(2+) depletion, translocates from the endoplasmic reticulum to the plasma membrane where it activates CRAC channel pore-forming subunits ORA1, ORA2 and ORAI3 to generate sustained and oscillatory Ca(2+) entry (PubMed:16208375, PubMed:16537481, PubMed:32415068). Involved in enamel formation (PubMed:24621671)