예제 #1
0
def calc_span_dg(pdb: MyPDB, start: int, end: int, rosetta_splines: dict) -> float:
    """
    calculate a span's dG from structure
    """
    dg = 0.0
    for i in range(start, end+1):
        dg += interpolate.splev( pdb.get_res(i).memb_z, rosetta_splines[ pdb.get_res(i).res_type ], der=0 )
    return dg
def setup_db(args):
    rost_db = parse_rost_db()
    failed = []
    logger = Logger('./db_setup.log')
    for k, v in rost_db.items():
        # if k != 'q9u6b8': continue
        logger.create_header('working on %s' % k)
        logger.log('seq: %s' % v['seq'])
        logger.log('pdb: %s' % v['pdb'])
        logger.log('chain: %s' % v['chain'])
        logger.log('ts: %s' % v['ts'])
        os.mkdir(k)
        os.chdir(k)

        # get pdb and extract chain
        download_pdb({'name': v['pdb'], 'path': './'})
        empty_pdb = MyPDB(name=v['pdb'])
        pdb = parse_PDB('pdb%s.ent' % v['pdb'])
        chain = pdb.chains[v['chain']]
        empty_pdb.add_chain(chain)
        write_PDB('%s_%s.pdb' % (k, v['chain']), empty_pdb)
        pdb_seq = extract_seq(empty_pdb)
        rdb_seq = AASeq(v['seq'])
        score, start, end = pdb_seq[v['chain']].align(rdb_seq)
        logger.log('pdb seq: %s' % pdb_seq[v['chain']].aligned)
        logger.log('rst seq: %s' % rdb_seq.aligned)

        # get spans and print xml
        spans = find_topo(v['ts'])

        new_spans = []
        for sp in spans:
            start = pdb_seq[v['chain']].aligned_position_at_non_aligned(
                sp[0]) + 1
            end = pdb_seq[v['chain']].aligned_position_at_non_aligned(
                sp[1]) + 1
            logger.log('span %i->%i %s moving to %i->%i' %
                       (sp[0], sp[1], sp[2], start, end))
            new_spans.append([start, end, sp[2]])
        create_AddMembrane_xml(new_spans, '%s_AddMembrane.xml' % v['pdb'])

        # create flags file
        with open('embed.flags', 'w+') as fout:
            fout.write(
                '-parser:protocol /home/labs/fleishman/jonathaw/elazaridis/protocols/embed_in_membrane.xml\n'
            )
            fout.write('-s %s\n' % '%s_%s.pdb' % (k, v['chain']))
            fout.write('-parser:script_vars add_memb_xml=%s\n' %
                       '%s_AddMembrane.xml' % v['pdb'])
            fout.write('-overwrite\n')
            fout.write('-score::elec_memb_sig_die\n')
            fout.write('-corrections::beta_nov15\n')
            fout.write('-score::memb_fa_sol\n')
        os.chdir('../')
예제 #3
0
def find_spans_pdb(pdb: MyPDB) -> list:
    memb_vec = []
    for res in pdb.iter_all_res():
        memb_vec.append( res.memb_z is not None )

    spans = []
    chain, start, end, ori = pdb.get_res(1).chain, -1, -1, 'fwd'
    tm_open = False
    for i in range(len(memb_vec)):
        if pdb.get_res(i+1).chain != chain and tm_open:
            end = i
            ori = 'fwd' if pdb.get_res(start).memb_z < 0 and pdb.get_res(end) > 0 else 'rev'
            spans.append([start, end, ori])
            tm_open = False
        if memb_vec[i] and not tm_open:
            start = i + 1
            tm_open = True
        if not memb_vec[i] and tm_open:
            end = i-1
            ori = 'fwd' if pdb.get_res(start).memb_z < 0 and pdb.get_res(end) > 0 else 'rev'
            spans.append([start, end, ori])
            tm_open = False
        chain = pdb.get_res(i+1).chain
    if tm_open:
        spans.append([start, i+1, ori])
    return spans
def setup_db(args):
    rost_db = parse_rost_db()
    failed = []
    logger = Logger('./db_setup.log')
    for k, v in rost_db.items():
        # if k != 'q9u6b8': continue
        logger.create_header('working on %s' % k)
        logger.log('seq: %s' % v['seq'])
        logger.log('pdb: %s' % v['pdb'])
        logger.log('chain: %s' % v['chain'])
        logger.log('ts: %s' % v['ts'])
        os.mkdir(k)
        os.chdir(k)

        # get pdb and extract chain
        download_pdb({'name': v['pdb'], 'path': './'})
        empty_pdb = MyPDB(name=v['pdb'])
        pdb = parse_PDB('pdb%s.ent' % v['pdb'])
        chain = pdb.chains[v['chain']]
        empty_pdb.add_chain(chain)
        write_PDB('%s_%s.pdb' % (k, v['chain']), empty_pdb)
        pdb_seq = extract_seq(empty_pdb)
        rdb_seq = AASeq(v['seq'])
        score, start, end = pdb_seq[v['chain']].align(rdb_seq)
        logger.log('pdb seq: %s' % pdb_seq[v['chain']].aligned)
        logger.log('rst seq: %s' % rdb_seq.aligned)


        # get spans and print xml
        spans = find_topo(v['ts'])

        new_spans = []
        for sp in spans:
            start = pdb_seq[v['chain']].aligned_position_at_non_aligned(sp[0]) + 1
            end = pdb_seq[v['chain']].aligned_position_at_non_aligned(sp[1]) + 1
            logger.log('span %i->%i %s moving to %i->%i' %(sp[0], sp[1], sp[2], start, end))
            new_spans.append([start, end, sp[2]])
        create_AddMembrane_xml(new_spans, '%s_AddMembrane.xml' % v['pdb'])

        # create flags file
        with open('embed.flags', 'w+') as fout:
            fout.write('-parser:protocol /home/labs/fleishman/jonathaw/elazaridis/protocols/embed_in_membrane.xml\n')
            fout.write('-s %s\n' % '%s_%s.pdb' % (k, v['chain']))
            fout.write('-parser:script_vars add_memb_xml=%s\n' % '%s_AddMembrane.xml' % v['pdb'])
            fout.write('-overwrite\n')
            fout.write('-score::elec_memb_sig_die\n')
            fout.write('-corrections::beta_nov15\n')
            fout.write('-score::memb_fa_sol\n')
        os.chdir('../')
예제 #5
0
def find_helix_vector(pdb: MyPDB, start: int, end: int):
    xs, ys, zs = [], [], []
    for i in range(start, end+1):
       res_i = pdb.get_res(i)
       for bb_atom in res_i.iter_bb():
           xs.append(bb_atom.xyz.x)
           ys.append(bb_atom.xyz.y)
           zs.append(bb_atom.xyz.z)
    xs_ = np.array(xs)
    ys_ = np.array(ys)
    zs_ = np.array(zs)

    dist = np.sqrt((xs[-1]-xs[0])**2 + (ys[-1]-ys[0])**2 + (zs[-1]-zs[0])**2  )

    data = np.concatenate((xs_[:, np.newaxis], ys_[:, np.newaxis], zs_[:, np.newaxis]), axis=1)
    datamean = data.mean(axis=0)
    uu, dd, vv = np.linalg.svd(data - datamean)
    linepts = vv[0] * np.mgrid[-dist/2:dist/2:2j][:, np.newaxis]
    linepts += datamean
    return linepts, data
예제 #6
0
def find_helix_vector(pdb: MyPDB, start: int, end: int):
    xs, ys, zs = [], [], []
    for i in range(start, end + 1):
        res_i = pdb.get_res(i)
        for bb_atom in res_i.iter_bb():
            xs.append(bb_atom.xyz.x)
            ys.append(bb_atom.xyz.y)
            zs.append(bb_atom.xyz.z)
    xs_ = np.array(xs)
    ys_ = np.array(ys)
    zs_ = np.array(zs)

    dist = np.sqrt((xs[-1] - xs[0])**2 + (ys[-1] - ys[0])**2 +
                   (zs[-1] - zs[0])**2)

    data = np.concatenate(
        (xs_[:, np.newaxis], ys_[:, np.newaxis], zs_[:, np.newaxis]), axis=1)
    datamean = data.mean(axis=0)
    uu, dd, vv = np.linalg.svd(data - datamean)
    linepts = vv[0] * np.mgrid[-dist / 2:dist / 2:2j][:, np.newaxis]
    linepts += datamean
    return linepts, data