Skip to content

Commit ee21c50

Browse files
committed
updated cosmic and opentargets docs
1 parent 30e25bc commit ee21c50

File tree

3 files changed

+14
-43
lines changed

3 files changed

+14
-43
lines changed

docs/src/en/opentargets.md

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,8 @@ Note: Not compatible with the `tractability` and `depmap` resources.
3434
Path to the JSON file the results will be saved in, e.g. path/to/directory/results.json. Default: Standard out.
3535
Python: `save=True` will save the output in the current working directory.
3636

37-
**Optional filter arguments**
38-
39-
`-fd` `--filter_disease` `disease_id`
40-
Filter by disease ID, e.g. 'EFO_0000274'. *Only valid for the `drugs` resource.*
41-
42-
`-fc` `--filter_drug` `drug_id`
43-
Filter by drug ID, e.g. 'CHEMBL1743081'. *Only valid for the `pharmacogenetics` resource.*
44-
45-
`-ft` `--filter_tissue` `tissue_id`
46-
Filter by tissue ID, e.g. 'UBERON_0000473'. *Only valid for the `expression` and `depmap` resources.*
47-
48-
`-fa` `--filter_anat_sys`
49-
Filter by anatomical system, e.g. 'nervous system'. *Only valid for the `expression` resource.*
50-
51-
`-fo` `--filter_organ` `anatomical_system`
52-
Filter by organ, e.g. 'brain'. *Only valid for the `expression` resource.*
53-
54-
`-fpa` `--filter_protein_a` `protein_a_id`
55-
Filter by the protein ID of the first protein in the interaction, e.g. 'ENSP00000304915'. *Only valid for the `interactions` resource.*
56-
57-
`-fpb` `--filter_protein_b` `protein_b_id`
58-
Filter by the protein ID of the second protein in the interaction, e.g. 'ENSP00000379111'. *Only valid for the `interactions` resource.*
59-
60-
`-fgb` `--filter_gene_b` `gene_b_id`
61-
Filter by the gene ID of the second protein in the interaction, e.g. 'ENSG00000077238'. *Only valid for the `interactions` resource.*
62-
63-
`filters`
64-
Python only. A dictionary of filters, e.g.
65-
```python
66-
{'disease_id': ['EFO_0000274', 'HP_0000964']}
67-
```
68-
69-
`filter_mode`
70-
Python only. `filter_mode='or'` combines filters of different IDs with OR logic.
71-
`filter_mode='and'` combines filters of different IDs with AND logic (default).
37+
`--filters`
38+
Filter results by exact equality using returned OpenTargets column names. Pass multiple filters by repeating the flag, e.g. '--filter disease.id=EFO_0000274 --filter drug.id=CHEMBL1743081'. Nested fields use dot notation, matching the column names returned by the API.
7239

7340
**Flags**
7441
`-csv` `--csv`

docs/src/en/updates.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- some output column/key names may differ to reflect the new API structure
77
- Removed the `--filter_mode` argument
88
- [`gget blast`](blast.md): Fixed compatibility with newer pandas versions (≥ 2.0) where `pd.read_html()` no longer accepts raw HTML strings directly, causing a `FileNotFoundError` / `OSError: Filename too long` error when parsing BLAST results
9+
- [`gget cosmic`](cosmic.md): Added overwrite and gzip arguments to internals.
910

1011
**Version ≥ 0.30.3** (Feb 22, 2026):
1112
- [`gget virus`](virus.md): New filtering options, quiet mode, and improved download reliability

gget/gget_cosmic.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def is_valid_email(email):
2626
return re.match(email_pattern, email) is not None
2727

2828

29-
def download_reference(download_link, tar_folder_path, file_path, verbose, email = None, password = None):
29+
def download_reference(download_link, tar_folder_path, file_path, verbose, email = None, password = None, unzip = False):
3030
if not email:
3131
email = input("Please enter your COSMIC email: ")
3232
if not is_valid_email(email):
@@ -75,15 +75,16 @@ def download_reference(download_link, tar_folder_path, file_path, verbose, email
7575
if verbose:
7676
logger.info(f"Extracted tar file to {tar_folder_path}")
7777

78-
with gzip.open(f"{file_path}.gz", "rb") as f_in:
79-
with open(file_path, "wb") as f_out:
80-
shutil.copyfileobj(f_in, f_out)
81-
if verbose:
82-
logger.info(f"Unzipped file to {file_path}")
78+
if unzip:
79+
with gzip.open(f"{file_path}.gz", "rb") as f_in:
80+
with open(file_path, "wb") as f_out:
81+
shutil.copyfileobj(f_in, f_out)
82+
if verbose:
83+
logger.info(f"Unzipped file to {file_path}")
8384

8485

8586
def select_reference(
86-
cosmic_project, reference_dir, grch_version, cosmic_version, verbose, email = None, password = None, overwrite = None
87+
cosmic_project, reference_dir, grch_version, cosmic_version, verbose, email = None, password = None, unzip = True, overwrite = None
8788
):
8889
# if cosmic_project == "transcriptome":
8990
# download_link = f"https://cancer.sanger.ac.uk/api/mono/products/v1/downloads/scripted?path=grch{grch_version}/cosmic/v{cosmic_version}/Cosmic_Genes_Fasta_v{cosmic_version}_GRCh{grch_version}.tar&bucket=downloads"
@@ -149,6 +150,8 @@ def select_reference(
149150

150151
tar_folder_path = os.path.join(reference_dir, tarred_folder)
151152
file_path = os.path.join(tar_folder_path, contained_file)
153+
if not unzip:
154+
file_path += ".gz"
152155

153156
if os.path.exists(file_path):
154157
if overwrite is None:
@@ -195,7 +198,7 @@ def select_reference(
195198
.lower()
196199
)
197200
if proceed in ["yes", "y"]:
198-
download_reference(download_link, tar_folder_path, file_path, verbose, email = email, password = password)
201+
download_reference(download_link, tar_folder_path, file_path, verbose, email = email, password = password, unzip = unzip)
199202
else:
200203
raise KeyboardInterrupt(
201204
f"Database download canceled. Learn more about COSMIC at https://cancer.sanger.ac.uk/cosmic/download/cosmic."

0 commit comments

Comments
 (0)