From 988524d5a04c72215fb1fb0039114177ab65b99c Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Tue, 16 Jan 2024 09:20:34 +0100 Subject: [PATCH] feat: replace OrphaPacket by ORDO CSV (#84) --- Snakefile | 8 ++--- download_urls.yml | 2 +- excerpt-data/6045c008f1c0f370/url.txt | 3 -- excerpt-data/6045c008f1c0f370/v10.1.tar.gz | 3 -- rules/output/annonars/genes.smk | 4 +-- rules/output/annonars/genes.spec.yaml | 2 +- rules/work/genes/ordo.smk | 34 ++++++++++++++++++++++ rules/work/genes/orphapacket.smk | 34 ---------------------- scripts/genes-orpha-diseases.py | 10 +++---- varfish_db_downloader/versions.py | 6 ++-- 10 files changed, 50 insertions(+), 56 deletions(-) delete mode 100644 excerpt-data/6045c008f1c0f370/url.txt delete mode 100644 excerpt-data/6045c008f1c0f370/v10.1.tar.gz create mode 100644 rules/work/genes/ordo.smk delete mode 100644 rules/work/genes/orphapacket.smk diff --git a/Snakefile b/Snakefile index 43eacca..c33391d 100644 --- a/Snakefile +++ b/Snakefile @@ -86,7 +86,7 @@ rule all: # # genes f"work/download/genes/rcnv/2022/Collins_rCNV_2022.dosage_sensitivity_scores.tsv.gz", - f"work/download/genes/orphapacket/{DV.orphapacket}/orphapacket.tar.gz", + f"work/download/genes/ordo/{DV.ordo}/ordo.csv", "work/download/genes/alphamissense/1/AlphaMissense_gene_hg38.tsv.gz", f"work/genes/dbnsfp/{DV.dbnsfp}/genes.tsv.gz", "work/genes/decipher/v3/decipher_hi_prediction.tsv.gz", @@ -96,7 +96,7 @@ rule all: f"work/genes/gnomad/{DV.gnomad_constraints}/gnomad_constraints.tsv", f"work/genes/hgnc/{DV.today}/hgnc_info.jsonl", f"work/genes/omim/{DV.hpo}+{DV.today}/omim_diseases.tsv", - f"work/genes/orphapacket/{DV.orphapacket}+{DV.today}/orpha_diseases.tsv", + f"work/genes/ordo/{DV.ordo}/orpha_diseases.tsv", "work/genes/rcnv/2022/rcnv_collins_2022.tsv", "work/genes/shet/2019/shet_weghorn_2019.tsv", f"work/genes/clingen/{DV.today}/ClinGen_gene_curation_list_GRCh37.tsv", @@ -177,7 +177,7 @@ rule all: f"output/full/annonars/cons-grch37-{DV.ucsc_cons_37}+{PV.annonars}/rocksdb/IDENTITY", f"output/full/annonars/cons-grch38-{DV.ucsc_cons_38}+{PV.annonars}/rocksdb/IDENTITY", # ----- genes - f"output/full/annonars/genes-{DV.acmg_sf}+{DV.gnomad_constraints}+{DV.dbnsfp}+{DV.hpo}+{DV.orphapacket}+{DV.today}+{PV.annonars}/rocksdb/IDENTITY", + f"output/full/annonars/genes-{DV.acmg_sf}+{DV.gnomad_constraints}+{DV.dbnsfp}+{DV.hpo}+{DV.ordo}+{DV.today}+{PV.annonars}/rocksdb/IDENTITY", # -- worker data f"output/full/worker/genes-regions-grch37-{DV.refseq_37}+{PV.worker}/refseq_genes.bin", f"output/full/worker/genes-regions-grch37-{DV.ensembl_37}+{PV.worker}/ensembl_genes.bin", @@ -350,7 +350,7 @@ include: "rules/work/genes/mehari_data_tx.smk" include: "rules/work/genes/ncbi.smk" include: "rules/work/genes/omim.smk" include: "rules/work/genes/panelapp.smk" -include: "rules/work/genes/orphapacket.smk" +include: "rules/work/genes/ordo.smk" include: "rules/work/genes/rcnv.smk" include: "rules/work/genes/shet.smk" include: "rules/work/genes/domino.smk" diff --git a/download_urls.yml b/download_urls.yml index a4f0af8..417611c 100644 --- a/download_urls.yml +++ b/download_urls.yml @@ -101,7 +101,7 @@ strategy: manual count: null -- url: https://github.com/Orphanet/orphapacket/archive/refs/tags/v10.1.tar.gz +- url: https://data.bioontology.org/ontologies/ORDO/download?apikey=8b5b7825-538d-40e0-9e9e-5ab9274a9aeb&download_format=csv excerpt_strategy: strategy: no-excerpt count: null diff --git a/excerpt-data/6045c008f1c0f370/url.txt b/excerpt-data/6045c008f1c0f370/url.txt deleted file mode 100644 index 17796bd..0000000 --- a/excerpt-data/6045c008f1c0f370/url.txt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:58b5f890e962de336ac264c788ae9136ad1eb69f52c1f536379c2984b85beef1 -size 71 diff --git a/excerpt-data/6045c008f1c0f370/v10.1.tar.gz b/excerpt-data/6045c008f1c0f370/v10.1.tar.gz deleted file mode 100644 index 4779579..0000000 --- a/excerpt-data/6045c008f1c0f370/v10.1.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:38de2709b2f9a9c4e0b9ec18c5ebae337a47e97897808069dcee7ba5c39d3224 -size 1503498 diff --git a/rules/output/annonars/genes.smk b/rules/output/annonars/genes.smk index b461a34..8247030 100644 --- a/rules/output/annonars/genes.smk +++ b/rules/output/annonars/genes.smk @@ -11,7 +11,7 @@ rule output_annonars_genes: # -- build annonars genes RocksDB file hgnc="work/genes/hgnc/{date}/hgnc_info.jsonl", ncbi="work/genes/entrez/{date}/gene_info.jsonl", omim="work/genes/omim/{v_hpo}+{date}/omim_diseases.tsv", - orpha="work/genes/orphapacket/{v_orpha}+{date}/orpha_diseases.tsv", + orpha="work/genes/ordo/{v_orpha}/orpha_diseases.tsv", panelapp="work/download/genes/panelapp/{date}/panelapp.jsonl", rcnv="work/genes/rcnv/2022/rcnv_collins_2022.tsv", shet="work/genes/shet/2019/shet_weghorn_2019.tsv", @@ -65,6 +65,6 @@ rule output_annonars_genes: # -- build annonars genes RocksDB file \ --value v_annonars={wildcards.v_annonars} \ --value v_downloader={PV.downloader} \ - --value v_orphapacket={wildcards.v_orpha} \ + --value v_ordo={wildcards.v_orpha} \ > {output.spec_yaml} """ diff --git a/rules/output/annonars/genes.spec.yaml b/rules/output/annonars/genes.spec.yaml index e4cd860..21b050e 100644 --- a/rules/output/annonars/genes.spec.yaml +++ b/rules/output/annonars/genes.spec.yaml @@ -38,7 +38,7 @@ x-created-from: - name: OMIM version: {{ today }} - name: ORDO - version: {{ v_orphapacket }} + version: {{ v_ordo }} - name: rCNV pHaplo/pTriplo scores version: 2022-Collins-et-al - name: sHet scores diff --git a/rules/work/genes/ordo.smk b/rules/work/genes/ordo.smk new file mode 100644 index 0000000..7b14cc8 --- /dev/null +++ b/rules/work/genes/ordo.smk @@ -0,0 +1,34 @@ +## Rules related to ORDO download + + +rule genes_ordo_download: # -- download ORDO CSV file + output: + csv=f"work/download/genes/ordo/{DV.ordo}/ordo.csv", + csv_md5=f"work/download/genes/ordo/{DV.ordo}/ordo.csv.md5", + shell: + r""" + wget --no-check-certificate \ + -O {output.csv} \ + 'https://data.bioontology.org/ontologies/ORDO/submissions/28/download?apikey=8b5b7825-538d-40e0-9e9e-5ab9274a9aeb&download_format=csv' + + md5sum {output.csv} > {output.csv_md5} + """ + +rule genes_ordo_convert: # -- postprocess file for HGNC gene IDs + input: + csv="work/download/genes/ordo/{version}/ordo.csv", + output: + tsv="work/genes/ordo/{version}/orpha_diseases.tsv", + tsv_md5="work/genes/ordo/{version}/orpha_diseases.tsv.md5", + shell: + """ + export TMPDIR=$(mktemp -d) + trap "rm -rf $TMPDIR" ERR EXIT + + python ./scripts/genes-orpha-diseases.py {input.csv} \ + | qsv sort -d '\t' \ + | qsv fmt -t '\t' \ + > {output.tsv} + + md5sum {output.tsv} > {output.tsv}.md5 + """ diff --git a/rules/work/genes/orphapacket.smk b/rules/work/genes/orphapacket.smk deleted file mode 100644 index b5201a5..0000000 --- a/rules/work/genes/orphapacket.smk +++ /dev/null @@ -1,34 +0,0 @@ -## Rules related to annotating genes with ORDO terms - - -rule genes_orphapacket_download: # -- download orphapacket file - output: - tar="work/download/genes/orphapacket/{version}/orphapacket.tar.gz", - shell: - r""" - wget -O {output.tar} \ - https://github.com/Orphanet/orphapacket/archive/refs/tags/v10.1.tar.gz - """ - - -rule genes_orphapacket_diseases: # -- postprocess file for HGNC gene IDs - input: - tar="work/download/genes/orphapacket/{version}/orphapacket.tar.gz", - xlink="output/full/mehari/genes-xlink-{date}/genes-xlink.tsv", - output: - tsv="work/genes/orphapacket/{version}+{date}/orpha_diseases.tsv", - tsv_md5="work/genes/orphapacket/{version}+{date}/orpha_diseases.tsv.md5", - shell: - """ - export TMPDIR=$(mktemp -d) - trap "rm -rf $TMPDIR" ERR EXIT - - tar -C $TMPDIR -xf $(readlink -f {input.tar}) - - python ./scripts/genes-orpha-diseases.py {input.xlink} $TMPDIR/orphapacket-*/json \ - | qsv sort -d '\t' \ - | qsv fmt -t '\t' \ - > {output.tsv} - - md5sum {output.tsv} > {output.tsv}.md5 - """ diff --git a/scripts/genes-orpha-diseases.py b/scripts/genes-orpha-diseases.py index 75da52d..151d520 100755 --- a/scripts/genes-orpha-diseases.py +++ b/scripts/genes-orpha-diseases.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -"""Helper script to extract gene-disease association from orphapacket.""" +"""Helper script to extract gene-disease association from ORDO CSV.""" import csv import json @@ -8,13 +8,13 @@ def main(): - symbol_to_hgnc = {} + records = {} with open(sys.argv[1], "rt") as inputf: - reader = csv.DictReader(inputf, delimiter="\t") + reader = csv.DictReader(inputf, delimiter=",") for record in reader: - symbol_to_hgnc[record["gene_symbol"]] = record["hgnc_id"] + records[record["gene_symbol"]] = record["hgnc_id"] - print(f"# xlink entries: {len(symbol_to_hgnc)}", file=sys.stderr) + print(f"# xlink entries: {len(records)}", file=sys.stderr) base_path = pathlib.Path(sys.argv[2]) print("\t".join(["hgnc_id", "orpha_id", "disease_name"])) diff --git a/varfish_db_downloader/versions.py b/varfish_db_downloader/versions.py index 4ec6af1..fc0d7f5 100644 --- a/varfish_db_downloader/versions.py +++ b/varfish_db_downloader/versions.py @@ -102,8 +102,8 @@ class DataVersions: acmg_sf: str #: HPO hpo: str - #: OrphaPacket - orphapacket: str + #: ORDO + ordo: str #: Pathogenic MMS patho_mms: str #: Mehari transcript data. @@ -162,7 +162,7 @@ class DataVersions: dbsnp="b151", acmg_sf="3.1", hpo="20230606", - orphapacket="10.1", + ordo="4.4", patho_mms="20220730", mehari_tx="0.4.4", clinvar_release=CLINVAR_RELEASE,