batch_sequence_fetch
Retrieve DNA or protein sequences for multiple genomic regions or feature IDs in JSON or FASTA format, supporting species-specific queries via the Ensembl REST API.
Instructions
Fetch sequences for multiple regions or features
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format (default: fasta) | |
| regions | Yes | List of regions or feature IDs (max 50) | |
| species | No | Species name (default: homo_sapiens) |
Implementation Reference
- src/index.ts:1611-1650 (handler)The main execution handler for the 'batch_sequence_fetch' tool. It processes multiple regions by calling the single 'get_sequence' handler for each, collects successes and failures, and returns a batched JSON result.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:878-879 (registration)Registration of the tool handler in the central CallToolRequestSchema switch statement within setupToolHandlers().case 'batch_sequence_fetch': return this.handleBatchSequenceFetch(args);
- src/index.ts:814-826 (registration)Tool metadata registration including name, description, and input schema in the ListToolsRequestSchema response.{ 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)Input validation type guard function defining the expected parameters and constraints for the batch_sequence_fetch tool (defined but not explicitly used in handler).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)) ); };