validate_go_id
Validate the format and existence of a Gene Ontology (GO) identifier to ensure accuracy in ontology-based analysis and gene annotation research.
Instructions
Validate GO identifier format and check if term exists
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | GO identifier to validate |
Implementation Reference
- src/index.ts:495-556 (handler)The main handler function implementing the 'validate_go_id' tool: validates input arguments, normalizes the GO ID, checks format with regex, queries QuickGO API to verify existence, and returns comprehensive validation results including term info if valid.private async handleValidateGoId(args: any) { if (!isValidTermArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'GO ID is required'); } try { const termId = this.normalizeGoId(args.id); // Check format const isValidFormat = /^GO:\d{7}$/.test(termId); let exists = false; let termInfo = null; if (isValidFormat) { try { const response = await this.quickGoClient.get(`/ontology/go/terms/${termId}`); termInfo = response.data.results?.[0]; exists = !!termInfo; } catch (e) { exists = false; } } const validation = { input_id: args.id, normalized_id: termId, valid_format: isValidFormat, exists: exists, term_info: exists ? { name: termInfo?.name, namespace: termInfo?.aspect === 'F' ? 'molecular_function' : termInfo?.aspect === 'P' ? 'biological_process' : 'cellular_component', obsolete: termInfo?.isObsolete || false } : null, format_rules: { pattern: 'GO:NNNNNNN', example: 'GO:0008150', description: 'GO identifiers consist of "GO:" followed by exactly 7 digits' } }; return { content: [ { type: 'text', text: JSON.stringify(validation, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error validating GO ID: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:317-323 (schema)Input schema for the validate_go_id tool, defining required 'id' parameter as string.inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'GO identifier to validate' }, }, required: ['id'], },
- src/index.ts:347-348 (registration)Registration/dispatch of the validate_go_id tool in the CallToolRequestSchema handler switch statement.case 'validate_go_id': return this.handleValidateGoId(args);
- src/index.ts:314-324 (registration)Tool registration in ListToolsRequestSchema response, including name, description, and schema.{ name: 'validate_go_id', description: 'Validate GO identifier format and check if term exists', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'GO identifier to validate' }, }, required: ['id'], }, },
- src/index.ts:361-369 (helper)Helper function used by the handler to normalize GO ID format (adds 'GO:' prefix if missing).private normalizeGoId(id: string): string { if (id.startsWith('GO:')) { return id; } if (/^\d{7}$/.test(id)) { return `GO:${id}`; } return id; }