示例#1
0
def write_RMSD():
    print('\nCalculating backbone RMSDs\n')
    RMSD = {}
    de_novo_atoms, chain_count = read_in.read_in_atomistic(
        g_var.final_dir + 'final_cg2at_de_novo.pdb')  ## reads in final pdb
    if chain_count != g_var.system['PROTEIN']:
        sys.exit('number of chains in atomistic protein input (' +
                 str(chain_count) + ') does not match CG representation (' +
                 str(g_var.system['PROTEIN']) + ')')
    RMSD['de novo '] = RMSD_measure(de_novo_atoms)  ## gets rmsd of de novo

    if g_var.user_at_input and 'PROTEIN' in g_var.cg_residues:
        if g_var.args.o in ['all', 'align']:
            at_input_atoms, chain_count = read_in.read_in_atomistic(
                g_var.final_dir + 'final_cg2at_aligned.pdb')
            RMSD['at aligned'] = RMSD_measure(at_input_atoms)
    with open(g_var.final_dir + 'structure_quality.dat', 'w') as qual_out:
        qual_out.write('\n{0:^10}{1:^25}{2:^10}\n'.format(
            'output ', 'chain', 'RMSD (' + chr(197) + ')'))
        qual_out.write('{0:^10}{1:^25}{2:^10}\n'.format(
            '-------', '-----', '---------'))
        print('\n{0:^10}{1:^25}{2:^10}'.format('output ', 'chain',
                                               'RMSD (' + chr(197) + ')'))
        print('{0:^10}{1:^25}{2:^10}'.format('-------', '-----', '---------'))
        for rmsd in RMSD:
            for chain in RMSD[rmsd]:
                qual_out.write('{0:^10}{1:^25}{2:^10}\n'.format(
                    rmsd, str(chain), float(RMSD[rmsd][chain])))
                print('{0:^10}{1:^25}{2:^10}'.format(rmsd, str(chain),
                                                     float(RMSD[rmsd][chain])))
        print('\nAll RMSDs have been saved in: \n' + g_var.final_dir +
              'structure_quality.dat\n')
示例#2
0
def write_RMSD():
    print('\nCalculating backbone RMSDs\n')
    RMSD={}
    de_novo_atoms, chain_count = read_in.read_in_atomistic(g_var.final_dir+'final_cg2at_de_novo.pdb') ## reads in final pdb
    if chain_count != g_var.system['PROTEIN']:
        sys.exit('number of chains in atomistic protein input ('+str(chain_count)+') does not match CG representation ('+str(g_var.system['PROTEIN'])+')')
    RMSD_de_novo = RMSD_measure_de_novo(de_novo_atoms) ## gets rmsd of de novo

    if g_var.user_at_input and 'PROTEIN' in g_var.cg_residues: 
        if g_var.args.o in ['all', 'align']: 
            at_input_atoms, chain_count = read_in.read_in_atomistic(g_var.final_dir+'final_cg2at_aligned.pdb')
            RMSD_aligned = RMSD_measure_de_novo(at_input_atoms)   
            seg_rmsd = RMSD_measure_aligned(at_input_atoms)   

    with open(g_var.final_dir+'structure_quality.dat', 'w') as qual_out:   
        line_1   = ' chain    De novo BB RMSD ('+chr(197)+')'
        line_2   = ' -----    -------------------'
        if 'seg_rmsd' in locals():
            line_1+= '    Aligned BB RMSD ('+chr(197)+')    Seg backbone RMSD ('+chr(197)+')'
            line_2+= '    -------------------    ---------------------'
        qual_out.write(line_1+'\n'+line_2+'\n')
        print(line_1+'\n'+line_2)

        for chain in RMSD_de_novo:
            line = ' {0:^5}{1:^28}'.format(str(chain), float(RMSD_de_novo[chain]))
            if 'seg_rmsd' in locals():
                line += '{0:^18}'.format(float(RMSD_aligned[chain]))
                if chain in seg_rmsd:
                    line+= '{0:^28}'.format(', '.join(seg_rmsd[chain])) 
            print(line)
            qual_out.write(line+'\n')
        print('\n * Segment alignments may have minor deviations due to either clashes or structure hybridisation.\n\nAll RMSDs have been saved in: \n'+g_var.final_dir+'structure_quality.dat\n')
示例#3
0
文件: gro.py 项目: pstansfeld/cg2at
def create_aligned():
    print('\nCreating aligned system')
    at_mod.merge_system_pdbs(
        '_aligned')  ## create restraint positions for aligned system
    aligned_atoms, chain_count = read_in.read_in_atomistic(
        g_var.working_dir +
        'PROTEIN/PROTEIN_aligned_merged.pdb')  ## reads in final pdb
    rmsd = at_mod_p.RMSD_measure_de_novo(
        aligned_atoms)  ## gets rmsd of de novo
    for chain in rmsd:
        if rmsd[chain] > 3:
            print(
                'Your aligned structure is quite far from the CG, therefore running gentle steering\n'
            )
            print_rmsd(rmsd)
            steer = ['very_low', 'low', 'mid', 'high', 'very_high', 'ultra']
            break
        else:
            steer = ['low', 'high', 'ultra']

    final_file = run_steer(
        steer, g_var.merged_directory + 'checked_ringed_lipid_de_novo')
    if final_file:
        gen.file_copy_and_check(
            final_file, g_var.final_dir +
            'final_cg2at_aligned.pdb')  ## copy to final folder
    else:
        final_file = run_steer(
            ['very_low', 'low', 'mid', 'high', 'very_high', 'ultra'],
            g_var.merged_directory + 'checked_ringed_lipid_de_novo')
        print('Completed alignment, please find final aligned system: \n' +
              g_var.final_dir + 'final_cg2at_aligned.pdb')
        gen.file_copy_and_check(
            final_file, g_var.final_dir +
            'final_cg2at_aligned.pdb')  ## copy to final folder
示例#4
0
def RMSD_measure_aligned(Final_structure):
    seg_rmsd = {}
    total_initial, total_final = np.array([]), np.array([])
    for chain in g_var.atomistic_protein_input_aligned:
        initial_structure, chain_count = read_in.read_in_atomistic(
            g_var.working_dir + 'PROTEIN/MIN/PROTEIN_aligned_' + str(chain) +
            '.pdb')
        P_R = []
        for key in g_var.atomistic_protein_input_aligned[chain].keys():
            P_R.append(
                np.arange(int(key.split(':')[0]) - 1, int(key.split(':')[1])))
        final_backbone = get_coordinates(Final_structure, P_R, chain)
        initial_backbone = get_coordinates(initial_structure, P_R, 0)
        seg_rmsd[chain] = []
        for segment in range(len(final_backbone)):
            initial_backbone_fitted = RMSD_align(
                initial_backbone[segment][:, :3],
                final_backbone[segment][:, :3])
            total_initial = np.append(total_initial, initial_backbone_fitted)
            total_final = np.append(total_final,
                                    final_backbone[segment][:, :3])
            RMSD_val = Calculate_RMSD(np.array(initial_backbone_fitted),
                                      final_backbone[segment][:, :3])
            if RMSD_val > 0.15:
                seg_rmsd[chain].append(str(RMSD_val) + ' *')
            else:
                seg_rmsd[chain].append(str(RMSD_val))
    # print(Calculate_RMSD(total_initial, total_final))
    return seg_rmsd
示例#5
0
 read_in.fix_pbc(box_vec_initial, g_var.box_vec, box_shift)
 #### checks if fragment database and input files match
 at_mod.sanity_check()
 ### convert protein to atomistic representation
 g_var.tc['r_i_t'] = time.time()
 if 'PROTEIN' in g_var.cg_residues:
     g_var.coord_atomistic = at_mod_p.build_multi_residue_atomistic_system(
         g_var.cg_residues, 'PROTEIN')  ## converts protein to atomistic
     if not g_var.user_at_input and g_var.args.v >= 1:  ## prints protein sequences
         print(gen.print_sequnce_info('PROTEIN'))
     ## reads in user chain, runs a sequence alignment and finds existing disulphide bonds
     g_var.tc['p_d_n_t'] = time.time()
     if g_var.user_at_input:
         for file_num, file_name in enumerate(g_var.args.a):
             atomistic_protein_input_raw, g_var.chain_count = read_in.read_in_atomistic(
                 g_var.input_directory + 'AT_INPUT_' + str(file_num) +
                 '.pdb')  ## reads in user structure
             g_var.atomistic_protein_input_raw.update(
                 atomistic_protein_input_raw)
         read_in.duplicate_chain()  ## duplicates user chcains
         at_mod_p.check_sequence()  ## gets user sequence
         at_mod_p.align_chain_sequence('PROTEIN')  ## aligns chains
         at_mod_p.find_disulphide_bonds_user_sup(
         )  ## finds user disulphide bonds
     at_mod_p.find_disulphide_bonds_de_novo()  ## finds CG disulphide bonds
     g_var.coord_atomistic = at_mod_p.correct_disulphide_bonds(
         g_var.coord_atomistic)  ## fixes sulphur distances
     final_coordinates_atomistic_de_novo = at_mod_p.finalise_novo_atomistic(
         g_var.coord_atomistic,
         'PROTEIN')  ## fixes carbonyl oxygens, hydrogens and writes pdb
     ## aligns user chains to the CG system