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
= "Q9P0L9"
uniprot_id = fetch_uniprot_data(uniprot_id)
data display_uniprot_data(data)
UniProt ID: Q9P0L9
Protein Name: Polycystin-2-like protein 1
Organism: Homo sapiens
Function: Pore-forming subunit of a heterotetrameric, non-selective cation channel that is permeable to Ca(2+) (PubMed:10517637, PubMed:11959145, PubMed:23212381, PubMed:25820328, PubMed:27754867, PubMed:29425510, PubMed:30004384). Pore-forming subunit of a calcium-permeant ion channel formed by PKD1L2 and PKD1L1 in primary cilia, where it controls cilium calcium concentration, but does not affect cytoplasmic calcium concentration (PubMed:24336289). The channel formed by PKD1L2 and PKD1L1 in primary cilia regulates sonic hedgehog/SHH signaling and GLI2 transcription (PubMed:24336289). Pore-forming subunit of a channel formed by PKD1L2 and PKD1L3 that contributes to sour taste perception in gustatory cells (PubMed:19812697). The heteromeric channel formed by PKD1L2 and PKD1L3 is activated by low pH, but opens only when the extracellular pH rises again (PubMed:23212381). May play a role in the perception of carbonation taste (By similarity). May play a role in the sensory perception of water, via a mechanism that activates the channel in response to dilution of salivary bicarbonate and changes in salivary pH (By similarity)