Skip to main content
Glama
taehojo
by taehojo

compare_variants_same_gene

Compare and rank multiple genetic variants within a single gene to analyze their relative impact and identify compound heterozygotes for gene-level analysis.

Instructions

Compare multiple variants within the same gene.

Ranks variants by impact within a single gene context.

Perfect for: gene-level analysis, compound heterozygote analysis.

Example: "Compare 5 BRCA1 variants"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
variantsYes
gene_nameNoOptional: gene name for context

Implementation Reference

  • Core handler function that executes the tool logic: processes list of variants, predicts effects using AlphaGenome API via predict_variant_effect helper, ranks by absolute expression fold change, returns ranked results with gene context.
    def compare_variants_same_gene(client, params: Dict[str, Any]) -> Dict[str, Any]:
        """Compare multiple variants in the same gene."""
        variants_data = params.get('variants', [])
        gene = params.get('gene', 'unknown')
    
        results = []
        for v in variants_data:
            try:
                result = predict_variant_effect(client, v)
                results.append({
                    'variant': result['variant'],
                    'impact': result['interpretation']['impact_level'],
                    'expression_fc': result['predictions'].get('rna_seq', {}).get('fold_change', 0),
                    'clinical_sig': result['interpretation']['clinical_significance']
                })
            except Exception as e:
                print(f"Warning: Failed: {e}", file=sys.stderr)
                continue
    
        results.sort(key=lambda x: abs(x['expression_fc']), reverse=True)
        return {
            'gene': gene,
            'total_variants': len(results),
            'ranked_variants': results
        }
  • MCP server request handler case for the tool: validates (implicitly), calls client proxy, formats result as JSON text content.
    case 'compare_variants_same_gene': {
      const result = await getClient().compareVariantsSameGene(args);
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Input schema definition for the tool: requires array of at least 2 variants (each with chr, pos, ref, alt), optional gene_name.
    export const COMPARE_VARIANTS_SAME_GENE_TOOL: Tool = {
      name: 'compare_variants_same_gene',
      description: `Compare multiple variants within the same gene.
    
    Ranks variants by impact within a single gene context.
    
    Perfect for: gene-level analysis, compound heterozygote analysis.
    
    Example: "Compare 5 BRCA1 variants"`,
      inputSchema: {
        type: 'object',
        properties: {
          variants: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                chromosome: { type: 'string' },
                position: { type: 'number' },
                ref: { type: 'string' },
                alt: { type: 'string' },
              },
              required: ['chromosome', 'position', 'ref', 'alt'],
            },
            minItems: 2,
          },
          gene_name: {
            type: 'string',
            description: 'Optional: gene name for context',
          },
        },
        required: ['variants'],
      },
    };
  • src/index.ts:235-240 (registration)
    Tool dispatch registration in MCP CallToolRequestSchema handler switch statement.
    case 'compare_variants_same_gene': {
      const result = await getClient().compareVariantsSameGene(args);
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • src/tools.ts:724-724 (registration)
    Tool registration in ALL_TOOLS export array used by ListToolsRequestSchema handler.
    COMPARE_VARIANTS_SAME_GENE_TOOL,
  • Client proxy method that spawns Python bridge subprocess with action='compare_variants_same_gene' and params, handles errors.
    async compareVariantsSameGene(params: any): Promise<any> {
      try {
        return await this.callPythonBridge('compare_variants_same_gene', params);
      } catch (error) {
        if (error instanceof ApiError) throw error;
        throw new ApiError(`Same-gene variant comparison failed: ${error}`, 500);
      }
    }

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/taehojo/alphagenome-mcp'

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