2023-11-01 10:09:29 +08:00
|
|
|
#! /usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
run_wdl_path = os.path.join(os.path.dirname(__file__), 'run_wdl.py')
|
|
|
|
|
|
2023-11-30 15:31:35 +08:00
|
|
|
|
|
|
|
|
def environ_test():
|
|
|
|
|
workflow_path = os.environ.get('WORKFLOW', None)
|
|
|
|
|
public_path = os.environ.get('PUBLIC', None)
|
|
|
|
|
database_path = os.environ.get('DATABASE', None)
|
|
|
|
|
if not (workflow_path and public_path and database_path):
|
|
|
|
|
raise UserWarning('未设置WORKFLOW, PUBLIC, DATABASE环境')
|
|
|
|
|
|
|
|
|
|
|
2023-11-01 10:09:29 +08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
|
parser = argparse.ArgumentParser(description="JM to run pipeline")
|
|
|
|
|
|
|
|
|
|
parser.add_argument('-n', '--barcode', help="sample's barcode", required=True)
|
|
|
|
|
parser.add_argument('-s', '--normal', help="sample's normal", default='', required=False, nargs='?')
|
|
|
|
|
parser.add_argument('-u', '--umi', action='store_true', help="is umi sample", default=False)
|
|
|
|
|
parser.add_argument('-i', '--input_dir', help="sample's input_dir/workdir", required=True)
|
|
|
|
|
parser.add_argument('-o', '--output_dir', help="Output directory, default ./", default='./')
|
|
|
|
|
parser.add_argument('-p', '--project', help="project", required=True)
|
|
|
|
|
parser.add_argument('-c', '--cancer', help="cancer", required=True)
|
2023-11-29 15:13:30 +08:00
|
|
|
parser.add_argument('-b', '--probe', help="probe, 682, 624, 160, 17 for now ", required=True)
|
2023-11-01 10:09:29 +08:00
|
|
|
parser.add_argument('-w', '--wdl', help="wdl", default='/home/zhangchao/project/pipeline/workflow/pipeline.wdl')
|
2023-11-29 15:13:30 +08:00
|
|
|
parser.add_argument('-node', '--start_node',
|
|
|
|
|
help="node begain to run; 'addQc', 'addAlignment', "
|
|
|
|
|
"'addTarget', 'addFusion', 'addCnv', 'addMsi', 'addChemo',"
|
2023-11-30 15:31:35 +08:00
|
|
|
" 'addHcs, addTmb, addAutoReport' and also run more than one "
|
|
|
|
|
"node ,like this 'addTarget,addFusion'",
|
2023-11-29 15:13:30 +08:00
|
|
|
default='addQc')
|
2023-11-01 10:09:29 +08:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
2023-11-30 15:31:35 +08:00
|
|
|
environ_test()
|
|
|
|
|
|
2023-11-01 10:09:29 +08:00
|
|
|
res_path = os.path.realpath(os.path.join(args.output_dir, args.barcode))
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(res_path):
|
|
|
|
|
os.makedirs(res_path)
|
|
|
|
|
|
|
|
|
|
cmd = f'nohup python ' \
|
|
|
|
|
f'{run_wdl_path} -n {args.barcode} -s {args.normal} ' \
|
|
|
|
|
f'{"-u " if args.umi else ""} -i {args.input_dir} ' \
|
2023-11-29 15:13:30 +08:00
|
|
|
f'-node {args.start_node} ' \
|
|
|
|
|
f'-o {res_path} -b {args.probe} -p {args.project} -c {args.cancer} -w {args.wdl} ' \
|
2023-11-01 10:09:29 +08:00
|
|
|
f'> {res_path}/{args.barcode}_run.log ' \
|
|
|
|
|
f'2>> {res_path}/{args.barcode}_run.log &'
|
2023-11-30 15:31:35 +08:00
|
|
|
# with open(os.path.join(res_path, 'exec'), 'w') as execfile:
|
|
|
|
|
# execfile.write(cmd + '\n')
|
2023-11-01 10:09:29 +08:00
|
|
|
os.system(cmd)
|