get_subcellular_location
Retrieve subcellular localization data for a protein using a gene symbol. Supports output in JSON or TSV format, aiding in protein research and analysis.
Instructions
Get subcellular localization data for a protein
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format (default: json) | |
| gene | Yes | Gene symbol |
Implementation Reference
- src/index.ts:1010-1036 (handler)The primary handler function for the 'get_subcellular_location' tool. Validates input using isValidGeneArgs, fetches data via fetchSubcellularLocalization helper, formats as JSON response or error.private async handleGetSubcellularLocation(args: any) { if (!isValidGeneArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid gene arguments'); } try { const result = await this.fetchSubcellularLocalization(args.gene); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching subcellular location: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:535-546 (schema)Tool schema definition including name, description, and inputSchema for validation (gene symbol required, optional format). Part of tools list registration.{ name: 'get_subcellular_location', description: 'Get subcellular localization data for a protein', inputSchema: { type: 'object', properties: { gene: { type: 'string', description: 'Gene symbol' }, format: { type: 'string', enum: ['json', 'tsv'], description: 'Output format (default: json)' }, }, required: ['gene'], }, },
- src/index.ts:685-686 (registration)Registration/dispatch in the CallToolRequestHandler switch statement, routing calls to the handler function.case 'get_subcellular_location': return this.handleGetSubcellularLocation(args);
- src/index.ts:753-756 (helper)Helper method that performs the API query for subcellular location data, selecting specific columns like scl (subcell location), scml, etc., and limits to 1 result.private async fetchSubcellularLocalization(gene: string): Promise<any> { const columns = ['g', 'eg', 'scl', 'scml', 'scal', 'relce']; return this.searchProteins(gene, 'json', columns, 1); }
- src/index.ts:63-73 (helper)Type guard/validation function for gene-based tool arguments, ensuring valid gene string and optional format. Used by the handler.const isValidGeneArgs = ( args: any ): args is { gene: string; format?: string } => { return ( typeof args === 'object' && args !== null && typeof args.gene === 'string' && args.gene.length > 0 && (args.format === undefined || ['json', 'tsv', 'xml', 'trig'].includes(args.format)) ); };