|
| 1 | +import typer |
| 2 | +from bedboss._version import __version__ |
| 3 | + |
| 4 | +app_bbuploader = typer.Typer( |
| 5 | + pretty_exceptions_short=False, |
| 6 | + pretty_exceptions_show_locals=False, |
| 7 | + help="Automatic BEDbase uploader for GEO data", |
| 8 | +) |
| 9 | + |
| 10 | + |
| 11 | +@app_bbuploader.command( |
| 12 | + help="Run bedboss uploading pipeline for specified genome in specified period of time." |
| 13 | +) |
| 14 | +def upload_all( |
| 15 | + bedbase_config: str = typer.Option(..., help="Path to bedbase config file"), |
| 16 | + outfolder: str = typer.Option(..., help="Path to output folder"), |
| 17 | + start_date: str = typer.Option( |
| 18 | + None, help="The earliest date when opep was updated [Default: 2000/01/01]" |
| 19 | + ), |
| 20 | + end_date: str = typer.Option( |
| 21 | + None, help="The latest date when opep was updated [Default: today's date]" |
| 22 | + ), |
| 23 | + search_limit: int = typer.Option( |
| 24 | + 10, help="Limit of projects to be searched. [Default: 10]" |
| 25 | + ), |
| 26 | + search_offset: int = typer.Option( |
| 27 | + 0, help="Limit of projects to be searched. [Default: 0]" |
| 28 | + ), |
| 29 | + download_limit: int = typer.Option( |
| 30 | + 100, help="Limit of projects to be downloaded [Default: 100]" |
| 31 | + ), |
| 32 | + genome: str = typer.Option( |
| 33 | + None, |
| 34 | + help="Reference genome [Default: None] (e.g. hg38) - if None, all genomes will be processed", |
| 35 | + ), |
| 36 | + create_bedset: bool = typer.Option( |
| 37 | + True, help="Create bedset from bed files. [Default: True]" |
| 38 | + ), |
| 39 | + rerun: bool = typer.Option(True, help="Re-run all the samples. [Default: False]"), |
| 40 | + run_skipped: bool = typer.Option( |
| 41 | + True, help="Run skipped projects. [Default: False]" |
| 42 | + ), |
| 43 | + run_failed: bool = typer.Option(True, help="Run failed projects. [Default: False]"), |
| 44 | +): |
| 45 | + from .main import upload_all as upload_all_function |
| 46 | + |
| 47 | + upload_all_function( |
| 48 | + bedbase_config=bedbase_config, |
| 49 | + outfolder=outfolder, |
| 50 | + start_date=start_date, |
| 51 | + end_date=end_date, |
| 52 | + search_limit=search_limit, |
| 53 | + search_offset=search_offset, |
| 54 | + download_limit=download_limit, |
| 55 | + genome=genome, |
| 56 | + create_bedset=create_bedset, |
| 57 | + rerun=rerun, |
| 58 | + run_skipped=run_skipped, |
| 59 | + run_failed=run_failed, |
| 60 | + ) |
| 61 | + |
| 62 | + |
| 63 | +@app_bbuploader.command(help="Run bedboss uploading pipeline for GSE.") |
| 64 | +def upload_gse( |
| 65 | + bedbase_config: str = typer.Option(..., help="Path to bedbase config file"), |
| 66 | + outfolder: str = typer.Option(..., help="Path to output folder"), |
| 67 | + gse: str = typer.Option( |
| 68 | + ..., help="GSE number that can be found in pephub. eg. GSE123456" |
| 69 | + ), |
| 70 | + create_bedset: bool = typer.Option( |
| 71 | + True, help="Create bedset from bed files. [Default: True]" |
| 72 | + ), |
| 73 | + genome: str = typer.Option( |
| 74 | + None, |
| 75 | + help=" reference genome to upload to database. If None, all genomes will be processed", |
| 76 | + ), |
| 77 | + rerun: bool = typer.Option(True, help="Re-run all the samples. [Default: False]"), |
| 78 | + run_skipped: bool = typer.Option( |
| 79 | + True, help="Run skipped projects. [Default: False]" |
| 80 | + ), |
| 81 | + run_failed: bool = typer.Option(True, help="Run failed projects. [Default: False]"), |
| 82 | +): |
| 83 | + from .main import upload_gse as upload_gse_function |
| 84 | + |
| 85 | + upload_gse_function( |
| 86 | + bedbase_config=bedbase_config, |
| 87 | + outfolder=outfolder, |
| 88 | + gse=gse, |
| 89 | + create_bedset=create_bedset, |
| 90 | + genome=genome, |
| 91 | + rerun=rerun, |
| 92 | + run_skipped=run_skipped, |
| 93 | + run_failed=run_failed, |
| 94 | + ) |
| 95 | + |
| 96 | + |
| 97 | +def version_callback(value: bool): |
| 98 | + if value: |
| 99 | + typer.echo(f"Bedboss version: {__version__}") |
| 100 | + raise typer.Exit() |
| 101 | + |
| 102 | + |
| 103 | +@app_bbuploader.callback() |
| 104 | +def common( |
| 105 | + ctx: typer.Context, |
| 106 | + version: bool = typer.Option( |
| 107 | + None, "--version", "-v", callback=version_callback, help="App version" |
| 108 | + ), |
| 109 | +): |
| 110 | + pass |
0 commit comments