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
= "P30511"
uniprot_id = fetch_uniprot_data(uniprot_id)
data display_uniprot_data(data)
UniProt ID: P30511
Protein Name: HLA class I histocompatibility antigen, alpha chain F
Organism: Homo sapiens
Function: Non-classical major histocompatibility class Ib molecule postulated to play a role in immune surveillance, immune tolerance and inflammation. Functions in two forms, as a heterotrimeric complex with B2M/beta-2 microglobulin and a peptide (peptide-bound HLA-F-B2M) and as an open conformer (OC) devoid of peptide and B2M (peptide-free OC). In complex with B2M, presents non-canonical self-peptides carrying post-translational modifications, particularly phosphorylated self-peptides. Peptide-bound HLA-F-B2M acts as a ligand for LILRB1 inhibitory receptor, a major player in maternal-fetal tolerance. Peptide-free OC acts as a ligand for KIR3DS1 and KIR3DL2 receptors (PubMed:28636952). Upon interaction with activating KIR3DS1 receptor on NK cells, triggers NK cell degranulation and anti-viral cytokine production (PubMed:27455421). Through interaction with KIR3DL2 receptor, inhibits NK and T cell effector functions (PubMed:24018270). May interact with other MHC class I OCs to cross-present exogenous viral, tumor or minor histompatibility antigens to cytotoxic CD8+ T cells, triggering effector and memory responses (PubMed:23851683). May play a role in inflammatory responses in the peripheral nervous system. Through interaction with KIR3DL2, may protect motor neurons from astrocyte-induced toxicity (PubMed:26928464)