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
= "P27487"
uniprot_id = fetch_uniprot_data(uniprot_id)
data display_uniprot_data(data)
UniProt ID: P27487
Protein Name: Dipeptidyl peptidase 4
Organism: Homo sapiens
Function: Cell surface glycoprotein receptor involved in the costimulatory signal essential for T-cell receptor (TCR)-mediated T-cell activation (PubMed:10900005, PubMed:10951221, PubMed:11772392, PubMed:17287217). Acts as a positive regulator of T-cell coactivation, by binding at least ADA, CAV1, IGF2R, and PTPRC (PubMed:10900005, PubMed:10951221, PubMed:11772392, PubMed:14691230). Its binding to CAV1 and CARD11 induces T-cell proliferation and NF-kappa-B activation in a T-cell receptor/CD3-dependent manner (PubMed:17287217). Its interaction with ADA also regulates lymphocyte-epithelial cell adhesion (PubMed:11772392). In association with FAP is involved in the pericellular proteolysis of the extracellular matrix (ECM), the migration and invasion of endothelial cells into the ECM (PubMed:10593948, PubMed:16651416). May be involved in the promotion of lymphatic endothelial cells adhesion, migration and tube formation (PubMed:18708048). When overexpressed, enhanced cell proliferation, a process inhibited by GPC3 (PubMed:17549790). Acts also as a serine exopeptidase with a dipeptidyl peptidase activity that regulates various physiological processes by cleaving peptides in the circulation, including many chemokines, mitogenic growth factors, neuropeptides and peptide hormones such as brain natriuretic peptide 32 (PubMed:10570924, PubMed:16254193). Removes N-terminal dipeptides sequentially from polypeptides having unsubstituted N-termini provided that the penultimate residue is proline (PubMed:10593948)