Source: https://github.com/aipoch/medical-research-skills
COSMIC Database Skill
When to Use
- Use this skill when you need access cosmic to download mutation datasets, query cancer gene census, and retrieve mutational signatures when your genomic analysis requires curated somatic mutation resources in a reproducible workflow.
- Use this skill when a evidence insight task needs a packaged method instead of ad-hoc freeform output.
- Use this skill when the user expects a concrete deliverable, validation step, or file-based result.
- Use this skill when
scripts/download_cosmic.py is the most direct path to complete the request.
- Use this skill when you need the
cosmic-database package behavior rather than a generic answer.
Key Features
- Scope-focused workflow aligned to: Access COSMIC to download mutation datasets, query Cancer Gene Census, and retrieve mutational signatures when your genomic analysis requires curated somatic mutation resources.
- Packaged executable path(s):
scripts/download_cosmic.py.
- Reference material available in
references/ for task-specific guidance.
- Structured execution path designed to keep outputs consistent and reviewable.
Dependencies
Python: 3.10+. Repository baseline for current packaged skills.
Third-party packages: not explicitly version-pinned in this skill package. Add pinned versions if this skill needs stricter environment control.
Example Usage
cd "20260316/scientific-skills/Evidence Insight/cosmic-database"
python -m py_compile scripts/download_cosmic.py
python scripts/download_cosmic.py --help
Example run plan:
- Confirm the user input, output path, and any required config values.
- Edit the in-file
CONFIG block or documented parameters if the script uses fixed settings.
- Run
python scripts/download_cosmic.py with the validated inputs.
- Review the generated output and return the final artifact with any assumptions called out.
Implementation Details
- Execution model: validate the request, choose the packaged workflow, and produce a bounded deliverable.
- Input controls: confirm the source files, scope limits, output format, and acceptance criteria before running any script.
- Primary implementation surface:
scripts/download_cosmic.py.
- Reference guidance:
references/ contains supporting rules, prompts, or checklists.
- Parameters to clarify first: input path, output path, scope filters, thresholds, and any domain-specific constraints.
- Output discipline: keep results reproducible, identify assumptions explicitly, and avoid undocumented side effects.
1. When to Use
Use this skill when you need COSMIC data for tasks such as:
- Downloading COSMIC mutation exports (TSV/VCF) for cohort or sample-level variant analysis.
- Retrieving Cancer Gene Census (CGC) gene lists for oncogene/tumor suppressor annotation and prioritization.
- Working with COSMIC mutational signatures (SBS/DBS/ID) for signature attribution or comparative studies.
- Accessing additional COSMIC genomics datasets (e.g., copy number, fusions, expression) for multi-omics integration.
- Building reproducible pipelines that programmatically fetch the latest COSMIC releases.
2. Key Features
- Authenticated downloads of COSMIC files (e.g., TSV/VCF; often GZIP-compressed).
- Cancer Gene Census access for curated cancer gene information.
- Mutational signature retrieval including SBS, DBS, and ID signatures.
- Support for multiple COSMIC dataset types, such as mutation, copy number, fusion, and expression resources.
- Pandas-friendly workflow for loading and filtering downloaded tables.
3. Dependencies
- Python 3.9+
pandas >= 1.5
requests >= 2.28
External requirements:
4. Example Usage
The following example downloads a COSMIC file and loads it into a pandas DataFrame.
from scripts.download_cosmic import download_cosmic_file
import pandas as pd
# 1) Download a COSMIC dataset (example path; adjust to your target release/build)
download_cosmic_file(
email="user@email.com",
password="pwd",
filepath="GRCh38/cosmic/latest/CosmicMutantExport.tsv.gz"
)
# 2) Load the downloaded GZIP-compressed TSV
df = pd.read_csv(
"CosmicMutantExport.tsv.gz",
sep="\t",
compression="gzip"
)
# 3) Example analysis: filter by gene symbol (column name depends on the dataset)
# df_gene = df[df["Gene name"] == "TP53"]
For dataset field definitions and COSMIC file specifics, see: references/cosmic_data_reference.md.
5. Implementation Details
- Authentication: Downloads require COSMIC account credentials (email/password) and are performed via an authenticated HTTP session.
- File targeting: The
filepath parameter specifies the COSMIC resource path (e.g., genome build such as GRCh38, release channel such as latest, and the target filename).
- Data format: Many COSMIC exports are distributed as GZIP-compressed TSV (and sometimes VCF). Use
pandas.read_csv(..., sep="\t", compression="gzip") for TSV .gz files.
- Typical workflow:
- Download the desired COSMIC export.
- Load into a DataFrame (or parse VCF with an appropriate library if needed).
- Filter/aggregate by gene, tumor type, sample, or signature depending on the analysis goal.
1---2name: cosmic-database3description: Access COSMIC to download mutation datasets, query Cancer Gene Census, and retrieve mutational signatures when your genomic analysis requires curated somatic mutation resources.4license: MIT5---6> **Source**: [https://github.com/aipoch/medical-research-skills](https://github.com/aipoch/medical-research-skills)78# COSMIC Database Skill910## When to Use1112- Use this skill when you need access cosmic to download mutation datasets, query cancer gene census, and retrieve mutational signatures when your genomic analysis requires curated somatic mutation resources in a reproducible workflow.13- Use this skill when a evidence insight task needs a packaged method instead of ad-hoc freeform output.14- Use this skill when the user expects a concrete deliverable, validation step, or file-based result.15- Use this skill when `scripts/download_cosmic.py` is the most direct path to complete the request.16- Use this skill when you need the `cosmic-database` package behavior rather than a generic answer.1718## Key Features1920- Scope-focused workflow aligned to: Access COSMIC to download mutation datasets, query Cancer Gene Census, and retrieve mutational signatures when your genomic analysis requires curated somatic mutation resources.21- Packaged executable path(s): `scripts/download_cosmic.py`.22- Reference material available in `references/` for task-specific guidance.23- Structured execution path designed to keep outputs consistent and reviewable.2425## Dependencies2627- `Python`: `3.10+`. Repository baseline for current packaged skills.28- `Third-party packages`: `not explicitly version-pinned in this skill package`. Add pinned versions if this skill needs stricter environment control.2930## Example Usage3132```bash33cd "20260316/scientific-skills/Evidence Insight/cosmic-database"34python -m py_compile scripts/download_cosmic.py35python scripts/download_cosmic.py --help36```3738Example run plan:391. Confirm the user input, output path, and any required config values.402. Edit the in-file `CONFIG` block or documented parameters if the script uses fixed settings.413. Run `python scripts/download_cosmic.py` with the validated inputs.424. Review the generated output and return the final artifact with any assumptions called out.4344## Implementation Details4546- Execution model: validate the request, choose the packaged workflow, and produce a bounded deliverable.47- Input controls: confirm the source files, scope limits, output format, and acceptance criteria before running any script.48- Primary implementation surface: `scripts/download_cosmic.py`.49- Reference guidance: `references/` contains supporting rules, prompts, or checklists.50- Parameters to clarify first: input path, output path, scope filters, thresholds, and any domain-specific constraints.51- Output discipline: keep results reproducible, identify assumptions explicitly, and avoid undocumented side effects.5253## 1. When to Use5455Use this skill when you need COSMIC data for tasks such as:5657- Downloading COSMIC mutation exports (TSV/VCF) for cohort or sample-level variant analysis.58- Retrieving Cancer Gene Census (CGC) gene lists for oncogene/tumor suppressor annotation and prioritization.59- Working with COSMIC mutational signatures (SBS/DBS/ID) for signature attribution or comparative studies.60- Accessing additional COSMIC genomics datasets (e.g., copy number, fusions, expression) for multi-omics integration.61- Building reproducible pipelines that programmatically fetch the latest COSMIC releases.6263## 2. Key Features6465- **Authenticated downloads** of COSMIC files (e.g., TSV/VCF; often GZIP-compressed).66- **Cancer Gene Census access** for curated cancer gene information.67- **Mutational signature retrieval** including **SBS**, **DBS**, and **ID** signatures.68- **Support for multiple COSMIC dataset types**, such as mutation, copy number, fusion, and expression resources.69- **Pandas-friendly workflow** for loading and filtering downloaded tables.7071## 3. Dependencies7273- Python **3.9+**74- `pandas` **>= 1.5**75- `requests` **>= 2.28**7677External requirements:7879- A registered COSMIC account at https://cancer.sanger.ac.uk/cosmic80- Valid COSMIC login credentials (email + password)8182## 4. Example Usage8384The following example downloads a COSMIC file and loads it into a pandas DataFrame.8586```python87from scripts.download_cosmic import download_cosmic_file88import pandas as pd8990# 1) Download a COSMIC dataset (example path; adjust to your target release/build)91download_cosmic_file(92 email="user@email.com",93 password="pwd",94 filepath="GRCh38/cosmic/latest/CosmicMutantExport.tsv.gz"95)9697# 2) Load the downloaded GZIP-compressed TSV98df = pd.read_csv(99 "CosmicMutantExport.tsv.gz",100 sep="\t",101 compression="gzip"102)103104# 3) Example analysis: filter by gene symbol (column name depends on the dataset)105106# df_gene = df[df["Gene name"] == "TP53"]107```108109For dataset field definitions and COSMIC file specifics, see: `references/cosmic_data_reference.md`.110111## 5. Implementation Details112113- **Authentication**: Downloads require COSMIC account credentials (email/password) and are performed via an authenticated HTTP session.114- **File targeting**: The `filepath` parameter specifies the COSMIC resource path (e.g., genome build such as `GRCh38`, release channel such as `latest`, and the target filename).115- **Data format**: Many COSMIC exports are distributed as **GZIP-compressed TSV** (and sometimes **VCF**). Use `pandas.read_csv(..., sep="\t", compression="gzip")` for TSV `.gz` files.116- **Typical workflow**:117 1. Download the desired COSMIC export.118 2. Load into a DataFrame (or parse VCF with an appropriate library if needed).119 3. Filter/aggregate by gene, tumor type, sample, or signature depending on the analysis goal.