Batch Query Open Targets Graphql
batch_query_open_targets_graphqlFull Description
Execute the same GraphQL query multiple times with different variable sets.
Use this tool instead of the regular query tool when you need to run the same query repeatedly with different arguments (e.g., querying multiple drugs, targets, or diseases).
WORKFLOW
- Follow these steps in order:
Step 1: RESOLVE IDENTIFIERS If user provides common names (gene symbols, disease names, drug names), use search_entity tool FIRST to convert them to standardized IDs:
- Targets/Genes: "BRCA1", "BRCA2" -> ENSEMBL IDs "ENSG00000012048", "ENSG00000139618"
- Diseases: "breast cancer" -> EFO/MONDO ID "MONDO_0007254"
- Drugs: "aspirin", "ibuprofen" -> ChEMBL IDs "CHEMBL1201583", "CHEMBL521"
- Variants: Use "chr_pos_ref_alt" format or rsIDs
Example: search_entity(query_string="BRCA1 BRCA2", entity_names=["target"])
Step 2: LEARN QUERY STRUCTURE Call get_open_targets_graphql_schema to retrieve the full API schema. Study the schema to understand available types, fields, and their relationships, then construct a GraphQL query that fetches the information the user needs.
Step 3: CONSTRUCT AND EXECUTE BATCH QUERY Build GraphQL query and variables_list using:
- Standardized IDs from Step 1 (REQUIRED)
- Query patterns from Step 2
Call this tool with query_string, variables_list, and key_field.
REQUIRED IDENTIFIER FORMATS:
- Targets/Genes: ENSEMBL IDs (e.g., "ENSG00000139618")
- Diseases: EFO IDs (e.g., "EFO_0000305") or MONDO IDs (e.g., "MONDO_0007254")
- Drugs: ChEMBL IDs (e.g., "CHEMBL1201583")
- Variants: "chr_pos_ref_alt" format (e.g., "19_44908822_C_T") or rsIDs (e.g., "rs7412")
- Studies: Study IDs (e.g., "GCST90002357")
- Credible Sets: Study Locus IDs (e.g., "7d68cc9c70351c9dbd2a2c0c145e555d")
Args: query_string: The GraphQL query string to execute for all variable sets variables_list: List of variable dictionaries, one per query execution key_field: Variable field name to use as key in results mapping (e.g., "chemblId")
Returns: dict: Results keyed by the specified field value, with execution summary: { "status": "success", "results": { "<key_value>": {"status": "success", "data": ...}, ... }, "summary": {"total": <int>, "successful": <int>, "failed": <int>} }
Parameters (3 required)
key_fieldstringVariable field to use as result key
query_stringstringGraphQL query string
variables_listarrayList of variables for each query execution