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 = "Q9P0L9"
data = fetch_uniprot_data(uniprot_id)
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)