Skip to content

Commit

Permalink
aviary: Improve and refactor help.
Browse files Browse the repository at this point in the history
  • Loading branch information
wwood committed Dec 11, 2023
1 parent b17aaf1 commit 18bbcac
Showing 1 changed file with 26 additions and 69 deletions.
95 changes: 26 additions & 69 deletions aviary/aviary.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ def str2bool(v):
else:
raise argparse.ArgumentTypeError('Boolean value expected.')

def add_workflow_arg(parser, default, help=None):
if help is None:
help = 'Main workflow to run. This is the snakemake target rule to run.'
parser.add_argument(
'-w', '--workflow',
help=help,
dest='workflow',
nargs="+",
default=default,
)

def main():
if len(sys.argv) == 1 or sys.argv[1] == '-h' or sys.argv[1] == '--help':
phelp()
Expand Down Expand Up @@ -832,13 +843,7 @@ def main():



assemble_options.add_argument(
'-w', '--workflow',
help='Main workflow to run',
dest='workflow',
nargs="+",
default=['complete_assembly_with_qc'],
)
add_workflow_arg(assemble_options, ['complete_assembly_with_qc'])

########################## ~ RECOVER ~ ###########################

Expand All @@ -862,13 +867,7 @@ def main():
required=False,
)

recover_options.add_argument(
'-w', '--workflow',
help='Main workflow to run',
dest='workflow',
nargs="+",
default=['recover_mags'],
)
add_workflow_arg(recover_options, ['recover_mags'])

recover_options.add_argument(
'--perform-strain-analysis', '--perform_strain_analysis',
Expand Down Expand Up @@ -902,13 +901,7 @@ def main():
required=False,
)

annotate_options.add_argument(
'-w', '--workflow',
help='Main workflow to run',
dest='workflow',
nargs="+",
default=['annotate'],
)
add_workflow_arg(annotate_options, ['annotate'])

########################## ~ diversity ~ ###########################

Expand All @@ -933,13 +926,7 @@ def main():
required=False,
)

diversity_options.add_argument(
'-w', '--workflow',
help='Main workflow to run',
dest='workflow',
nargs="+",
default=['lorikeet'],
)
add_workflow_arg(diversity_options, ['lorikeet'])

diversity_options.add_argument(
'--perform-strain-analysis', '--perform_strain_analysis',
Expand Down Expand Up @@ -975,13 +962,7 @@ def main():
required=True,
)

cluster_options.add_argument(
'-w', '--workflow',
help='Main workflow to run',
dest='workflow',
nargs="+",
default=['complete_cluster'],
)
add_workflow_arg(cluster_options, ['complete_cluster'])

########################## ~ VIRAL ~ ###########################

Expand All @@ -997,13 +978,7 @@ def main():
''')

viral_options.add_argument(
'-w', '--workflow',
help='Main workflow to run',
dest='workflow',
nargs="+",
default=['create_webpage_genotype'],
)
add_workflow_arg(viral_options, ['create_webpage_genotype'])

########################## ~ COMPLETE ~ ###########################

Expand All @@ -1028,13 +1003,7 @@ def main():
required=False,
)

complete_options.add_argument(
'-w', '--workflow',
help='Main workflow to run',
dest='workflow',
nargs="+",
default=['get_bam_indices', 'recover_mags', 'annotate', 'lorikeet'],
)
add_workflow_arg(complete_options, ['get_bam_indices', 'recover_mags', 'annotate', 'lorikeet'])

########################## ~ ISOLATE ~ ###########################

Expand All @@ -1050,13 +1019,7 @@ def main():
''')

isolate_options.add_argument(
'-w', '--workflow',
help='Main workflows to run',
dest='workflow',
nargs="+",
default=['circlator'],
)
add_workflow_arg(isolate_options, ['circlator'])

########################## ~ BATCH ~ ###########################

Expand Down Expand Up @@ -1131,12 +1094,10 @@ def main():
default='95'
)

batch_options.add_argument(
'-w', '--workflow',
help='Main workflow to run for each sample',
dest='workflow',
nargs="+",
default=['get_bam_indices', 'recover_mags', 'annotate', 'lorikeet'],
add_workflow_arg(
batch_options,
['get_bam_indices', 'recover_mags', 'annotate', 'lorikeet'],
help='Main workflow (snakemake target rule) to run for each sample'
)

########################## ~ configure ~ ###########################
Expand Down Expand Up @@ -1188,13 +1149,7 @@ def main():
required=False,
)

configure_options.add_argument(
'-w', '--workflow',
help=argparse.SUPPRESS,
dest='workflow',
nargs="+",
default=['download_databases'],
)
add_workflow_arg(configure_options, ['download_databases'], help=argparse.SUPPRESS)

###########################################################################
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
Expand Down Expand Up @@ -1303,6 +1258,8 @@ def manage_env_vars(args):
args.eggnog_db_path = Config.get_software_db_path('EGGNOG_DATA_DIR', '--eggnog-db-path')
if args.checkm2_db_path is None:
args.checkm2_db_path = Config.get_software_db_path('CHECKM2DB', '--checkm2-db-path')
if args.singlem_metapackage_path is None:
args.singlem_db_path = Config.get_software_db_path('SINGLEM_METAPACKAGE_PATH', '--singlem-metapackage-path')
except AttributeError:
pass

Expand Down

0 comments on commit 18bbcac

Please sign in to comment.