diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index ef091474..485ae350 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -9,9 +9,11 @@ # Manual * [gget alphafold](en/alphafold.md) -* [gget archs4](en/archs4.md) +* [gget archs4](en/archs4.md) +* [gget bgee](en/bgee.md) * [gget blast](en/blast.md) -* [gget blat](en/blat.md) +* [gget blat](en/blat.md) +* [gget cbio](en/cbio.md) * [gget cellxgene](en/cellxgene.md) * [gget cosmic](en/cosmic.md) * [gget diamond](en/diamond.md) @@ -20,15 +22,13 @@ * [gget gpt](en/gpt.md) * [gget info](en/info.md) * [gget muscle](en/muscle.md) -* [gget mutate](en/mutate.md) +* [gget mutate](en/mutate.md) +* [gget opentargets](en/opentargets.md) * [gget pdb](en/pdb.md) * [gget ref](en/ref.md) * [gget search](en/search.md) * [gget setup](en/setup.md) -* [gget seq](en/seq.md) -* [gget opentargets](en/opentargets.md) -* [gget cbio](en/cbio.md) -* [gget bgee](en/bgee.md) +* [gget seq](en/seq.md) --- diff --git a/docs/src/en/cbio.md b/docs/src/en/cbio.md index d663548f..84ffd01e 100644 --- a/docs/src/en/cbio.md +++ b/docs/src/en/cbio.md @@ -13,7 +13,8 @@ Return format: JSON (command-line) or string list (Python). **Positional argument** `keywords` -Space-separated list of keywords to search for, e.g. breast lung. +Space-separated list of keywords to search for, e.g. breast lung. +Python: Pass keywords as a list of strings. ### `plot` subcommand (Python: `gget.cbio_plot`) Plot cancer genomics heatmaps using data from cBioPortal. @@ -89,7 +90,7 @@ gget cbio search esophag ovary ovarian ```python # Python import gget -gget.cbio_search('esophag', 'ovary', 'ovarian') +gget.cbio_search(['esophag', 'ovary', 'ovarian']) ``` → Returns a list of studies with cancer types matching the keywords `esophag`, `ovary`, or `ovarian`. diff --git a/gget/gget_cbio.py b/gget/gget_cbio.py index 4adfaddd..d500190e 100644 --- a/gget/gget_cbio.py +++ b/gget/gget_cbio.py @@ -289,13 +289,12 @@ def _extract_study_name(name: str) -> str: return name -def cbio_search(*key_words: str): +def cbio_search(key_words): """ Find cBioPortal study IDs by keyword. Args: - - :param key_words: list of keywords to search for + key_words list of keywords to search for Return: @@ -315,6 +314,9 @@ def cbio_search(*key_words: str): ) return [] + if isinstance(key_words, str): + key_words = [key_words] + api = SwaggerClient.from_url( "https://www.cbioportal.org/api/v2/api-docs", config={ diff --git a/gget/main.py b/gget/main.py index 0d82f41c..19c13d9f 100644 --- a/gget/main.py +++ b/gget/main.py @@ -58,7 +58,10 @@ def _get_help_string(self, action): help_str += " (default: %(default)s)" return help_str - +def convert_to_list(*args): + args_list = list(args) + return args_list + def int_or_str(value): try: return int(value) @@ -3314,7 +3317,7 @@ def main(): ## cbio return if args.command == "cbio": if args.subcommand == "search": - cbio_results = cbio_search(*args.keywords) + cbio_results = cbio_search(convert_to_list(*args.keywords)) print(json.dumps(cbio_results, ensure_ascii=False, indent=4)) elif args.subcommand == "plot": cbio_plot( diff --git a/tests/fixtures/test_cbio.json b/tests/fixtures/test_cbio.json index e179eaef..f8b766bc 100644 --- a/tests/fixtures/test_cbio.json +++ b/tests/fixtures/test_cbio.json @@ -27,7 +27,7 @@ "/tmp/test_cbio_download/msk_impact_2017/sv.txt": "24ce260e03b417d47929f8fc34fc49a4", "/tmp/test_cbio_download/egc_msk_2023/clinical_patient.txt": "6fbd67c0eca7a24fa6918f37c989033f", - "/tmp/test_cbio_download/egc_msk_2023/clinical_sample.txt": "8469bcc199fc653afb867242b3ab6e00", + "/tmp/test_cbio_download/egc_msk_2023/clinical_sample.txt": "a4423dfa78788df1b9f49fef31f282a9", "/tmp/test_cbio_download/egc_msk_2023/cna.txt": "1acb67c06284754ee472402753e54263", "/tmp/test_cbio_download/egc_msk_2023/mutations.txt": "be28497d2f95d933ad8e14a04adc2beb", "/tmp/test_cbio_download/egc_msk_2023/sv.txt": "c1a0011480b533d2b659373ffd178c32" @@ -42,4 +42,4 @@ }, "expected_result": false } -} \ No newline at end of file +} diff --git a/tests/fixtures/test_cbio_search.json b/tests/fixtures/test_cbio_search.json index 119f56ba..64c4b7a9 100644 --- a/tests/fixtures/test_cbio_search.json +++ b/tests/fixtures/test_cbio_search.json @@ -7,26 +7,29 @@ "ovarian" ], "expected_result": [ + "egc_tmucih_2015", "egc_msk_2017", - "egc_msk_2023", - "egc_msk_tp53_ccr_2022", "egc_mskcc_2020", - "egc_tmucih_2015", - "egc_trap_ccr_msk_2023", - "egc_trap_msk_2020", + "egc_msk_tp53_ccr_2022", + "escc_ucla_2014", "esca_broad", - "esca_tcga", - "esca_tcga_pan_can_atlas_2018", "escc_icgc", - "escc_ucla_2014", + "egc_trap_msk_2020", "hgsoc_msk_2021", "lgsoc_mapk_msk_2022", - "msk_spectrum_tme_2022", - "ov_tcga", - "ov_tcga_pan_can_atlas_2018", "ov_tcga_pub", "scco_mskcc", - "stes_tcga_pub" + "stes_tcga_pub", + "egc_trap_ccr_msk_2023", + "esca_tcga", + "egc_msk_2023", + "ov_tcga", + "msk_spectrum_tme_2022", + "esca_tcga_pan_can_atlas_2018", + "ov_tcga_pan_can_atlas_2018", + "esca_tcga_gdc", + "hgsoc_tcga_gdc", + "ovary_cptac_gdc" ] } -} \ No newline at end of file +} diff --git a/tests/fixtures/test_enrichr.json b/tests/fixtures/test_enrichr.json index df2c03d7..829a9694 100644 --- a/tests/fixtures/test_enrichr.json +++ b/tests/fixtures/test_enrichr.json @@ -5821,7 +5821,7 @@ "species": "fish" }, "expected_result": "ValueError", - "expected_msg": "Database 'pathway' is not supported for species 'fish'. Please select a database from the species-specific libraries listed at: https://maayanlab.cloud/FishEnrichr/#libraries." + "expected_msg": "Database 'pathway' is not supported for species 'fish'. Please select a database from the species-specific libraries listed at: https://maayanlab.cloud/FishEnrichr/#stats." }, "test_enrichr_bad_background": { "type": "error", @@ -6310,4 +6310,4 @@ ] ] } -} \ No newline at end of file +}