예제 #1
0
def extract(ms, target, state_index=0, discard=0):
    """Extract configurations at the target thermodynamic state."""
    # discard starting configuration from trajectory
    trj = extract_trajectory(nc_path=str(ms),
                             to_file=str(target),
                             state_index=state_index,
                             start_frame=discard)
    return trj
예제 #2
0
def extract(ms, target, state_index=0, discard=0):
    """Extract configurations at the target thermodynamic state."""
    # discard starting configuration from trajectory
    discard += 1
    start_frame = ceil(discard / checkpoint_iterations)
    trj = extract_trajectory(nc_path=str(ms),
                             to_file=str(target),
                             state_index=state_index,
                             start_frame=start_frame)
    return trj
예제 #3
0
def extract():
    """Extract configurations at the target thermodynamic state."""
    # discard starting configuration from trajectory
    burnin = burnin_iterations + 1
    start_frame = ceil(burnin / checkpoint_iterations)
    trj = extract_trajectory(nc_path=ms_container,
                             to_file=target_container,
                             state_index=ref_state_index,
                             start_frame=start_frame)
    return trj
예제 #4
0
    def demux(self,
              state_index=None,
              *,
              replica_index=None,
              to_file=None,
              **kwargs):
        """demux trajectories.

        Default: extract configurations for state_index = 0.

        """

        trj_file = Path(to_file) if to_file else Path('trj.nc')
        trj_dir = trj_file.parent.resolve()
        trj_dir.mkdir(parents=True, exist_ok=True)

        if (state_index is None) and (replica_index is None):
            state_index = self.ref_state
        top = kwargs.pop('top', None) or self.topology
        if not top:
            raise ValueError('Need a topology.')
        nc_path = kwargs.pop('nc_path', None) or self.reporter.filepath

        trj = mmdemux.extract_trajectory(ref_system=self.ref_system,
                                         top=top,
                                         nc_path=nc_path,
                                         state_index=state_index,
                                         replica_index=replica_index,
                                         to_file=trj_file,
                                         **kwargs)

        # save a ref pdb for topology
        out_dir = trj_file.parent
        filename = out_dir / 'system.pdb'
        trj[-1].save(str(filename))

        # save a ref pdb for topology
        out_dir = trj_file.parent
        filename = out_dir / 'system.pdb'
        trj[-1].save(str(filename))

        # save system as .xml
        serialized_system = mm.openmm.XmlSerializer.serialize(self.ref_system)
        with open('system.xml', 'w') as fp:
            print(serialized_system, file=fp)

        return trj
예제 #5
0
from mmdemux import extract_trajectory
from mmlite.gromacs import generate_gromacs_input
from mmlite.utils import multistate_reporter_metadata

burnin_iterations = 100  # number of burnin iterations (#iterations)
checkpoint_iterations = 10  # checkpoint_interval (#iterations)

ref_state_index = 0

ms_container = Path('frames/trj.nc')  # trajectory filepath
target_container = Path('frames/trj.0.nc')  # trajectory filepath

burnin_iterations += 1  # discard starting configuration from trajectory

start_frame = ceil(burnin_iterations / checkpoint_iterations)

reference_system, topology = multistate_reporter_metadata(
    ms_container, 'reference_state.system topography.topology'.split())

# save the sampled configurations at the target thermodynamic state
trj = extract_trajectory(nc_path=ms_container,
                         to_file=target_container,
                         state_index=ref_state_index,
                         start_frame=start_frame)

# create gromacs .top and .gro files in the target directory
generate_gromacs_input(target_container,
                       topology=topology,
                       system=reference_system,
                       split='.gro')
예제 #6
0
def test_from_pdb_file():
    kw = dict(kwargs)
    kw['top'] = 'test_repex.pdb'
    trj = extract_trajectory(state_index=0, **kw)
    assert trj.n_frames == 11
예제 #7
0
def test_from_system_file():
    kw = dict(kwargs)
    kw['ref_system'] = 'test_repex.xml'
    trj = extract_trajectory(state_index=0, **kw)
    assert trj.n_frames == 11
예제 #8
0
def test_index_out_of_bounds():
    trj = extract_trajectory(state_index=3, **kwargs)
    assert trj.n_frames == 0
예제 #9
0
def test_replica():
    trj = extract_trajectory(replica_index=0, **kwargs)
    assert trj.n_frames == 11
예제 #10
0
def test_state():
    trj = extract_trajectory(state_index=0, **kwargs)
    assert trj.n_frames == 11