ensemble_list = [] rmsd_cutoff = 2.0 for replica_index in range(len(replica_positions)): trajectory = md.load(str("replica_" + str(replica_index + 1) + ".pdb")) rmsds = md.rmsd(trajectory, native_structure) rmsd_to_helical[replica_index] = rmsds for rmsd_index in range(len(rmsd_to_helical[replica_index])): if rmsd_to_helical[replica_index][rmsd_index] < rmsd_cutoff: rmsd_list.append(rmsd_to_helical[replica_index][rmsd_index]) ensemble_list.append(replica_positions[replica_index][rmsd_index]) random.shuffle(ensemble_list) file_index = 1 for pose in ensemble_list: if file_index <= 100: file_name = str("pose_" + str(file_index) + ".pdb") cgmodel.positions = pose write_pdbfile_without_topology(cgmodel, file_name) target_traj = md.load(file_name) aligned_target_traj = target_traj.superpose(native_structure) cgmodel.positions = unit.Quantity(aligned_target_traj.xyz[0], cgmodel.positions.unit) write_pdbfile_without_topology(cgmodel, file_name) file_index = file_index + 1 else: exit()
if os.path.exists(nonnative_ensemble_directory): nonnative_ensemble, nonnative_ensemble_energies = get_ensemble_data( cgmodel, nonnative_ensemble_directory) if len(nonnative_ensemble) != nonnative_ensemble_size: print("ERROR: " + str(len(nonnative_ensemble_energies)) + " nonnative poses were found in existing output folders, but " + str(nonnative_ensemble_size) + " poses were requested.") print( "This probably means that the requested ensemble size changed since the script was last run." ) exit() else: os.mkdir(nonnative_ensemble_directory) for pose in nonnative_ensemble: cgmodel.positions = pose write_ensemble_pdb(cgmodel, ensemble_directory=nonnative_ensemble_directory) if os.path.exists(native_ensemble_directory): native_ensemble, native_ensemble_energies = get_ensemble_data( cgmodel, native_ensemble_directory) if len(native_ensemble_energies) != native_ensemble_size: print("ERROR: " + str(len(native_ensemble_energies)) + " native poses were found in existing output folders, but " + str(native_ensemble_size) + " poses were requested.") print( "This probably means that the requested ensemble size changed since the script was last run." ) exit() else: