Пример #1
0
def at_np_solvent(cg_residue_type,cg_residues):   
    atomistic_fragments={}  #### residue dictionary
#### run through every residue in a particular residue type
    residue_type={}
    residue_type_mass={}
    atomistic_fragments_list = []
    for cg_resid, cg_residue in enumerate(cg_residues):
        atomistic_fragments[cg_resid]={}
        frag_location=gen.fragment_location(cg_residue_type) ### get fragment location from database
        residue_type[cg_residue_type], residue_type_mass[cg_residue_type] = at_mod.get_atomistic(frag_location, cg_residue_type)
        for group in residue_type[cg_residue_type]:
            center, at_frag_centers, cg_frag_centers, group_fit = at_mod.rigid_fit(residue_type[cg_residue_type][group], 
                                                                                    residue_type_mass[cg_residue_type], 
                                                                                    cg_residue, cg_residues[cg_residue])
            at_connect, cg_connect = at_mod.connectivity(cg_residues[cg_residue], at_frag_centers, cg_frag_centers, group_fit, group)
            xyz_rot_apply=at_mod.get_rotation(cg_connect, at_connect, center, cg_residue_type, group, cg_resid)

            atomistic_fragments = at_mod.apply_rotations(atomistic_fragments,cg_resid, group_fit, center, xyz_rot_apply)
            
        if cg_residue_type in g_var.np_residues:
            atomistic_fragments[cg_resid] = at_mod.check_hydrogens(atomistic_fragments[cg_resid])
        atomistic_fragments_list, sol_p_bead =  sort_np_dictionary(atomistic_fragments[cg_resid], atomistic_fragments_list)
    if cg_residue_type in g_var.sol_residues:
        return atomistic_fragments_list, sol_p_bead*len(cg_residues)
    else:
        return atomistic_fragments_list, len(atomistic_fragments)
Пример #2
0
def add_posres_file():
    print()
    frag_location = gen.fragment_location(g_var.args.posre)[:-4]
    molecule, posre, footer = read_itp(frag_location + '.itp')
    write_posre_file(frag_location, posre)
    if not footer:
        append_ifdef(frag_location + '.itp')
    sys.exit()
Пример #3
0
def build_multi_residue_atomistic_system(cg_residues, sys_type):   
#### initisation of counters
    chain_count=0
    coord_atomistic={}
    g_var.seq_cg={sys_type:{}}
    g_var.ter_res={sys_type:{}}
    gen.mkdir_directory(g_var.working_dir+sys_type)  ### make and change to protein directory
#### for each residue in protein
    residue_type={}
    residue_type_mass={}
    new_chain = True
    for cg_residue_id, residue_number in enumerate(cg_residues[sys_type]):

        if np.round((cg_residue_id/len(cg_residues[sys_type]))*100,2).is_integer():
            print('Converting de_novo '+sys_type+': ',np.round((cg_residue_id/len(cg_residues[sys_type]))*100,2),'%', end='\r')
        resname = cg_residues[sys_type][residue_number][next(iter(cg_residues[sys_type][residue_number]))]['residue_name']
        if new_chain: 
            if chain_count not in coord_atomistic:
                if sys_type == 'PROTEIN':
                    g_var.backbone_coords[chain_count]=[]
                coord_atomistic[chain_count]={}
                g_var.seq_cg[sys_type][chain_count]=[]
                g_var.ter_res[sys_type][chain_count]=[resname, False]
            new_chain = False
        coord_atomistic[chain_count][residue_number]={}
        frag_location=gen.fragment_location(resname) ### get fragment location from database
        residue_type[resname], residue_type_mass[resname] = at_mod.get_atomistic(frag_location)
        g_var.seq_cg[sys_type] = add_to_sequence(g_var.seq_cg[sys_type], resname, chain_count)
        new_chain = False
        for group in residue_type[resname]:
            for key in list(residue_type[resname][group].keys()):
                if key not in cg_residues[sys_type][residue_number]:
                    del residue_type[resname][group][key]
            if len(residue_type[resname][group]) > 0:
                center, at_frag_centers, cg_frag_centers, group_fit = at_mod.rigid_fit(residue_type[resname][group], residue_type_mass[resname], residue_number, cg_residues[sys_type][residue_number])
                at_connect, cg_connect = at_mod.connectivity(cg_residues[sys_type][residue_number], at_frag_centers, cg_frag_centers, group_fit, group)
                for group_bead in group_fit:
                    if group_bead in g_var.res_top[resname]['CONNECT']:
                        at_connect, cg_connect, new_chain = at_mod.BB_connectivity(at_connect,cg_connect, cg_residues[sys_type], group_fit[group_bead], residue_number, group_bead)
                        if sys_type == 'PROTEIN':
                            g_var.backbone_coords[chain_count].append(np.append(cg_residues[sys_type][residue_number][group_bead]['coord'], 1)) 




                xyz_rot_apply = at_mod.get_rotation(cg_connect, at_connect, center, resname, group, residue_number)
                coord_atomistic[chain_count] = at_mod.apply_rotations(coord_atomistic[chain_count],residue_number, group_fit, center, xyz_rot_apply)
        if new_chain:
            g_var.ter_res[sys_type][chain_count][1] = resname
            chain_count+=1

    print('Completed initial conversion of '+sys_type+'\n')        
    g_var.system[sys_type]=chain_count
    if sys_type == 'PROTEIN':
        for chain in range(chain_count):
            g_var.skip_disul[chain]=False
    return coord_atomistic
Пример #4
0
def read_solvent_conversion(cg_residue_type, cg_residues):
    residue_type = {}
    residue_type_mass = {}
    for cg_resid, cg_residue in enumerate(cg_residues):
        frag_location = gen.fragment_location(
            cg_residue_type)  ### get fragment location from database
        residue_type[cg_residue_type], residue_type_mass[
            cg_residue_type] = at_mod.get_atomistic(frag_location)
        for res_type in residue_type[cg_residue_type]:
            if g_var.water in residue_type[cg_residue_type][res_type]:
                sol_p_bead = 0
                for atom in residue_type[cg_residue_type][res_type][
                        g_var.water].values():
                    if int(atom['resid_ori']) > sol_p_bead:
                        sol_p_bead = int(atom['resid_ori'])
                return sol_p_bead, sol_p_bead * len(cg_residues)
Пример #5
0
def read_solvent_conversion(cg_residue_type,cg_residues):
    residue_type={}
    residue_type_mass={}
    for cg_resid, cg_residue in enumerate(cg_residues):
        frag_location=gen.fragment_location(cg_residue_type) ### get fragment location from database
        residue_type[cg_residue_type], residue_type_mass[cg_residue_type] = at_mod.get_atomistic(frag_location, cg_residue_type)

        for group in residue_type[cg_residue_type]:
            sol_p_bead = 0
            for frag in residue_type[cg_residue_type][group].values():
                for atom in frag.values():
                    if int(atom['resid_ori']) > sol_p_bead:
                        sol_p_bead = int(atom['resid_ori'])
            return sol_p_bead, sol_p_bead*len(cg_residues)
    
    sys.exit('There is an issue with the solvent recalculation')
Пример #6
0
def sanity_check_fragments(res, cg, sin_bead):
#### fetches bead and atom info from fragment database
    location = gen.fragment_location(res)
    residue, fragment_mass = get_atomistic(location, res)
    atom_list = []
    bead_list = []
    for group in residue.values():
        for bead in group:
            bead_list.append(bead)
            if not sin_bead:
                for atom in group[bead]:
                    atom_list.append(atom)
            else:
                if bead == sin_bead:
                    for atom in group[bead]:
                        atom_list.append(atom)
    return sorted(bead_list), atom_list
Пример #7
0
def atomistic_non_protein_non_solvent(cg_residue_type, cg_residues):
    atomistic_fragments = {}  #### residue dictionary
    #### run through every residue in a particular residue type
    residue_type = {}
    residue_type_mass = {}
    if not os.path.exists(g_var.working_dir + cg_residue_type + '/' +
                          cg_residue_type + '_all.pdb'):
        for cg_resid, cg_residue in enumerate(cg_residues):
            atomistic_fragments[cg_resid] = {}
            frag_location = gen.fragment_location(
                cg_residue_type)  ### get fragment location from database
            residue_type[cg_residue_type], residue_type_mass[
                cg_residue_type] = at_mod.get_atomistic(frag_location)
            for group in residue_type[cg_residue_type]:
                center, at_frag_centers, cg_frag_centers, group_fit = at_mod.rigid_fit(
                    residue_type[cg_residue_type][group],
                    residue_type_mass[cg_residue_type], cg_residue,
                    cg_residues[cg_residue])
                at_connect, cg_connect = at_mod.connectivity(
                    cg_residues[cg_residue], at_frag_centers, cg_frag_centers,
                    group_fit, group)
                if len(at_connect) == len(cg_connect) and len(cg_connect) > 0:
                    try:
                        xyz_rot_apply = at_mod.kabsch_rotate(
                            np.array(at_connect) - center,
                            np.array(cg_connect) - center)
                    except BaseException:
                        sys.exit('There is a issue with residue: ' +
                                 cg_residue_type + ' in group: ' + str(group))
                else:
                    print('atom connections: ' + str(len(at_connect)) +
                          ' does not match CG connections: ' +
                          str(len(cg_connect)))
                    sys.exit('residue number: ' + str(cg_resid) +
                             ', residue type: ' + str(cg_residue_type) +
                             ', group: ' + group)
                for bead in group_fit:
                    for atom in group_fit[bead]:
                        group_fit[bead][atom]['coord'] = at_mod.rotate_atom(
                            group_fit[bead][atom]['coord'], center,
                            xyz_rot_apply)
                        atom_new = group_fit[bead][atom].copy()
                        atomistic_fragments[cg_resid][atom] = atom_new
        return atomistic_fragments, 0
    else:
        return atomistic_fragments, len(cg_residues)
Пример #8
0
def atomistic_non_protein_solvent(cg_residue_type, cg_residues):
    atomistic_fragments = {}  #### residue dictionary
    #### run through every residue in a particular residue type
    residue_type = {}
    residue_type_mass = {}

    for cg_resid, cg_residue in enumerate(cg_residues):
        for bead in cg_residues[cg_residue]:
            fragment = bead
            break
        atomistic_fragments[cg_resid] = {}
        frag_location = gen.fragment_location(
            cg_residue_type)  ### get fragment location from database
        residue_type[cg_residue_type], residue_type_mass[
            cg_residue_type] = at_mod.get_atomistic(frag_location)
        if os.path.exists(g_var.working_dir + 'SOL' +
                          '/SOL_all.pdb') and cg_residue_type == 'SOL':
            sol_p_bead = 0
            for atom in residue_type_mass[cg_residue_type][g_var.water]:
                if atom[3] > 1:
                    sol_p_bead += 1
            return sol_p_bead, sol_p_bead * len(cg_residues)
        for res_type in residue_type[cg_residue_type]:
            if fragment in residue_type[cg_residue_type][res_type]:
                center, at_frag_centers, cg_frag_centers, group_fit = at_mod.rigid_fit(
                    residue_type[cg_residue_type][res_type],
                    residue_type_mass[cg_residue_type], cg_residue,
                    cg_residues[cg_residue])
                xyz_rot_apply = gen.AnglesToRotMat([
                    np.random.uniform(0, math.pi * 2),
                    np.random.uniform(0, math.pi * 2),
                    np.random.uniform(0, math.pi * 2)
                ])
                for bead in group_fit:
                    for atom in group_fit[bead]:
                        group_fit[bead][atom]['coord'] = at_mod.rotate_atom(
                            group_fit[bead][atom]['coord'], center,
                            xyz_rot_apply)
                        atom_new = group_fit[bead][atom].copy()
                        atomistic_fragments[cg_resid][atom] = atom_new
    return atomistic_fragments, 0