Skip to main content
Glama

translate_sequence

Convert DNA sequences into protein sequences using genetic code tables for biological analysis and research applications.

Instructions

Translate DNA sequence to protein sequence

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sequenceYesDNA sequence to translate
genetic_codeNoGenetic code table (default: 1 for standard)

Implementation Reference

  • The handler function that executes the translate_sequence tool. It cleans the input DNA sequence, translates it to protein using the standard genetic code codon table (ignoring non-ATCG characters, using X for unknown codons), and returns the result in JSON format.
    private async handleTranslateSequence(args: any) { try { const geneticCode = args.genetic_code || 1; // Simple translation implementation const codonTable: { [key: string]: string } = { 'TTT': 'F', 'TTC': 'F', 'TTA': 'L', 'TTG': 'L', 'TCT': 'S', 'TCC': 'S', 'TCA': 'S', 'TCG': 'S', 'TAT': 'Y', 'TAC': 'Y', 'TAA': '*', 'TAG': '*', 'TGT': 'C', 'TGC': 'C', 'TGA': '*', 'TGG': 'W', 'CTT': 'L', 'CTC': 'L', 'CTA': 'L', 'CTG': 'L', 'CCT': 'P', 'CCC': 'P', 'CCA': 'P', 'CCG': 'P', 'CAT': 'H', 'CAC': 'H', 'CAA': 'Q', 'CAG': 'Q', 'CGT': 'R', 'CGC': 'R', 'CGA': 'R', 'CGG': 'R', 'ATT': 'I', 'ATC': 'I', 'ATA': 'I', 'ATG': 'M', 'ACT': 'T', 'ACC': 'T', 'ACA': 'T', 'ACG': 'T', 'AAT': 'N', 'AAC': 'N', 'AAA': 'K', 'AAG': 'K', 'AGT': 'S', 'AGC': 'S', 'AGA': 'R', 'AGG': 'R', 'GTT': 'V', 'GTC': 'V', 'GTA': 'V', 'GTG': 'V', 'GCT': 'A', 'GCC': 'A', 'GCA': 'A', 'GCG': 'A', 'GAT': 'D', 'GAC': 'D', 'GAA': 'E', 'GAG': 'E', 'GGT': 'G', 'GGC': 'G', 'GGA': 'G', 'GGG': 'G', }; const sequence = args.sequence.toUpperCase().replace(/[^ATCG]/g, ''); let protein = ''; for (let i = 0; i < sequence.length - 2; i += 3) { const codon = sequence.substr(i, 3); if (codon.length === 3) { protein += codonTable[codon] || 'X'; } } return { content: [ { type: 'text', text: JSON.stringify({ input_sequence: args.sequence, cleaned_sequence: sequence, protein_sequence: protein, genetic_code: geneticCode, length: protein.length, }, null, 2), }, ], }; } catch (error) { return this.handleError(error, 'translating sequence'); } }
  • Input schema definition for the translate_sequence tool, specifying the required 'sequence' parameter and optional 'genetic_code'.
    name: 'translate_sequence', description: 'Translate DNA sequence to protein sequence', inputSchema: { type: 'object', properties: { sequence: { type: 'string', description: 'DNA sequence to translate' }, genetic_code: { type: 'number', description: 'Genetic code table (default: 1 for standard)', minimum: 1, maximum: 31 }, }, required: ['sequence'], }, },
  • src/index.ts:846-847 (registration)
    Registration of the translate_sequence tool handler in the switch statement for CallToolRequestSchema.
    case 'translate_sequence': return this.handleTranslateSequence(args);
  • Type guard function for validating input arguments to the translate_sequence tool (defined but not used in the handler).
    const isValidTranslateArgs = ( args: any ): args is { sequence: string; genetic_code?: number } => { return ( typeof args === 'object' && args !== null && typeof args.sequence === 'string' && args.sequence.length > 0 && (args.genetic_code === undefined || (typeof args.genetic_code === 'number' && args.genetic_code >= 1 && args.genetic_code <= 31)) ); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Augmented-Nature/Ensembl-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server