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 = "P98155"
data = fetch_uniprot_data(uniprot_id)
display_uniprot_data(data)UniProt ID: P98155
Protein Name: Very low-density lipoprotein receptor
Organism: Homo sapiens
Function: Multifunctional cell surface receptor that binds VLDL and transports it into cells by endocytosis and therefore plays an important role in energy metabolism. Binds also to a wide range of other molecules including Reelin/RELN or apolipoprotein E/APOE-containing ligands as well as clusterin/CLU (PubMed:24381170, PubMed:30873003). In the off-state of the pathway, forms homooligomers or heterooligomers with LRP8 (PubMed:30873003). Upon binding to ligands, homooligomers are rearranged to higher order receptor clusters that transmit the extracellular RELN signal to intracellular signaling processes by binding to DAB1 (PubMed:30873003). This interaction results in phosphorylation of DAB1 leading to the ultimate cell responses required for the correct positioning of newly generated neurons. Later, mediates a stop signal for migrating neurons, preventing them from entering the marginal zone (By similarity)