Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def call_snakemake(workdir, targets=None):
return snakemake.snakemake(
os.path.join(workdir, 'Snakefile'),
configfile=os.path.join(workdir, 'config.yaml'),
workdir=workdir,
dryrun=True,
targets=targets)
'parameters': {'dependencies': ['Task1']}},
{'task': 'SimpleParallelAnalysisTask',
'module': 'testtask',
'analysis_name': 'Task3',
'parameters': {'dependencies': ['Task2']}}
]}
generator = snakewriter.SnakefileGenerator(taskDict, simple_merfish_data)
workflow = generator.generate_workflow()
outputTask1 = simple_merfish_data.load_analysis_task('Task1')
outputTask2 = simple_merfish_data.load_analysis_task('Task2')
outputTask3 = simple_merfish_data.load_analysis_task('Task3')
assert not outputTask1.is_complete()
assert not outputTask2.is_complete()
assert not outputTask3.is_complete()
snakemake.snakemake(workflow)
assert outputTask1.is_complete()
assert outputTask2.is_complete()
assert outputTask3.is_complete()
shutil.rmtree('.snakemake')
print('\ttargets: {}'.format(repr(targs)))
print('\toutput: {}'.format(repr(paramsD['elvers_directories']['out_dir'])))
print('\treport: {}'.format(repr(reportfile)))
print('--------')
# Set up a context manager to capture stdout if we're building
# a directed acyclic graph (which prints the graph in dot format
# to stdout instead of to a file).
# If we are not bulding a dag, pass all output straight to stdout
# without capturing any of it.
passthru = not building_dag
with CaptureStdout(passthru=passthru) as output:
# run!!
# params file becomes snakemake configfile
status = snakemake.snakemake(snakefile, configfiles=[paramsfile], use_conda=True,
targets=['elvers'], printshellcmds=True,
cores=args.threads, cleanup_conda= args.cleanup_conda,
dryrun=args.dry_run, lock=not args.nolock,
unlock=args.unlock,
verbose=args.verbose, debug_dag=args.debug,
conda_prefix=args.conda_prefix,
cluster_config=args.cluster_config,
cluster=args.cluster_cmd,
create_envs_only=args.create_envs_only,
restart_times=args.restart_times,
force_incomplete=args.force_incomplete,
printdag=building_dag, keepgoing=args.keep_going,
forcetargets=args.forcetargets,forceall=args.forceall)
if building_dag:
print('Snakefile generated at %s' % snakefilePath)
if not args.generate_only:
if args.analysis_task:
print('Running %s' % args.analysis_task)
e.run(dataSet.load_analysis_task(args.analysis_task),
index=args.fragment_index, join=True)
elif snakefilePath:
snakemakeParameters = {}
if args.snakemake_parameters:
with open(os.sep.join([m.SNAKEMAKE_PARAMETERS_HOME,
args.snakemake_parameters])) as f:
snakemakeParameters = json.load(f)
print('Running MERlin pipeline through snakemake')
snakemake.snakemake(snakefilePath, cores=args.core_count,
workdir=dataSet.get_snakemake_path(),
stats=snakefilePath + '.stats',
**snakemakeParameters)
if not args.no_report:
reportTime = int(time.time())
try:
with open(snakefilePath + '.stats', 'r') as f:
requests.post('http://merlin.georgeemanuel.com/post',
files={
'file': (
'.'.join(
['snakestats',
dataSet.dataSetName,
str(reportTime)]) + '.csv',
f)},
stack = StageStack.get(t)
targets.append(os.path.join(t, 'all_targets.stamp'))
except YmpStageError as exc:
stage_stack_failure = exc
targets.append(t)
kwargs['targets'] = targets
log.debug("Running snakemake.snakemake with args: %s", kwargs)
# A snakemake workflow was created above to resolve the
# stage stack. Unload it so things run correctly from within
# snakemake.
cfg.unload()
import snakemake
res = snakemake.snakemake(ymp._snakefile, **kwargs)
if not res and stage_stack_failure:
log.error("Incomplete stage stack: %s", stage_stack_failure)
return res
def run_workflow(case_id, config_data):
print("== Start PEDIA workflow == ")
snakefile = 'Snakefile'
target_file = os.path.join(config_data.output['output_path'], 'results', str(case_id), 'run.out')
snakemake.snakemake(snakefile, targets=[target_file], workdir='.')
print("== PEDIA workflow is completed == ")
def run_snakemake(self):
"""Run Snakemake and display result files afterwards"""
print('\nRunning Snakemake\n=================\n', file=sys.stderr)
snakemake.snakemake(
snakefile=os.path.join(self.args.work_dir, 'Snakefile'),
workdir=self.args.work_dir,
)
# TODO: check Snakemake result
print('\nThe End\n=======\n', file=sys.stderr)
print('\n'.join(textwrap.wrap(textwrap.dedent(r"""
You can find the results in the "{}/report.txt" file.
""").format(self.args.work_dir).lstrip())), file=sys.stderr)
snakemake(resource_filename('isicle', 'rules/ccs_standard.snakefile'),
configfile=args.config,
config=config,
cluster_config=args.cluster,
cluster=cluster,
keepgoing=True,
force_incomplete=True,
cores=args.cores,
nodes=args.jobs,
dryrun=args.dryrun,
unlock=args.unlock,
touch=args.touch,
latency_wait=args.latency)
# lite mode
elif args.mode == 'lite':
snakemake(resource_filename('isicle', 'rules/ccs_lite.snakefile'),
configfile=args.config,
config=config,
cluster_config=args.cluster,
cluster=cluster,
keepgoing=True,
force_incomplete=True,
cores=args.cores,
nodes=args.jobs,
dryrun=args.dryrun,
unlock=args.unlock,
touch=args.touch,
latency_wait=args.latency)
# chemical shifts module
elif args.which == 'shifts':
snakemake(resource_filename('isicle', 'rules/shifts.snakefile'),