[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CYGSZ12ZFTKZRNTRKBV5RG":3,"skill-same:01M6CYGSZ12ZFTKZRNTRKBV5RG":83},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":31,"publishedAt":46,"linkOnly":47,"markdownContent":48,"markdownBody":49,"frontMatter":50,"refName":53,"commitSha":54,"skillDirectory":55,"forksCount":56,"repositoryHtmlUrl":57,"repositoryHomepageUrl":58,"ownerHtmlUrl":59,"ownerBlogUrl":60,"ownerDescription":61,"updatedAt":62,"install":63,"resources":76},"01M6CYGSZ12ZFTKZRNTRKBV5RG","jaspar-database",null,"Query JASPAR for transcription factor binding site (TFBS) profiles (PWMs\u002FPFMs). Search by TF name, species, or class; scan DNA sequences for TF binding sites; compare matrices; essential for regulatory genomics, motif analysis, and GWAS regulatory variant interpretation.","eric861129\u002FSKILLS_All-in-one","eric861129","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F74950944?v=4","01M6CXHDYEYRPFGGV4EFXCSYCF","ChiYu-Huang","01M6CXHE2J5CN1EBTY0FKV3ZKW",52,"CC0-1.0","https:\u002F\u002Fgithub.com\u002Feric861129\u002FSKILLS_All-in-one\u002Fblob\u002Fmain\u002Fpublic\u002FSKILLS\u002FScientific & Research Tools\u002Fjaspar-database\u002FSKILL.md",[18,23,26],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":27,"categoryName":28,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[32,33,34,35,36,37,38,39,40,41,42,43,44,45],"database","jaspar database","interpretation","search","analysis","site","regulatory","transcription","scan","query","genomics","DNA","essential","matrices","2026-11-10 10:12:30",false,"---\nname: jaspar-database\ndescription: Query JASPAR for transcription factor binding site (TFBS) profiles (PWMs\u002FPFMs). Search by TF name, species, or class; scan DNA sequences for TF binding sites; compare matrices; essential for regulatory genomics, motif analysis, and GWAS regulatory variant interpretation.\nlicense: CC0-1.0\nmetadata:\n    skill-author: Kuan-lin Huang\n---\n\n# JASPAR Database\n\n## Overview\n\nJASPAR (https:\u002F\u002Fjaspar.elixir.no\u002F) is the gold-standard open-access database of curated, non-redundant transcription factor (TF) binding profiles stored as position frequency matrices (PFMs). JASPAR 2024 contains 1,210 non-redundant TF binding profiles for 164 eukaryotic species. Each profile is experimentally derived (ChIP-seq, SELEX, HT-SELEX, protein binding microarray, etc.) and rigorously validated.\n\n**Key resources:**\n- JASPAR portal: https:\u002F\u002Fjaspar.elixir.no\u002F\n- REST API: https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002F\n- API docs: https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002Fdocs\u002F\n- Python package: `jaspar` (via Biopython) or direct API\n\n## When to Use This Skill\n\nUse JASPAR when:\n\n- **TF binding site prediction**: Scan a DNA sequence for potential binding sites of a TF\n- **Regulatory variant interpretation**: Does a GWAS\u002FeQTL variant disrupt a TF binding motif?\n- **Promoter\u002Fenhancer analysis**: What TFs are predicted to bind to a regulatory element?\n- **Gene regulatory network construction**: Link TFs to their target genes via motif scanning\n- **TF family analysis**: Compare binding profiles across a TF family (e.g., all homeobox factors)\n- **ChIP-seq analysis**: Find known TF motifs enriched in ChIP-seq peaks\n- **ENCODE\u002FATAC-seq interpretation**: Match open chromatin regions to TF binding profiles\n\n## Core Capabilities\n\n### 1. JASPAR REST API\n\nBase URL: `https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002F`\n\n```python\nimport requests\n\nBASE_URL = \"https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\"\n\ndef jaspar_get(endpoint, params=None):\n    url = f\"{BASE_URL}\u002F{endpoint}\"\n    response = requests.get(url, params=params, headers={\"Accept\": \"application\u002Fjson\"})\n    response.raise_for_status()\n    return response.json()\n```\n\n### 2. Search for TF Profiles\n\n```python\ndef search_jaspar(\n    tf_name=None,\n    species=None,\n    collection=\"CORE\",\n    tf_class=None,\n    tf_family=None,\n    page=1,\n    page_size=25\n):\n    \"\"\"Search JASPAR for TF binding profiles.\"\"\"\n    params = {\n        \"collection\": collection,\n        \"page\": page,\n        \"page_size\": page_size,\n        \"format\": \"json\"\n    }\n    if tf_name:\n        params[\"name\"] = tf_name\n    if species:\n        params[\"species\"] = species  # Use taxonomy ID or name, e.g., \"9606\" for human\n    if tf_class:\n        params[\"tf_class\"] = tf_class\n    if tf_family:\n        params[\"tf_family\"] = tf_family\n\n    return jaspar_get(\"matrix\", params)\n\n# Examples:\n# Search for human CTCF profile\nctcf = search_jaspar(\"CTCF\", species=\"9606\")\nprint(f\"Found {ctcf['count']} CTCF profiles\")\n\n# Search for all homeobox TFs in human\nhox_tfs = search_jaspar(tf_class=\"Homeodomain\", species=\"9606\")\n\n# Search for a TF family\nnfkb = search_jaspar(tf_family=\"NF-kappaB\")\n```\n\n### 3. Fetch a Specific Matrix (PFM\u002FPWM)\n\n```python\ndef get_matrix(matrix_id):\n    \"\"\"Fetch a specific JASPAR matrix by ID (e.g., 'MA0139.1' for CTCF).\"\"\"\n    return jaspar_get(f\"matrix\u002F{matrix_id}\u002F\")\n\n# Example: Get CTCF matrix\nctcf_matrix = get_matrix(\"MA0139.1\")\n\n# Matrix structure:\n# {\n#   \"matrix_id\": \"MA0139.1\",\n#   \"name\": \"CTCF\",\n#   \"collection\": \"CORE\",\n#   \"tax_group\": \"vertebrates\",\n#   \"pfm\": { \"A\": [...], \"C\": [...], \"G\": [...], \"T\": [...] },\n#   \"consensus\": \"CCGCGNGGNGGCAG\",\n#   \"length\": 19,\n#   \"species\": [{\"tax_id\": 9606, \"name\": \"Homo sapiens\"}],\n#   \"class\": [\"C2H2 zinc finger factors\"],\n#   \"family\": [\"BEN domain factors\"],\n#   \"type\": \"ChIP-seq\",\n#   \"uniprot_ids\": [\"P49711\"]\n# }\n```\n\n### 4. Download PFM\u002FPWM as Matrix\n\n```python\nimport numpy as np\n\ndef get_pwm(matrix_id, pseudocount=0.8):\n    \"\"\"\n    Fetch a PFM from JASPAR and convert to PWM (log-odds).\n    Returns numpy array of shape (4, L) in order A, C, G, T.\n    \"\"\"\n    matrix = get_matrix(matrix_id)\n    pfm = matrix[\"pfm\"]\n\n    # Convert PFM to numpy\n    pfm_array = np.array([pfm[\"A\"], pfm[\"C\"], pfm[\"G\"], pfm[\"T\"]], dtype=float)\n\n    # Add pseudocount\n    pfm_array += pseudocount\n\n    # Normalize to get PPM\n    ppm = pfm_array \u002F pfm_array.sum(axis=0, keepdims=True)\n\n    # Convert to PWM (log-odds relative to background 0.25)\n    background = 0.25\n    pwm = np.log2(ppm \u002F background)\n\n    return pwm, matrix[\"name\"]\n\n# Example\npwm, name = get_pwm(\"MA0139.1\")  # CTCF\nprint(f\"PWM for {name}: shape {pwm.shape}\")\nmax_score = pwm.max(axis=0).sum()\nprint(f\"Maximum possible score: {max_score:.2f} bits\")\n```\n\n### 5. Scan a DNA Sequence for TF Binding Sites\n\n```python\nimport numpy as np\nfrom typing import List, Tuple\n\nNUCLEOTIDE_MAP = {'A': 0, 'C': 1, 'G': 2, 'T': 3,\n                  'a': 0, 'c': 1, 'g': 2, 't': 3}\n\ndef scan_sequence(sequence: str, pwm: np.ndarray, threshold_pct: float = 0.8) -> List[dict]:\n    \"\"\"\n    Scan a DNA sequence for TF binding sites using a PWM.\n\n    Args:\n        sequence: DNA sequence string\n        pwm: PWM array (4 x L) in ACGT order\n        threshold_pct: Fraction of max score to use as threshold (0-1)\n\n    Returns:\n        List of hits with position, score, and matched sequence\n    \"\"\"\n    motif_len = pwm.shape[1]\n    max_score = pwm.max(axis=0).sum()\n    min_score = pwm.min(axis=0).sum()\n    threshold = min_score + threshold_pct * (max_score - min_score)\n\n    hits = []\n    seq = sequence.upper()\n\n    for i in range(len(seq) - motif_len + 1):\n        subseq = seq[i:i + motif_len]\n        # Skip if contains non-ACGT\n        if any(c not in NUCLEOTIDE_MAP for c in subseq):\n            continue\n\n        score = sum(pwm[NUCLEOTIDE_MAP[c], j] for j, c in enumerate(subseq))\n\n        if score >= threshold:\n            relative_score = (score - min_score) \u002F (max_score - min_score)\n            hits.append({\n                \"position\": i + 1,  # 1-based\n                \"score\": score,\n                \"relative_score\": relative_score,\n                \"sequence\": subseq,\n                \"strand\": \"+\"\n            })\n\n    return hits\n\n# Example: Scan a promoter sequence for CTCF binding sites\npromoter = \"AGCCCGCGAGGNGGCAGTTGCCTGGAGCAGGATCAGCAGATC\"\npwm, name = get_pwm(\"MA0139.1\")\nhits = scan_sequence(promoter, pwm, threshold_pct=0.75)\nfor hit in hits:\n    print(f\"  Position {hit['position']}: {hit['sequence']} (score: {hit['score']:.2f}, {hit['relative_score']:.0%})\")\n```\n\n### 6. Scan Both Strands\n\n```python\ndef reverse_complement(seq: str) -> str:\n    complement = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C', 'N': 'N'}\n    return ''.join(complement.get(b, 'N') for b in reversed(seq.upper()))\n\ndef scan_both_strands(sequence: str, pwm: np.ndarray, threshold_pct: float = 0.8):\n    \"\"\"Scan forward and reverse complement strands.\"\"\"\n    fwd_hits = scan_sequence(sequence, pwm, threshold_pct)\n    for h in fwd_hits:\n        h[\"strand\"] = \"+\"\n\n    rev_seq = reverse_complement(sequence)\n    rev_hits = scan_sequence(rev_seq, pwm, threshold_pct)\n    seq_len = len(sequence)\n    for h in rev_hits:\n        h[\"strand\"] = \"-\"\n        h[\"position\"] = seq_len - h[\"position\"] - len(h[\"sequence\"]) + 2  # Convert to fwd coords\n\n    all_hits = fwd_hits + rev_hits\n    return sorted(all_hits, key=lambda x: x[\"position\"])\n```\n\n### 7. Variant Impact on TF Binding\n\n```python\ndef variant_tfbs_impact(ref_seq: str, alt_seq: str, pwm: np.ndarray,\n                          tf_name: str, threshold_pct: float = 0.7):\n    \"\"\"\n    Assess impact of a SNP on TF binding by comparing ref vs alt sequences.\n    Both sequences should be centered on the variant with flanking context.\n    \"\"\"\n    ref_hits = scan_both_strands(ref_seq, pwm, threshold_pct)\n    alt_hits = scan_both_strands(alt_seq, pwm, threshold_pct)\n\n    max_ref = max((h[\"score\"] for h in ref_hits), default=None)\n    max_alt = max((h[\"score\"] for h in alt_hits), default=None)\n\n    result = {\n        \"tf\": tf_name,\n        \"ref_max_score\": max_ref,\n        \"alt_max_score\": max_alt,\n        \"ref_has_site\": len(ref_hits) > 0,\n        \"alt_has_site\": len(alt_hits) > 0,\n    }\n    if max_ref and max_alt:\n        result[\"score_change\"] = max_alt - max_ref\n        result[\"effect\"] = \"gained\" if max_alt > max_ref else \"disrupted\"\n    elif max_ref and not max_alt:\n        result[\"effect\"] = \"disrupted\"\n    elif not max_ref and max_alt:\n        result[\"effect\"] = \"gained\"\n    else:\n        result[\"effect\"] = \"no_site\"\n\n    return result\n```\n\n## Query Workflows\n\n### Workflow 1: Find All TF Binding Sites in a Promoter\n\n```python\nimport requests, numpy as np\n\n# 1. Get relevant TF matrices (e.g., all human TFs in CORE collection)\nresponse = requests.get(\n    \"https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002Fmatrix\u002F\",\n    params={\"species\": \"9606\", \"collection\": \"CORE\", \"page_size\": 500, \"page\": 1}\n)\nmatrices = response.json()[\"results\"]\n\n# 2. For each matrix, compute PWM and scan promoter\npromoter = \"CCCGCCCGCCCGCCGCCCGCAGTTAATGAGCCCAGCGTGCC\"  # Example\n\nall_hits = []\nfor m in matrices[:10]:  # Limit for demo\n    pwm_data = requests.get(f\"https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002Fmatrix\u002F{m['matrix_id']}\u002F\").json()\n    pfm = pfm_data[\"pfm\"]\n    pfm_arr = np.array([pfm[\"A\"], pfm[\"C\"], pfm[\"G\"], pfm[\"T\"]], dtype=float) + 0.8\n    ppm = pfm_arr \u002F pfm_arr.sum(axis=0)\n    pwm = np.log2(ppm \u002F 0.25)\n\n    hits = scan_sequence(promoter, pwm, threshold_pct=0.8)\n    for h in hits:\n        h[\"tf_name\"] = m[\"name\"]\n        h[\"matrix_id\"] = m[\"matrix_id\"]\n    all_hits.extend(hits)\n\nprint(f\"Found {len(all_hits)} TF binding sites\")\nfor h in sorted(all_hits, key=lambda x: -x[\"score\"])[:5]:\n    print(f\"  {h['tf_name']} ({h['matrix_id']}): pos {h['position']}, score {h['score']:.2f}\")\n```\n\n### Workflow 2: SNP Impact on TF Binding (Regulatory Variant Analysis)\n\n1. Retrieve the genomic sequence flanking the SNP (±20 bp each side)\n2. Construct ref and alt sequences\n3. Scan with all relevant TF PWMs\n4. Report TFs whose binding is created or destroyed by the SNP\n\n### Workflow 3: Motif Enrichment Analysis\n\n1. Identify a set of peak sequences (e.g., from ChIP-seq or ATAC-seq)\n2. Scan all peaks with JASPAR PWMs\n3. Compare hit rates in peaks vs. background sequences\n4. Report significantly enriched motifs (Fisher's exact test or FIMO-style scoring)\n\n## Collections Available\n\n| Collection | Description | Profiles |\n|------------|-------------|----------|\n| `CORE` | Non-redundant, high-quality profiles | ~1,210 |\n| `UNVALIDATED` | Experimentally derived but not validated | ~500 |\n| `PHYLOFACTS` | Phylogenetically conserved sites | ~50 |\n| `CNE` | Conserved non-coding elements | ~30 |\n| `POLII` | RNA Pol II binding profiles | ~20 |\n| `FAM` | TF family representative profiles | ~170 |\n| `SPLICE` | Splice factor profiles | ~20 |\n\n## Best Practices\n\n- **Use CORE collection** for most analyses — best validated and non-redundant\n- **Threshold selection**: 80% of max score is common for de novo prediction; 90% for high-confidence\n- **Always scan both strands** — TFs can bind in either orientation\n- **Provide flanking context** for variant analysis: at least (motif_length - 1) bp on each side\n- **Consider background**: PWM scores relative to uniform (0.25) background; adjust for actual GC content\n- **Cross-validate with ChIP-seq data** when available — motif scanning has many false positives\n- **Use Biopython's motifs module** for full-featured scanning: `from Bio import motifs`\n\n## Additional Resources\n\n- **JASPAR portal**: https:\u002F\u002Fjaspar.elixir.no\u002F\n- **API documentation**: https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002Fdocs\u002F\n- **JASPAR 2024 paper**: Castro-Mondragon et al. (2022) Nucleic Acids Research. PMID: 34875674\n- **Biopython motifs**: https:\u002F\u002Fbiopython.org\u002Fdocs\u002Flatest\u002FTutorial\u002Fchapter_motifs.html\n- **FIMO tool** (for large-scale scanning): https:\u002F\u002Fmeme-suite.org\u002Fmeme\u002Ftools\u002Ffimo\n- **HOMER** (motif enrichment): http:\u002F\u002Fhomer.ucsd.edu\u002Fhomer\u002F\n- **GitHub**: https:\u002F\u002Fgithub.com\u002Fwassermanlab\u002FJASPAR-UCSC-tracks\n","# JASPAR Database\n\n## Overview\n\nJASPAR (https:\u002F\u002Fjaspar.elixir.no\u002F) is the gold-standard open-access database of curated, non-redundant transcription factor (TF) binding profiles stored as position frequency matrices (PFMs). JASPAR 2024 contains 1,210 non-redundant TF binding profiles for 164 eukaryotic species. Each profile is experimentally derived (ChIP-seq, SELEX, HT-SELEX, protein binding microarray, etc.) and rigorously validated.\n\n**Key resources:**\n- JASPAR portal: https:\u002F\u002Fjaspar.elixir.no\u002F\n- REST API: https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002F\n- API docs: https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002Fdocs\u002F\n- Python package: `jaspar` (via Biopython) or direct API\n\n## When to Use This Skill\n\nUse JASPAR when:\n\n- **TF binding site prediction**: Scan a DNA sequence for potential binding sites of a TF\n- **Regulatory variant interpretation**: Does a GWAS\u002FeQTL variant disrupt a TF binding motif?\n- **Promoter\u002Fenhancer analysis**: What TFs are predicted to bind to a regulatory element?\n- **Gene regulatory network construction**: Link TFs to their target genes via motif scanning\n- **TF family analysis**: Compare binding profiles across a TF family (e.g., all homeobox factors)\n- **ChIP-seq analysis**: Find known TF motifs enriched in ChIP-seq peaks\n- **ENCODE\u002FATAC-seq interpretation**: Match open chromatin regions to TF binding profiles\n\n## Core Capabilities\n\n### 1. JASPAR REST API\n\nBase URL: `https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002F`\n\n```python\nimport requests\n\nBASE_URL = \"https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\"\n\ndef jaspar_get(endpoint, params=None):\n    url = f\"{BASE_URL}\u002F{endpoint}\"\n    response = requests.get(url, params=params, headers={\"Accept\": \"application\u002Fjson\"})\n    response.raise_for_status()\n    return response.json()\n```\n\n### 2. Search for TF Profiles\n\n```python\ndef search_jaspar(\n    tf_name=None,\n    species=None,\n    collection=\"CORE\",\n    tf_class=None,\n    tf_family=None,\n    page=1,\n    page_size=25\n):\n    \"\"\"Search JASPAR for TF binding profiles.\"\"\"\n    params = {\n        \"collection\": collection,\n        \"page\": page,\n        \"page_size\": page_size,\n        \"format\": \"json\"\n    }\n    if tf_name:\n        params[\"name\"] = tf_name\n    if species:\n        params[\"species\"] = species  # Use taxonomy ID or name, e.g., \"9606\" for human\n    if tf_class:\n        params[\"tf_class\"] = tf_class\n    if tf_family:\n        params[\"tf_family\"] = tf_family\n\n    return jaspar_get(\"matrix\", params)\n\n# Examples:\n# Search for human CTCF profile\nctcf = search_jaspar(\"CTCF\", species=\"9606\")\nprint(f\"Found {ctcf['count']} CTCF profiles\")\n\n# Search for all homeobox TFs in human\nhox_tfs = search_jaspar(tf_class=\"Homeodomain\", species=\"9606\")\n\n# Search for a TF family\nnfkb = search_jaspar(tf_family=\"NF-kappaB\")\n```\n\n### 3. Fetch a Specific Matrix (PFM\u002FPWM)\n\n```python\ndef get_matrix(matrix_id):\n    \"\"\"Fetch a specific JASPAR matrix by ID (e.g., 'MA0139.1' for CTCF).\"\"\"\n    return jaspar_get(f\"matrix\u002F{matrix_id}\u002F\")\n\n# Example: Get CTCF matrix\nctcf_matrix = get_matrix(\"MA0139.1\")\n\n# Matrix structure:\n# {\n#   \"matrix_id\": \"MA0139.1\",\n#   \"name\": \"CTCF\",\n#   \"collection\": \"CORE\",\n#   \"tax_group\": \"vertebrates\",\n#   \"pfm\": { \"A\": [...], \"C\": [...], \"G\": [...], \"T\": [...] },\n#   \"consensus\": \"CCGCGNGGNGGCAG\",\n#   \"length\": 19,\n#   \"species\": [{\"tax_id\": 9606, \"name\": \"Homo sapiens\"}],\n#   \"class\": [\"C2H2 zinc finger factors\"],\n#   \"family\": [\"BEN domain factors\"],\n#   \"type\": \"ChIP-seq\",\n#   \"uniprot_ids\": [\"P49711\"]\n# }\n```\n\n### 4. Download PFM\u002FPWM as Matrix\n\n```python\nimport numpy as np\n\ndef get_pwm(matrix_id, pseudocount=0.8):\n    \"\"\"\n    Fetch a PFM from JASPAR and convert to PWM (log-odds).\n    Returns numpy array of shape (4, L) in order A, C, G, T.\n    \"\"\"\n    matrix = get_matrix(matrix_id)\n    pfm = matrix[\"pfm\"]\n\n    # Convert PFM to numpy\n    pfm_array = np.array([pfm[\"A\"], pfm[\"C\"], pfm[\"G\"], pfm[\"T\"]], dtype=float)\n\n    # Add pseudocount\n    pfm_array += pseudocount\n\n    # Normalize to get PPM\n    ppm = pfm_array \u002F pfm_array.sum(axis=0, keepdims=True)\n\n    # Convert to PWM (log-odds relative to background 0.25)\n    background = 0.25\n    pwm = np.log2(ppm \u002F background)\n\n    return pwm, matrix[\"name\"]\n\n# Example\npwm, name = get_pwm(\"MA0139.1\")  # CTCF\nprint(f\"PWM for {name}: shape {pwm.shape}\")\nmax_score = pwm.max(axis=0).sum()\nprint(f\"Maximum possible score: {max_score:.2f} bits\")\n```\n\n### 5. Scan a DNA Sequence for TF Binding Sites\n\n```python\nimport numpy as np\nfrom typing import List, Tuple\n\nNUCLEOTIDE_MAP = {'A': 0, 'C': 1, 'G': 2, 'T': 3,\n                  'a': 0, 'c': 1, 'g': 2, 't': 3}\n\ndef scan_sequence(sequence: str, pwm: np.ndarray, threshold_pct: float = 0.8) -> List[dict]:\n    \"\"\"\n    Scan a DNA sequence for TF binding sites using a PWM.\n\n    Args:\n        sequence: DNA sequence string\n        pwm: PWM array (4 x L) in ACGT order\n        threshold_pct: Fraction of max score to use as threshold (0-1)\n\n    Returns:\n        List of hits with position, score, and matched sequence\n    \"\"\"\n    motif_len = pwm.shape[1]\n    max_score = pwm.max(axis=0).sum()\n    min_score = pwm.min(axis=0).sum()\n    threshold = min_score + threshold_pct * (max_score - min_score)\n\n    hits = []\n    seq = sequence.upper()\n\n    for i in range(len(seq) - motif_len + 1):\n        subseq = seq[i:i + motif_len]\n        # Skip if contains non-ACGT\n        if any(c not in NUCLEOTIDE_MAP for c in subseq):\n            continue\n\n        score = sum(pwm[NUCLEOTIDE_MAP[c], j] for j, c in enumerate(subseq))\n\n        if score >= threshold:\n            relative_score = (score - min_score) \u002F (max_score - min_score)\n            hits.append({\n                \"position\": i + 1,  # 1-based\n                \"score\": score,\n                \"relative_score\": relative_score,\n                \"sequence\": subseq,\n                \"strand\": \"+\"\n            })\n\n    return hits\n\n# Example: Scan a promoter sequence for CTCF binding sites\npromoter = \"AGCCCGCGAGGNGGCAGTTGCCTGGAGCAGGATCAGCAGATC\"\npwm, name = get_pwm(\"MA0139.1\")\nhits = scan_sequence(promoter, pwm, threshold_pct=0.75)\nfor hit in hits:\n    print(f\"  Position {hit['position']}: {hit['sequence']} (score: {hit['score']:.2f}, {hit['relative_score']:.0%})\")\n```\n\n### 6. Scan Both Strands\n\n```python\ndef reverse_complement(seq: str) -> str:\n    complement = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C', 'N': 'N'}\n    return ''.join(complement.get(b, 'N') for b in reversed(seq.upper()))\n\ndef scan_both_strands(sequence: str, pwm: np.ndarray, threshold_pct: float = 0.8):\n    \"\"\"Scan forward and reverse complement strands.\"\"\"\n    fwd_hits = scan_sequence(sequence, pwm, threshold_pct)\n    for h in fwd_hits:\n        h[\"strand\"] = \"+\"\n\n    rev_seq = reverse_complement(sequence)\n    rev_hits = scan_sequence(rev_seq, pwm, threshold_pct)\n    seq_len = len(sequence)\n    for h in rev_hits:\n        h[\"strand\"] = \"-\"\n        h[\"position\"] = seq_len - h[\"position\"] - len(h[\"sequence\"]) + 2  # Convert to fwd coords\n\n    all_hits = fwd_hits + rev_hits\n    return sorted(all_hits, key=lambda x: x[\"position\"])\n```\n\n### 7. Variant Impact on TF Binding\n\n```python\ndef variant_tfbs_impact(ref_seq: str, alt_seq: str, pwm: np.ndarray,\n                          tf_name: str, threshold_pct: float = 0.7):\n    \"\"\"\n    Assess impact of a SNP on TF binding by comparing ref vs alt sequences.\n    Both sequences should be centered on the variant with flanking context.\n    \"\"\"\n    ref_hits = scan_both_strands(ref_seq, pwm, threshold_pct)\n    alt_hits = scan_both_strands(alt_seq, pwm, threshold_pct)\n\n    max_ref = max((h[\"score\"] for h in ref_hits), default=None)\n    max_alt = max((h[\"score\"] for h in alt_hits), default=None)\n\n    result = {\n        \"tf\": tf_name,\n        \"ref_max_score\": max_ref,\n        \"alt_max_score\": max_alt,\n        \"ref_has_site\": len(ref_hits) > 0,\n        \"alt_has_site\": len(alt_hits) > 0,\n    }\n    if max_ref and max_alt:\n        result[\"score_change\"] = max_alt - max_ref\n        result[\"effect\"] = \"gained\" if max_alt > max_ref else \"disrupted\"\n    elif max_ref and not max_alt:\n        result[\"effect\"] = \"disrupted\"\n    elif not max_ref and max_alt:\n        result[\"effect\"] = \"gained\"\n    else:\n        result[\"effect\"] = \"no_site\"\n\n    return result\n```\n\n## Query Workflows\n\n### Workflow 1: Find All TF Binding Sites in a Promoter\n\n```python\nimport requests, numpy as np\n\n# 1. Get relevant TF matrices (e.g., all human TFs in CORE collection)\nresponse = requests.get(\n    \"https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002Fmatrix\u002F\",\n    params={\"species\": \"9606\", \"collection\": \"CORE\", \"page_size\": 500, \"page\": 1}\n)\nmatrices = response.json()[\"results\"]\n\n# 2. For each matrix, compute PWM and scan promoter\npromoter = \"CCCGCCCGCCCGCCGCCCGCAGTTAATGAGCCCAGCGTGCC\"  # Example\n\nall_hits = []\nfor m in matrices[:10]:  # Limit for demo\n    pwm_data = requests.get(f\"https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002Fmatrix\u002F{m['matrix_id']}\u002F\").json()\n    pfm = pfm_data[\"pfm\"]\n    pfm_arr = np.array([pfm[\"A\"], pfm[\"C\"], pfm[\"G\"], pfm[\"T\"]], dtype=float) + 0.8\n    ppm = pfm_arr \u002F pfm_arr.sum(axis=0)\n    pwm = np.log2(ppm \u002F 0.25)\n\n    hits = scan_sequence(promoter, pwm, threshold_pct=0.8)\n    for h in hits:\n        h[\"tf_name\"] = m[\"name\"]\n        h[\"matrix_id\"] = m[\"matrix_id\"]\n    all_hits.extend(hits)\n\nprint(f\"Found {len(all_hits)} TF binding sites\")\nfor h in sorted(all_hits, key=lambda x: -x[\"score\"])[:5]:\n    print(f\"  {h['tf_name']} ({h['matrix_id']}): pos {h['position']}, score {h['score']:.2f}\")\n```\n\n### Workflow 2: SNP Impact on TF Binding (Regulatory Variant Analysis)\n\n1. Retrieve the genomic sequence flanking the SNP (±20 bp each side)\n2. Construct ref and alt sequences\n3. Scan with all relevant TF PWMs\n4. Report TFs whose binding is created or destroyed by the SNP\n\n### Workflow 3: Motif Enrichment Analysis\n\n1. Identify a set of peak sequences (e.g., from ChIP-seq or ATAC-seq)\n2. Scan all peaks with JASPAR PWMs\n3. Compare hit rates in peaks vs. background sequences\n4. Report significantly enriched motifs (Fisher's exact test or FIMO-style scoring)\n\n## Collections Available\n\n| Collection | Description | Profiles |\n|------------|-------------|----------|\n| `CORE` | Non-redundant, high-quality profiles | ~1,210 |\n| `UNVALIDATED` | Experimentally derived but not validated | ~500 |\n| `PHYLOFACTS` | Phylogenetically conserved sites | ~50 |\n| `CNE` | Conserved non-coding elements | ~30 |\n| `POLII` | RNA Pol II binding profiles | ~20 |\n| `FAM` | TF family representative profiles | ~170 |\n| `SPLICE` | Splice factor profiles | ~20 |\n\n## Best Practices\n\n- **Use CORE collection** for most analyses — best validated and non-redundant\n- **Threshold selection**: 80% of max score is common for de novo prediction; 90% for high-confidence\n- **Always scan both strands** — TFs can bind in either orientation\n- **Provide flanking context** for variant analysis: at least (motif_length - 1) bp on each side\n- **Consider background**: PWM scores relative to uniform (0.25) background; adjust for actual GC content\n- **Cross-validate with ChIP-seq data** when available — motif scanning has many false positives\n- **Use Biopython's motifs module** for full-featured scanning: `from Bio import motifs`\n\n## Additional Resources\n\n- **JASPAR portal**: https:\u002F\u002Fjaspar.elixir.no\u002F\n- **API documentation**: https:\u002F\u002Fjaspar.elixir.no\u002Fapi\u002Fv1\u002Fdocs\u002F\n- **JASPAR 2024 paper**: Castro-Mondragon et al. (2022) Nucleic Acids Research. PMID: 34875674\n- **Biopython motifs**: https:\u002F\u002Fbiopython.org\u002Fdocs\u002Flatest\u002FTutorial\u002Fchapter_motifs.html\n- **FIMO tool** (for large-scale scanning): https:\u002F\u002Fmeme-suite.org\u002Fmeme\u002Ftools\u002Ffimo\n- **HOMER** (motif enrichment): http:\u002F\u002Fhomer.ucsd.edu\u002Fhomer\u002F\n- **GitHub**: https:\u002F\u002Fgithub.com\u002Fwassermanlab\u002FJASPAR-UCSC-tracks\n",{"name":5,"license":15,"metadata":51,"description":7},{"skill-author":52},"Kuan-lin Huang","main","cbdd44aae21131521c09e42762e36178c790eacf","public\u002FSKILLS\u002FScientific & Research Tools\u002Fjaspar-database",13,"https:\u002F\u002Fgithub.com\u002Feric861129\u002FSKILLS_All-in-one","http:\u002F\u002Fhuangchiyu.com\u002FSKILLS_All-in-one\u002F","https:\u002F\u002Fgithub.com\u002Feric861129","https:\u002F\u002Fhuangchiyu.com\u002FChiYu-Blog\u002F","開發工程師，專注於 C#／.NET 系統現代化、AI-assisted engineering、開源工具與技術寫作。","2026-04-16 14:28:14",{"source":8,"skillName":5,"commands":64,"prompt":74,"zipAvailable":75},[65,68,71],{"tool":66,"command":67},"npx","npx skills add eric861129\u002FSKILLS_All-in-one --skill jaspar-database",{"tool":69,"command":70},"bunx","bunx skills add eric861129\u002FSKILLS_All-in-one --skill jaspar-database",{"tool":72,"command":73},"pnpm","pnpm dlx skills add eric861129\u002FSKILLS_All-in-one --skill jaspar-database","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Feric861129\u002FSKILLS_All-in-one\u002Fblob\u002Fmain\u002Fpublic\u002FSKILLS\u002FScientific & Research Tools\u002Fjaspar-database\u002FSKILL.md",true,[77],{"path":78,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fapi_reference.md","REFERENCE","参考文档",4375,"https:\u002F\u002Fgithub.com\u002Feric861129\u002FSKILLS_All-in-one\u002Fblob\u002Fmain\u002Fpublic\u002FSKILLS\u002FScientific & Research Tools\u002Fjaspar-database\u002Freferences\u002Fapi_reference.md",[84,112,143,169,194,214],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":92,"publishedAt":46},"01M6CZ1WR3KNVTKSWH4GNWT646","what-if-oracle","Run structured What-If scenario analysis with multi-branch possibility exploration. Use this skill when the user asks speculative questions like \"what if...\", \"what would happen if...\", \"what are the possibilities\", \"explore scenarios\", \"scenario analysis\", \"possibility space\", \"what could go wrong\", \"best case \u002F worst case\", \"risk analysis\", \"contingency planning\", \"strategic options\", or any question about uncertain futures. Also trigger when the user faces a fork-in-the-road decision, wants to stress-test an idea, or needs to think through consequences before committing.","MIT","https:\u002F\u002Fgithub.com\u002Feric861129\u002FSKILLS_All-in-one\u002Fblob\u002Fmain\u002Fpublic\u002FSKILLS\u002FWriting & Research\u002Fwhat-if-oracle\u002FSKILL.md",[91],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[93,94,95,96,97,98,99,100,36,101,102,103,104,105,106,107,108,109,110,111],"oracle","what if oracle","go","run","planning","ux","futures","risk","explore","decision","branch","question","read","write","idea","exploration","options","stress-test","strategies",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":128,"publishedAt":46},"01M6CZ1QHGJE91A95MSN5EK5Q9","venue-templates","Access comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.","https:\u002F\u002Fgithub.com\u002Feric861129\u002FSKILLS_All-in-one\u002Fblob\u002Fmain\u002Fpublic\u002FSKILLS\u002FWriting & Research\u002Fvenue-templates\u002FSKILL.md",[118,121,124,125],{"categoryNo":119,"categoryName":120,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":122,"categoryName":123,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000021","资料检索与研究",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":126,"categoryName":127,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000036","内容创作者",[129,130,131,132,133,134,135,136,137,138,105,106,139,140,141,142],"templates","venue templates","research","guidelines","NeurIPS","ICML","LaTeX","science","Bash","access","edit","proposals","Academic","requirements",{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":151,"publishedAt":46},"01M6CZ1KBQD2E5RTFB3BGVX7CD","the-fool","Use when challenging ideas, plans, decisions, or proposals using structured critical reasoning. Invoke to play devil's advocate, run a pre-mortem, red team, or audit evidence and assumptions.","https:\u002F\u002Fgithub.com\u002Feric861129\u002FSKILLS_All-in-one\u002Fblob\u002Fmain\u002Fpublic\u002FSKILLS\u002FWriting & Research\u002Fthe-fool\u002FSKILL.md",[149,150],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":27,"categoryName":28,"taxonomyType":29,"taxonomyTypeDesc":30},[152,153,95,154,155,96,156,157,158,159,160,161,162,163,140,164,165,166,167,168],"the fool","review","workflow","architecture","code","audit","forge","devil","team","designer","reviewer","challenge","stress test","evidence","expert","poke","ideas",{"skillNo":170,"name":171,"nameZh":6,"description":172,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":6,"sourceHtmlUrl":173,"categories":174,"keywords":178,"publishedAt":46},"01M6CZ1ES826S7P1X3333E40TA","scientific-writing","Core skill for the deep research and writing tool. Write scientific manuscripts in full paragraphs (never bullet points). Use two-stage process with (1) section outlines with key points using research-lookup then (2) convert to flowing prose. IMRAD structure, citations (APA\u002FAMA\u002FVancouver), figures\u002Ftables, reporting guidelines (CONSORT\u002FSTROBE\u002FPRISMA), for research papers and journal submissions.","https:\u002F\u002Fgithub.com\u002Feric861129\u002FSKILLS_All-in-one\u002Fblob\u002Fmain\u002Fpublic\u002FSKILLS\u002FWriting & Research\u002Fscientific-writing\u002FSKILL.md",[175,176,177],{"categoryNo":119,"categoryName":120,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":126,"categoryName":127,"taxonomyType":29,"taxonomyTypeDesc":30},[179,180,132,181,182,183,184,185,137,186,105,106,139,187,188,189,190,191,192,193],"writing","scientific writing","core","reporting","deep research","Citations","Outlines","tool","use","never","structure","deep","full","stage","prisma",{"skillNo":195,"name":196,"nameZh":6,"description":197,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":6,"sourceHtmlUrl":198,"categories":199,"keywords":201,"publishedAt":46},"01M6CZ1B2JGJTB9FRD0TW4RXXE","scientific-brainstorming","Creative research ideation and exploration. Use for open-ended brainstorming sessions, exploring interdisciplinary connections, challenging assumptions, or identifying research gaps. Best for early-stage research planning when you do not have specific observations yet. For formulating testable hypotheses from data use hypothesis-generation.","https:\u002F\u002Fgithub.com\u002Feric861129\u002FSKILLS_All-in-one\u002Fblob\u002Fmain\u002Fpublic\u002FSKILLS\u002FWriting & Research\u002Fscientific-brainstorming\u002FSKILL.md",[200],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[202,203,131,204,97,205,206,207,187,208,209,210,108,211,212,192,213],"brainstorming","scientific brainstorming","sessions","data","hypothesis","open","ideation","creative","do","connections","research ideation","generation",{"skillNo":215,"name":216,"nameZh":6,"description":217,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":6,"sourceHtmlUrl":218,"categories":219,"keywords":224,"publishedAt":46},"01M6CZ16JG8N7A2ZX04BGE8J2Y","research-lookup","Look up current research information using the Parallel Chat API (primary) or Perplexity sonar-pro-search (academic paper searches). Automatically routes queries to the best backend. Use for finding papers, gathering research data, and verifying scientific information.","https:\u002F\u002Fgithub.com\u002Feric861129\u002FSKILLS_All-in-one\u002Fblob\u002Fmain\u002Fpublic\u002FSKILLS\u002FWriting & Research\u002Fresearch-lookup\u002FSKILL.md",[220,221,222,223],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":122,"categoryName":123,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":27,"categoryName":28,"taxonomyType":29,"taxonomyTypeDesc":30},[131,225,226,35,205,227,228,137,229,230,105,106,139,187,231,232,233,234,235,141],"lookup","research lookup","perplexity","api","parallel","openrouter","backend","up","look","queries","chat"]