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 = "P05067"
data = fetch_uniprot_data(uniprot_id)
display_uniprot_data(data)UniProt ID: P05067
Protein Name: Amyloid-beta precursor protein
Organism: Homo sapiens
Function: Functions as a cell surface receptor and performs physiological functions on the surface of neurons relevant to neurite growth, neuronal adhesion and axonogenesis. Interaction between APP molecules on neighboring cells promotes synaptogenesis (PubMed:25122912). Involved in cell mobility and transcription regulation through protein-protein interactions. Can promote transcription activation through binding to APBB1-KAT5 and inhibits Notch signaling through interaction with Numb. Couples to apoptosis-inducing pathways such as those mediated by G(o) and JIP. Inhibits G(o) alpha ATPase activity (By similarity). Acts as a kinesin I membrane receptor, mediating the axonal transport of beta-secretase and presenilin 1 (By similarity). By acting as a kinesin I membrane receptor, plays a role in axonal anterograde transport of cargo towards synapses in axons (PubMed:17062754, PubMed:23011729). Involved in copper homeostasis/oxidative stress through copper ion reduction. In vitro, copper-metallated APP induces neuronal death directly or is potentiated through Cu(2+)-mediated low-density lipoprotein oxidation. Can regulate neurite outgrowth through binding to components of the extracellular matrix such as heparin and collagen I and IV. The splice isoforms that contain the BPTI domain possess protease inhibitor activity. Induces a AGER-dependent pathway that involves activation of p38 MAPK, resulting in internalization of amyloid-beta peptide and leading to mitochondrial dysfunction in cultured cortical neurons. Provides Cu(2+) ions for GPC1 which are required for release of nitric oxide (NO) and subsequent degradation of the heparan sulfate chains on GPC1