def run(pdbfile, rnalib,code_to_type,mutations, args_termini= False, args_modbase = False, args_modres = False,
        args_chain = " ", args_nter = [], args_cter = [], args_readpatch = False, args_patches=[],
        args_rnalib = False, args_heavy = False, args_pdb2pqr = False, args_refe= None, args_whatif = False, args_manual = False, args_startatom = 1,args_startres = 1 ):

    
    pdb = read_pdb(open(pdbfile),mutations=mutations, add_termini=args_termini, modbase=args_modbase, modres=args_modres)
    pdblines = write_pdb(pdb, args_chain, code_to_type, args_startatom =args_startatom, args_startres = args_startres)[0]

    termini_pdb(pdb, args_nter, args_cter)
    patches = {}
    if args_readpatch:
        indata = open(os.path.splitext(pdbfile)[0] + '.patch').readlines()
        indata = [line.split() for line in indata]
        args_patches = indata

    for p in args_patches:
        resid = p[0].strip()
        resindices = [ri for ri, r in enumerate(pdb) if r.resid.strip() == resid]
        if len(resindices) == 0:
            raise ValueError("No residues have resid %s" % resid)
        elif len(resindices) > 1:
            raise ValueError("Multiple residues have resid %s" % resid)
        resid2 = pdb[resindices[0]].resid
        if resid2 not in patches: patches[resid2] = []
        pname = p[1].lower()
        if pname == "none": pname = None
        patches[resid2].append(pname)
    patch_pdb(pdb, patches)

    if args_refe:
        refe = read_pdb(open(args_refe),mutations=mutations, add_termini=args_termini)
        patch_pdb(refe, patches)
        if not args_heavy:
            update_patches(refe)
        set_reference(pdb, refe)
    if args_rnalib:
        pdbcomplete.apply_rnalib(pdb, rnalib, args_heavy)
    if args_pdb2pqr:
        pdblines = write_pdb(pdb, args_chain, code_to_type, one_letter_na=True, args_startatom =args_startatom, args_startres = args_startres)[0]
        pqrlines = run_pdb2pqr(pdblines)
        pqr = read_pdb(pqrlines,mutations=mutations)
        pdbcomplete.pdbcomplete(pdb, pqr)
        if not args_heavy and not args_refe:
            update_patches(pdb)
    if args_whatif:
        pdblines = write_pdb(pdb, args_chain, code_to_type, one_letter_na=True, args_startatom =args_startatom, args_startres = args_startres)[0]
        whatiflines = run_whatif(pdblines)
        whatif = read_pdb(whatiflines,mutations=mutations)
        pdbcomplete.pdbcomplete(pdb, whatif)
        if not args_heavy and not args_refe and not args_pdb2pqr:
            update_patches(pdb)

    if args_refe:
        pdbfix(pdb, refe)

    if not args_manual:
        pdb_lastresort(pdb)
        check_pdb(pdb, heavy=args_heavy)
    pdblines, mapping = write_pdb(pdb, args_chain,code_to_type, heavy=args_heavy, args_startatom =args_startatom, args_startres = args_startres)
    return pdblines, mapping, pdb
Пример #2
0
def run(pdbfile):
    pdb = read_pdb(open(pdbfile),
                   pdbfile,
                   add_termini=args.termini,
                   modbase=args.modbase,
                   modres=args.modres)
    pdblines = write_pdb(pdb, args.chain)[0]

    termini_pdb(pdb, args.nter, args.cter)
    patches = {}
    if args.readpatch:
        indata = open(os.path.splitext(pdbfile)[0] + '.patch').readlines()
        indata = [line.split() for line in indata]
        args.patches = indata

    for p in args.patches:
        resid = p[0].strip()
        resindices = [
            ri for ri, r in enumerate(pdb) if r.resid.strip() == resid
        ]
        if len(resindices) == 0:
            raise ValueError("No residues have resid %s" % resid)
        elif len(resindices) > 1:
            raise ValueError("Multiple residues have resid %s" % resid)
        resid2 = pdb[resindices[0]].resid
        if resid2 not in patches: patches[resid2] = []
        pname = p[1].lower()
        if pname == "none": pname = None
        patches[resid2].append(pname)
    patch_pdb(pdb, patches)

    if args.refe:
        refe = read_pdb(open(args.refe), args.refe, add_termini=args.termini)
        patch_pdb(refe, patches)
        if not args.heavy:
            update_patches(refe, top_patches)
        set_reference(pdb, refe)
    if args.nalib:
        pdbcomplete.apply_nalib(pdb, nalib, args.manual, args.heavy)
    if args.pdb2pqr:
        pdblines = write_pdb(pdb, args.chain, one_letter_na=True)[0]
        pqrlines = run_pdb2pqr(pdblines)
        pqr = read_pdb(pqrlines, "<PDB2PQR output from %s>" % pdbfile)
        pdbcomplete.pdbcomplete(pdb, pqr)
        if not args.heavy and not args.refe:
            update_patches(pdb, top_patches)

    if args.refe:
        pdbfix(pdb, refe)

    if not args.manual:
        pdb_lastresort(pdb)
        check_pdb(pdb, heavy=args.heavy)
    pdblines, mapping = write_pdb(pdb, args.chain, heavy=args.heavy)
    return pdblines, mapping, pdb