@brainpilot/skills 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/01_Meta-Skills/workflow-skill-creator/SKILL.md +288 -0
- package/skills/01_Meta-Skills/workflow-skill-creator/references/cli_script_template.py +217 -0
- package/skills/06_fMRI_Neuroimaging/netneurotools-guide/SKILL.md +212 -0
- package/skills/06_fMRI_Neuroimaging/netneurotools-guide/references/datasets.md +252 -0
- package/skills/06_fMRI_Neuroimaging/netneurotools-guide/references/interface-plotting.md +238 -0
- package/skills/06_fMRI_Neuroimaging/netneurotools-guide/references/metrics.md +236 -0
- package/skills/06_fMRI_Neuroimaging/netneurotools-guide/references/networks.md +273 -0
- package/skills/06_fMRI_Neuroimaging/netneurotools-guide/references/spatial-modularity.md +291 -0
- package/skills/06_fMRI_Neuroimaging/netneurotools-guide/references/stats.md +290 -0
- package/skills/09_Cellular_Molecular_Neuroscience/alphafold-database-fetch-and-analyze/SKILL.md +116 -0
- package/skills/09_Cellular_Molecular_Neuroscience/alphafold-database-fetch-and-analyze/references/citation.bib +58 -0
- package/skills/09_Cellular_Molecular_Neuroscience/alphafold-database-fetch-and-analyze/scripts/analyze_pae.py +212 -0
- package/skills/09_Cellular_Molecular_Neuroscience/alphafold-database-fetch-and-analyze/scripts/analyze_plddt.py +125 -0
- package/skills/09_Cellular_Molecular_Neuroscience/alphafold-database-fetch-and-analyze/scripts/fetch_structure.py +168 -0
- package/skills/09_Cellular_Molecular_Neuroscience/gtex-database/SKILL.md +176 -0
- package/skills/09_Cellular_Molecular_Neuroscience/gtex-database/references/citation.bib +14 -0
- package/skills/09_Cellular_Molecular_Neuroscience/gtex-database/scripts/gtex_cli.py +281 -0
- package/skills/09_Cellular_Molecular_Neuroscience/human-protein-atlas-database/SKILL.md +181 -0
- package/skills/09_Cellular_Molecular_Neuroscience/human-protein-atlas-database/references/citation.bib +14 -0
- package/skills/09_Cellular_Molecular_Neuroscience/human-protein-atlas-database/references/search-api.md +137 -0
- package/skills/09_Cellular_Molecular_Neuroscience/human-protein-atlas-database/scripts/hpa_cli.py +263 -0
- package/skills/09_Cellular_Molecular_Neuroscience/pdb-database/SKILL.md +169 -0
- package/skills/09_Cellular_Molecular_Neuroscience/pdb-database/references/citation.bib +15 -0
- package/skills/09_Cellular_Molecular_Neuroscience/pdb-database/scripts/download_coordinate_files.py +113 -0
- package/skills/09_Cellular_Molecular_Neuroscience/pdb-database/scripts/fetch_pdb_metadata.py +70 -0
- package/skills/09_Cellular_Molecular_Neuroscience/pdb-database/scripts/fetch_schema.py +251 -0
- package/skills/09_Cellular_Molecular_Neuroscience/pdb-database/scripts/search_pdb.py +187 -0
- package/skills/09_Cellular_Molecular_Neuroscience/pymol/SKILL.md +146 -0
- package/skills/09_Cellular_Molecular_Neuroscience/pymol/references/PYMOL_REFERENCE.md +160 -0
- package/skills/09_Cellular_Molecular_Neuroscience/pymol/references/RECIPES.md +348 -0
- package/skills/09_Cellular_Molecular_Neuroscience/pymol/references/citation.bib +6 -0
- package/skills/17_Literature_Databases/literature-search-arxiv/SKILL.md +120 -0
- package/skills/17_Literature_Databases/literature-search-arxiv/references/citation.bib +18 -0
- package/skills/17_Literature_Databases/literature-search-arxiv/references/query_syntax.md +34 -0
- package/skills/17_Literature_Databases/literature-search-arxiv/scripts/download_paper.py +116 -0
- package/skills/17_Literature_Databases/literature-search-arxiv/scripts/download_paper_source.py +98 -0
- package/skills/17_Literature_Databases/literature-search-arxiv/scripts/search_arxiv.py +174 -0
- package/skills/17_Literature_Databases/literature-search-biorxiv/SKILL.md +169 -0
- package/skills/17_Literature_Databases/literature-search-biorxiv/references/citation.bib +12 -0
- package/skills/17_Literature_Databases/literature-search-biorxiv/scripts/search_by_dates.py +297 -0
- package/skills/17_Literature_Databases/literature-search-biorxiv/scripts/search_by_doi.py +72 -0
- package/skills/17_Literature_Databases/literature-search-europepmc/SKILL.md +229 -0
- package/skills/17_Literature_Databases/literature-search-europepmc/references/citation.bib +15 -0
- package/skills/17_Literature_Databases/literature-search-europepmc/scripts/europepmc_api.py +345 -0
- package/skills/17_Literature_Databases/literature-search-openalex/SKILL.md +169 -0
- package/skills/17_Literature_Databases/literature-search-openalex/references/authors.md +78 -0
- package/skills/17_Literature_Databases/literature-search-openalex/references/citation.bib +8 -0
- package/skills/17_Literature_Databases/literature-search-openalex/references/geo_and_language.md +37 -0
- package/skills/17_Literature_Databases/literature-search-openalex/references/institutions.md +64 -0
- package/skills/17_Literature_Databases/literature-search-openalex/references/publishers_funders.md +42 -0
- package/skills/17_Literature_Databases/literature-search-openalex/references/sources.md +79 -0
- package/skills/17_Literature_Databases/literature-search-openalex/references/taxonomy.md +52 -0
- package/skills/17_Literature_Databases/literature-search-openalex/references/topics.md +29 -0
- package/skills/17_Literature_Databases/literature-search-openalex/references/type_values.md +65 -0
- package/skills/17_Literature_Databases/literature-search-openalex/references/works.md +304 -0
- package/skills/17_Literature_Databases/literature-search-openalex/scripts/openalex_cli.py +633 -0
- package/skills/17_Literature_Databases/pubmed-database/SKILL.md +185 -0
- package/skills/17_Literature_Databases/pubmed-database/references/advanced-linking.md +128 -0
- package/skills/17_Literature_Databases/pubmed-database/references/advanced-search.md +98 -0
- package/skills/17_Literature_Databases/pubmed-database/references/bulk-workflows.md +88 -0
- package/skills/17_Literature_Databases/pubmed-database/references/citation-matching.md +155 -0
- package/skills/17_Literature_Databases/pubmed-database/references/citation.bib +15 -0
- package/skills/17_Literature_Databases/pubmed-database/references/cross-database-linking.md +93 -0
- package/skills/17_Literature_Databases/pubmed-database/references/fetch-and-resolve.md +125 -0
- package/skills/17_Literature_Databases/pubmed-database/references/search-and-discovery.md +106 -0
- package/skills/17_Literature_Databases/pubmed-database/references/utilities.md +42 -0
- package/skills/17_Literature_Databases/pubmed-database/scripts/pubmed_api.py +715 -0
- package/skills/18_Genetics_Genomics/alphagenome-single-variant-analysis/SKILL.md +251 -0
- package/skills/18_Genetics_Genomics/alphagenome-single-variant-analysis/pyproject.toml +15 -0
- package/skills/18_Genetics_Genomics/alphagenome-single-variant-analysis/references/citation.bib +12 -0
- package/skills/18_Genetics_Genomics/alphagenome-single-variant-analysis/scripts/analyze_ism.py +334 -0
- package/skills/18_Genetics_Genomics/alphagenome-single-variant-analysis/scripts/generate_ontology_mapping.py +170 -0
- package/skills/18_Genetics_Genomics/alphagenome-single-variant-analysis/scripts/interpret_splicing.py +305 -0
- package/skills/18_Genetics_Genomics/alphagenome-single-variant-analysis/scripts/lookup_gene_info.py +337 -0
- package/skills/18_Genetics_Genomics/alphagenome-single-variant-analysis/scripts/resolve_ontology_terms.py +155 -0
- package/skills/18_Genetics_Genomics/alphagenome-single-variant-analysis/scripts/visualize_genome_tracks.py +402 -0
- package/skills/18_Genetics_Genomics/alphagenome-single-variant-analysis/scripts/visualize_variant_effects.py +1198 -0
- package/skills/18_Genetics_Genomics/clinvar-database/SKILL.md +370 -0
- package/skills/18_Genetics_Genomics/clinvar-database/references/citation.bib +23 -0
- package/skills/18_Genetics_Genomics/clinvar-database/scripts/clinvar_api.py +711 -0
- package/skills/18_Genetics_Genomics/dbsnp-database/SKILL.md +350 -0
- package/skills/18_Genetics_Genomics/dbsnp-database/references/api-notes.md +88 -0
- package/skills/18_Genetics_Genomics/dbsnp-database/references/citation.bib +12 -0
- package/skills/18_Genetics_Genomics/dbsnp-database/scripts/dbsnp_cli.py +625 -0
- package/skills/18_Genetics_Genomics/gnomad-database/SKILL.md +73 -0
- package/skills/18_Genetics_Genomics/gnomad-database/references/citation.bib +14 -0
- package/skills/18_Genetics_Genomics/gnomad-database/scripts/get_gene_constraint.py +90 -0
- package/skills/18_Genetics_Genomics/gnomad-database/scripts/get_variant_frequency.py +181 -0
- package/skills/18_Genetics_Genomics/gnomad-database/scripts/search_variants.py +207 -0
- package/skills/19_Pharmacology/chembl-database/SKILL.md +283 -0
- package/skills/19_Pharmacology/chembl-database/references/api_endpoints.md +97 -0
- package/skills/19_Pharmacology/chembl-database/references/citation.bib +30 -0
- package/skills/19_Pharmacology/chembl-database/scripts/chembl_api.py +657 -0
- package/skills/19_Pharmacology/clinical-trials-database/SKILL.md +378 -0
- package/skills/19_Pharmacology/clinical-trials-database/references/citation.bib +11 -0
- package/skills/19_Pharmacology/clinical-trials-database/references/clinical_trials_api.md +187 -0
- package/skills/19_Pharmacology/clinical-trials-database/references/studies_schema.md +143 -0
- package/skills/19_Pharmacology/clinical-trials-database/scripts/clinical_trials_api.py +373 -0
- package/skills/19_Pharmacology/openfda-database/SKILL.md +225 -0
- package/skills/19_Pharmacology/openfda-database/references/api_endpoints.md +207 -0
- package/skills/19_Pharmacology/openfda-database/references/citation.bib +15 -0
- package/skills/19_Pharmacology/openfda-database/references/recipes.md +150 -0
- package/skills/19_Pharmacology/openfda-database/scripts/openfda_query.py +505 -0
- package/skills/19_Pharmacology/opentargets-database/SKILL.md +198 -0
- package/skills/19_Pharmacology/opentargets-database/references/OpenTargets_GraphQL_Guide.md +216 -0
- package/skills/19_Pharmacology/opentargets-database/references/citation.bib +15 -0
- package/skills/19_Pharmacology/opentargets-database/scripts/query_opentargets.py +533 -0
- package/skills/19_Pharmacology/pubchem-database/SKILL.md +164 -0
- package/skills/19_Pharmacology/pubchem-database/references/citation.bib +15 -0
- package/skills/19_Pharmacology/pubchem-database/references/endpoints.md +71 -0
- package/skills/19_Pharmacology/pubchem-database/references/workflows.md +32 -0
- package/skills/19_Pharmacology/pubchem-database/scripts/pubchem_api.py +327 -0
- package/skills/20_Infrastructure/uv/SKILL.md +30 -0
- package/skills/01_Meta-Skills/academic-research-hub/SKILL.md +0 -108
- package/skills/01_Meta-Skills/academic-research-hub/scripts/requirements.txt +0 -17
- package/skills/01_Meta-Skills/academic-research-hub/scripts/research.py +0 -781
- package/skills/01_Meta-Skills/beautiful-log/SKILL.md +0 -64
- package/skills/01_Meta-Skills/beautiful-log/scripts/beautiful_log.py +0 -274
- package/skills/01_Meta-Skills/ethoclaw-daily-paper/SKILL.md +0 -130
- package/skills/01_Meta-Skills/ethoclaw-daily-paper/assets/config.template.yaml +0 -54
- package/skills/01_Meta-Skills/ethoclaw-daily-paper/assets/top5_digest_template.md +0 -5
- package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/build_top5_digest.py +0 -300
- package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/common.py +0 -137
- package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/merge_results.py +0 -106
- package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/run_pipeline.py +0 -177
- package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/search_arxiv.py +0 -162
- package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/search_pubmed.py +0 -202
- package/skills/01_Meta-Skills/ethoclaw-normalize-tabular/SKILL.md +0 -173
- package/skills/01_Meta-Skills/ethoclaw-normalize-tabular/scripts/normalize_data.py +0 -874
- package/skills/01_Meta-Skills/ethoclaw-pdf-research/SKILL.md +0 -134
- package/skills/01_Meta-Skills/ethoclaw-pdf-research/references/confirmation-prompts.md +0 -31
- package/skills/01_Meta-Skills/ethoclaw-pdf-research/references/output-patterns.md +0 -45
- package/skills/01_Meta-Skills/ethoclaw-pdf-research/scripts/build_markdown_deliverables.py +0 -41
- package/skills/01_Meta-Skills/ethoclaw-pdf-research/scripts/build_research_log.py +0 -84
- package/skills/01_Meta-Skills/ethoclaw-pdf-research/scripts/build_summary_md.py +0 -63
- package/skills/01_Meta-Skills/ethoclaw-pdf-research/scripts/extract_pdf_bundle.py +0 -140
- package/skills/01_Meta-Skills/experiment-controller/SKILL.md +0 -140
- package/skills/01_Meta-Skills/knowledge-graph-builder/SKILL.md +0 -366
- package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/entity_resolution.py +0 -120
- package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/extraction_prompt_template.txt +0 -19
- package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/graph_query.py +0 -106
- package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/hypothesis_cli_reference.py +0 -42
- package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/new_data_source_template.py +0 -116
- package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/requirements.txt +0 -15
- package/skills/01_Meta-Skills/method-design/SKILL.md +0 -61
- package/skills/01_Meta-Skills/multi-search-engine/SKILL.md +0 -119
- package/skills/01_Meta-Skills/research-idea/SKILL.md +0 -65
- package/skills/05_EEG_ERP/eeg-skill/SKILL.md +0 -197
- package/skills/05_EEG_ERP/meg-skill/SKILL.md +0 -188
- package/skills/05_EEG_ERP/meg-skill/scripts/time_frequency.py +0 -223
- package/skills/05_EEG_ERP/mne-eeg-tool/SKILL.md +0 -165
- package/skills/05_EEG_ERP/mne-eeg-tool/scripts/eeg_pipeline_reference.py +0 -231
- package/skills/05_EEG_ERP/seed-iv-skill/SKILL.md +0 -184
- package/skills/05_EEG_ERP/seed-iv-skill/scripts/classify_seed_iv.py +0 -154
- package/skills/05_EEG_ERP/seed-iv-skill/scripts/extract_seed_iv_features.py +0 -190
- package/skills/05_EEG_ERP/seed-iv-skill/scripts/validate_seed_iv.py +0 -102
- package/skills/05_EEG_ERP/seed-vig-skill/SKILL.md +0 -182
- package/skills/05_EEG_ERP/seed-vig-skill/scripts/classify_seed_vig.py +0 -165
- package/skills/05_EEG_ERP/seed-vig-skill/scripts/extract_seed_vig_features.py +0 -185
- package/skills/05_EEG_ERP/seed-vig-skill/scripts/validate_seed_vig.py +0 -88
- package/skills/06_fMRI_Neuroimaging/abcd-skill/SKILL.md +0 -308
- package/skills/06_fMRI_Neuroimaging/abcd-skill/scripts/abcd_qc_summary.py +0 -449
- package/skills/06_fMRI_Neuroimaging/abcd-skill/scripts/extract_abcd_phenotype.py +0 -292
- package/skills/06_fMRI_Neuroimaging/abcd-skill/scripts/reorganize_abcd.py +0 -387
- package/skills/06_fMRI_Neuroimaging/abide-skill/SKILL.md +0 -302
- package/skills/06_fMRI_Neuroimaging/abide-skill/scripts/abide_qc_summary.py +0 -317
- package/skills/06_fMRI_Neuroimaging/abide-skill/scripts/extract_abide_phenotype.py +0 -267
- package/skills/06_fMRI_Neuroimaging/abide-skill/scripts/reorganize_abide.py +0 -387
- package/skills/06_fMRI_Neuroimaging/adhd200-skill/SKILL.md +0 -244
- package/skills/06_fMRI_Neuroimaging/adhd200-skill/scripts/adhd200_qc_summary.py +0 -98
- package/skills/06_fMRI_Neuroimaging/adhd200-skill/scripts/extract_adhd200_phenotype.py +0 -134
- package/skills/06_fMRI_Neuroimaging/adhd200-skill/scripts/reorganize_adhd200.py +0 -206
- package/skills/06_fMRI_Neuroimaging/adni-skill/SKILL.md +0 -358
- package/skills/06_fMRI_Neuroimaging/adni-skill/scripts/generate_adni_task_files.py +0 -1305
- package/skills/06_fMRI_Neuroimaging/adni-skill/scripts/generate_vqa_from_tasks.py +0 -766
- package/skills/06_fMRI_Neuroimaging/adni-skill/scripts/reorganize_adni.py +0 -491
- package/skills/06_fMRI_Neuroimaging/aibl-skill/SKILL.md +0 -295
- package/skills/06_fMRI_Neuroimaging/aibl-skill/scripts/aibl_qc_summary.py +0 -260
- package/skills/06_fMRI_Neuroimaging/aibl-skill/scripts/extract_aibl_phenotype.py +0 -365
- package/skills/06_fMRI_Neuroimaging/aibl-skill/scripts/reorganize_aibl.py +0 -394
- package/skills/06_fMRI_Neuroimaging/aomic-skill/SKILL.md +0 -292
- package/skills/06_fMRI_Neuroimaging/aomic-skill/scripts/aomic_qc_summary.py +0 -258
- package/skills/06_fMRI_Neuroimaging/aomic-skill/scripts/extract_aomic_phenotype.py +0 -284
- package/skills/06_fMRI_Neuroimaging/aomic-skill/scripts/reorganize_aomic.py +0 -322
- package/skills/06_fMRI_Neuroimaging/asl-skill/SKILL.md +0 -168
- package/skills/06_fMRI_Neuroimaging/asl-skill/scripts/compute_cbf.py +0 -224
- package/skills/06_fMRI_Neuroimaging/bids-organizer/SKILL.md +0 -241
- package/skills/06_fMRI_Neuroimaging/bold5000-skill/SKILL.md +0 -186
- package/skills/06_fMRI_Neuroimaging/bold5000-skill/scripts/bold5000_qc_summary.py +0 -96
- package/skills/06_fMRI_Neuroimaging/bold5000-skill/scripts/extract_bold5000_stimulus.py +0 -125
- package/skills/06_fMRI_Neuroimaging/bold5000-skill/scripts/reorganize_bold5000.py +0 -102
- package/skills/06_fMRI_Neuroimaging/camcan-skill/SKILL.md +0 -213
- package/skills/06_fMRI_Neuroimaging/camcan-skill/scripts/camcan_qc_summary.py +0 -131
- package/skills/06_fMRI_Neuroimaging/camcan-skill/scripts/extract_camcan_phenotype.py +0 -145
- package/skills/06_fMRI_Neuroimaging/camcan-skill/scripts/validate_camcan.py +0 -141
- package/skills/06_fMRI_Neuroimaging/cobre-skill/SKILL.md +0 -201
- package/skills/06_fMRI_Neuroimaging/cobre-skill/scripts/cobre_qc_summary.py +0 -95
- package/skills/06_fMRI_Neuroimaging/cobre-skill/scripts/extract_cobre_phenotype.py +0 -104
- package/skills/06_fMRI_Neuroimaging/cobre-skill/scripts/reorganize_cobre.py +0 -140
- package/skills/06_fMRI_Neuroimaging/conn-tool/SKILL.md +0 -180
- package/skills/06_fMRI_Neuroimaging/dcm2nii/SKILL.md +0 -189
- package/skills/06_fMRI_Neuroimaging/dmt-har-med-skill/SKILL.md +0 -183
- package/skills/06_fMRI_Neuroimaging/dmt-har-med-skill/scripts/dmt_har_med_qc_summary.py +0 -96
- package/skills/06_fMRI_Neuroimaging/dmt-har-med-skill/scripts/extract_dmt_har_med_phenotype.py +0 -121
- package/skills/06_fMRI_Neuroimaging/dmt-har-med-skill/scripts/reorganize_dmt_har_med.py +0 -125
- package/skills/06_fMRI_Neuroimaging/dwi-skill/SKILL.md +0 -359
- package/skills/06_fMRI_Neuroimaging/fmri-skill/SKILL.md +0 -371
- package/skills/06_fMRI_Neuroimaging/fmriprep-tool/SKILL.md +0 -228
- package/skills/06_fMRI_Neuroimaging/freesurfer-tool/SKILL.md +0 -286
- package/skills/06_fMRI_Neuroimaging/freesurfer-tool/scripts/freesurfer_processor.py +0 -145
- package/skills/06_fMRI_Neuroimaging/fsl-tool/SKILL.md +0 -208
- package/skills/06_fMRI_Neuroimaging/hbn-skill/SKILL.md +0 -271
- package/skills/06_fMRI_Neuroimaging/hbn-skill/scripts/extract_hbn_phenotype.py +0 -107
- package/skills/06_fMRI_Neuroimaging/hbn-skill/scripts/hbn_qc_summary.py +0 -96
- package/skills/06_fMRI_Neuroimaging/hbn-skill/scripts/reorganize_hbn.py +0 -150
- package/skills/06_fMRI_Neuroimaging/hcpa-skill/SKILL.md +0 -210
- package/skills/06_fMRI_Neuroimaging/hcpa-skill/scripts/extract_hcpa_phenotype.py +0 -146
- package/skills/06_fMRI_Neuroimaging/hcpa-skill/scripts/hcpa_qc_summary.py +0 -120
- package/skills/06_fMRI_Neuroimaging/hcpa-skill/scripts/reorganize_hcpa.py +0 -155
- package/skills/06_fMRI_Neuroimaging/hcpd-skill/SKILL.md +0 -210
- package/skills/06_fMRI_Neuroimaging/hcpd-skill/scripts/extract_hcpd_phenotype.py +0 -148
- package/skills/06_fMRI_Neuroimaging/hcpd-skill/scripts/hcpd_qc_summary.py +0 -125
- package/skills/06_fMRI_Neuroimaging/hcpd-skill/scripts/reorganize_hcpd.py +0 -146
- package/skills/06_fMRI_Neuroimaging/hcpep-skill/SKILL.md +0 -215
- package/skills/06_fMRI_Neuroimaging/hcpep-skill/scripts/extract_hcpep_phenotype.py +0 -157
- package/skills/06_fMRI_Neuroimaging/hcpep-skill/scripts/hcpep_qc_summary.py +0 -143
- package/skills/06_fMRI_Neuroimaging/hcpep-skill/scripts/reorganize_hcpep.py +0 -146
- package/skills/06_fMRI_Neuroimaging/hcppipeline-tool/SKILL.md +0 -217
- package/skills/06_fMRI_Neuroimaging/hcpya-skill/SKILL.md +0 -214
- package/skills/06_fMRI_Neuroimaging/hcpya-skill/scripts/extract_hcpya_phenotype.py +0 -190
- package/skills/06_fMRI_Neuroimaging/hcpya-skill/scripts/hcpya_qc_summary.py +0 -152
- package/skills/06_fMRI_Neuroimaging/hcpya-skill/scripts/reorganize_hcpya.py +0 -203
- package/skills/06_fMRI_Neuroimaging/ixi-skill/SKILL.md +0 -198
- package/skills/06_fMRI_Neuroimaging/ixi-skill/scripts/ixi_qc_summary.py +0 -137
- package/skills/06_fMRI_Neuroimaging/ixi-skill/scripts/reorganize_ixi.py +0 -190
- package/skills/06_fMRI_Neuroimaging/mnd-skill/SKILL.md +0 -191
- package/skills/06_fMRI_Neuroimaging/mnd-skill/scripts/extract_mnd_phenotype.py +0 -143
- package/skills/06_fMRI_Neuroimaging/mnd-skill/scripts/mnd_qc_summary.py +0 -120
- package/skills/06_fMRI_Neuroimaging/mnd-skill/scripts/validate_mnd.py +0 -107
- package/skills/06_fMRI_Neuroimaging/mschallenge-skill/SKILL.md +0 -203
- package/skills/06_fMRI_Neuroimaging/mschallenge-skill/scripts/analyze_lesions.py +0 -119
- package/skills/06_fMRI_Neuroimaging/mschallenge-skill/scripts/longitudinal_lesion.py +0 -148
- package/skills/06_fMRI_Neuroimaging/mschallenge-skill/scripts/mschallenge_qc_summary.py +0 -132
- package/skills/06_fMRI_Neuroimaging/mschallenge-skill/scripts/validate_mschallenge.py +0 -116
- package/skills/06_fMRI_Neuroimaging/nibabel-skill/SKILL.md +0 -184
- package/skills/06_fMRI_Neuroimaging/nibabel-skill/scripts/atlas_coordinate_reference.py +0 -61
- package/skills/06_fMRI_Neuroimaging/nibabel-skill/scripts/freesurfer_io_reference.py +0 -34
- package/skills/06_fMRI_Neuroimaging/nibabel-skill/scripts/nifti_inspection_reference.py +0 -35
- package/skills/06_fMRI_Neuroimaging/nifd-skill/SKILL.md +0 -205
- package/skills/06_fMRI_Neuroimaging/nifd-skill/scripts/extract_nifd_phenotype.py +0 -132
- package/skills/06_fMRI_Neuroimaging/nifd-skill/scripts/nifd_qc_summary.py +0 -111
- package/skills/06_fMRI_Neuroimaging/nifd-skill/scripts/validate_nifd.py +0 -111
- package/skills/06_fMRI_Neuroimaging/nii2dcm/SKILL.md +0 -143
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/SKILL.md +0 -266
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/connectome_reference.py +0 -65
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/denoise_timeseries_reference.py +0 -58
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/hierarchical_parcellation_reference.py +0 -53
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/kmeans_parcellation_reference.py +0 -53
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/preprocess_bold_reference.py +0 -76
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/rest_dictlearning_reference.py +0 -56
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/rest_ica_reference.py +0 -59
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/second_level_glm_reference.py +0 -58
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/spacenet_classifier_reference.py +0 -59
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/svm_classifier_reference.py +0 -60
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/task_glm_reference.py +0 -63
- package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/zalff_summary_reference.py +0 -109
- package/skills/06_fMRI_Neuroimaging/nsd-skill/SKILL.md +0 -210
- package/skills/06_fMRI_Neuroimaging/nsd-skill/scripts/extract_nsd_stimulus.py +0 -171
- package/skills/06_fMRI_Neuroimaging/nsd-skill/scripts/nsd_qc_summary.py +0 -142
- package/skills/06_fMRI_Neuroimaging/nsd-skill/scripts/validate_nsd.py +0 -142
- package/skills/06_fMRI_Neuroimaging/oasis-skill/SKILL.md +0 -205
- package/skills/06_fMRI_Neuroimaging/oasis-skill/scripts/extract_oasis_phenotype.py +0 -126
- package/skills/06_fMRI_Neuroimaging/oasis-skill/scripts/oasis_qc_summary.py +0 -115
- package/skills/06_fMRI_Neuroimaging/oasis-skill/scripts/validate_oasis.py +0 -119
- package/skills/06_fMRI_Neuroimaging/pet-skill/SKILL.md +0 -173
- package/skills/06_fMRI_Neuroimaging/pet-skill/scripts/compute_suvr.py +0 -202
- package/skills/06_fMRI_Neuroimaging/pnc-skill/SKILL.md +0 -206
- package/skills/06_fMRI_Neuroimaging/pnc-skill/scripts/extract_pnc_phenotype.py +0 -136
- package/skills/06_fMRI_Neuroimaging/pnc-skill/scripts/pnc_qc_summary.py +0 -116
- package/skills/06_fMRI_Neuroimaging/pnc-skill/scripts/validate_pnc.py +0 -120
- package/skills/06_fMRI_Neuroimaging/ppmi-skill/SKILL.md +0 -209
- package/skills/06_fMRI_Neuroimaging/ppmi-skill/scripts/extract_ppmi_phenotype.py +0 -138
- package/skills/06_fMRI_Neuroimaging/ppmi-skill/scripts/ppmi_qc_summary.py +0 -111
- package/skills/06_fMRI_Neuroimaging/ppmi-skill/scripts/validate_ppmi.py +0 -117
- package/skills/06_fMRI_Neuroimaging/qsiprep-tool/SKILL.md +0 -320
- package/skills/06_fMRI_Neuroimaging/rest-mneta-mdd-skill/SKILL.md +0 -215
- package/skills/06_fMRI_Neuroimaging/rest-mneta-mdd-skill/scripts/extract_rest_mdd_phenotype.py +0 -132
- package/skills/06_fMRI_Neuroimaging/rest-mneta-mdd-skill/scripts/harmonize_sites.py +0 -152
- package/skills/06_fMRI_Neuroimaging/rest-mneta-mdd-skill/scripts/rest_mdd_qc_summary.py +0 -124
- package/skills/06_fMRI_Neuroimaging/rest-mneta-mdd-skill/scripts/validate_rest_mdd.py +0 -103
- package/skills/06_fMRI_Neuroimaging/smri-skill/SKILL.md +0 -302
- package/skills/06_fMRI_Neuroimaging/tcp-skill/SKILL.md +0 -204
- package/skills/06_fMRI_Neuroimaging/tcp-skill/scripts/extract_tcp_phenotype.py +0 -139
- package/skills/06_fMRI_Neuroimaging/tcp-skill/scripts/tcp_qc_summary.py +0 -111
- package/skills/06_fMRI_Neuroimaging/tcp-skill/scripts/validate_tcp.py +0 -99
- package/skills/06_fMRI_Neuroimaging/ucla-cnp-skill/SKILL.md +0 -217
- package/skills/06_fMRI_Neuroimaging/ucla-cnp-skill/scripts/extract_ucla_cnp_phenotype.py +0 -145
- package/skills/06_fMRI_Neuroimaging/ucla-cnp-skill/scripts/ucla_cnp_qc_summary.py +0 -111
- package/skills/06_fMRI_Neuroimaging/ucla-cnp-skill/scripts/validate_ucla_cnp.py +0 -113
- package/skills/06_fMRI_Neuroimaging/ukb-skill/SKILL.md +0 -310
- package/skills/06_fMRI_Neuroimaging/ukb-skill/scripts/build_ukb_survival.py +0 -210
- package/skills/06_fMRI_Neuroimaging/ukb-skill/scripts/extract_ukb_cases.py +0 -308
- package/skills/06_fMRI_Neuroimaging/ukb-skill/scripts/extract_ukb_phenotype.py +0 -232
- package/skills/06_fMRI_Neuroimaging/ukb-skill/scripts/ukb_qc_summary.py +0 -158
- package/skills/06_fMRI_Neuroimaging/wmh-segmentation/SKILL.md +0 -133
- package/skills/07_Computational_Modeling/detrending/SKILL.md +0 -118
- package/skills/07_Computational_Modeling/dictlearning/SKILL.md +0 -122
- package/skills/07_Computational_Modeling/filtering/SKILL.md +0 -121
- package/skills/07_Computational_Modeling/glm/SKILL.md +0 -153
- package/skills/07_Computational_Modeling/hierarchical/SKILL.md +0 -121
- package/skills/07_Computational_Modeling/ica/SKILL.md +0 -122
- package/skills/07_Computational_Modeling/kmeans/SKILL.md +0 -119
- package/skills/07_Computational_Modeling/run_models/SKILL.md +0 -427
- package/skills/07_Computational_Modeling/spacenet/SKILL.md +0 -122
- package/skills/07_Computational_Modeling/svm/SKILL.md +0 -120
- package/skills/08_Computational_Neuroscience/brain_gnn/SKILL.md +0 -183
- package/skills/08_Computational_Neuroscience/dipy-tool/SKILL.md +0 -239
- package/skills/08_Computational_Neuroscience/dipy-tool/scripts/dti_metrics_reference.py +0 -70
- package/skills/08_Computational_Neuroscience/dipy-tool/scripts/load_and_mask_reference.py +0 -76
- package/skills/08_Computational_Neuroscience/dipy-tool/scripts/roi_stats_reference.py +0 -59
- package/skills/08_Computational_Neuroscience/fm_app/SKILL.md +0 -195
- package/skills/08_Computational_Neuroscience/neurostorm/SKILL.md +0 -151
- package/skills/13_Visualization/brain-visualization/SKILL.md +0 -191
- package/skills/13_Visualization/brain-visualization/scripts/connectome_reference.py +0 -108
- package/skills/13_Visualization/brain-visualization/scripts/freesurfer_ply_reference.py +0 -54
- package/skills/13_Visualization/brain-visualization/scripts/zalff_summary_reference.py +0 -116
- package/skills/13_Visualization/ethoclaw-paper-figure-layout/SKILL.md +0 -78
- package/skills/13_Visualization/ethoclaw-paper-figure-layout/assets/naturecomm_figures.tex +0 -74
- package/skills/13_Visualization/ethoclaw-paper-figure-layout/scripts/layout_results_foldered.py +0 -579
- package/skills/14_Writing/overleaf-skill/SKILL.md +0 -184
- package/skills/14_Writing/overleaf-skill/scripts/install.sh +0 -30
- package/skills/14_Writing/paper-writing/SKILL.md +0 -146
- package/skills/14_Writing/paper-writing/scripts/data_statement_templates.py +0 -164
- package/skills/14_Writing/paper-writing/scripts/figure_templates.py +0 -315
- package/skills/14_Writing/paper-writing/scripts/nature_figure_style.py +0 -214
- package/skills/14_Writing/paper-writing/scripts/section_phrasebank.py +0 -246
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/SKILL.md +0 -274
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/report_template_en.html +0 -112
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/report_template_en.md +0 -21
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/cluster-section.md +0 -5
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/heatmap-section.md +0 -5
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/integrated-interpretation.md +0 -3
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/overview.md +0 -3
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/project-summary.md +0 -3
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/radar-section.md +0 -5
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/raw-trajectory.md +0 -3
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/sample-check.md +0 -3
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/single-subject-section.md +0 -3
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/stats-section.md +0 -5
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/epm.md +0 -52
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/fst.md +0 -37
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/nor.md +0 -39
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/oft.md +0 -43
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/tcst.md +0 -45
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/tst.md +0 -36
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/input-types.md +0 -59
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/interpretation-guardrails.md +0 -45
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/metadata-schema.md +0 -57
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/report-sections.md +0 -86
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/section-selection-rules.md +0 -169
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/scripts/build_report_manifest.py +0 -27
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/scripts/render_report.py +0 -34
- package/skills/16_Animal_Behavior/ethoclaw-analysis-report/scripts/report_utils.py +0 -1121
- package/skills/16_Animal_Behavior/ethoclaw-animal-grounding/SKILL.md +0 -390
- package/skills/16_Animal_Behavior/ethoclaw-animal-grounding/reference_code.py +0 -98
- package/skills/16_Animal_Behavior/ethoclaw-animal-pose-estimation/SKILL.md +0 -336
- package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/README.md +0 -21
- package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/SKILL.md +0 -41
- package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/batch_kinematic_generator.py +0 -663
- package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/config.json +0 -19
- package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/generate_kinematic_parameter.py +0 -401
- package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/kinematic_generator.py +0 -265
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-clustermap-generate/SKILL.md +0 -72
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-clustermap-generate/references/config.example.toml +0 -56
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-clustermap-generate/scripts/cluster_all_params.py +0 -232
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-clustermap-generate/scripts/cluster_all_params_from_config.py +0 -236
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-radar-generate/SKILL.md +0 -68
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-radar-generate/references/notes.md +0 -5
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-radar-generate/scripts/plot_h5_radar.py +0 -513
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/SKILL.md +0 -52
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/config.toml +0 -81
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/references/stats-rule.md +0 -18
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/scripts/h5_inspect.py +0 -79
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/scripts/h5_violin_batch.py +0 -624
- package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/scripts/h5_violin_stats.py +0 -438
- package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/SKILL.md +0 -280
- package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/core_scripts/heatmap_trajectory.py +0 -790
- package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/core_scripts/heatmap_velocity.py +0 -855
- package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/reference_data/reference_2d.csv +0 -101
- package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/reference_data/reference_2d.h5 +0 -0
- package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/reference_data/reference_data_readme.md +0 -126
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
# Copyright 2026 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Queries the openFDA API and returns results in clean JSON format.
|
|
16
|
+
|
|
17
|
+
This script provides a CLI for searching, counting, and downloading data from
|
|
18
|
+
all 28 openFDA API endpoints across 8 categories: drug, device, food, tobacco,
|
|
19
|
+
other, animalandveterinary, cosmetic, and transparency.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
# /// script
|
|
23
|
+
# requires-python = ">=3.10"
|
|
24
|
+
# dependencies = [
|
|
25
|
+
# "polite-http",
|
|
26
|
+
# "python-dotenv",
|
|
27
|
+
# ]
|
|
28
|
+
# ///
|
|
29
|
+
|
|
30
|
+
from __future__ import annotations
|
|
31
|
+
|
|
32
|
+
import argparse
|
|
33
|
+
import json
|
|
34
|
+
import os
|
|
35
|
+
import sys
|
|
36
|
+
from typing import Any
|
|
37
|
+
|
|
38
|
+
import dotenv
|
|
39
|
+
from polite_http import http_client
|
|
40
|
+
|
|
41
|
+
BASE_URL = "https://api.fda.gov"
|
|
42
|
+
CLIENT = http_client.HttpClient(BASE_URL, qps=4.0)
|
|
43
|
+
|
|
44
|
+
VALID_ENDPOINTS = {
|
|
45
|
+
"drug": [
|
|
46
|
+
"event",
|
|
47
|
+
"label",
|
|
48
|
+
"ndc",
|
|
49
|
+
"enforcement",
|
|
50
|
+
"drugsfda",
|
|
51
|
+
"shortages",
|
|
52
|
+
],
|
|
53
|
+
"device": [
|
|
54
|
+
"510k",
|
|
55
|
+
"classification",
|
|
56
|
+
"enforcement",
|
|
57
|
+
"event",
|
|
58
|
+
"pma",
|
|
59
|
+
"recall",
|
|
60
|
+
"registrationlisting",
|
|
61
|
+
"udi",
|
|
62
|
+
"covid19serology",
|
|
63
|
+
],
|
|
64
|
+
"food": ["enforcement", "event"],
|
|
65
|
+
"tobacco": [
|
|
66
|
+
"problem",
|
|
67
|
+
"researchpreventionads",
|
|
68
|
+
"researchdigitalads",
|
|
69
|
+
"researchsmokefree",
|
|
70
|
+
],
|
|
71
|
+
"other": ["historicaldocument", "nsde", "substance", "unii"],
|
|
72
|
+
"animalandveterinary": ["event"],
|
|
73
|
+
"cosmetic": ["event"],
|
|
74
|
+
"transparency": ["crl"],
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
ALL_RESULTS_SAFETY_CAP = 25000
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _warn_no_api_key(api_key: str | None) -> None:
|
|
81
|
+
key = api_key or os.environ.get("FDA_API_KEY")
|
|
82
|
+
if not key:
|
|
83
|
+
print(
|
|
84
|
+
"WARNING: No API key provided. This API has much lower rate limits"
|
|
85
|
+
" without a key. Get one at https://open.fda.gov/apis/authentication/"
|
|
86
|
+
" and pass via --api_key or the FDA_API_KEY environment variable.",
|
|
87
|
+
file=sys.stderr,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _write_output(data: dict[str, Any], output_path: str) -> None:
|
|
92
|
+
out_dir = os.path.dirname(output_path)
|
|
93
|
+
if out_dir:
|
|
94
|
+
os.makedirs(out_dir, exist_ok=True)
|
|
95
|
+
|
|
96
|
+
if isinstance(data, dict):
|
|
97
|
+
data["_license_notice"] = (
|
|
98
|
+
"Data provided by openFDA. Please review the licensing terms at"
|
|
99
|
+
" https://open.fda.gov/license/"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
with open(output_path, "w") as f:
|
|
103
|
+
json.dump(data, f, indent=2)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _print_json(data: dict[str, Any]) -> None:
|
|
107
|
+
"""Prints a dictionary as indented JSON to stdout."""
|
|
108
|
+
print(json.dumps(data, indent=2))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _validate_endpoint(category: str, endpoint: str) -> bool:
|
|
112
|
+
if category not in VALID_ENDPOINTS:
|
|
113
|
+
return False
|
|
114
|
+
return endpoint in VALID_ENDPOINTS[category]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _print_endpoint_error(category: str, endpoint: str) -> None:
|
|
118
|
+
"""Prints an error message for an invalid endpoint and exits.
|
|
119
|
+
|
|
120
|
+
The error message includes the valid endpoints for the given category.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
category: The API category provided.
|
|
124
|
+
endpoint: The invalid API endpoint provided.
|
|
125
|
+
"""
|
|
126
|
+
valid = ", ".join(VALID_ENDPOINTS.get(category, []))
|
|
127
|
+
_print_json({
|
|
128
|
+
"status": "error",
|
|
129
|
+
"message": (
|
|
130
|
+
f"Invalid endpoint '{endpoint}' for category "
|
|
131
|
+
f"'{category}'. Valid endpoints: {valid}"
|
|
132
|
+
),
|
|
133
|
+
})
|
|
134
|
+
sys.exit(1)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _build_url(
|
|
138
|
+
*,
|
|
139
|
+
category: str,
|
|
140
|
+
endpoint: str,
|
|
141
|
+
search: str | None = None,
|
|
142
|
+
sort: str | None = None,
|
|
143
|
+
limit: int = 10,
|
|
144
|
+
skip: int = 0,
|
|
145
|
+
count_field: str | None = None,
|
|
146
|
+
api_key: str | None = None,
|
|
147
|
+
) -> str:
|
|
148
|
+
"""Builds the openFDA API URL with the given parameters.
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
category: The API category (e.g., "drug").
|
|
152
|
+
endpoint: The API endpoint within the category (e.g., "event").
|
|
153
|
+
search: Optional search query string.
|
|
154
|
+
sort: Optional sort field and order string.
|
|
155
|
+
limit: The maximum number of results per request.
|
|
156
|
+
skip: The number of records to skip for pagination.
|
|
157
|
+
count_field: Optional field to count unique values for.
|
|
158
|
+
api_key: Optional API key.
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
A string representing the constructed URL.
|
|
162
|
+
"""
|
|
163
|
+
url = f"{BASE_URL}/{category}/{endpoint}.json?"
|
|
164
|
+
params = []
|
|
165
|
+
|
|
166
|
+
key = api_key or os.environ.get("FDA_API_KEY")
|
|
167
|
+
if key:
|
|
168
|
+
params.append(f"api_key={key}")
|
|
169
|
+
if search:
|
|
170
|
+
params.append(f"search={search}")
|
|
171
|
+
if sort:
|
|
172
|
+
params.append(f"sort={sort}")
|
|
173
|
+
if count_field:
|
|
174
|
+
params.append(f"count={count_field}")
|
|
175
|
+
else:
|
|
176
|
+
params.append(f"limit={limit}")
|
|
177
|
+
params.append(f"skip={skip}")
|
|
178
|
+
|
|
179
|
+
return url + "&".join(params)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _fetch(url: str) -> dict[str, Any]:
|
|
183
|
+
"""Fetches JSON data from the given URL and handles errors."""
|
|
184
|
+
|
|
185
|
+
try:
|
|
186
|
+
return CLIENT.fetch_json(url)
|
|
187
|
+
except http_client.HttpError as e:
|
|
188
|
+
if e.status_code == 429:
|
|
189
|
+
return {
|
|
190
|
+
"status": "error",
|
|
191
|
+
"http_code": 429,
|
|
192
|
+
"message": (
|
|
193
|
+
"Rate limit exceeded (HTTP 429). You have hit the openFDA request"
|
|
194
|
+
" limit. Without an API key the limit is 240 requests/min and"
|
|
195
|
+
" 1,000/day. With a free API key the daily limit increases to"
|
|
196
|
+
" 120,000. Register at: https://open.fda.gov/apis/authentication/"
|
|
197
|
+
),
|
|
198
|
+
}
|
|
199
|
+
if e.status_code is not None:
|
|
200
|
+
body = ""
|
|
201
|
+
if e.body:
|
|
202
|
+
body = e.body.decode("utf-8", errors="replace")
|
|
203
|
+
try:
|
|
204
|
+
error_json = json.loads(body)
|
|
205
|
+
return {"status": "error", "http_code": e.status_code, **error_json}
|
|
206
|
+
except (json.JSONDecodeError, ValueError):
|
|
207
|
+
return {
|
|
208
|
+
"status": "error",
|
|
209
|
+
"http_code": e.status_code,
|
|
210
|
+
"message": f"HTTP {e.status_code}: {str(e)}",
|
|
211
|
+
"body": body[:500],
|
|
212
|
+
}
|
|
213
|
+
return {"status": "error", "message": f"Network error: {str(e)}"}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def cmd_search(args: argparse.Namespace) -> None:
|
|
217
|
+
"""Searches the openFDA API and writes the results to a file.
|
|
218
|
+
|
|
219
|
+
Constructs a search URL based on the provided arguments, fetches the data,
|
|
220
|
+
and writes the JSON response to the file specified by --output. Also prints
|
|
221
|
+
a summary of the operation to stdout.
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
args: An argparse.Namespace object containing the command-line arguments,
|
|
225
|
+
including category, endpoint, search, sort, limit, skip, api_key, and
|
|
226
|
+
output.
|
|
227
|
+
"""
|
|
228
|
+
if not _validate_endpoint(args.category, args.endpoint):
|
|
229
|
+
_print_endpoint_error(args.category, args.endpoint)
|
|
230
|
+
|
|
231
|
+
_warn_no_api_key(args.api_key)
|
|
232
|
+
|
|
233
|
+
url = _build_url(
|
|
234
|
+
category=args.category,
|
|
235
|
+
endpoint=args.endpoint,
|
|
236
|
+
search=args.search,
|
|
237
|
+
sort=args.sort,
|
|
238
|
+
limit=args.limit,
|
|
239
|
+
skip=args.skip,
|
|
240
|
+
api_key=args.api_key,
|
|
241
|
+
)
|
|
242
|
+
result = _fetch(url)
|
|
243
|
+
_write_output(result, args.output)
|
|
244
|
+
|
|
245
|
+
total = result.get("meta", {}).get("results", {}).get("total", "?")
|
|
246
|
+
count = len(result.get("results", []))
|
|
247
|
+
_print_json({
|
|
248
|
+
"status": "success",
|
|
249
|
+
"output": args.output,
|
|
250
|
+
"results_in_file": count,
|
|
251
|
+
"total_matching": total,
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def cmd_count(args: argparse.Namespace) -> None:
|
|
256
|
+
"""Counts unique values for a specified field using the openFDA API.
|
|
257
|
+
|
|
258
|
+
Fetches counts of unique terms for a given field based on the provided
|
|
259
|
+
search criteria. Optionally, it can return only a summary of the top N
|
|
260
|
+
most frequent terms. The results are written to the file specified by
|
|
261
|
+
--output.
|
|
262
|
+
|
|
263
|
+
Args:
|
|
264
|
+
args: An argparse.Namespace object containing the command-line arguments,
|
|
265
|
+
including category, endpoint, search, count_field, summary, and output.
|
|
266
|
+
"""
|
|
267
|
+
if not _validate_endpoint(args.category, args.endpoint):
|
|
268
|
+
_print_endpoint_error(args.category, args.endpoint)
|
|
269
|
+
|
|
270
|
+
_warn_no_api_key(args.api_key)
|
|
271
|
+
|
|
272
|
+
url = _build_url(
|
|
273
|
+
category=args.category,
|
|
274
|
+
endpoint=args.endpoint,
|
|
275
|
+
search=args.search,
|
|
276
|
+
sort=args.sort,
|
|
277
|
+
count_field=args.count_field,
|
|
278
|
+
api_key=args.api_key,
|
|
279
|
+
)
|
|
280
|
+
result = _fetch(url)
|
|
281
|
+
|
|
282
|
+
if args.summary and "results" in result:
|
|
283
|
+
result["results"] = result["results"][: args.summary]
|
|
284
|
+
|
|
285
|
+
_write_output(result, args.output)
|
|
286
|
+
|
|
287
|
+
entries = len(result.get("results", []))
|
|
288
|
+
top_terms = []
|
|
289
|
+
for r in result.get("results", [])[:5]:
|
|
290
|
+
top_terms.append({"term": r.get("term"), "count": r.get("count")})
|
|
291
|
+
_print_json({
|
|
292
|
+
"status": "success",
|
|
293
|
+
"output": args.output,
|
|
294
|
+
"entries": entries,
|
|
295
|
+
"top_terms": top_terms,
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def cmd_download(args: argparse.Namespace) -> None:
|
|
300
|
+
"""Downloads multiple pages of openFDA results and writes them to a file.
|
|
301
|
+
|
|
302
|
+
Fetches results from the specified openFDA endpoint, handling pagination
|
|
303
|
+
based on --max_pages or --all_results. The fetched records are
|
|
304
|
+
accumulated and written as a single JSON object to the file specified
|
|
305
|
+
by --output.
|
|
306
|
+
|
|
307
|
+
Args:
|
|
308
|
+
args: An argparse.Namespace object containing the command-line arguments.
|
|
309
|
+
"""
|
|
310
|
+
if not _validate_endpoint(args.category, args.endpoint):
|
|
311
|
+
_print_endpoint_error(args.category, args.endpoint)
|
|
312
|
+
|
|
313
|
+
_warn_no_api_key(args.api_key)
|
|
314
|
+
|
|
315
|
+
all_results = []
|
|
316
|
+
skip = args.skip
|
|
317
|
+
limit = args.limit
|
|
318
|
+
|
|
319
|
+
if args.all_results:
|
|
320
|
+
max_records = ALL_RESULTS_SAFETY_CAP
|
|
321
|
+
limit = min(limit, 1000) if limit else 1000
|
|
322
|
+
max_pages = max_records // limit + 1
|
|
323
|
+
print(
|
|
324
|
+
f"Fetching all results (safety cap: {max_records} records)...",
|
|
325
|
+
file=sys.stderr,
|
|
326
|
+
)
|
|
327
|
+
else:
|
|
328
|
+
max_pages = args.max_pages
|
|
329
|
+
max_records = max_pages * limit
|
|
330
|
+
|
|
331
|
+
for page in range(max_pages):
|
|
332
|
+
url = _build_url(
|
|
333
|
+
category=args.category,
|
|
334
|
+
endpoint=args.endpoint,
|
|
335
|
+
search=args.search,
|
|
336
|
+
sort=args.sort,
|
|
337
|
+
limit=limit,
|
|
338
|
+
skip=skip,
|
|
339
|
+
api_key=args.api_key,
|
|
340
|
+
)
|
|
341
|
+
result = _fetch(url)
|
|
342
|
+
|
|
343
|
+
if result.get("status") == "error" or "error" in result:
|
|
344
|
+
print(json.dumps(result, indent=2), file=sys.stderr)
|
|
345
|
+
break
|
|
346
|
+
|
|
347
|
+
results = result.get("results", [])
|
|
348
|
+
if not results:
|
|
349
|
+
break
|
|
350
|
+
|
|
351
|
+
all_results.extend(results)
|
|
352
|
+
meta = result.get("meta", {}).get("results", {})
|
|
353
|
+
total = meta.get("total", 0)
|
|
354
|
+
|
|
355
|
+
print(
|
|
356
|
+
f"Page {page + 1}: fetched {len(results)} records "
|
|
357
|
+
f"({len(all_results)}/{total} total)",
|
|
358
|
+
file=sys.stderr,
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
skip += limit
|
|
362
|
+
if skip >= total or len(all_results) >= max_records:
|
|
363
|
+
break
|
|
364
|
+
|
|
365
|
+
output_data = {
|
|
366
|
+
"status": "success",
|
|
367
|
+
"results_count": len(all_results),
|
|
368
|
+
"results": all_results,
|
|
369
|
+
}
|
|
370
|
+
_write_output(output_data, args.output)
|
|
371
|
+
|
|
372
|
+
_print_json({
|
|
373
|
+
"status": "success",
|
|
374
|
+
"message": f"Downloaded {len(all_results)} records to {args.output}",
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def parse_args() -> argparse.Namespace:
|
|
379
|
+
"""Parses command-line arguments for the openFDA query script.
|
|
380
|
+
|
|
381
|
+
Defines subparsers for 'search', 'count', and 'download' commands,
|
|
382
|
+
along with common arguments like category, endpoint, search, sort,
|
|
383
|
+
limit, skip, api_key, and output.
|
|
384
|
+
|
|
385
|
+
Returns:
|
|
386
|
+
argparse.Namespace: The parsed command-line arguments.
|
|
387
|
+
"""
|
|
388
|
+
parser = argparse.ArgumentParser(
|
|
389
|
+
description="Query the openFDA API (all 28 endpoints)"
|
|
390
|
+
)
|
|
391
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
392
|
+
|
|
393
|
+
common = argparse.ArgumentParser(add_help=False)
|
|
394
|
+
common.add_argument(
|
|
395
|
+
"--category",
|
|
396
|
+
type=str,
|
|
397
|
+
required=True,
|
|
398
|
+
choices=sorted(VALID_ENDPOINTS.keys()),
|
|
399
|
+
help="API category (e.g. drug, device, food)",
|
|
400
|
+
)
|
|
401
|
+
common.add_argument(
|
|
402
|
+
"--endpoint",
|
|
403
|
+
type=str,
|
|
404
|
+
required=True,
|
|
405
|
+
help="API endpoint within the category (e.g. event, label, 510k)",
|
|
406
|
+
)
|
|
407
|
+
common.add_argument(
|
|
408
|
+
"--search",
|
|
409
|
+
type=str,
|
|
410
|
+
default=None,
|
|
411
|
+
help="Search query (e.g. 'patient.drug.medicinalproduct:aspirin')",
|
|
412
|
+
)
|
|
413
|
+
common.add_argument(
|
|
414
|
+
"--sort",
|
|
415
|
+
type=str,
|
|
416
|
+
default=None,
|
|
417
|
+
help="Sort field:order (e.g. 'receivedate:desc')",
|
|
418
|
+
)
|
|
419
|
+
common.add_argument(
|
|
420
|
+
"--limit",
|
|
421
|
+
type=int,
|
|
422
|
+
default=10,
|
|
423
|
+
help="Max results per request (default 10, max 1000)",
|
|
424
|
+
)
|
|
425
|
+
common.add_argument(
|
|
426
|
+
"--skip",
|
|
427
|
+
type=int,
|
|
428
|
+
default=0,
|
|
429
|
+
help="Pagination offset (default 0)",
|
|
430
|
+
)
|
|
431
|
+
common.add_argument(
|
|
432
|
+
"--api_key",
|
|
433
|
+
type=str,
|
|
434
|
+
default=None,
|
|
435
|
+
help="API key (also reads FDA_API_KEY env var)",
|
|
436
|
+
)
|
|
437
|
+
common.add_argument(
|
|
438
|
+
"--output",
|
|
439
|
+
type=str,
|
|
440
|
+
required=True,
|
|
441
|
+
help="Output file path for results JSON (required)",
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
subparsers.add_parser(
|
|
445
|
+
"search",
|
|
446
|
+
parents=[common],
|
|
447
|
+
help="Search an endpoint and save JSON results to --output",
|
|
448
|
+
)
|
|
449
|
+
|
|
450
|
+
count_parser = subparsers.add_parser(
|
|
451
|
+
"count",
|
|
452
|
+
parents=[common],
|
|
453
|
+
help="Count unique field values and save to --output",
|
|
454
|
+
)
|
|
455
|
+
count_parser.add_argument(
|
|
456
|
+
"--count_field",
|
|
457
|
+
type=str,
|
|
458
|
+
required=True,
|
|
459
|
+
help="Field to count on (e.g. 'patient.reaction.reactionmeddrapt.exact')",
|
|
460
|
+
)
|
|
461
|
+
count_parser.add_argument(
|
|
462
|
+
"--summary",
|
|
463
|
+
type=int,
|
|
464
|
+
default=None,
|
|
465
|
+
metavar="N",
|
|
466
|
+
help="Return only the top N most frequent terms (e.g. --summary 10)",
|
|
467
|
+
)
|
|
468
|
+
|
|
469
|
+
download_parser = subparsers.add_parser(
|
|
470
|
+
"download",
|
|
471
|
+
parents=[common],
|
|
472
|
+
help="Download multiple pages of results to --output",
|
|
473
|
+
)
|
|
474
|
+
download_parser.add_argument(
|
|
475
|
+
"--max_pages",
|
|
476
|
+
type=int,
|
|
477
|
+
default=10,
|
|
478
|
+
help="Max pages to fetch (default 10)",
|
|
479
|
+
)
|
|
480
|
+
download_parser.add_argument(
|
|
481
|
+
"--all_results",
|
|
482
|
+
action="store_true",
|
|
483
|
+
default=False,
|
|
484
|
+
help=(
|
|
485
|
+
"Fetch all matching results (auto-paginate). "
|
|
486
|
+
f"Safety cap: {ALL_RESULTS_SAFETY_CAP} records."
|
|
487
|
+
),
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
return parser.parse_args()
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
def main():
|
|
494
|
+
dotenv.load_dotenv(os.path.expanduser("~/.env"))
|
|
495
|
+
main_args = parse_args()
|
|
496
|
+
if main_args.command == "search":
|
|
497
|
+
cmd_search(main_args)
|
|
498
|
+
elif main_args.command == "count":
|
|
499
|
+
cmd_count(main_args)
|
|
500
|
+
elif main_args.command == "download":
|
|
501
|
+
cmd_download(main_args)
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
if __name__ == "__main__":
|
|
505
|
+
main()
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: opentargets-database
|
|
3
|
+
description: >
|
|
4
|
+
Query Open Targets Platform for target-disease associations, drug target
|
|
5
|
+
discovery, tractability/safety data, genetics/omics evidence, known drugs,
|
|
6
|
+
for therapeutic target identification.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Open Targets Database Skill
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This skill provides access to the Open Targets Platform GraphQL API. It
|
|
14
|
+
aggregates multi-modal evidence from genetics (GWAS/eQTL), pathways, animal
|
|
15
|
+
models, and clinical trials to rank target-disease associations and identify
|
|
16
|
+
druggable genes.
|
|
17
|
+
|
|
18
|
+
## Prerequisites
|
|
19
|
+
|
|
20
|
+
1. **`uv`**: Read the `uv` skill and follow its Setup instructions to ensure
|
|
21
|
+
`uv` is installed and on PATH.
|
|
22
|
+
2. **User Notification**: If .licenses/opentargets_database_LICENSE.txt does
|
|
23
|
+
not already exist in the workspace root directory then (1) prominently
|
|
24
|
+
notify the user to check the terms at
|
|
25
|
+
https://platform-docs.opentargets.org/licence, then (2) create the file
|
|
26
|
+
recording the notification text and timestamp.
|
|
27
|
+
|
|
28
|
+
## Core Rules
|
|
29
|
+
|
|
30
|
+
- **Use the Wrapper**: ALWAYS execute the provided helper scripts to query the
|
|
31
|
+
database rather than accessing the database directly. The scripts
|
|
32
|
+
automatically enforce fair use and implement retry logic.
|
|
33
|
+
- **Output Flag**: The `--output` flag is always required as output can be
|
|
34
|
+
very large. Use `jq` or write your own code to process this JSON file.
|
|
35
|
+
- **Notification**: If this skill is used, ensure this is mentioned in the
|
|
36
|
+
output.
|
|
37
|
+
|
|
38
|
+
## Quick Reference
|
|
39
|
+
|
|
40
|
+
Always use the provided Python script `scripts/query_opentargets.py` to quickly
|
|
41
|
+
query the database. It handles API communication, retries, formatting, and
|
|
42
|
+
automatically truncates overly large responses. NEVER write your own curl or
|
|
43
|
+
similar requests.
|
|
44
|
+
|
|
45
|
+
**Usage:**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
uv run scripts/query_opentargets.py --output /tmp/opentargets_results.json [OPTIONS] COMMAND [ARGS]...
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Common Options:**
|
|
52
|
+
|
|
53
|
+
- `--output PATH`: **Required**. Path to write the JSON output file.
|
|
54
|
+
- `--limit N`: Limit the number of items returned in arrays (default is 50).
|
|
55
|
+
Use a smaller number like 10 when doing preliminary exploration.
|
|
56
|
+
- `--page-size N`: Set the API pagination size (default is 200). Increase if
|
|
57
|
+
you need more results (e.g., a study with many credible sets).
|
|
58
|
+
|
|
59
|
+
**Available Commands:**
|
|
60
|
+
|
|
61
|
+
- **`get-gwas-studies`** *`efo_id`*: Fetches all GWAS studies associated with
|
|
62
|
+
a specific disease ontology EFO ID (e.g. `EFO_0000685`).
|
|
63
|
+
- **`get-study-credible-sets`** *`study_id`*: Fetches all credible sets for a
|
|
64
|
+
given study ID (e.g. `FINNGEN_R12_RX_CROHN_2NDLINE`). Returns confidence,
|
|
65
|
+
finemapping method, variant, and p-value info.
|
|
66
|
+
- **`get-qtl-credible-sets`** *`variant_id`*: Retrieves QTL credible sets for
|
|
67
|
+
a specific variant ID (e.g. `19_44908822_C_T`).
|
|
68
|
+
- **`get-l2g`** *`variant_id [--study-id ID]`*: Returns Locus-to-Gene (L2G)
|
|
69
|
+
predictions/scores for a locus to identify the most likely causal gene. Only
|
|
70
|
+
`variant_id` is required; use `--study-id` to filter to a specific study.
|
|
71
|
+
Accepts `chr` prefix (e.g. `chr1_113834946_A_G`).
|
|
72
|
+
- **`get-target-druggability`** *`ensembl_id`*: Provides tractability data
|
|
73
|
+
(small molecule, antibody, etc.) and clinical trial safety info for a
|
|
74
|
+
gene/target.
|
|
75
|
+
- **`get-associated-targets`** *`efo_id`*: Find all target genes associated
|
|
76
|
+
with a specific disease EFO ID.
|
|
77
|
+
- **`get-associated-diseases`** *`ensembl_id`*: Find all diseases associated
|
|
78
|
+
with a specific target Ensembl ID.
|
|
79
|
+
- **`search-disease`** *`query_string`*: Search for a disease by name to find
|
|
80
|
+
its EFO ID and other metadata.
|
|
81
|
+
- **`get-credible-sets-near-target`** *`ensembl_id [--window N]`*: Fetches
|
|
82
|
+
credible sets for a target and filters them to those within a genomic window
|
|
83
|
+
around the target. Useful for finding variants "nearby" a gene.
|
|
84
|
+
- **`custom-query`** *`query [--variables '{}']`*: Run a raw GraphQL query for
|
|
85
|
+
any other Open Targets data.
|
|
86
|
+
|
|
87
|
+
## L2G Query Usage
|
|
88
|
+
|
|
89
|
+
The `get-l2g` command has two modes:
|
|
90
|
+
|
|
91
|
+
* **Variant only** (`get-l2g <variant_id>`): Returns L2G predictions from
|
|
92
|
+
**all credible sets across all studies** where that variant is the lead
|
|
93
|
+
variant. This can return a large number of results (e.g., hundreds). Use
|
|
94
|
+
this when the user wants a broad view of which gene is most likely causal at
|
|
95
|
+
a locus, or when no specific study is mentioned.
|
|
96
|
+
* **Variant + study** (`get-l2g <variant_id> --study-id <study_id>`): Returns
|
|
97
|
+
L2G predictions only for credible sets from that specific study. Use this
|
|
98
|
+
when the user asks about a specific GWAS study or when you need to narrow
|
|
99
|
+
down the results.
|
|
100
|
+
|
|
101
|
+
> **Incomplete results warning:** The variant-only mode can return hundreds of
|
|
102
|
+
> credible sets. The default `--page-size` is 200, so if the API reports a
|
|
103
|
+
> `count` higher than the number of `rows` returned, **you are seeing incomplete
|
|
104
|
+
> results**. Always compare `count` to the actual number of rows. If they
|
|
105
|
+
> differ, either increase `--page-size` or inform the user that only a subset
|
|
106
|
+
> was retrieved.
|
|
107
|
+
|
|
108
|
+
## Querying by Region
|
|
109
|
+
|
|
110
|
+
To find studies with variants "nearby" a gene, use
|
|
111
|
+
`get-credible-sets-near-target`, which improves upon the base API by performing
|
|
112
|
+
a flexible search based on genomic position: `uv run
|
|
113
|
+
scripts/query_opentargets.py --output /tmp/results.json
|
|
114
|
+
get-credible-sets-near-target ENSG00000156515 --window 500000`
|
|
115
|
+
|
|
116
|
+
Note that the Open Targets GraphQL schema includes a `regions` parameter for
|
|
117
|
+
`credibleSets`, however it performs an exact match against pre-computed region
|
|
118
|
+
strings (e.g., `chr10:68769984-69903496`) and there is some missing data. Use
|
|
119
|
+
get-credible-sets-near-target as it allows a genomic range overlap search.
|
|
120
|
+
|
|
121
|
+
This fetches credible sets associated with the target and filters them in Python
|
|
122
|
+
based on the variant's genomic position.
|
|
123
|
+
|
|
124
|
+
## Advanced GraphQL Queries
|
|
125
|
+
|
|
126
|
+
If you need to query endpoints or fields not exposed by the built-in
|
|
127
|
+
subcommands, use the `custom-query` subcommand.
|
|
128
|
+
|
|
129
|
+
**Before writing a custom query:** Read the reference documentation to
|
|
130
|
+
understand the API schema, types, and see example queries. See
|
|
131
|
+
[references/OpenTargets_GraphQL_Guide.md](references/OpenTargets_GraphQL_Guide)
|
|
132
|
+
for full schema details, endpoints, and examples.
|
|
133
|
+
|
|
134
|
+
**Example: Finding drugs for a disease**
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
uv run scripts/query_opentargets.py custom-query \
|
|
138
|
+
query drugsForDisease($id: String!) {
|
|
139
|
+
disease(efoId: $id) {
|
|
140
|
+
name
|
|
141
|
+
drugAndClinicalCandidates {
|
|
142
|
+
count
|
|
143
|
+
rows {
|
|
144
|
+
maxClinicalStage
|
|
145
|
+
drug {
|
|
146
|
+
id
|
|
147
|
+
name
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}' \
|
|
153
|
+
--variables '{"id": "EFO_1001006"}'
|
|
154
|
+
--output '/tmp/opentargets_result.json'
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Confidence Star Ratings
|
|
158
|
+
|
|
159
|
+
The Open Targets Platform assigns a **confidence level** to each credible set
|
|
160
|
+
based on the fine-mapping method and quality checks. These correspond to star
|
|
161
|
+
ratings displayed in the platform UI:
|
|
162
|
+
|
|
163
|
+
| Stars | Confidence String (API value) |
|
|
164
|
+
| -------------- | --------------------------------------------------------- |
|
|
165
|
+
| ★★★★ (4 stars) | `SuSiE fine-mapped credible set with in-sample LD` |
|
|
166
|
+
| ★★★ (3 stars) | `SuSiE fine-mapped credible set with out-of-sample LD` |
|
|
167
|
+
| ★★ (2 stars) | `PICS fine-mapped credible set extracted from summary |
|
|
168
|
+
: : statistics` :
|
|
169
|
+
| ★ (1 star) | `PICS fine-mapped credible set based on reported top hit` |
|
|
170
|
+
| None | `Unknown confidence` |
|
|
171
|
+
|
|
172
|
+
When users ask about "N-star confidence", match their request to the
|
|
173
|
+
corresponding string in the `confidence` field of the API response.
|
|
174
|
+
|
|
175
|
+
## Tips and Common Mistakes
|
|
176
|
+
|
|
177
|
+
- **ID Formats**:
|
|
178
|
+
- Disease IDs must be in EFO format (e.g. `EFO_0000685`).
|
|
179
|
+
- Target IDs must be Ensembl IDs (e.g. `ENSG00000169083`), not HGNC
|
|
180
|
+
symbols. If you only have a gene symbol, you may need to map it first
|
|
181
|
+
using a custom GraphQL `search` query.
|
|
182
|
+
- Variant IDs are formatted as `chromosome_position_ref_alt` (e.g.,
|
|
183
|
+
`1_154426264_C_T`). A `chr` prefix (e.g. `chr1_154426264_C_T`) is
|
|
184
|
+
automatically stripped by the tool.
|
|
185
|
+
- Study IDs can be GWAS Catalog IDs (e.g. `GCST90204201`) or
|
|
186
|
+
project-specific IDs (e.g. `FINNGEN_R12_RX_CROHN_2NDLINE`).
|
|
187
|
+
- **Truncation**: The tool truncates arrays longer than `--limit` to protect
|
|
188
|
+
the context window. If you see `"_truncated"`, you can run the query again
|
|
189
|
+
with a higher limit if you specifically need more data, but be cautious with
|
|
190
|
+
large limit values. Always use the `--output` flag to save the result to a
|
|
191
|
+
file and avoid terminal output truncation.
|
|
192
|
+
- **Pagination and incomplete results**: The `--page-size` option (default:
|
|
193
|
+
200) controls how many items are fetched from the API. **Always check the
|
|
194
|
+
`count` field in the response and compare it to the number of `rows`
|
|
195
|
+
actually returned.** If `count` > number of rows, you have incomplete data —
|
|
196
|
+
either increase `--page-size` to fetch more, or inform the user that only a
|
|
197
|
+
partial result set was returned. This is especially important for `get-l2g`
|
|
198
|
+
without `--study-id`, which can return hundreds of credible sets.
|