analyze_sequence_composition
Analyze amino acid composition, hydrophobicity, and sequence properties for UniProt entries to study protein characteristics and structure insights.
Instructions
Amino acid composition, hydrophobicity, and other sequence properties
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accession | Yes | UniProt accession number |
Implementation Reference
- src/index.ts:1303-1358 (handler)The core handler function that executes the tool: validates input, fetches protein data from UniProt REST API, extracts sequence, computes amino acid composition (counts and frequencies), and calculates properties like hydrophobic, charged, and polar residues. Returns structured JSON analysis.private async handleAnalyzeSequenceComposition(args: any) { if (!isValidProteinInfoArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid sequence composition arguments'); } try { const response = await this.apiClient.get(`/uniprotkb/${args.accession}`, { params: { format: 'json' }, }); const protein = response.data; const sequence = protein.sequence?.value || ''; // Calculate amino acid composition const aaCount: { [key: string]: number } = {}; const aaFreq: { [key: string]: number } = {}; for (const aa of sequence) { aaCount[aa] = (aaCount[aa] || 0) + 1; } for (const aa in aaCount) { aaFreq[aa] = aaCount[aa] / sequence.length; } const composition = { accession: protein.primaryAccession, sequenceLength: sequence.length, molecularWeight: protein.sequence?.molWeight, aminoAcidComposition: aaCount, aminoAcidFrequency: aaFreq, hydrophobicResidues: ['A', 'I', 'L', 'M', 'F', 'W', 'Y', 'V'].reduce((sum, aa) => sum + (aaCount[aa] || 0), 0), chargedResidues: ['R', 'H', 'K', 'D', 'E'].reduce((sum, aa) => sum + (aaCount[aa] || 0), 0), polarResidues: ['S', 'T', 'N', 'Q'].reduce((sum, aa) => sum + (aaCount[aa] || 0), 0), }; return { content: [ { type: 'text', text: JSON.stringify(composition, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error analyzing sequence composition: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:754-755 (registration)Registers the tool handler in the CallToolRequestSchema switch statement within setupToolHandlers().case 'analyze_sequence_composition': return this.handleAnalyzeSequenceComposition(args);
- src/index.ts:546-556 (schema)Defines the tool's metadata including name, description, and input schema (accession required) in the ListToolsRequestSchema response.{ name: 'analyze_sequence_composition', description: 'Amino acid composition, hydrophobicity, and other sequence properties', inputSchema: { type: 'object', properties: { accession: { type: 'string', description: 'UniProt accession number' }, }, required: ['accession'], }, },
- src/index.ts:79-89 (helper)Input validation function used by the handler to check accession and optional format.const isValidProteinInfoArgs = ( args: any ): args is { accession: string; format?: string } => { return ( typeof args === 'object' && args !== null && typeof args.accession === 'string' && args.accession.length > 0 && (args.format === undefined || ['json', 'tsv', 'fasta', 'xml'].includes(args.format)) ); };