예제 #1
0
def non_solvent(box_vec, system, atomistic_fragments, residue_type):
    #### loop through all resids of that residue type
    for resid in atomistic_fragments[residue_type]:
        skip = os.path.exists(g_var.working_dir + residue_type + '/' +
                              residue_type + '_' + str(resid) + '.pdb')
        if not skip:
            pdb_output = gen.create_pdb(
                g_var.working_dir + residue_type + '/' + residue_type + '_' +
                str(resid) + '.pdb', box_vec)
            atomistic_fragments[residue_type][resid] = at_mod.check_hydrogens(
                atomistic_fragments[residue_type][resid])
            ####### check if any atoms in residue overlap #######
            coord = []
            for atom in atomistic_fragments[residue_type][resid]:
                coord.append(
                    atomistic_fragments[residue_type][resid][atom]['coord'])
            coord = at_mod.check_atom_overlap(coord)
            for atom_val, atom in enumerate(
                    atomistic_fragments[residue_type][resid]):
                atomistic_fragments[residue_type][resid][atom][
                    'coord'] = coord[atom_val]

            for at_id, atom in enumerate(
                    atomistic_fragments[residue_type][resid]):
                #### write residue out to a pdb file
                short_line = atomistic_fragments[residue_type][resid][at_id +
                                                                      1]
                pdb_output.write(g_var.pdbline % (
                    (at_id + 1, short_line['atom'], short_line['res_type'],
                     ' ', 1, short_line['coord'][0], short_line['coord'][1],
                     short_line['coord'][2], 0.00, 0.00)) + '\n')
    system[residue_type] = int(resid) + 1
    return system, atomistic_fragments
예제 #2
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)
예제 #3
0
def finalise_novo_atomistic(atomistic, cg_residues, box_vec):
    final_at_residues={}
    final_at = {}
    for chain in atomistic: 
        at_number=0    
        final_at_residues[chain]={}  
        final_at[chain]={}
        coords=[]
        skip = os.path.exists(g_var.working_dir+'PROTEIN/PROTEIN_novo_'+str(chain)+'.pdb')
        if not skip:
            pdb_output = gen.create_pdb(g_var.working_dir+'PROTEIN/PROTEIN_novo_'+str(chain)+'.pdb', box_vec)
        for res_index, residue_id in enumerate(atomistic[chain]):
            if atomistic[chain][residue_id][1]['res_type'] in f_loc.mod_residues:
                atomistic[chain][residue_id] = at_mod.check_hydrogens(atomistic[chain][residue_id])
            if res_index < len(atomistic[chain])-2:
                atomistic[chain][residue_id] = fix_carbonyl(residue_id, cg_residues, atomistic[chain][residue_id])
            else:
                atomistic[chain][residue_id] = atomistic[chain][residue_id]
            for at_val, atom in enumerate(atomistic[chain][residue_id]):
                atomistic[chain][residue_id][at_val+1]['resid'] = res_index
                coords.append(atomistic[chain][residue_id][at_val+1]['coord'])
                final_at[chain][at_number]=atomistic[chain][residue_id][at_val+1]
                at_number+=1
            final_at_residues[chain][res_index]=atomistic[chain][residue_id]

        coords = at_mod.check_atom_overlap(coords)
        for atom in final_at[chain]:
            final_at[chain][atom]['coord']=coords[atom]
            final_at_residues[chain][final_at[chain][atom]['resid']][atom]=final_at[chain][atom]
            if not skip:
                pdb_output.write(g_var.pdbline%((atom,final_at[chain][atom]['atom'],final_at[chain][atom]['res_type'],ascii_uppercase[chain],\
                                final_at[chain][atom]['resid'],final_at[chain][atom]['coord'][0],final_at[chain][atom]['coord'][1],final_at[chain][atom]['coord'][2],1,0))+'\n')
    if 'pdb_output' in locals():
        pdb_output.close()
    return final_at_residues
예제 #4
0
def finalise_novo_atomistic(coord_atomistic, sys_type):
    final_at_residues = {}
    final_at = {}
    for chain in coord_atomistic:
        at_number = 0
        final_at_residues[chain] = {}
        final_at[chain] = {}
        coords = []
        skip = os.path.exists(g_var.working_dir + sys_type + '/' + sys_type +
                              '_de_novo_' + str(chain) + '.pdb')
        if not skip:
            pdb_output = gen.create_pdb(g_var.working_dir + sys_type + '/' +
                                        sys_type + '_de_novo_' + str(chain) +
                                        '.pdb')
        for res_index, residue_id in enumerate(coord_atomistic[chain]):
            if coord_atomistic[chain][residue_id][next(
                    iter(coord_atomistic[chain][residue_id])
            )]['res_type'] in g_var.mod_residues + g_var.o_residues:
                coord_atomistic[chain][residue_id] = at_mod.check_hydrogens(
                    coord_atomistic[chain][residue_id])
            if sys_type == 'PROTEIN':
                if res_index <= len(coord_atomistic[chain]) - 3:
                    coord_atomistic[chain][
                        residue_id], cross_vector = fix_carbonyl(
                            residue_id, g_var.cg_residues['PROTEIN'],
                            coord_atomistic[chain][residue_id], False)
                elif res_index < len(
                        coord_atomistic[chain]) and 'cross_vector' in locals():
                    coord_atomistic[chain][
                        residue_id], cross_vector = fix_carbonyl(
                            residue_id, g_var.cg_residues['PROTEIN'],
                            coord_atomistic[chain][residue_id], cross_vector)
            order = np.sort(
                np.array(list(coord_atomistic[chain][residue_id].keys())))
            for at_val, atom in enumerate(order):
                coord_atomistic[chain][residue_id][atom]['resid'] = res_index
                coords.append(
                    coord_atomistic[chain][residue_id][atom]['coord'])
                final_at[chain][at_number] = coord_atomistic[chain][
                    residue_id][atom]
                at_number += 1
            final_at_residues[chain][res_index] = coord_atomistic[chain][
                residue_id]
        coords = at_mod.check_atom_overlap(coords)
        for atom in final_at[chain]:
            final_at[chain][atom]['coord'] = coords[atom]
            if not skip:
                x, y, z = gen.trunc_coord(final_at[chain][atom]['coord'])
                pdb_output.write(g_var.pdbline%((atom,final_at[chain][atom]['atom'],final_at[chain][atom]['res_type'],' ',\
                                final_at[chain][atom]['resid'],x,y,z,1,0))+'\n')
    if 'pdb_output' in locals():
        pdb_output.close()
    return final_at_residues
예제 #5
0
파일: at_mod_np.py 프로젝트: IAlibay/cg2at
def non_solvent(system, atomistic_fragments, residue_type):
    #### loop through all resids of that residue type
    system[residue_type] = len(atomistic_fragments[residue_type])

    if not os.path.exists(g_var.working_dir + residue_type + '/' +
                          residue_type + '_all.pdb') and not os.path.exists(
                              g_var.working_dir + residue_type + '/' +
                              residue_type + '_merged.pdb'):
        NP = {}
        count = 0
        coord = []
        index_conversion = {}
        for resid in atomistic_fragments[residue_type]:
            if not os.path.exists(g_var.working_dir + residue_type + '/' +
                                  residue_type + '_merged.pdb'):
                atomistic_fragments[residue_type][
                    resid] = at_mod.check_hydrogens(
                        atomistic_fragments[residue_type][resid])
                for at_id, atom in enumerate(
                        atomistic_fragments[residue_type][resid], 1):
                    if not atomistic_fragments[residue_type][resid][at_id][
                            'atom'].startswith('M'):
                        index_conversion[count] = len(coord)
                        coord.append(atomistic_fragments[residue_type][resid]
                                     [at_id]['coord'])
                    NP[count] = atomistic_fragments[residue_type][resid][at_id]
                    count += 1

        coord = at_mod.check_atom_overlap(coord)
        pdb_output_all = gen.create_pdb(g_var.working_dir + residue_type +
                                        '/' + residue_type + '_all.pdb')
        atom_counter = 0
        for at_val, atom in enumerate(NP):
            if at_val in index_conversion:
                x, y, z = gen.trunc_coord(coord[index_conversion[at_val]])
            else:
                x, y, z = gen.trunc_coord([
                    NP[atom]['coord'][0], NP[atom]['coord'][1],
                    NP[atom]['coord'][2]
                ])
            if atom_counter >= 99_999:
                atom_counter = 1
            else:
                atom_counter += 1
            pdb_output_all.write(g_var.pdbline % (
                (atom_counter, NP[atom]['atom'], NP[atom]['res_type'], ' ', 1,
                 x, y, z, 0.00, 0.00)) + '\n')
    return system