Ejemplo n.º 1
0
sams_sampler.verbose = True

# DEBUG: Write PDB of initial frame
print("Writing initial frame to 'initial.pdb'...")
from simtk.openmm.app import PDBFile
outfile = open('initial.pdb', 'w')
PDBFile.writeFile(topology, positions, outfile)
outfile.close()

# Run the simulation
print('Running simulation...')
#exen_sampler.update_scheme = 'restricted-range' # scheme for deciding which alchemical state to jump to
exen_sampler.update_scheme = 'global-jump' # scheme for deciding which alchemical state to jump to
#exen_sampler.locality = thermodynamic_state_neighbors # neighbors to examine for each state
sams_sampler.update_method = 'rao-blackwellized' # scheme for updating free energy estimates
niterations = 20000 # number of iterations to run
sams_sampler.run(niterations) # run sampler
ncfile.close()

# Analyze
from sams import analysis
# States
from collections import namedtuple
MockTestsystem = namedtuple('MockTestsystem', ['description', 'thermodynamic_states'])
testsystem = MockTestsystem(description='DDR1 umbrella states', thermodynamic_states=thermodynamic_states)
analysis.analyze(netcdf_filename, testsystem, 'output.pdf')
# Write trajectory
reference_pdb_filename = 'trajectory.pdb'
trajectory_filename = 'trajectory.xtc'
analysis.write_trajectory(netcdf_filename, topology, reference_pdb_filename, trajectory_filename)
Ejemplo n.º 2
0
sams_sampler.verbose = True

# DEBUG: Write PDB of initial frame
print("Writing initial frame to 'initial.pdb'...")
from simtk.openmm.app import PDBFile
outfile = open('initial.pdb', 'w')
PDBFile.writeFile(topology, positions, outfile)
outfile.close()

# Run the simulation
print('Running simulation...')
#exen_sampler.update_scheme = 'restricted-range' # scheme for deciding which alchemical state to jump to
exen_sampler.update_scheme = 'global-jump' # scheme for deciding which alchemical state to jump to
#exen_sampler.locality = thermodynamic_state_neighbors # neighbors to examine for each state
sams_sampler.update_method = 'rao-blackwellized' # scheme for updating free energy estimates
niterations = 20000 # number of iterations to run
sams_sampler.run(niterations) # run sampler
ncfile.close()

# Analyze
from sams import analysis
# States
from collections import namedtuple
MockTestsystem = namedtuple('MockTestsystem', ['description', 'thermodynamic_states'])
testsystem = MockTestsystem(description='DDR1 umbrella states', thermodynamic_states=thermodynamic_states)
analysis.analyze(netcdf_filename, testsystem, 'output.pdf')
# Write trajectory
reference_pdb_filename = 'trajectory.pdb'
trajectory_filename = 'trajectory.xtc'
analysis.write_trajectory(netcdf_filename, topology, reference_pdb_filename, trajectory_filename)
# Create thermodynamic states
thermodynamic_states = list()

# Umbrella off state
parameters = {
    'umbrella1_K' : 0.0, 'umbrella1_r0' : 0.0, # umbrella parameters
    'umbrella2_K' : 0.0, 'umbrella2_r0' : 0.0, # umbrella parameters
}
thermodynamic_states.append( ThermodynamicState(system=system, temperature=temperature, pressure=pressure, parameters=parameters) )

# Umbrella on state
alchemical_lambda = 0.0
for umbrella1_distance in umbrella_distances:
    for umbrella2_distance in umbrella_distances:
        parameters = {
            'umbrella1_K' : umbrella_K.value_in_unit_system(unit.md_unit_system), 'umbrella1_r0' : umbrella1_distance.value_in_unit_system(unit.md_unit_system), # umbrella parameters
            'umbrella2_K' : umbrella_K.value_in_unit_system(unit.md_unit_system), 'umbrella2_r0' : umbrella2_distance.value_in_unit_system(unit.md_unit_system), # umbrella parameters
            }
        thermodynamic_states.append( ThermodynamicState(system=system, temperature=temperature, pressure=pressure, parameters=parameters) )

# Analyze
from sams import analysis
# States
from collections import namedtuple
MockTestsystem = namedtuple('MockTestsystem', ['description', 'thermodynamic_states'])
testsystem = MockTestsystem(description='DDR1 umbrella states', thermodynamic_states=thermodynamic_states)
analysis.analyze(netcdf_filename, testsystem, '2d-distance-output.pdf')
# Write trajectory
analysis.write_trajectory(netcdf_filename, topology, pdb_trajectory_filename, xtc_trajectory_filename)
Ejemplo n.º 4
0
    #pdb_filename = resource_filename('sams', os.path.join('data', 'abl-imatinib', 'inhibitor.pdb'))
    #generate_ffxml(pdb_filename)
    #stop

    netcdf_filename = 'output2.nc'

    #testsystem = HarmonicOscillatorSimulatedTempering(netcdf_filename=netcdf_filename)
    #testsystem = AblImatinibVacuumAlchemical(netcdf_filename=netcdf_filename)
    testsystem = AblImatinibExplicitAlchemical(netcdf_filename=netcdf_filename)
    #testsystem = HostGuestAlchemical(netcdf_filename=netcdf_filename)
    #testsystem = AlanineDipeptideExplicitAlchemical()
    #testsystem = AlanineDipeptideVacuumSimulatedTempering(netcdf_filename=netcdf_filename)
    #testsystem = AlanineDipeptideExplicitSimulatedTempering(netcdf_filename=netcdf_filename)
    #testsystem = WaterBoxAlchemical(netcdf_filename=netcdf_filename)

    testsystem.exen_sampler.update_scheme = 'restricted-range'
    testsystem.mcmc_sampler.nsteps = 2500
    testsystem.exen_sampler.locality = 5
    testsystem.sams_sampler.update_method = 'rao-blackwellized'
    niterations = 5000
    #testsystem.sams_sampler.run(niterations)

    # Test analysis
    from sams.analysis import analyze, write_trajectory
    netcdf_filename = 'output.nc'
    analyze(netcdf_filename, testsystem, 'analyze.pdf')
    reference_pdb_filename = 'output.pdb'
    dcd_trajectory_filename = 'output.dcd'
    trajectory_filename = 'output.xtc'
    write_trajectory(netcdf_filename, testsystem.topology, reference_pdb_filename, trajectory_filename)
Ejemplo n.º 5
0
        parameters = {
            'umbrella1_K':
            umbrella_K.value_in_unit_system(unit.md_unit_system),
            'umbrella1_r0':
            umbrella1_distance.value_in_unit_system(
                unit.md_unit_system),  # umbrella parameters
            'umbrella2_K':
            umbrella_K.value_in_unit_system(unit.md_unit_system),
            'umbrella2_r0':
            umbrella2_distance.value_in_unit_system(
                unit.md_unit_system),  # umbrella parameters
        }
        thermodynamic_states.append(
            ThermodynamicState(system=system,
                               temperature=temperature,
                               pressure=pressure,
                               parameters=parameters))

# Analyze
from sams import analysis
# States
from collections import namedtuple
MockTestsystem = namedtuple('MockTestsystem',
                            ['description', 'thermodynamic_states'])
testsystem = MockTestsystem(description='DDR1 umbrella states',
                            thermodynamic_states=thermodynamic_states)
analysis.analyze(netcdf_filename, testsystem, '2d-distance-output.pdf')
# Write trajectory
analysis.write_trajectory(netcdf_filename, topology, pdb_trajectory_filename,
                          xtc_trajectory_filename)
Ejemplo n.º 6
0
    #generate_ffxml(pdb_filename)
    #stop

    netcdf_filename = 'output2.nc'

    #testsystem = HarmonicOscillatorSimulatedTempering(netcdf_filename=netcdf_filename)
    #testsystem = AblImatinibVacuumAlchemical(netcdf_filename=netcdf_filename)
    testsystem = AblImatinibExplicitAlchemical(netcdf_filename=netcdf_filename)
    #testsystem = HostGuestAlchemical(netcdf_filename=netcdf_filename)
    #testsystem = AlanineDipeptideExplicitAlchemical()
    #testsystem = AlanineDipeptideVacuumSimulatedTempering(netcdf_filename=netcdf_filename)
    #testsystem = AlanineDipeptideExplicitSimulatedTempering(netcdf_filename=netcdf_filename)
    #testsystem = WaterBoxAlchemical(netcdf_filename=netcdf_filename)

    testsystem.exen_sampler.update_scheme = 'restricted-range'
    testsystem.mcmc_sampler.nsteps = 2500
    testsystem.exen_sampler.locality = 5
    testsystem.sams_sampler.update_method = 'rao-blackwellized'
    niterations = 5000
    #testsystem.sams_sampler.run(niterations)

    # Test analysis
    from sams.analysis import analyze, write_trajectory
    netcdf_filename = 'output.nc'
    analyze(netcdf_filename, testsystem, 'analyze.pdf')
    reference_pdb_filename = 'output.pdb'
    dcd_trajectory_filename = 'output.dcd'
    trajectory_filename = 'output.xtc'
    write_trajectory(netcdf_filename, testsystem.topology,
                     reference_pdb_filename, trajectory_filename)