def build_cgmodel(rosetta_scoring):
    # Set values for the parameters in our coarse grained model:
    polymer_length = 2
    backbone_lengths = [1]
    sidechain_lengths = [1]
    sidechain_positions = [0]
    include_bond_forces = False  # NOTE: By default bonds are constrained to their equilibrium lengths, even when this variable is set to False, unless 'constrain_bonds'=False
    constrain_bonds = True
    include_bond_angle_forces = False
    include_nonbonded_forces = True
    include_torsion_forces = False

    # Particle properties
    mass = 100.0 * unit.amu
    masses = {'backbone_bead_masses': mass, 'sidechain_bead_masses': mass}
    bond_length = 1.0 * unit.angstrom
    bond_lengths = {
        'bb_bb_bond_length': bond_length,
        'bb_sc_bond_length': bond_length,
        'sc_sc_bond_length': bond_length
    }
    bond_force_constant = 0.0 * unit.kilocalorie_per_mole / unit.nanometer / unit.nanometer
    bond_force_constants = {
        'bb_bb_bond_k': bond_force_constant,
        'bb_sc_bond_k': bond_force_constant,
        'sc_sc_bond_k': bond_force_constant
    }
    r_min = bond_length
    sigma = r_min / (2.0**(1 / 6))
    sigmas = {'bb_sigma': sigma, 'sc_sigma': sigma}
    epsilon = 0.2 * unit.kilocalorie_per_mole
    epsilons = {'bb_eps': epsilon, 'sc_eps': epsilon}
    exclusions = True

    # Get positions from a local PDB file written by PyRosetta, and modified (by hand) to have a geometry where the nonbonded interactions are easy to evaluate
    cgmodel = CGModel(polymer_length=polymer_length,
                      backbone_lengths=backbone_lengths,
                      sidechain_lengths=sidechain_lengths,
                      sidechain_positions=sidechain_positions,
                      masses=masses,
                      sigmas=sigmas,
                      epsilons=epsilons,
                      bond_lengths=bond_lengths,
                      include_nonbonded_forces=include_nonbonded_forces,
                      include_bond_forces=include_bond_forces,
                      include_bond_angle_forces=include_bond_angle_forces,
                      include_torsion_forces=include_torsion_forces,
                      rosetta_scoring=rosetta_scoring,
                      exclusions=exclusions,
                      constrain_bonds=constrain_bonds)
    pyrosetta_sequence = ''.join([
        str('X[' + str(monomer['monomer_name']) + ']')
        for monomer in cgmodel.sequence
    ])
    pose = pyrosetta.pose_from_sequence(pyrosetta_sequence)
    pose.dump_pdb("test_pyrosetta.pdb")
    cgmodel.positions = PDBFile("test_pyrosetta.pdb").getPositions()
    cgmodel.topology = build_topology(cgmodel)
    return (cgmodel, pose)
Ejemplo n.º 2
0
def build_cgmodel(rosetta_scoring):
    # Set values for the parameters in our coarse grained model:
    polymer_length = 2
    backbone_lengths = [1]
    sidechain_lengths = [0]
    sidechain_positions = [0]
    include_bond_forces = False  # NOTE: By default bonds are constrained to their equilibrium lengths, even when this variable is set to False, unless 'constrain_bonds'=False
    constrain_bonds = False
    include_bond_angle_forces = False
    include_nonbonded_forces = True
    include_torsion_forces = False

    # Particle properties
    mass = 100.0 * unit.amu
    masses = {'backbone_bead_masses': mass, 'sidechain_bead_masses': mass}
    bond_length = 1.0 * unit.angstrom
    bond_lengths = {
        'bb_bb_bond_length': bond_length,
        'bb_sc_bond_length': bond_length,
        'sc_sc_bond_length': bond_length
    }
    bond_force_constant = 0.0 * unit.kilocalorie_per_mole / unit.nanometer / unit.nanometer
    bond_force_constants = {
        'bb_bb_bond_k': bond_force_constant,
        'bb_sc_bond_k': bond_force_constant,
        'sc_sc_bond_k': bond_force_constant
    }
    r_min = bond_length
    sigma = r_min / (2.0**(1 / 6))
    sigmas = {'bb_sigma': sigma, 'sc_sigma': sigma}
    epsilon = 0.2 * unit.kilocalorie_per_mole
    epsilons = {'bb_eps': epsilon, 'sc_eps': epsilon}
    exclusions = False

    # Get positions from a local PDB file written by PyRosetta, and modified (by hand) to have a geometry where the nonbonded interactions are easy to evaluate
    positions = get_positions_from_pdbfile("openmm_init.pdb")

    # Build a coarse grained model
    cgmodel = CGModel(polymer_length=polymer_length,
                      backbone_lengths=backbone_lengths,
                      sidechain_lengths=sidechain_lengths,
                      sidechain_positions=sidechain_positions,
                      masses=masses,
                      sigmas=sigmas,
                      epsilons=epsilons,
                      bond_lengths=bond_lengths,
                      include_nonbonded_forces=include_nonbonded_forces,
                      include_bond_forces=include_bond_forces,
                      include_bond_angle_forces=include_bond_angle_forces,
                      include_torsion_forces=include_torsion_forces,
                      rosetta_scoring=rosetta_scoring,
                      exclusions=exclusions,
                      constrain_bonds=constrain_bonds,
                      positions=positions)

    return (cgmodel)
A_list = []
Pf_list = []
E_list = []
S_list = []
C_list = []

for epsilon in epsilon_list:

 epsilons = {'bb_eps': epsilon,'sc_eps': epsilon}
 output_directory = str(str(output)+"/"+str(round(epsilon._value,2)))
 if not os.path.exists(output_directory):
  os.mkdir(output_directory)
 output_data = str(str(output_directory)+"/output.nc")

 # Build a coarse grained model using the positions for the initial structure
 cgmodel = CGModel(polymer_length=polymer_length,backbone_lengths=backbone_lengths,sidechain_lengths=sidechain_lengths,sidechain_positions=sidechain_positions,masses=masses,sigmas=sigmas,epsilons=epsilons,bond_lengths=bond_lengths,bond_force_constants=bond_force_constants,torsion_force_constants=torsion_force_constants,equil_torsion_angles=equil_torsion_angles,torsion_periodicities=torsion_periodicities,include_nonbonded_forces=include_nonbonded_forces,include_bond_forces=include_bond_forces,include_bond_angle_forces=include_bond_angle_forces,include_torsion_forces=include_torsion_forces,constrain_bonds=constrain_bonds,positions=positions)

 if os.path.exists(output_data):
  # Search for existing data, and read it if possible
  print("Reading replica exchange data")
  replica_energies,replica_positions,replica_states = read_replica_exchange_data(system=cgmodel.system,topology=cgmodel.topology,temperature_list=temperature_list,output_data=output_data,print_frequency=print_frequency)
 else:
  # Run a replica exchange simulation with this cgmodel
  replica_energies,replica_positions,replica_states = run_replica_exchange(cgmodel.topology,cgmodel.system,cgmodel.positions,temperature_list=temperature_list,simulation_time_step=simulation_time_step,total_simulation_time=total_simulation_time,print_frequency=print_frequency,output_data=output_data)
  make_replica_pdb_files(cgmodel.topology,replica_positions)

 native_structure = get_native_structure(replica_positions,replica_energies,temperature_list)

 # Set parameters for definition/evaluation of native contacts
 native_structure_contact_distance_cutoff = 1.05 * cgmodel.get_sigma(0) # This distance cutoff determines which nonbonded interactions are considered 'native' contacts
 native_contact_cutoff_ratio = 1.1 # The distance ratio (in comparison with the distance of a contact in the native structure) below which a nonbonded interaction is considered 'native'
Ejemplo n.º 4
0
 print("Epsilon = " + str(epsilon))
 output_data = str(
     str(top_directory) + '/eps_' + str(round(epsilon._value, 1)) +
     '_sig_' + str(round(sigma._value, 1)) + '.nc')
 sigmas = {
     'bb_bb_sigma': sigma,
     'bb_sc_sigma': sigma,
     'sc_sc_sigma': sigma
 }
 epsilons = {
     'bb_bb_eps': epsilon,
     'bb_sc_eps': epsilon,
     'sc_sc_eps': epsilon
 }
 cgmodel = CGModel(sigmas=sigmas,
                   epsilons=epsilons,
                   bond_lengths=bond_lengths)
 if not os.path.exists(output_data):
     success = False
     while not success:
         try:
             replica_energies, replica_positions, replica_states = run_replica_exchange(
                 cgmodel.topology,
                 cgmodel.system,
                 cgmodel.positions,
                 temperature_list=temperature_list,
                 simulation_time_step=simulation_time_step,
                 total_simulation_time=total_simulation_time,
                 print_frequency=print_frequency,
                 output_data=output_data)
             success = True
Ejemplo n.º 5
0
bond_length = 1.0 * unit.angstrom
bond_lengths = {'bb_bb_bond_length': bond_length,'bb_sc_bond_length': bond_length,'sc_sc_bond_length': bond_length}
bond_force_constant = 0 * unit.kilojoule_per_mole / unit.nanometer / unit.nanometer
bond_force_constants = {'bb_bb_bond_k': bond_force_constant, 'bb_sc_bond_k': bond_force_constant, 'sc_sc_bond_k': bond_force_constant}

epsilon = 0.5 * unit.kilocalorie_per_mole
epsilons = {'bb_bb_eps': epsilon,'sc_sc_eps': epsilon}
sigmas = {'bb_bb_sigma': bond_length,'sc_sc_sigma': bond_length}

bond_angle_force_constant = 9.9e5 * unit.kilojoule_per_mole / unit.radian / unit.radian
bond_angle_force_constants = {'bb_bb_bb_angle_k': bond_angle_force_constant,'bb_bb_sc_angle_k': bond_angle_force_constant}
equil_bond_angle = 120.0*(3.14/180.0)
equil_bond_angles = {'bb_bb_bb_angle_0': equil_bond_angle}

positions = PDBFile("init.pdb").getPositions()
cgmodel = CGModel(polymer_length=polymer_length,backbone_lengths=backbone_lengths,sidechain_lengths=sidechain_lengths,sidechain_positions=sidechain_positions,masses=masses,sigmas=sigmas,epsilons=epsilons,bond_lengths=bond_lengths,bond_force_constants=bond_force_constants,bond_angle_force_constants=bond_angle_force_constants,equil_bond_angles=equil_bond_angles,include_nonbonded_forces=include_nonbonded_forces,include_bond_forces=include_bond_forces,include_bond_angle_forces=include_bond_angle_forces,include_torsion_forces=include_torsion_forces,constrain_bonds=constrain_bonds,positions=positions,exclusions=False)

model_angle_list = cgmodel.bond_angle_list
angle_list = []
for angle in model_angle_list:
  if all([cgmodel.get_particle_type(i) == "backbone" for i in angle]):
    angle_list.append(angle)
bond_angles = []
trajectory = md.load("init.pdb")
for angle in angle_list:
      traj_angles = md.compute_angles(trajectory,[angle])
      for sample in traj_angles:
       bond_angles.append(sample[0])

run_simulation(cgmodel,output_directory,total_simulation_time,simulation_time_step,1.0*unit.kelvin,20,output_pdb="output.pdb",output_data="output.dat")
 for bb_bb_bb_equil_bond_angle in bb_bb_bb_equil_bond_angles:
     print("Performing simulations for a coarse grained model")
     print("with bb_bb_bb bond angles of " +
           str(round(bb_bb_bb_equil_bond_angle * 180.0 / 3.1415, 1)) +
           " degrees")
     equil_bond_angle = 120
     equil_bond_angles = {
         'bb_bb_bb_angle_0': bb_bb_bb_equil_bond_angle,
         'bb_bb_sc_angle_0': equil_bond_angle,
         'bb_sc_sc_angle_0': equil_bond_angle,
         'sc_sc_sc_angle_0': equil_bond_angle,
         'sc_bb_sc_angle_0': equil_bond_angle,
         'sc_sc_bb_angle_0': equil_bond_angle
     }
     cgmodel = CGModel(
         equil_bond_angles=equil_bond_angles,
         bond_angle_force_constants=bond_angle_force_constants,
         include_torsion_forces=False)
     output_data = str(
         str(top_directory) + "/bond_angle_" +
         str(round(bb_bb_bb_equil_bond_angle, 2)) + "_" +
         str(polymer_length) + ".nc")
     if not os.path.exists(output_data):
         success = False
         while not success:
             try:
                 replica_energies, replica_positions, replica_states = run_replica_exchange(
                     cgmodel.topology,
                     cgmodel.system,
                     cgmodel.positions,
                     temperature_list=temperature_list,
                     simulation_time_step=simulation_time_step,
Ejemplo n.º 7
0
}

sigma = 2.5 * bond_length
#sigma_list = [ (1.5 + i*0.1) * bond_length for i in range(grid_size)]
epsilon = 0.05 * unit.kilocalorie_per_mole
sigmas = {'bb_bb_sigma': sigma, 'bb_sc_sigma': sigma, 'sc_sc_sigma': sigma}
epsilons = {'bb_bb_eps': epsilon, 'bb_sc_eps': epsilon, 'sc_sc_eps': epsilon}
cgmodel = CGModel(polymer_length=polymer_length,
                  backbone_lengths=backbone_lengths,
                  sidechain_lengths=sidechain_lengths,
                  sidechain_positions=sidechain_positions,
                  masses=masses,
                  sigmas=sigmas,
                  epsilons=epsilons,
                  bond_lengths=bond_lengths,
                  bond_force_constants=bond_force_constants,
                  bond_angle_force_constants=bond_angle_force_constants,
                  torsion_force_constants=torsion_force_constants,
                  equil_bond_angles=equil_bond_angles,
                  equil_torsion_angles=equil_torsion_angles,
                  include_nonbonded_forces=include_nonbonded_forces,
                  include_bond_forces=include_bond_forces,
                  include_bond_angle_forces=include_bond_angle_forces,
                  include_torsion_forces=include_torsion_forces,
                  constrain_bonds=constrain_bonds)

ensemble = get_ensemble(cgmodel, low_energy=True)
energies = []
index = 1
for pose in ensemble:
    cgmodel.positions = pose
    cgmodel.simulation = build_mm_simulation(cgmodel.topology, cgmodel.system,
Ejemplo n.º 8
0
def build_cgmodel(rosetta_scoring):
    # Set values for the parameters in our coarse grained model:
    polymer_length = 2
    backbone_lengths = [1]
    sidechain_lengths = [1]
    sidechain_positions = [0]
    include_bond_forces = False  # NOTE: By default bonds are constrained to their equilibrium lengths, even when this variable is set to False, unless 'constrain_bonds'=False
    constrain_bonds = True
    include_bond_angle_forces = True
    include_nonbonded_forces = True
    include_torsion_forces = True

    # Particle properties
    mass = 100.0 * unit.amu
    masses = {'backbone_bead_masses': mass, 'sidechain_bead_masses': mass}
    bond_length = 1.0 * unit.angstrom
    bond_lengths = {
        'bb_bb_bond_length': bond_length,
        'bb_sc_bond_length': bond_length,
        'sc_sc_bond_length': bond_length
    }
    bond_force_constant = 0.0 * unit.kilocalorie_per_mole / unit.nanometer / unit.nanometer
    bond_force_constants = {
        'bb_bb_bond_k': bond_force_constant,
        'bb_sc_bond_k': bond_force_constant,
        'sc_sc_bond_k': bond_force_constant
    }
    r_min = bond_length
    sigma = r_min / (2.0**(1 / 6))
    sigmas = {'bb_sigma': sigma, 'sc_sigma': sigma}
    epsilon = 10.0 * unit.kilocalorie_per_mole
    epsilons = {'bb_eps': epsilon, 'sc_eps': epsilon}
    exclusions = True

    # Bond angle properties
    bond_angle_force_constant = 2 * unit.kilocalorie_per_mole / unit.radian / unit.radian
    bond_angle_force_constants = {
        'bb_bb_sc_angle_k': bond_angle_force_constant
    }
    equil_bond_angle = 90.0 * (3.141 / 180.0)
    equil_bond_angles = {'bb_bb_sc_angle_0': equil_bond_angle}

    # Torsion properties
    torsion_force_constant = 3 * unit.kilocalorie_per_mole / unit.radian / unit.radian
    torsion_force_constants = {'sc_bb_bb_sc_torsion_k': torsion_force_constant}
    torsion_periodicity = 1
    torsion_periodicities = {'sc_bb_bb_sc_period': torsion_periodicity}
    equil_torsion_angle = 0.0 * (3.141 / 180.0)
    equil_torsion_angles = {'sc_bb_bb_sc_torsion_0': equil_torsion_angle}

    # Get positions from a local PDB file written by PyRosetta, and modified (by hand) to have a geometry where the nonbonded interactions are easy to evaluate
    cgmodel = CGModel(polymer_length=polymer_length,
                      backbone_lengths=backbone_lengths,
                      sidechain_lengths=sidechain_lengths,
                      sidechain_positions=sidechain_positions,
                      masses=masses,
                      sigmas=sigmas,
                      epsilons=epsilons,
                      bond_lengths=bond_lengths,
                      include_nonbonded_forces=include_nonbonded_forces,
                      include_bond_forces=include_bond_forces,
                      include_bond_angle_forces=include_bond_angle_forces,
                      include_torsion_forces=include_torsion_forces,
                      rosetta_scoring=rosetta_scoring,
                      exclusions=exclusions,
                      constrain_bonds=constrain_bonds,
                      equil_torsion_angles=equil_torsion_angles,
                      torsion_force_constants=torsion_force_constants,
                      torsion_periodicities=torsion_periodicities,
                      equil_bond_angles=equil_bond_angles,
                      bond_angle_force_constants=bond_angle_force_constants)
    pyrosetta_sequence = ''.join([
        str('X[' + str(monomer['monomer_name']) + ']')
        for monomer in cgmodel.sequence
    ])
    res_file_list = list(
        set([
            str(str(monomer['monomer_name']) + ".params")
            for monomer in cgmodel.sequence
        ]))
    res_file_list = " ".join(res_file_list)
    assign_mm_atom_properties_with_cgopenmm_cgmodel(cgmodel)
    exit()
    pose = pyrosetta.pose_from_sequence(pyrosetta_sequence)
    for residue_index in range(pose.total_residue()):
        print(pose.residue(residue_index))
    exit()
    pose.dump_pdb("test_pyrosetta.pdb")
    cgmodel.positions = PDBFile("test_pyrosetta.pdb").getPositions()
    cgmodel.topology = build_topology(cgmodel)
    return (cgmodel, pose)
import os, timeit
import numpy as np
import matplotlib.pyplot as pyplot
from simtk import unit
from simtk.openmm.app.pdbfile import PDBFile
from foldamers.cg_model.cgmodel import CGModel
from foldamers.parameters.secondary_structure import *

positions = PDBFile(str(str(os.getcwd().split('examples')[0])+"ensembles/12_1_1_0/helix.pdb")).getPositions()

cgmodel = CGModel(positions=positions)
pitch,radius,monomers_per_turn,residual = get_helical_parameters(cgmodel)
print(pitch,radius,monomers_per_turn,residual)

cgmodel = orient_along_z_axis(cgmodel)

show_helical_fit(cgmodel)

p2 = calculate_p2(cgmodel)
print(p2)

exit()
  os.mkdir(output_directory)
output_data=str(str(os.getcwd().split('examples')[0])+"examples/homopolymer_heat_capacity_varying_simulation_time/output/output5.0.nc")

# OpenMM simulation settings
print_frequency = 5 # Number of steps to skip when printing output
total_simulation_time = 15.0 * unit.nanosecond # Units = picoseconds
simulation_time_step = 5.0 * unit.femtosecond
total_steps = round(total_simulation_time.__div__(simulation_time_step))

# Yank (replica exchange) simulation settings
number_replicas = 30
min_temp = 5.0 * unit.kelvin
max_temp = 100.0 * unit.kelvin
temperature_list = get_temperature_list(min_temp,max_temp,number_replicas)

cgmodel = CGModel()

if not os.path.exists(output_data):
     replica_energies,replica_positions,replica_states = run_replica_exchange(cgmodel.topology,cgmodel.system,cgmodel.positions,temperature_list=temperature_list,simulation_time_step=simulation_time_step,total_simulation_time=total_simulation_time,print_frequency=print_frequency,output_data=output_data)
else:
     print("Reading simulation data.")
     replica_energies,replica_positions,replica_states = read_replica_exchange_data(system=cgmodel.system,topology=cgmodel.topology,temperature_list=temperature_list,output_data=output_data,print_frequency=print_frequency)

configurations,energies = get_decorrelated_samples(replica_positions,replica_energies,temperature_list)

max_num_samples = 0
for traj in configurations:
  if len(traj) > max_num_samples:
    max_num_samples = len(traj)

pitch_kn = np.zeros((len(configurations),max_num_samples))
Ejemplo n.º 11
0
    'epsilons': epsilons,
    'sigmas': sigmas
}

monomer_types = [A, B]

sequence = [A, A, A, B, A, A, A, B, A, A, A, B]
polymer_length = len(sequence)

cgmodel = CGModel(polymer_length=polymer_length,
                  bond_force_constants=bond_force_constants,
                  bond_angle_force_constants=bond_angle_force_constants,
                  torsion_force_constants=torsion_force_constants,
                  equil_bond_angles=equil_bond_angles,
                  equil_torsion_angles=equil_torsion_angles,
                  include_nonbonded_forces=include_nonbonded_forces,
                  include_bond_forces=include_bond_forces,
                  include_bond_angle_forces=include_bond_angle_forces,
                  include_torsion_forces=include_torsion_forces,
                  constrain_bonds=constrain_bonds,
                  heteropolymer=True,
                  monomer_types=monomer_types,
                  sequence=sequence)

if not os.path.exists(output_data):
    replica_energies, replica_positions, replica_states = run_replica_exchange(
        cgmodel.topology,
        cgmodel.system,
        cgmodel.positions,
        temperature_list=temperature_list,
        simulation_time_step=simulation_time_step,
        total_simulation_time=total_simulation_time,
Ejemplo n.º 12
0
    os.mkdir(top_directory)

# OpenMM simulation settings
print_frequency = 20  # Number of steps to skip when printing output
total_simulation_time = 1.0 * unit.nanosecond  # Units = picoseconds
simulation_time_step = 5.0 * unit.femtosecond
total_steps = round(total_simulation_time.__div__(simulation_time_step))

# Yank (replica exchange) simulation settings
number_replicas = 10
min_temp = 10.0 * unit.kelvin
max_temp = 50.0 * unit.kelvin
temperature_list = get_temperature_list(min_temp, max_temp, number_replicas)
print("Using " + str(len(temperature_list)) + " replicas.")

cgmodel = CGModel()
output_data = str(str(top_directory) + "/output.nc")

if not os.path.exists(output_data):
    replica_energies, replica_positions, replica_states = run_replica_exchange(
        cgmodel.topology,
        cgmodel.system,
        cgmodel.positions,
        temperature_list=temperature_list,
        simulation_time_step=simulation_time_step,
        total_simulation_time=total_simulation_time,
        print_frequency=print_frequency,
        output_data=output_data)
else:
    replica_energies, replica_positions, replica_states = read_replica_exchange_data(
        system=cgmodel.system,
Ejemplo n.º 13
0
    for i in range(sigma_increments)
]

df_ij_list = []
ddf_ij_list = []
Delta_u_list = []
dDelta_u_list = []
Delta_s_list = []
dDelta_s_list = []
C_v_list = []
dC_v_list = []

for sigma in sigma_list:
    output_data = str(str(top_directory) + "/rep_ex_" + str(sigma) + ".nc")
    sigmas = {'bb_bb_sigma': sigma, 'bb_sc_sigma': sigma, 'sc_sc_sigma': sigma}
    cgmodel = CGModel(sigmas=sigmas)
    if not os.path.exists(output_data):
        print(
            "Performing simulations and free energy analysis for a coarse grained model"
        )
        print("with sigma values of " + str(sigma))
        replica_energies, replica_positions, replica_states = run_replica_exchange(
            cgmodel.topology,
            cgmodel.system,
            cgmodel.positions,
            temperature_list=temperature_list,
            simulation_time_step=simulation_time_step,
            total_simulation_time=total_simulation_time,
            print_frequency=print_frequency,
            output_data=output_data)
        steps_per_stage = round(total_steps / exchange_attempts)
Ejemplo n.º 14
0
# OpenMM simulation settings
print_frequency = 20  # Number of steps to skip when printing output
total_simulation_time = 5.0 * unit.nanosecond  # Units = picoseconds
simulation_time_step = 5.0 * unit.femtosecond
total_steps = round(total_simulation_time.__div__(simulation_time_step))

# Yank (replica exchange) simulation settings
output_data = str(str(top_directory) + "/output.nc")
number_replicas = 30
min_temp = 10.0 * unit.kelvin
max_temp = 200.0 * unit.kelvin
temperature_list = get_temperature_list(min_temp, max_temp, number_replicas)
print("Using " + str(len(temperature_list)) + " replicas.")

cgmodel = CGModel()
model_torsion_list = cgmodel.torsion_list

torsion_list = []
for torsion in model_torsion_list:
    if all([cgmodel.get_particle_type(i) == "backbone" for i in torsion]):
        torsion_list.append(torsion)

torsions_list = []
bin_counts_list = []

torsion_force_constant_list = [0.001 * 10**i for i in range(grid_size)]
for constant in torsion_force_constant_list:
    torsion_force_constants = {'bb_bb_bb_bb_torsion_k': constant}
    cgmodel = CGModel(torsion_force_constants=torsion_force_constants)
Ejemplo n.º 15
0
bond_lengths = {'bb_bb_bond_length': bond_length,'bb_sc_bond_length': bond_length,'sc_sc_bond_length': bond_length}

C_v_list = []
dC_v_list = []
folding_T_list = []

sigma_list = [ (2.5 + i*0.1) * bond_length for i in range(grid_size)]
epsilon_list = [ unit.Quantity((0.05 + i*0.025),unit.kilocalorie_per_mole) for i in range(grid_size)]
for sigma in sigma_list:
 for epsilon in epsilon_list:
  print("Sigma = "+str(sigma))
  print("Epsilon = "+str(epsilon))
  output_data = str(str(top_directory)+'/eps_'+str(round(epsilon._value,1))+'_sig_'+str(round(sigma._value,1))+'.nc')
  sigmas = {'bb_bb_sigma': sigma,'bb_sc_sigma': sigma,'sc_sc_sigma': sigma}
  epsilons = {'bb_bb_eps': epsilon,'bb_sc_eps': epsilon,'sc_sc_eps': epsilon}
  cgmodel = CGModel(sigmas=sigmas,epsilons=epsilons,bond_lengths=bond_lengths)
  if not os.path.exists(output_data):
     replica_energies,replica_positions,replica_states = run_replica_exchange(cgmodel.topology,cgmodel.system,cgmodel.positions,temperature_list=temperature_list,simulation_time_step=simulation_time_step,total_simulation_time=total_simulation_time,print_frequency=print_frequency,output_data=output_data)
     minimum_energy_structure = get_minimum_energy_pose(cgmodel.topology,replica_energies,replica_positions)
  else:
     replica_energies,replica_positions,replica_states = read_replica_exchange_data(system=cgmodel.system,topology=cgmodel.topology,temperature_list=temperature_list,output_data=output_data,print_frequency=print_frequency)

  C_v,dC_v,new_temperature_list = get_heat_capacity(replica_energies,temperature_list,num_intermediate_states=1)
  C_v_list.append(C_v)
  dC_v_list.append(dC_v)
  folding_T_list.append(new_temperature_list[np.argmax(np.array([float(i) for i in C_v]))])

file_name = str(str(top_directory)+"/folding_T_eps_sig.png")
figure = pyplot.figure(1)
temperature_list = np.array([temperature for temperature in new_temperature_list])
x = np.unique([sigma.in_units_of(unit.nanometer)._value for sigma in sigma_list])
Ejemplo n.º 16
0
# OpenMM simulation settings
print_frequency = 20  # Number of steps to skip when printing output
total_simulation_time = 0.5 * unit.nanosecond  # Units = picoseconds
simulation_time_step = 5.0 * unit.femtosecond
total_steps = round(total_simulation_time.__div__(simulation_time_step))

# Yank (replica exchange) simulation settings
output_data = str(str(top_directory) + "/output.nc")
number_replicas = 30
min_temp = 10.0 * unit.kelvin
max_temp = 200.0 * unit.kelvin
temperature_list = get_temperature_list(min_temp, max_temp, number_replicas)
print("Using " + str(len(temperature_list)) + " replicas.")

cgmodel = CGModel(positions=native_structure)
model_angle_list = cgmodel.bond_angle_list

angle_list = []
for angle in model_angle_list:
    if all([cgmodel.get_particle_type(i) == "backbone" for i in angle]):
        angle_list.append(angle)

bond_angle_list = []
bin_counts_list = []

bond_angle_force_constant_list = [
    unit.Quantity((0.001 * 10**i),
                  unit.kilocalorie_per_mole / unit.radian / unit.radian)
    for i in range(grid_size)
]
def build_cgmodel():
    # Set values for the parameters in our coarse grained model:
    polymer_length = 3
    backbone_lengths = [1]
    sidechain_lengths = [1]
    sidechain_positions = [0]
    include_bond_forces = False  # NOTE: Bonds are constrained to their equilibrium lengths, by default, even when this variable is set to False.
    include_bond_angle_forces = False
    include_nonbonded_forces = True
    include_torsion_forces = False
    rosetta_scoring = True

    # Particle properties
    mass = 100.0 * unit.amu
    masses = {'backbone_bead_masses': mass, 'sidechain_bead_masses': mass}
    bond_length = 1.0 * unit.angstrom
    bond_lengths = {
        'bb_bb_bond_length': bond_length,
        'bb_sc_bond_length': bond_length,
        'sc_sc_bond_length': bond_length
    }
    bond_force_constant = 0.0 * unit.kilocalorie_per_mole / unit.nanometer / unit.nanometer
    bond_force_constants = {
        'bb_bb_bond_k': bond_force_constant,
        'bb_sc_bond_k': bond_force_constant,
        'sc_sc_bond_k': bond_force_constant
    }
    r_min = bond_length
    sigma = r_min / (2.0**(1 / 6))
    sigmas = {'bb_bb_sigma': sigma, 'sc_sc_sigma': sigma}
    epsilon = 0.2 * unit.kilocalorie_per_mole
    epsilons = {'bb_bb_eps': epsilon, 'sc_sc_eps': epsilon}
    # Bond angle properties
    bond_angle_force_constant = 2 * unit.kilocalorie_per_mole / unit.radian / unit.radian
    bond_angle_force_constants = {
        'bb_bb_bb_angle_k': bond_angle_force_constant,
        'bb_bb_sc_angle_k': bond_angle_force_constant
    }
    equil_bond_angle = 120.0 * (3.141 / 180.0)
    equil_bond_angles = {
        'bb_bb_bb_angle_0': equil_bond_angle,
        'bb_bb_sc_angle_0': equil_bond_angle
    }
    # Torsion properties
    torsion_force_constant = 3
    torsion_force_constants = {
        'bb_bb_bb_bb_torsion_k': torsion_force_constant,
        'sc_bb_bb_sc_torsion_k': 0.0,
        'bb_bb_bb_sc_torsion_k': 0.0,
        'sc_bb_bb_bb_torsion_k': 0.0
    }
    torsion_periodicity = 3
    torsion_periodicities = {
        'bb_bb_bb_bb_period': torsion_periodicity,
        'sc_bb_bb_sc_period': 0,
        'bb_bb_bb_sc_period': 0,
        'sc_bb_bb_bb_period': 0
    }
    equil_torsion_angle = 0.0 * (3.141 / 180.0)
    equil_torsion_angles = {
        'bb_bb_bb_bb_torsion_0': equil_torsion_angle,
        'sc_bb_bb_sc_torsion_0': 0.0,
        'bb_bb_bb_sc_torsion_0': 0.0,
        'sc_bb_bb_bb_torsion_0': 0.0
    }

    # Build a coarse grained model
    cgmodel = CGModel(polymer_length=polymer_length,
                      backbone_lengths=backbone_lengths,
                      sidechain_lengths=sidechain_lengths,
                      sidechain_positions=sidechain_positions,
                      masses=masses,
                      sigmas=sigmas,
                      epsilons=epsilons,
                      bond_lengths=bond_lengths,
                      bond_force_constants=bond_force_constants,
                      bond_angle_force_constants=bond_angle_force_constants,
                      torsion_force_constants=torsion_force_constants,
                      equil_bond_angles=equil_bond_angles,
                      equil_torsion_angles=equil_torsion_angles,
                      include_nonbonded_forces=include_nonbonded_forces,
                      include_bond_forces=include_bond_forces,
                      include_bond_angle_forces=include_bond_angle_forces,
                      include_torsion_forces=include_torsion_forces,
                      rosetta_scoring=rosetta_scoring,
                      torsion_periodicities=torsion_periodicities)

    # Get positions by building a pose with PyRosetta
    pyrosetta_sequence = ''.join([
        str('X[' + str(monomer['monomer_name']) + ']')
        for monomer in cgmodel.sequence
    ])
    pose = pyrosetta.pose_from_sequence(pyrosetta_sequence)
    pose.dump_pdb("init.pdb")
    cgmodel.positions = PDBFile("init.pdb").getPositions()
    cgmodel.topology = build_topology(cgmodel)

    return (cgmodel)
Ejemplo n.º 18
0
# Get initial positions from local file
positions = PDBFile("helix.pdb").getPositions()

# Build a coarse grained model
cgmodel = CGModel(
    polymer_length=polymer_length,
    backbone_lengths=backbone_lengths,
    sidechain_lengths=sidechain_lengths,
    sidechain_positions=sidechain_positions,
    masses=masses,
    sigmas=sigmas,
    epsilons=epsilons,
    bond_lengths=bond_lengths,
    bond_force_constants=bond_force_constants,
    bond_angle_force_constants=bond_angle_force_constants,
    torsion_force_constants=torsion_force_constants,
    equil_bond_angles=equil_bond_angles,
    equil_torsion_angles=equil_torsion_angles,
    torsion_periodicities=torsion_periodicities,
    include_nonbonded_forces=include_nonbonded_forces,
    include_bond_forces=include_bond_forces,
    include_bond_angle_forces=include_bond_angle_forces,
    include_torsion_forces=include_torsion_forces,
    constrain_bonds=constrain_bonds,
    positions=positions,
)

# Run replica exchange simulations *if* there is not existing data in 'output_directory'.
# If there is data in 'output_directory', read that data instead.
if not os.path.exists(output_data) or overwrite_files == True:
    replica_energies, replica_positions, replica_states = run_replica_exchange(
Ejemplo n.º 19
0
print_frequency = 5 # Number of steps to skip when printing output
total_simulation_time = 2.0 * unit.nanosecond # Units = picoseconds
simulation_time_step = 5.0 * unit.femtosecond
total_steps = round(total_simulation_time.__div__(simulation_time_step))

# Yank (replica exchange) simulation settings
output_data=str(str(top_directory)+"/output.nc")
number_replicas = 20
min_temp = 50.0 * unit.kelvin
max_temp = 300.0 * unit.kelvin
temperature_list = get_temperature_list(min_temp,max_temp,number_replicas)
print("Using "+str(len(temperature_list))+" replicas.")
if total_steps > 10000:
   exchange_attempts = round(total_steps/1000)
else:
   exchange_attempts = 10

cgmodel = CGModel()

if not os.path.exists(output_data):
  replica_energies,replica_positions,replica_states = run_replica_exchange(cgmodel.topology,cgmodel.system,cgmodel.positions,temperature_list=temperature_list,simulation_time_step=simulation_time_step,total_simulation_time=total_simulation_time,print_frequency=print_frequency,output_data=output_data)
  make_replica_pdb_files(cgmodel.topology,replica_positions)
else:
  replica_energies,replica_positions,replica_states = read_replica_exchange_data(system=cgmodel.system,topology=cgmodel.topology,temperature_list=temperature_list,output_data=output_data,print_frequency=print_frequency)

C_v,dC_v,new_temperature_list = get_heat_capacity(replica_energies,temperature_list,num_intermediate_states=1)

calculate_C_v_fitness(C_v,new_temperature_list)

exit()