Esempio n. 1
0
def main():

    args = get_cli_args(
        verbosity=2,
        parallel=1,
        nbblocks=4,
        dump_pdb=0,
        clash_check=0,
        cache_sync=0.003,
        monte_carlo=0.0,
        cart_resl=1.0,
        ori_resl=5.0,
        splice_max_rms=0.7,
        min_radius=0.0,
        i_merge_bblock=0,
        dbfiles=["must_specify_dbfile.json"],
    )

    pyrosetta.init("-mute all -beta")

    db = (CachingBBlockDB(**vars(args)), CachingSpliceDB(**vars(args)))

    spec = (
        [
            ["C3_N", "_N"],
            ["Het:NCy", "CN"],
            ["Het:CCC", "CC"],
            ["Het:NNy", "NN"],
            ["Het:CCC", "C_"],
        ],
        Cyclic(3, from_seg=2, origin_seg=0, min_radius=args.min_radius),
    )

    make_peace(spec=spec, db=db, **vars(args))
Esempio n. 2
0
def spdb(datadir):
    return CachingSpliceDB(cachedirs=[str('.worms_pytest_cache')])
Esempio n. 3
0
def build_worms_setup_from_cli_args(argv, parser=None):
    arg = get_cli_args(argv, parser)

    numeric_level = getattr(logging, arg.loglevel.upper(), None)
    if not isinstance(numeric_level, int):
        raise ValueError('Invalid log level: %s' % arg.loglevel)
    logging.getLogger().setLevel(numeric_level)

    if arg.config_file == [""]:
        arg.config_file = []
    arg.topology = Topology(arg.topology)
    if not arg.config_file:
        if not arg.geometry or not arg.geometry[0]:
            print('--geometry not specified')
            sys.exit()
        crit = eval("".join(arg.geometry))
        bb = arg.bbconn[1::2]
        nc = arg.bbconn[0::2]
        arg.topology.check_nc(nc)
        crit.bbspec = _bbspec(bb, nc)
        assert len(nc) == len(bb)
        assert crit.from_seg < len(bb)
        assert crit.to_seg < len(bb)
        if isinstance(crit, Cyclic) and crit.origin_seg is not None:
            assert crit.origin_seg < len(bb)
        crit = [crit]
    else:
        crit = []
        for cfile in arg.config_file:
            with open(cfile) as inp:
                lines = inp.readlines()
                assert len(lines) is 2

                def orient(a, b):
                    return (a or "_") + (b or "_")

                bbnc = eval(lines[0])
                bb = [x[0] for x in bbnc]
                nc = [x[1] for x in bbnc]
                arg.topology.check_nc(nc)

                crit0 = eval(lines[1])
                crit0.bbspec = _bbspec(bb, nc)
                assert len(nc) == len(bb)
                assert crit0.from_seg < len(bb)
                assert crit0.to_seg < len(bb)
                if isinstance(crit0, Cyclic) and crit0.origin_seg is not None:
                    assert crit0.origin_seg < len(bb)
                crit.append(crit0)

    # oh god... fix these huge assumptions about Criteria
    for c in crit:
        # c.tolerance = arg.tolerance
        c.lever = arg.lever
        c.rot_tol = c.tolerance / arg.lever

    if arg.max_score0 > 9e8:
        arg.max_score0 = 2.0 * len(crit[0].bbspec)

    if arg.merge_bblock < 0:
        arg.merge_bblock = None
    if arg.only_merge_bblocks == [-1]:
        arg.only_merge_bblocks = []
    if arg.only_bblocks == [-1]:
        arg.only_bblocks = []
    if arg.only_ivertex == [-1]:
        arg.only_ivertex = []
    if arg.only_outputs == [-1]:
        arg.only_outputs = []
    if arg.bblock_ranges == [-1]:
        arg.bblock_ranges = []
    elif arg.shuffle_bblocks:
        print(
            "you probably shouldnt use --shuffle_bblocks with --bblock_ranges "
        )
        sys.exit(0)
    if arg.merge_segment == -1:
        arg.merge_segment = None
    arg.tolerance = min(arg.tolerance, 9e8)

    if arg.dbfiles == [""]:
        assert 0, "no --dbfiles specified"

    if len(arg.nbblocks) == 1:
        arg.nbblocks *= 100
    if arg.output_only_connected != 'auto':
        if arg.output_only_connected in ('', 0, '0', 'false', 'False'):
            arg.output_only_connected = False
        else:
            arg.output_only_connected = True

    kw = vars(arg)
    if arg.disable_cache:
        kw["db"] = NoCacheBBlockDB(**kw), NoCacheSpliceDB(**kw)
    else:
        kw["db"] = CachingBBlockDB(**kw), CachingSpliceDB(**kw)

    print("-------------- arg ---------------")
    for k, v in kw.items():
        print("   ", k, v)
    print("-----------------------------------")

    kw["db"][0].report()

    return crit, kw
Esempio n. 4
0
def main():
    import argparse
    import glob
    import pyrosetta
    pyrosetta.init('-mute all -beta')

    parser = argparse.ArgumentParser()
    parser.add_argument('--verbosity', type=int, dest='verbosity', default=0)
    parser.add_argument('--parallel', type=int, dest='parallel', default=True)
    parser.add_argument('--nbblocks', type=int, dest='nbblocks', default=4)
    parser.add_argument('--clash_check',
                        type=int,
                        dest='clash_check',
                        default=0)
    parser.add_argument('--dump_pdb', type=int, dest='dump_pdb', default=0)
    parser.add_argument('--cache_sync',
                        type=float,
                        dest='cache_sync',
                        default=0.01)
    parser.add_argument('--monte_carlo',
                        type=int,
                        dest='monte_carlo',
                        default=0)
    args = parser.parse_args()

    bbdb = CachingBBlockDB(dbfiles=[
        'worms/data/c6_database.json',
        'worms/data/HBRP_Cx_database.json',
        'worms/data/HFuse_Cx_database.20180219.json',
        'worms/data/HFuse_het_2chain_2arm_database.ZCON-103_2.20180406.json',
        'worms/data/HFuse_het_2chain_2arm_database.ZCON-112_2.20180406.json',
        'worms/data/HFuse_het_2chain_2arm_database.ZCON-127_2.20180406.json',
        'worms/data/HFuse_het_2chain_2arm_database.ZCON-13_2.20180406.json',
        'worms/data/HFuse_het_2chain_2arm_database.ZCON-15_2.20180406.json',
        'worms/data/HFuse_het_2chain_2arm_database.ZCON-34_2.20180406.json',
        'worms/data/HFuse_het_2chain_2arm_database.ZCON-37_2.20180406.json',
        'worms/data/HFuse_het_2chain_2arm_database.ZCON-39_2.20180406.json',
        'worms/data/HFuse_het_2chain_2arm_database.ZCON-9_2.20180406.json',
        'worms/data/HFuse_het_3chain_2arm_database.Sh13_3.20180406.json',
        'worms/data/HFuse_het_3chain_2arm_database.Sh13_3.20180416.json',
        'worms/data/HFuse_het_3chain_2arm_database.Sh29_3.20180406.json',
        'worms/data/HFuse_het_3chain_2arm_database.Sh29_3.20180416.json',
        'worms/data/HFuse_het_3chain_2arm_database.Sh34_3.20180416.json',
        'worms/data/HFuse_het_3chain_2arm_database.Sh3e_3.20180406.json',
        'worms/data/HFuse_het_3chain_3arm_database.Sh13_3.20180406.json',
        'worms/data/HFuse_het_3chain_3arm_database.Sh13_3.20180416.json',
        'worms/data/HFuse_het_3chain_3arm_database.Sh29_3.20180406.json',
        'worms/data/HFuse_het_3chain_3arm_database.Sh29_3.20180416.json',
        'worms/data/HFuse_het_3chain_3arm_database.Sh34_3.20180416.json',
        'worms/data/HFuse_het_3chain_3arm_database.Sh3e_3.20180406.json',
        'worms/data/master_database_generation2.json',
        'worms/data/test_db_file.json',
        'worms/data/test_fullsize_prots.json',
    ],
                           read_new_pdbs=True,
                           verbosity=args.verbosity)

    spdb = CachingSpliceDB()

    worm_grow_3(
        bbdb,
        spdb,
        nbblocks=args.nbblocks,
        parallel=args.parallel,
        verbosity=args.verbosity,
        monte_carlo=args.monte_carlo,
        clash_check=args.clash_check,
        dump_pdb=args.dump_pdb,
        cache_sync=args.cache_sync,
    )
    sys.stdout.flush()
Esempio n. 5
0
def parse_args(argv):
    args = util.get_cli_args(
        argv=argv,
        geometry=[''],
        bbconn=[''],
        config_file=[''],
        nbblocks=64,
        use_saved_bblocks=0,
        monte_carlo=[0.0],
        parallel=1,
        verbosity=2,
        precache_splices=1,
        precache_splices_and_quit=0,
        pbar=0,
        pbar_interval=10.0,
        #
        cachedirs=[''],
        disable_cache=0,
        dbfiles=[''],
        load_poses=0,
        read_new_pdbs=0,
        run_cache='',
        merge_bblock=-1,
        no_duplicate_bases=1,
        shuffle_bblocks=1,
        only_merge_bblocks=[-1],

        # splice stuff
        splice_rms_range=4,
        splice_max_rms=0.7,
        splice_clash_d2=3.5**2,  # ca only
        splice_contact_d2=8.0**2,
        splice_clash_contact_range=40,
        splice_clash_contact_by_helix=1,
        splice_ncontact_cut=38,
        splice_ncontact_no_helix_cut=6,
        splice_nhelix_contacted_cut=3,
        splice_max_chain_length=450,
        #
        tolerance=1.0,
        lever=25.0,
        min_radius=0.0,
        hash_cart_resl=1.0,
        hash_ori_resl=5.0,
        merged_err_cut=999.0,
        rms_err_cut=3.0,
        ca_clash_dis=3.0,
        #
        max_linear=1000000,
        max_merge=100000,
        max_clash_check=10000,
        max_output=1000,
        max_score0=9e9,
        #
        output_from_pose=1,
        output_symmetric=1,
        output_prefix='./worms',
        output_centroid=0,
        output_only_AAAA=0,
        #
        cache_sync=0.003,
        #
        postfilt_splice_max_rms=0.7,
        postfilt_splice_rms_length=9,
        postfilt_splice_ncontact_cut=40,
        postfilt_splice_ncontact_no_helix_cut=2,
        postfilt_splice_nhelix_contacted_cut=3,
    )
    if args.config_file == ['']:
        args.config_file = []
    if not args.config_file:
        crit = eval(''.join(args.geometry))
        bb = args.bbconn[1::2]
        nc = args.bbconn[0::2]
        crit.bbspec = list(list(x) for x in zip(bb, nc))
        assert len(nc) == len(bb)
        assert crit.from_seg < len(bb)
        assert crit.to_seg < len(bb)
        if isinstance(crit, Cyclic) and crit.origin_seg is not None:
            assert crit.origin_seg < len(bb)
        crit = [crit]
    else:
        crit = []
        for cfile in args.config_file:
            with open(cfile) as inp:
                lines = inp.readlines()
                assert len(lines) is 2

                def orient(a, b):
                    return (a or '_') + (b or '_')

                bbnc = eval(lines[0])
                bb = [x[0] for x in bbnc]
                nc = [x[1] for x in bbnc]

                crit0 = eval(lines[1])
                crit0.bbspec = list(list(x) for x in zip(bb, nc))
                assert len(nc) == len(bb)
                assert crit0.from_seg < len(bb)
                assert crit0.to_seg < len(bb)
                if isinstance(crit0, Cyclic) and crit0.origin_seg is not None:
                    assert crit0.origin_seg < len(bb)
                crit.append(crit0)

    # oh god... fix these huge assumptions about Criteria
    for c in crit:
        c.tolerance = args.tolerance
        c.lever = args.lever
        c.rot_tol = args.tolerance / args.lever

    if args.max_score0 > 9e8:
        args.max_score0 = 2.0 * len(crit[0].bbspec)

    if args.merge_bblock < 0: args.merge_bblock = None
    if args.only_merge_bblocks == [-1]:
        args.only_merge_bblocks = []

    kw = vars(args)
    if args.disable_cache:
        kw['db'] = NoCacheBBlockDB(**kw), NoCacheSpliceDB(**kw)
    else:
        kw['db'] = CachingBBlockDB(**kw), CachingSpliceDB(**kw)

    return crit, kw