batch_sequence_fetch
Retrieve DNA sequences for multiple genomic regions or features from Ensembl in a single request, supporting up to 50 regions with configurable output formats.
Instructions
Fetch sequences for multiple regions or features
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| regions | Yes | List of regions or feature IDs (max 50) | |
| species | No | Species name (default: homo_sapiens) | |
| format | No | Output format (default: fasta) |
Implementation Reference
- src/index.ts:1611-1650 (handler)The handler function for the 'batch_sequence_fetch' tool. It iterates over the provided regions, fetches sequences individually using handleGetSequence, collects results (success or error per region), and returns a batched JSON response.private async handleBatchSequenceFetch(args: any) { try { const species = this.getDefaultSpecies(args.species); const format = args.format || 'fasta'; const results = []; for (const region of args.regions) { try { const sequenceResult = await this.handleGetSequence({ region, species, format, }); results.push({ region, success: true, data: JSON.parse(sequenceResult.content[0].text), }); } catch (error) { results.push({ region, success: false, error: error instanceof Error ? error.message : 'Unknown error', }); } } return { content: [ { type: 'text', text: JSON.stringify({ batch_results: results }, null, 2), }, ], }; } catch (error) { return this.handleError(error, 'batch sequence fetch'); } }
- src/index.ts:876-879 (registration)Registration in the tool dispatch switch statement within CallToolRequestSchema handler. Maps the tool name to its handler method.case 'batch_gene_lookup': return this.handleBatchGeneLookup(args); case 'batch_sequence_fetch': return this.handleBatchSequenceFetch(args);
- src/index.ts:815-826 (registration)Tool registration in the ListToolsRequestSchema response, including name, description, and input schema.name: 'batch_sequence_fetch', description: 'Fetch sequences for multiple regions or features', inputSchema: { type: 'object', properties: { regions: { type: 'array', items: { type: 'string' }, description: 'List of regions or feature IDs (max 50)', minItems: 1, maxItems: 50 }, species: { type: 'string', description: 'Species name (default: homo_sapiens)' }, format: { type: 'string', enum: ['json', 'fasta'], description: 'Output format (default: fasta)' }, }, required: ['regions'], }, },
- src/index.ts:375-388 (schema)Type guard function for validating input arguments to batch_sequence_fetch, matching the inputSchema.const isValidBatchSequenceArgs = ( args: any ): args is { regions: string[]; species?: string; format?: string } => { return ( typeof args === 'object' && args !== null && Array.isArray(args.regions) && args.regions.length > 0 && args.regions.length <= 50 && args.regions.every((r: any) => typeof r === 'string' && r.length > 0) && (args.species === undefined || typeof args.species === 'string') && (args.format === undefined || ['json', 'fasta'].includes(args.format)) ); };