bc_get_uniprot_id_by_protein_symbol
Retrieve UniProt IDs using protein names and species IDs. This tool queries the UniProt database to map protein symbols to their corresponding UniProt identifiers for accurate biological data analysis.
Instructions
Query the UniProt database for the UniProt ID using the protein name.
Args: protein_symbol (str): The name of the protein to search for (e.g., "SYNPO"). species (str): The organism ID (e.g., "9606" for human). Default is "9606".
Returns: str: The UniProt ID of the protein.
Raises: ValueError: If no results are found for the given protein name.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| protein_symbol | Yes | The name of the gene to search for (e.g., 'SYNPO') | |
| species | No | The organism ID (e.g., '9606' for human) | 9606 |
Implementation Reference
- The handler function for the tool 'get_uniprot_id_by_protein_symbol' (likely the requested 'bc_get_uniprot_id_by_protein_symbol'). It queries the UniProt REST API to retrieve the UniProt accession ID given a protein symbol and species taxonomy ID. Includes inline schema via Pydantic Annotated types.@core_mcp.tool() def get_uniprot_id_by_protein_symbol( protein_symbol: Annotated[str, Field(description="Gene or protein name to search for (e.g., 'SYNPO')")], species: Annotated[ str, Field(description="Organism taxonomy ID (e.g., '9606' for human)"), ] = "9606", ) -> str | None: """Retrieve UniProt accession ID from protein name and species. Returns the primary accession or None if not found. Returns: str or None: UniProt accession ID string (e.g., 'P04637') or None if not found. """ url = f"https://rest.uniprot.org/uniprotkb/search?query=protein_name:{protein_symbol}+AND+organism_id:{species}&format=json" response = requests.get(url) response.raise_for_status() data = response.json() if data["results"]: return data["results"][0]["primaryAccession"] return None
- src/biocontext_kb/core/uniprot/__init__.py:1-1 (registration)Imports and exports the tool function for use in the package.from ._get_uniprot_id_by_protein_symbol import get_uniprot_id_by_protein_symbol
- Pydantic schema defined inline in the tool function signature for input validation (protein_symbol: str, species: str = '9606') and output str | None.def get_uniprot_id_by_protein_symbol( protein_symbol: Annotated[str, Field(description="Gene or protein name to search for (e.g., 'SYNPO')")], species: Annotated[ str, Field(description="Organism taxonomy ID (e.g., '9606' for human)"), ] = "9606", ) -> str | None: