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 = "O14788"
data = fetch_uniprot_data(uniprot_id)
display_uniprot_data(data)UniProt ID: O14788
Protein Name: Tumor necrosis factor ligand superfamily member 11
Organism: Homo sapiens
Function: Cytokine that binds to TNFRSF11B/OPG and to TNFRSF11A/RANK. Osteoclast differentiation and activation factor. Augments the ability of dendritic cells to stimulate naive T-cell proliferation. May be an important regulator of interactions between T-cells and dendritic cells and may play a role in the regulation of the T-cell-dependent immune response. May also play an important role in enhanced bone-resorption in humoral hypercalcemia of malignancy (PubMed:22664871). Induces osteoclastogenesis by activating multiple signaling pathways in osteoclast precursor cells, chief among which is induction of long lasting oscillations in the intracellular concentration of Ca (2+) resulting in the activation of NFATC1, which translocates to the nucleus and induces osteoclast-specific gene transcription to allow differentiation of osteoclasts. During osteoclast differentiation, in a TMEM64 and ATP2A2-dependent manner induces activation of CREB1 and mitochondrial ROS generation necessary for proper osteoclast generation (By similarity)