def go(self, skip_dry_run=False): """Do the actual running""" if self.save_workflow_graph or (not skip_dry_run): self.dry_run() if self.dry_run_only: return # snakemake.main() accepts an `argv` parameter, but then the code has mixed responses to # that, and at places continues to read from sys.argv in a hardcoded manner. so we have to # overwrite our argv here. original_sys_argv = copy.deepcopy(sys.argv) sys.argv = ['snakemake', '--snakefile', get_workflow_snake_file_path(self.args.workflow), '--configfile', self.args.config_file] if self.additional_params: sys.argv.extend(self.additional_params) if self.list_dependencies: sys.argv.extend(['--dryrun', '--printshellcmds']) snakemake.main() sys.exit(0) else: sys.argv.extend(['-p']) snakemake.main() # restore the `sys.argv` to the original for the sake of sakity (totally made up word, # but you already know what it measn. you're welcome.) sys.argv = original_sys_argv
def go(self, skip_dry_run=False): """Do the actual running""" if self.save_workflow_graph or (not skip_dry_run): self.dry_run() if self.dry_run_only: return # snakemake.main() accepts an `argv` parameter, but then the code has mixed responses to # that, and at places continues to read from sys.argv in a hardcoded manner. so we have to # overwrite our argv here. original_sys_argv = copy.deepcopy(sys.argv) sys.argv = [ 'snakemake', '--snakefile', get_workflow_snake_file_path(self.args.workflow), '--configfile', self.args.config_file ] if self.additional_params: sys.argv.extend(self.additional_params) if self.list_dependencies: sys.argv.extend(['--dryrun', '--printshellcmds']) snakemake.main() sys.exit(0) else: sys.argv.extend(['-p']) snakemake.main() # restore the `sys.argv` to the original for the sake of sakity (totally made up word, # but you already know what it measn. you're welcome.) sys.argv = original_sys_argv
def run(self): ''' Run the wrapped command or workflow. ''' # Overwrite the generic method, because we have to use the snakemake API try: snakemake.main(self.remaining[1:]) except SystemExit: # snakemake main wants to exit ... but we want to write the xml files first return
def main(**config): """ Main function of pancovcorrect Parameter: config: A dict pass to snakemake as config. Value associate to 'snakemake' is parse with snakemake cli parser. Return: True if workflow execution was successful. """ params = config["snakemake"] del config["snakemake"] # Found Snakefile params.extend( [ "--snakefile", os.path.join(os.path.dirname(__file__), f"{package_name}.snk"), ] ) # Add parameter with config params.append("--config") for (name, value) in config.items(): params.append(f"{name}={value}") # Add target params.extend(["--", "all"]) return snakemake.main(params)
def proxy_to_snakemake(tailseeker_dir): from snakemake import main tailseeker_main_file = os.path.join(tailseeker_dir, 'tailseeker', 'main.py') if '-s' not in sys.argv and '--snakefile' not in sys.argv: sys.argv.insert(1, '-s') sys.argv.insert(2, tailseeker_main_file) sys.exit(main())
# This script makes it possible to invoke snakemake with 'python3 -m snakemake' from snakemake import main main()
def __call__(self, parser, namespace, values, option_string=None): snakemake.main(["-h"])
def proxy_to_snakemake(tailseeker_dir): from snakemake import main tailseeker_main_file = os.path.join(tailseeker_dir, 'tailseeker', 'main.py') if '-s' not in sys.argv and '--snakefile' not in sys.argv: sys.argv.insert(1, '-s') sys.argv.insert(2, tailseeker_main_file) sys.exit(main()) def show_banner(): if os.environ.get('TAILSEEKER_SKIP_BANNER', 'no') == 'no': print("""\ Tailseeker {version} - High-throughput measurement of poly(A) tails """.format(version=tailseeker.__version__)) def main(tailseeker_dir): show_banner() os.environ['TAILSEEKER_DIR'] = tailseeker_dir os.environ['TAILSEEKER_SKIP_BANNER'] = 'yes' check_configuration() proxy_to_snakemake(tailseeker_dir) if __name__ == '__main__': main()
def main_full(): snakefile = get_snakefile() options = argv[1:] options.append("-s") options.append(snakefile) snakemake.main(options)
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 # -*- coding: utf-8 -*- import re import sys from snakemake import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(main())