def main():
    args = docopt.docopt(__doc__)
    cluster.require_qsub()

    workspace = pipeline.ValidatedDesigns(args['<workspace>'], args['<round>'])
    workspace.check_paths()
    workspace.check_rosetta()
    workspace.make_dirs()
    workspace.clear_fragments()

    # Run the fragment generation script.

    generate_fragments = [
        'klab_generate_fragments',
        '--loops_file',
        workspace.loops_path,
        '--outdir',
        workspace.fragments_dir,
        '--memfree',
        args['--mem-free'],
        workspace.input_dir,
    ]

    if args['--dry-run']:
        print ' '.join(generate_fragments)
    else:
        subprocess.call(generate_fragments)
Ejemplo n.º 2
0
def main():
    args = docopt.docopt(__doc__)
    cluster.require_qsub()

    workspace = pipeline.workspace_from_path(args['<workspace>'])
    workspace.check_paths()
    workspace.make_dirs()
    workspace.clear_fragments()

    # Run the fragment generation script.

    generate_fragments = [
        'klab_generate_fragments',
        workspace.input_pdb_path,
        '--outdir',
        workspace.fragments_dir,
        '--memfree',
        args['--mem_free'],
    ]
    if not args['--ignore-loop-file']:
        generate_fragments += [
            '--loops_file',
            workspace.loops_path,
        ]

    if args['--dry-run']:
        print(' '.join(generate_fragments))
    else:
        subprocess.call(generate_fragments)
Ejemplo n.º 3
0
def main():
    args = docopt.docopt(__doc__)
    cluster.require_qsub()

    # Setup the workspace.

    workspace = pipeline.FixbbDesigns(args['<workspace>'], args['<round>'])
    workspace.check_paths()
    workspace.check_rosetta()
    workspace.make_dirs()

    if args['--clear'] or args['--test-run']:
        workspace.clear_outputs()

    # Decide which inputs to use.

    inputs = workspace.unclaimed_inputs
    nstruct = len(inputs) * int(args['--nstruct'])

    if not inputs:
        print """\
All the input structures have already been (or are already being) designed.  If
you want to rerun all the inputs from scratch, use the --clear flag."""
        raise SystemExit

    # Submit the design job.

    big_jobs.submit('pip_design.py',
                    workspace,
                    inputs=inputs,
                    nstruct=nstruct,
                    max_runtime=args['--max-runtime'],
                    max_memory=args['--max-memory'],
                    test_run=args['--test-run'])
def main():
    args = docopt.docopt(__doc__)
    cluster.require_qsub()

    # Setup the workspace.

    workspace = pipeline.ValidatedDesigns(args['<workspace>'], args['<round>'])
    workspace.check_paths()
    workspace.make_dirs()

    if args['--clear'] or args['--test-run']:
        workspace.clear_outputs()

    # Setup an output directory for each input.

    inputs = workspace.unclaimed_inputs
    nstruct = len(inputs) * int(args['--nstruct'])

    if nstruct == 0:
        scripting.print_error_and_die("""\
No unclaimed input files.

If you previously started a round of simulations and then stopped them for some
reason, the problem is probably that all the inputs are still claimed by those
simulations.  Use the '--clear' flag to remove the claims and try again.""")

    for input in inputs:
        subdir = workspace.output_subdir(input)
        scripting.clear_directory(subdir)

    # Launch the validation job.

    big_jobs.submit(
        'pip_validate.py',
        workspace,
        inputs=inputs,
        nstruct=nstruct,
        max_runtime=args['--max-runtime'],
        max_memory=args['--max-memory'],
        test_run=args['--test-run'],
    )
Ejemplo n.º 5
0
def main():
    args = docopt.docopt(__doc__)
    print(args)
    cluster.require_qsub()

    workspace = pipeline.workspace_from_dir(args['<workspace>'])
    # If not a fragment workspace, make a new one
    if not hasattr(workspace, 'fasta_path'):
        step = workspace.get_next_step()
        workspace = pipeline.ValidationWorkspace(workspace.root_dir, step)
    workspace.check_paths()
    workspace.make_dirs()
    workspace.clear_fragments()

    inputs = pick_inputs(workspace)
    if not inputs:
        print('All inputs already have fragments')
    # if not '--input_model' in args:
    # model = workspace.input_pdb_path
    # else:
    # model = args['--input_model']

    # Run the fragment generation script.

    generate_fragments = [
        'klab_generate_fragments',
        '--outdir',
        workspace.fragments_dir,
        '--memfree',
        args['--mem-free'],
    ] + inputs
    if not args['--ignore-loop-file']:
        generate_fragments += [
            '--loops_file',
            workspace.loops_path,
        ]

    if args['--dry-run']:
        print(' '.join(generate_fragments))
    else:
        subprocess.call(generate_fragments)
Ejemplo n.º 6
0
def main():
    arguments = docopt.docopt(__doc__)
    cluster.require_qsub()

    # Setup the workspace.

    workspace = pipeline.RestrainedModels(arguments['<workspace>'])
    workspace.check_paths()
    workspace.check_rosetta()
    workspace.make_dirs()

    if arguments['--clear'] or arguments['--test-run']:
        workspace.clear_outputs()

    # Submit the model building job.

    big_jobs.submit('pip_build.py',
                    workspace,
                    nstruct=arguments['--nstruct'],
                    max_runtime=arguments['--max-runtime'],
                    max_memory=arguments['--max-memory'],
                    test_run=arguments['--test-run'])
Ejemplo n.º 7
0
def main():
    cluster.require_qsub()

    start_time = time.time()

    workspace, job_info = big_jobs.initiate()
    pdbpath = workspace.input_path(job_info)
    if not os.path.exists(workspace.output_prefix(job_info)):
        os.mkdir(workspace.output_prefix(job_info))
    outpath = workspace.output_path(job_info)
    test_run = job_info.get('test_run', False)

    # append location of Rosetta binaries to path
    abinitio = '/wynton/home/kortemme/krivacic/rosetta/source/bin/AbinitioRelax.linuxgccrelease'

    # find necessary files
    print('fdir :', workspace.fragments_dir)
    print('pdb :', pdbpath)
    print(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath.lower()) + '?',
                     '*3mers.gz'))
    tmers = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath.lower()) + '?',
                     '*3mers.gz'))[0]
    nmers = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath.lower()) + '?',
                     '*9mers.gz'))[0]
    ss2 = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath.lower()) + '?',
                     '*psipred_ss2'))[0]
    fasta = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath.lower()) + '?',
                     '*fasta'))[0]

    # Set up tempdir
    if 'TMPDIR' in os.environ:
        os_tmp = os.environ['TMPDIR']
    elif args['--task']:
        os_tmp = os.path.join(os.environ['HOME'], 'temp')
    else:
        os_tmp = os.path.join('/scratch', os.environ['USER'])
    outdir_temp = os.path.join(os_tmp, str(task_num))
    if not os.path.exists(outdir_temp):
        os.makedirs(outdir_temp, exist_ok=True)

    # Run the ab initio relax script.
    outfile = os.path.join(
        outdir_temp, 'silent{}.out'.format(workspace.output_suffix(job_info)))
    relax_abinitio = [
        abinitio,
        '-abinitio:relax',
        '-use_filters',
        'true',
        '-abinitio::increase_cycles',
        '10',
        '-abinitio::rg_reweight',
        '0.5',
        '-abinitio::rsd_wt_helix',
        '0.5',
        '-abinitio::rsd_wt_loop',
        '0.5',
        '-relax::fast',
        '-in:file:fasta',
        fasta,
        '-in:file:frag3',
        tmers,
        '-in:file:frag9',
        nmers,
        '-in:file:psipred_ss2',
        ss2,
        '-nstruct',
        '10',
        # '-out:pdb_gz',
        # '-out:sf', workspace.output_prefix(job_info) + 'score{}.sc'.format(workspace.output_suffix(job_info)),
        # '-out:file:silent', workspace.output_prefix(job_info) + 'silent{}.out'.format(workspace.output_suffix(job_info)),
        '-out:file:silent',
        outfile,
        # '-out:prefix', workspace.output_prefix(job_info),
        # '-out:suffix', workspace.output_suffix(job_info),
        '-out:no_nstruct_label'
        # '--outdir', workspace.fragments_dir,
        # '--memfree', args['--mem-free']
    ]

    print('Running ROSETTA command:')
    print(' '.join(relax_abinitio))

    subprocess.call(relax_abinitio)

    from shutil import copyfile
    if not os.path.exists(workspace.output_prefix(job_info)):
        os.makedirs(workspace.output_prefix(job_info), exist_ok=True)
    final = os.path.join(
        workspace.output_prefix(job_info),
        'silent{}.out'.format(workspace.output_suffix(job_info)))
    copyfile(outfile, final)
Ejemplo n.º 8
0
def main():
    cluster.require_qsub()

    start_time = time.time()

    workspace, job_info = big_jobs.initiate()
    pdbpath = workspace.input_path(job_info)
    if not os.path.exists(workspace.output_prefix(job_info)):
        os.mkdir(workspace.output_prefix(job_info))
    outpath = workspace.output_path(job_info)
    test_run = job_info.get('test_run', False)

    # append location of Rosetta binaries to path
    abinitio = '/wynton/home/kortemme/krivacic/rosetta/source/bin/AbinitioRelax.linuxgccrelease'

    # find necessary files
    print('fdir :', workspace.fragments_dir)
    print('pdb :', pdbpath)
    print(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath.lower()) + '?',
                     '*3mers.gz'))
    tmers = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath.lower()) + '?',
                     '*3mers.gz'))[0]
    nmers = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath.lower()) + '?',
                     '*9mers.gz'))[0]
    ss2 = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath.lower()) + '?',
                     '*psipred_ss2'))[0]
    fasta = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath.lower()) + '?',
                     '*fasta'))[0]

    # Run the ab initio relax script.

    relax_abinitio = [
        abinitio,
        '-abinitio:relax',
        '-use_filters',
        'true',
        '-abinitio::increase_cycles',
        '10',
        '-abinitio::rg_reweight',
        '0.5',
        '-abinitio::rsd_wt_helix',
        '0.5',
        '-abinitio::rsd_wt_loop',
        '0.5',
        '-relax::fast',
        '-in:file:fasta',
        fasta,
        '-in:file:frag3',
        tmers,
        '-in:file:frag9',
        nmers,
        '-in:file:psipred_ss2',
        ss2,
        '-nstruct',
        '10',
        # '-out:pdb_gz',
        '-out:file:silent',
        workspace.output_prefix(job_info) +
        'silent_{}.out'.format(workspace.output_suffix(job_info)),
        # '-out:prefix', workspace.output_prefix(job_info),
        # '-out:suffix', workspace.output_suffix(job_info),
        '-out:no_nstruct_label'
        # '--outdir', workspace.fragments_dir,
        # '--memfree', args['--mem-free']
    ]

    print('Running ROSETTA command:')
    print(' '.join(relax_abinitio))

    subprocess.call(relax_abinitio)
Ejemplo n.º 9
0
def main():
    args = docopt.docopt(__doc__)
    if not args['--local'] and not args['--slurm'] and not args['--make-dirs']:
        cluster.require_qsub()

    workspace = pipeline.workspace_from_dir(args['<workspace>'])
    if args['--step']:
        step = args['--step']
    elif hasattr(workspace, 'step'):
        step = workspace.step
    else:
        step = workspace.get_next_step()

    if not args['<script>']:
        script = os.path.join(workspace.focus_dir, 'run.py')
    else:
        script = args['<script>']

    if not os.path.exists(script):
        raise pipeline.PathNotFound(script)


    # Workspace type is defined in the run script, so we first need to
    # import that.
    script_path = os.path.dirname(script)
    sys.path.insert(1, script_path)
    script_name = os.path.basename(script)[:-3]
    imp = importlib.import_module(script_name)

    workspace = imp.get_workspace(workspace.root_dir, step)
    workspace.check_paths()
    # workspace.check_rosetta()
    workspace.make_dirs()
    if args['--make-dirs']:
        sys.exit()
    # Copying the script to the focus directory helps track exactly what
    # we did at each step.
    shutil.copyfile(script, workspace.script_path)

    if args['--clear'] or args['--test-run']:
        workspace.clear_outputs()

    inputs = [
            x for x in workspace.unclaimed_inputs
            ]

    if len(inputs)==0:
        num_inputs = 1
    else:
        num_inputs = len(inputs)

    if args['--test-run']:
        nstruct = num_inputs * 10
    else:
        nstruct = num_inputs * int(args['--nstruct'])

    if workspace.subdirs:
        for inp in inputs:
            subdir = workspace.output_subdir(inp)
            # scripting.clear_directory(subdir)

    # Submit the job

    if args['--local']:
        print('Running locally.')
        for n in range(1,nstruct + 1):
            cmd = [workspace.python_path]
            cmd.append(workspace.script_path)
            cmd.append(workspace.focus_dir)
            cmd.append(str(n))
            execute(cmd)
            # read_and_display(cmd)

    elif args['--slurm']:
        big_jobs.submit_slurm(
                workspace, 
                nstruct=nstruct,
                max_runtime=args['--max-runtime'],
                max_memory=args['--max-memory'],
                test_run=args['--test-run'],
                job_name=script_name,
                inputs=inputs
                )

    else:
        big_jobs.submit(
                workspace.script_path, workspace,
                nstruct=nstruct,
                max_runtime=args['--max-runtime'],
                max_memory=args['--max-memory'],
                test_run=args['--test-run'],
                job_name=script_name,
                inputs=inputs
                )
Ejemplo n.º 10
0
def main():
    args = docopt.docopt(__doc__)
    print(args)
    cluster.require_qsub()

    start_time = time.time()

    workspace, job_info = big_jobs.initiate()
    pdbpath = workspace.input_path(job_info)
    if not os.path.exists(workspace.output_prefix(job_info)):
        os.mkdir(workspace.output_prefix(job_info))
    outpath = workspace.output_path(job_info)
    test_run = job_info.get('test_run', False)

    # append location of Rosetta binaries to path
    sys.path.append('/wynton/home/kortemme/krivacic/source/bin')

    # find necessary files
    tmers = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath) + '?', '*3mers.gz'))
    nmers = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath) + '?', '*9mers.gz'))
    ss2 = glob.glob(
        os.path.join(workspace.fragments_dir,
                     workspace.fragments_tag(pdbpath) + '?', '*psipred_ss2'))

    # Run the ab initio relaxation script.

    relax_abinitio = [
        'AbinitioRelax.linuxgccrelease',
        '-abinitio:relax',
        '-use_filters',
        'true',
        '-abinitio::increase_cycles',
        '10',
        '-abinitio::rg_reweight',
        '0.5',
        '-abinitio::rsd_wt_helix',
        '0.5',
        '-abinitio::rsd_wt_loop',
        '0.5',
        '-relax::fast',
        '-in:file:fasta',
        workspace.fasta_path,
        '-in:file:frag3',
        tmers,
        '-in:file:frag9',
        nmers,
        '-in:file:psipred_ss2',
        ss2,
        '-nstruct',
        args.nstruct,
        '-out:pdb_gz',
        '-out:prefix',
        workspace.output_prefix(job_info),
        '-out:suffix',
        workspace.output_suffix(job_info),
        # '--outdir', workspace.fragments_dir,
        # '--memfree', args['--mem-free']
    ]

    if args['--dry-run']:
        print(' '.join(relax_abinitio))
    else:
        subprocess.call(relax_abinitio)

    init()
    pose = pose_from_file(outpath)
    input_pose = pose_from_file(pdbpath)

    ca_rmsd = CA_rmsd(pose, input_pose)
    all_atom_rmsd = all_atom_rmsd(pose, input_pose)

    setPoseExtraScore(pose, 'EXTRA_METRIC_CA_RMSD [[-]]', ca_rmsd)
    setPoseExtraScore(pose, 'EXTRA_METRIC_AllAtom_RMSD [[-]]', all_atom_rmsd)

    filters = workspace.get_filters(pose,
                                    task_id=job_info['task_id'],
                                    score_fragments=not test_run,
                                    test_run=test_run)
    filters.run_filters()

    total_time = time.time() - start_time
    setPoseExtraScore(pose, 'EXTRA_METRIC_Run time', total_time)

    outname = os.path.basename(outpath)
    outfolder = os.path.join(workspace.output_prefix(job_info), 'filtered')
    pose.dump_pdb(os.path.join(outfolder, outpath))
Ejemplo n.º 11
0
def submit(workspace,
           cmd,
           distributor='local',
           clear=False,
           test_run=False,
           make_dirs=False,
           ntasks=None,
           nstruct=1,
           max_runtime='10:00:00',
           max_memory='5G'):
    # args = docopt.docopt(__doc__)
    # if not args['--local'] and not args['--slurm'] and not args['--make-dirs']:
    if distributor == 'sge':
        cluster.require_qsub()

    # if args['--step']:
    # step = args['--step']
    # elif hasattr(workspace, 'step'):
    # step = workspace.step
    # else:
    # step = workspace.get_next_step()

    # if not args['<script>']:
    # script = os.path.join(workspace.focus_dir, 'run.py')
    # else:
    # script = args['<script>']

    # if not os.path.exists(script):
    # raise pipeline.PathNotFound(script)

    # Workspace type is defined in the run script, so we first need to
    # import that.
    # script_path = os.path.dirname(script)
    # sys.path.insert(1, script_path)
    # script_name = os.path.basename(script)[:-3]
    # imp = importlib.import_module(script_name)
    script_name = os.path.basename(cmd[1]).split('.')[0]

    # workspace.check_paths()
    # workspace.check_rosetta()
    workspace.make_dirs()
    # if args['--make-dirs']:
    if make_dirs:
        sys.exit()
    # Copying the script to the focus directory helps track exactly what
    # we did at each step.
    # shutil.copyfile(script, workspace.script_path)

    # if args['--clear'] or args['--test-run']:
    if clear or test_run:
        workspace.clear_outputs()

    inputs = [x for x in workspace.unclaimed_inputs]

    if len(inputs) == 0:
        num_inputs = 1
    else:
        num_inputs = len(inputs)

    if ntasks:
        nstruct = ntasks
    else:
        nstruct = num_inputs * nstruct

    # if workspace.subdirs:
    # for inp in inputs:
    # subdir = workspace.output_subdir(inp)
    # scripting.clear_directory(subdir)

    # Submit the job

    if distributor == 'local':
        print('Running locally.')
        for n in range(1, nstruct + 1):
            # cmd = [workspace.python_path]
            # cmd.append(workspace.script_path)
            # cmd.append(workspace.focus_dir)
            # cmd.append(str(n))
            cmd += str(n),
            execute(cmd)
            # read_and_display(cmd)

    elif distributor == 'slurm':
        big_jobs.submit_slurm(workspace,
                              cmd,
                              nstruct=workspace.nstruct,
                              max_runtime=max_runtime,
                              max_memory=max_memory,
                              test_run=test_run,
                              job_name=script_name,
                              inputs=inputs)

    else:
        print('Submitting the following command to SGE:')
        print(' '.join(cmd))
        big_jobs.submit(workspace,
                        cmd,
                        nstruct=nstruct,
                        max_runtime=max_runtime,
                        max_memory=max_memory,
                        test_run=test_run,
                        job_name=script_name,
                        inputs=inputs)