SKILL.md
Version Compatibility
Reference examples tested with: BioPython 1.83+, Entrez Direct 21.0+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
dbSNP Queries
"Look up variant information by rsID" → Retrieve variant annotations, genomic coordinates, and cross-references to ClinVar/gnomAD from dbSNP using REST API queries.
- Python:
myvariant.MyVariantInfo().getvariant('rs12345')
Query rsID via myvariant.info
Goal: Retrieve variant information including dbSNP, ClinVar, and gnomAD annotations by rsID.
Approach: Query myvariant.info with the rsID and request specific annotation fields.
import myvariant
mv = myvariant.MyVariantInfo()
def get_rsid_info(rsid):
'''Get variant info by rsID'''
result = mv.getvariant(rsid, fields=['dbsnp', 'clinvar', 'gnomad_exome'])
return result
result = get_rsid_info('rs121913527')
Query via NCBI Entrez
Goal: Search and fetch dbSNP records directly from NCBI using Entrez E-utilities.
Approach: Use BioPython Entrez esearch to find SNP IDs, then efetch to retrieve full XML records.
from Bio import Entrez
import xml.etree.ElementTree as ET
Entrez.email = '[email protected]'
def search_dbsnp(rsid):
'''Search dbSNP by rsID'''
handle = Entrez.esearch(db='snp', term=rsid)
record = Entrez.read(handle)
handle.close()
return record
def fetch_dbsnp(snp_id):
'''Fetch dbSNP record by internal ID'''
handle = Entrez.efetch(db='snp', id=snp_id, rettype='xml')
xml_data = handle.read()
handle.close()
return xml_data
