Example #1
0
    #    calls = ["mkdir %s"%exp_wrk_dir,
    #             "split_file.py %s --outdir=%s %s"%(opts.split_args,exp_wrk_dir,experiment_fn),]
    #    if control_fn :
    #            calls.extend(["mkdir %s"%cnt_wrk_dir,
    #             "split_file.py %s --outdir=%s %s"%(opts.split_args,cnt_wrk_dir,control_fn),
    #            ])
    #    steps.append(PPS('Split files',calls,env=os.environ))

    ############################################################################
    # run macs
    ############################################################################
    cnt_flag = ''
    if control_fn :
        cnt_flag = '-c %s'%control_fn

    macs_name = get_macs_name(opts)
    macs_peaks_fn = macs_name+'_peaks.xls'
    macs_neg_peaks_fn = macs_name+'_negative_peaks.xls'
    macs_screen_output_fn = macs_name+'_output.txt'

    macs_d = {'exp_fn':experiment_fn,
              'cnt_flag':cnt_flag,
              'name':macs_name,
              'macs_exec':opts.macs_exec,
              'macs_args':opts.macs_args,
              'macs_out':macs_screen_output_fn,
              'gsize':org_settings['genome_size'],
              }
    calls = ["%(macs_exec)s --gsize=%(gsize)s -t %(exp_fn)s %(cnt_flag)s --name=%(name)s %(macs_args)s 2>&1 | tee %(macs_out)s"%macs_d]
    steps.append(PPS('Run MACS',calls,env=os.environ))
    if len(param_json_fn) == 0 :
        sys.stderr.write('Could not find parameter file, building one as best I can\n')
        curr_user = getpass.getuser()
        json_d = {'analysis path':os.getcwd(),
                  'stage url':all_tool_settings['web_stage'].get_('stage_url')+curr_user,
                  'stage dir':all_tool_settings['web_stage'].get_('stage_dir')+curr_user
                 }
    else :
        if len(param_json_fn) > 1 :
            sys.stderr.write('Found more than one parameter file, picking the first one: %s\n'%','.join(param_json_fn))
        param_json_fn = param_json_fn[0]
        json_d = json.load(open(param_json_fn))
        pipeline_args_str = ['%s=%s'%(k,v) for (k,v) in json_d['pipeline args'].iteritems()]
        pipeline_opts,pipeline_args =  pipeline_parser.parse_args(pipeline_args_str)

    macs_name = get_macs_name(pipeline_opts)
    meme_dir_name = macs_name + '_meme'
    meme_path = os.path.join(os.getcwd(),meme_dir_name)

    # 2. make a new directory to save all the stuff
    infosite_dir_name = macs_name+'_infosite'
    infosite_path = os.path.join(os.getcwd(),infosite_dir_name)
    if not os.path.exists(infosite_path) :
        os.mkdir(infosite_path)

    infosite_img_path = os.path.join(infosite_path,'images')
    if not os.path.exists(infosite_img_path) :
        os.mkdir(infosite_img_path)

    # 3. setup web staging directory
    stage_dir_path = os.path.join(json_d['stage dir'],infosite_dir_name)