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 = "Q13740"
data = fetch_uniprot_data(uniprot_id)
display_uniprot_data(data)UniProt ID: Q13740
Protein Name: CD166 antigen
Organism: Homo sapiens
Function: Cell adhesion molecule that mediates both heterotypic cell-cell contacts via its interaction with CD6, as well as homotypic cell-cell contacts (PubMed:15048703, PubMed:15496415, PubMed:16352806, PubMed:23169771, PubMed:24945728, PubMed:7760007). Promotes T-cell activation and proliferation via its interactions with CD6 (PubMed:15048703, PubMed:16352806, PubMed:24945728). Contributes to the formation and maturation of the immunological synapse via its interactions with CD6 (PubMed:15294938, PubMed:16352806). Mediates homotypic interactions with cells that express ALCAM (PubMed:15496415, PubMed:16352806). Acts as a ligand for the LILRB4 receptor, enhancing LILRB4-mediated inhibition of T cell proliferation (PubMed:29263213). Required for normal hematopoietic stem cell engraftment in the bone marrow (PubMed:24740813). Mediates attachment of dendritic cells onto endothelial cells via homotypic interaction (PubMed:23169771). Inhibits endothelial cell migration and promotes endothelial tube formation via homotypic interactions (PubMed:15496415, PubMed:23169771). Required for normal organization of the lymph vessel network. Required for normal hematopoietic stem cell engraftment in the bone marrow. Plays a role in hematopoiesis; required for normal numbers of hematopoietic stem cells in bone marrow. Promotes in vitro osteoblast proliferation and differentiation (By similarity). Promotes neurite extension, axon growth and axon guidance; axons grow preferentially on surfaces that contain ALCAM. Mediates outgrowth and pathfinding for retinal ganglion cell axons (By similarity)