bc_get_string_interactions
Retrieve high-confidence protein-protein interactions for a specific protein and species using a combined score threshold. Supports biomedical research by providing verified interaction data.
Instructions
Get all protein-protein interactions for a given protein with a combined score above the threshold.
Always provide the species parameter to ensure the correct protein is returned.
Args: protein_symbol (str): The name of the protein to search for (e.g., "TP53"). species (str): The species taxonomy ID (e.g., "10090" for mouse). min_score (int): Minimum combined score threshold (default: 700).
Returns: list: A list of dictionaries containing interacting proteins and their scores.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| min_score | No | Minimum combined score threshold | |
| protein_symbol | Yes | The name of the protein to search for (e.g., 'TP53') | |
| species | Yes | The species taxonomy ID (e.g., '10090' for mouse) |
Implementation Reference
- The main handler function for the 'get_string_interactions' tool. It uses the get_string_id helper to resolve the protein symbol to a STRING ID, then queries the STRING DB API for interaction partners above a minimum score threshold. Returns list of interactions or error dict. Note: This matches the functionality; tool name in code is 'get_string_interactions', likely the intended despite 'bc_' in query.@core_mcp.tool() def get_string_interactions( protein_symbol: Annotated[str, Field(description="Protein name to search for (e.g., 'TP53')")], species: Annotated[str, Field(description="Species taxonomy ID (e.g., '10090' for mouse)")], min_score: Annotated[int, Field(description="Minimum combined score threshold (0-1000)", ge=0, le=1000)] = 700, ) -> Union[List[Dict[str, Any]], dict]: """Retrieve protein-protein interactions for a given protein with scores above threshold. Always provide species parameter. Returns: list or dict: Protein interactions array with stringId_A, stringId_B, preferredName_A/B, score, evidence channels or error message. """ # First resolve the protein name to a STRING ID try: string_id = get_string_id.fn(protein_symbol=protein_symbol, species=species) if not string_id or not isinstance(string_id, str): return {"error": f"No STRING ID found for protein: {protein_symbol}"} url = f"https://string-db.org/api/json/interaction_partners?identifiers={string_id}&species={species}&required_score={min_score}&format=json" response = requests.get(url) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: return {"error": f"Failed to fetch interactions: {e!s}"} except Exception as e: return {"error": f"An error occurred: {e!s}"}
- Input schema defined using Pydantic Annotated with Field for validation and descriptions: protein_symbol (str), species (str), min_score (int, 0-1000, default 700). Output: Union[List[Dict[str, Any]], dict]def get_string_interactions( protein_symbol: Annotated[str, Field(description="Protein name to search for (e.g., 'TP53')")], species: Annotated[str, Field(description="Species taxonomy ID (e.g., '10090' for mouse)")], min_score: Annotated[int, Field(description="Minimum combined score threshold (0-1000)", ge=0, le=1000)] = 700, ) -> Union[List[Dict[str, Any]], dict]:
- src/biocontext_kb/core/_server.py:3-6 (registration)The FastMCP server instance 'core_mcp' is created here with identifier 'BC'. Tool functions are registered by decorating with @core_mcp.tool(), which likely handles the MCP tool registration. The 'BC' may relate to the 'bc_' prefix in the query.core_mcp = FastMCP( # type: ignore "BC", instructions="Provides access to biomedical knowledge bases.", )
- The helper function get_string_id, also a tool, resolves protein symbols to STRING database IDs by querying the STRING API. Called via get_string_id.fn() in the main handler.@core_mcp.tool() def get_string_id( protein_symbol: Annotated[str, Field(description="Protein name or identifier (e.g., 'TP53')")], species: Annotated[str, Field(description="Species taxonomy ID (e.g., '9606' for human)")] = "", return_field: Annotated[str, Field(description="Field to return: 'stringId' or 'preferredName'")] = "stringId", limit: Annotated[int, Field(description="Maximum number of matches to return")] = 1, ) -> Union[dict, str]: """Map protein identifiers (gene names, synonyms, UniProt IDs) to STRING database IDs. Using STRING IDs improves reliability. Returns: str or dict: STRING ID string (e.g., '9606.ENSP00000269305') or dict with error message. """ url = f"https://string-db.org/api/json/get_string_ids?identifiers={protein_symbol}&echo_query=1&limit={limit}" if species: url += f"&species={species}" try: response = requests.get(url) response.raise_for_status() data = response.json() if isinstance(data, dict) and "error" in data: return data if not data: return {"error": f"No STRING ID found for protein: {protein_symbol}"} return data[0].get(return_field) except requests.exceptions.RequestException as e: return {"error": f"Failed to fetch STRING ID: {e!s}"}
- src/biocontext_kb/core/stringdb/__init__.py:2-2 (registration)Import of get_string_interactions in the stringdb package __init__.py, exposing the tool.from ._get_string_interactions import get_string_interactions