-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reformatted cbioportal pipeline for nextflow compatibility
- Loading branch information
1 parent
1f1e326
commit 2062134
Showing
9 changed files
with
279 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,3 +187,4 @@ $RECYCLE.BIN/ | |
# Requests cache directory | ||
requests_cache/ | ||
data_cache/ | ||
*params.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import argparse | ||
|
||
from missense_kinase_toolkit import config, cbioportal | ||
|
||
def parsearg_utils(): | ||
parser = argparse.ArgumentParser( | ||
description="Get mutations from cBioPortal cohort and instance" | ||
) | ||
|
||
parser.add_argument( | ||
"--cohort", | ||
type=str, | ||
help="Optional: cBioPortal cohort IDs separated by commas (e.g., `msk_impact_2017` for Zehir, 2017 and `mskimpact` for MSKCC clinical sequencing cohort)", | ||
default="msk_impact_2017", | ||
) | ||
|
||
parser.add_argument( | ||
"--outDir", | ||
type=str, | ||
help="Required: Output directory path (str)", | ||
) | ||
|
||
parser.add_argument( | ||
"--instance", | ||
type=str, | ||
help="Optional: cBioPortal instance (e.g., `cbioportal.mskcc.org`). Default: `cbioportal.org` (str)", | ||
default="cbioportal.org", | ||
) | ||
|
||
parser.add_argument( | ||
"--token", | ||
type=str, | ||
default="", | ||
help="Optional: cBioPortal API token (str)", | ||
) | ||
|
||
parser.add_argument( | ||
"--requestsCache", | ||
type=str, | ||
default="", | ||
help="Optional: Requests cache (str)", | ||
) | ||
|
||
# TODO: add logging functionality | ||
return parser | ||
|
||
|
||
def main(): | ||
args = parsearg_utils().parse_args() | ||
|
||
str_studies = args.cohort | ||
list_studies = str_studies.split(",") | ||
list_studies = [study.strip() for study in list_studies] | ||
|
||
# required arguments | ||
config.set_output_dir(args.outDir) | ||
config.set_cbioportal_instance(args.instance) | ||
|
||
# optional arguments | ||
try: | ||
if args.token != "": | ||
config.set_cbioportal_instance(args.token) | ||
except AttributeError: | ||
pass | ||
|
||
try: | ||
if args.requestsCache != "": | ||
config.set_cbioportal_instance(args.requestsCache) | ||
except AttributeError: | ||
pass | ||
|
||
for study in list_studies: | ||
cbioportal.get_and_save_cbioportal_cohort(study) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import os | ||
import sys | ||
|
||
|
||
OUTPUT_DIR_VAR = "OUTPUT_DIR" | ||
CBIOPORTAL_INSTANCE_VAR = "CBIOPORTAL_INSTANCE" | ||
CBIOPORTAL_TOKEN_VAR = "CBIOPORTAL_TOKEN" | ||
REQUEST_CACHE_VAR = "REQUESTS_CACHE" | ||
|
||
|
||
def set_output_dir( | ||
val: str | ||
) -> None: | ||
"""Set the output directory in environment variables | ||
Parameters | ||
---------- | ||
val : str | ||
Output directory path | ||
Returns | ||
------- | ||
None | ||
""" | ||
os.environ[OUTPUT_DIR_VAR] = val | ||
|
||
|
||
def get_output_dir( | ||
) -> str | None: | ||
"""Get the output directory from the environment | ||
Returns | ||
------- | ||
str | None | ||
Output directory path if exists, otherwise None | ||
""" | ||
try: | ||
return os.environ[OUTPUT_DIR_VAR] | ||
except KeyError: | ||
print("Output directory not found in environment variables. This is necessary to run analysis. Exiting...") | ||
sys.exit(1) | ||
|
||
|
||
def set_cbioportal_instance( | ||
val: str | ||
) -> None: | ||
"""Set the cBioPortal instance in the environment variables | ||
Parameters | ||
---------- | ||
val : str | ||
cBioPortal instance; e.g., "cbioportal.mskcc.org" for MSKCC or | ||
Returns | ||
------- | ||
None | ||
""" | ||
os.environ[CBIOPORTAL_INSTANCE_VAR] = val | ||
|
||
|
||
def get_cbioportal_instance( | ||
) -> str | None: | ||
"""Get the cBioPortal instance from the environment | ||
Returns | ||
------- | ||
str | None | ||
cBioPortal instance as string if exists, otherwise None | ||
""" | ||
try: | ||
return os.environ[CBIOPORTAL_INSTANCE_VAR] | ||
except KeyError: | ||
print("cBioPortal isntance not found in environment variables. This is necessary to run analysis. Exiting...") | ||
sys.exit(1) | ||
|
||
|
||
def set_cbioportal_token( | ||
val: str | ||
) -> None: | ||
"""Set the cBioPortal token in the environment variables | ||
Parameters | ||
---------- | ||
val : str | ||
cBioPortal token | ||
Returns | ||
------- | ||
None | ||
""" | ||
os.environ[CBIOPORTAL_TOKEN_VAR] = val | ||
|
||
|
||
def maybe_get_cbioportal_token( | ||
) -> str | None: | ||
"""Get the cBioPortal token from the environment | ||
Returns | ||
------- | ||
str | None | ||
cBioPortal token as string if exists, otherwise None | ||
""" | ||
try: | ||
return os.environ[CBIOPORTAL_TOKEN_VAR] | ||
except KeyError: | ||
return None | ||
|
||
|
||
def set_request_cache( | ||
val: str | ||
) -> None: | ||
"""Set the request cache path in environment variables | ||
Parameters | ||
---------- | ||
val : str | ||
Request cache path | ||
Returns | ||
------- | ||
None | ||
""" | ||
os.environ[REQUEST_CACHE_VAR] = val | ||
|
||
|
||
def maybe_get_request_cache( | ||
) -> str | None: | ||
"""Get the request cache path from the environment | ||
Returns | ||
------- | ||
str | None | ||
Request cache path as string if exists, otherwise None | ||
""" | ||
try: | ||
return os.environ[REQUEST_CACHE_VAR] | ||
except KeyError: | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# NextFlow workflow to run pipeline | ||
|
||
To run: `nextflow run main.nf -params-file params.json` | ||
|
||
Generate own `params.json` file using the following parameters: | ||
``` | ||
{ | ||
"CBIOPORTAL_COHORT" : "TODO", | ||
"OUTPUT_DIR" : "TODO", | ||
"CBIOPORTAL_INSTANCE" : "TODO", | ||
"CBIOPORTAL_TOKEN" : "TODO", | ||
"REQUESTS_CACHE" : "TODO" | ||
} | ||
``` | ||
|
||
Below is a description of what each variable should contain. If variable is optional and not in use, do not create any entry in the `json` file. | ||
|
||
| Variable | Optional | Description | | ||
| :--------------------| :------: | :---------- | | ||
| 'CBIOPORTAL_COHORT' | No | cBioPortal cohort to analyze | | ||
| 'OUTPUT_DIR' | No | Path to outdir to save data | | ||
| 'CBIOPORTAL_INSTANCE'| Yes | `cbioportal.org` if none provided | | ||
| 'CBIOPORTAL_TOKEN' | Yes | Data Access Token if using private instance| | ||
| 'REQUESTS_CACHE' | Yes | Path to dir to cache requests data | |
Oops, something went wrong.