Example #1
0
def test_FahProjectBuilder_subset():
    cd = os.getcwd()
    
    native_filename = get("native.pdb", just_filename=True)
    frames_per_gen = 10
    
    traj = md.load(native_filename)
    
    fah_path = tempfile.mkdtemp()
    msmb_path = tempfile.mkdtemp()
    
    run_clone_gen = {(0, 0):5, (0, 1):6, (0, 2):7, (1, 0):20}
    reference_traj_lengths = np.array([5, 6, 7, 20]) * frames_per_gen
    
    atom_indices = np.arange(5)

    ref = reference_data.FAHReferenceData(traj, fah_path, run_clone_gen, frames_per_gen)
    
    os.chdir(msmb_path)
    
    new_native_filename = msmb_path + "/" + os.path.split(native_filename)[1]
    shutil.copy(native_filename, new_native_filename)  # Necessary on travis because we lack write permission in native.pdb directory
    
    pb = FahProjectBuilder(fah_path, '.xtc', new_native_filename, atom_indices=atom_indices)
    project = pb.get_project()
    
    new_traj = project.load_conf()
    
    eq(new_traj.n_atoms, 5)
    eq(project.traj_lengths, reference_traj_lengths)
    
    os.chdir(cd)
    shutil.rmtree(fah_path)
    shutil.rmtree(msmb_path)
Example #2
0
def test_FahProjectBuilder_new1():
    cd = os.getcwd()

    native_filename = get("native.pdb", just_filename=True)
    frames_per_gen = 10

    traj = md.load(native_filename)

    fah_path = tempfile.mkdtemp()
    msmb_path = tempfile.mkdtemp()

    run_clone_gen = {(0, 0): 5, (0, 1): 6, (0, 2): 7, (1, 0): 20}
    reference_traj_lengths = np.array([5, 6, 7, 20]) * frames_per_gen

    ref = reference_data.FAHReferenceData(traj, fah_path, run_clone_gen,
                                          frames_per_gen)

    os.chdir(msmb_path)

    pb = FahProjectBuilder(fah_path, '.xtc', native_filename)
    project = pb.get_project()

    eq(project.conf_filename, native_filename)
    eq(project.traj_lengths, reference_traj_lengths)

    os.chdir(cd)
    shutil.rmtree(fah_path)
    shutil.rmtree(msmb_path)
Example #3
0
def test_FahProjectBuilder_new1():
    cd = os.getcwd()
    
    native_filename = get("native.pdb", just_filename=True)
    frames_per_gen = 10
    
    traj = md.load(native_filename)
    
    fah_path = tempfile.mkdtemp()
    msmb_path = tempfile.mkdtemp()
    
    run_clone_gen = {(0, 0):5, (0, 1):6, (0, 2):7, (1, 0):20}
    reference_traj_lengths = np.array([5, 6, 7, 20]) * frames_per_gen

    ref = reference_data.FAHReferenceData(traj, fah_path, run_clone_gen, frames_per_gen)
    
    os.chdir(msmb_path)
    
    pb = FahProjectBuilder(fah_path, '.xtc', native_filename)
    project = pb.get_project()
    
    eq(project.conf_filename, native_filename)
    eq(project.traj_lengths, reference_traj_lengths)
    
    os.chdir(cd)
    shutil.rmtree(fah_path)
    shutil.rmtree(msmb_path)
Example #4
0
def test_FahProjectBuilder():
    cd = os.getcwd()
    td = tempfile.mkdtemp()
    os.chdir(td)

    traj_dir = get("project_reference/project.builder/fah_style_data", just_filename=True)
    conf_filename = os.path.join(traj_dir, 'native.pdb')
    
    pb = FahProjectBuilder(traj_dir, '.xtc', conf_filename)
    project = pb.get_project()
    eq_(project.n_trajs, 4)
    npt.assert_array_equal(project.traj_lengths, [1001, 1001, 501, 1001])
    os.chdir(cd)    
    shutil.rmtree(td)
Example #5
0
def test_FahProjectBuilder():
    cd = os.getcwd()
    td = tempfile.mkdtemp()
    os.chdir(td)

    traj_dir = os.path.join(reference_dir(), 
        "project_reference/project.builder/fah_style_data")
    conf_filename = os.path.join(traj_dir, 'native.pdb')
    
    pb = FahProjectBuilder(traj_dir, '.xtc', conf_filename)
    project = pb.get_project()
    eq_(project.n_trajs, 4)
    npt.assert_array_equal(project.traj_lengths, [1001, 1001, 501, 1001])
    os.chdir(cd)    
    shutil.rmtree(td)
Example #6
0
def run(projectfn, PDBfn, InputDir, source, min_length, stride, rmsd_cutoff):

    # check if we are doing an update or a fresh run
    if os.path.exists(projectfn):
        logger.info(
            "Found project info file encoding previous work, running in update mode..."
        )
        update = True
    else:
        update = False

    logger.info("Looking for %s stype data in %s", source, InputDir)
    if update:
        raise NotImplementedError("Ack! Update mode is not yet ready yet.")

    # if the source is fah, we'll use some special FaH specific loading functions
    # to (1) try to recover in case of errors and (2) load the specific directory
    # hierarchy of FaH (RUN/CLONE/GEN/frame.xtc)
    if source.startswith('file'):
        itype = '.dcd' if 'dcd' in source else '.xtc'
        pb = ProjectBuilder(InputDir,
                            input_traj_ext=itype,
                            conf_filename=PDBfn,
                            stride=stride)
    elif source == 'fah':
        pb = FahProjectBuilder(InputDir,
                               input_traj_ext='.xtc',
                               conf_filename=PDBfn,
                               stride=stride)
    else:
        raise ValueError("Invalid argument for source: %s" % source)

    # check that trajectories to not go farther than a certain RMSD
    # from the PDB. Useful to check for blowing up or other numerical instabilities
    if rmsd_cutoff is not None:
        # TODO: this is going to use ALL of the atom_indices, including hydrogen. This is
        # probably not the desired functionality
        validator = validators.RMSDExplosionValidator(PDBfn,
                                                      max_rmsd=rmsd_cutoff,
                                                      atom_indices=None)
        pb.add_validator(validator)

    # Only accept trajectories with more snapshots than min_length.
    if min_length > 0:
        validator = validators.MinLengthValidator(min_length)
        pb.add_validator(validator)

    # everyone wants to be centered
    pb.add_validator(validators.TrajCenterer())

    pb.get_project().save(projectfn)
    assert os.path.exists(projectfn), '%s does not exist' % projectfn
    logger.info("Finished data conversion successfully.")
    logger.info("Generated: %s, Trajectories/", projectfn)

    return
Example #7
0
def test_FahProjectBuilder_subset():
    cd = os.getcwd()

    native_filename = get("native.pdb", just_filename=True)
    frames_per_gen = 10

    traj = md.load(native_filename)

    fah_path = tempfile.mkdtemp()
    msmb_path = tempfile.mkdtemp()

    run_clone_gen = {(0, 0): 5, (0, 1): 6, (0, 2): 7, (1, 0): 20}
    reference_traj_lengths = np.array([5, 6, 7, 20]) * frames_per_gen

    atom_indices = np.arange(5)

    ref = reference_data.FAHReferenceData(traj, fah_path, run_clone_gen,
                                          frames_per_gen)

    os.chdir(msmb_path)

    new_native_filename = msmb_path + "/" + os.path.split(native_filename)[1]
    shutil.copy(
        native_filename, new_native_filename
    )  # Necessary on travis because we lack write permission in native.pdb directory

    pb = FahProjectBuilder(fah_path,
                           '.xtc',
                           new_native_filename,
                           atom_indices=atom_indices)
    project = pb.get_project()

    new_traj = project.load_conf()

    eq(new_traj.n_atoms, 5)
    eq(project.traj_lengths, reference_traj_lengths)

    os.chdir(cd)
    shutil.rmtree(fah_path)
    shutil.rmtree(msmb_path)
def test_FahProjectBuilder2():
    cd = os.getcwd()
    td = tempfile.mkdtemp()
    os.chdir(td)

    # check that we can build a new project:
    traj_dir = get("project_reference/project.builder/fah_style_data", just_filename=True)
    conv_traj_dir = get("project_reference/project.builder/Trajectories", just_filename=True)
    shutil.copytree(traj_dir, 'PROJXXXX')
    shutil.copytree(conv_traj_dir, 'Trajectories')
    shutil.copy2(get("project_reference/project.builder/ProjectInfo.yaml", just_filename=True), 'ProjectInfo.yaml')
    project_orig = Project.load_from('ProjectInfo.yaml')
    # made up project data

    pb = FahProjectBuilder('PROJXXXX', '.xtc', 'PROJXXXX/native.pdb', project=project_orig)
    project = pb.get_project()
    project_ref = get("project_reference/project.builder/ProjectInfo_final.yaml")

    assert project == project_ref

    os.chdir(cd)
    shutil.rmtree(td)
def test_FahProjectBuilder1():
    cd = os.getcwd()
    td = tempfile.mkdtemp()
    os.chdir(td)

    # check that we can build a new project:
    traj_dir = get("project_reference/project.builder/fah_style_data", just_filename=True)

    shutil.copytree(traj_dir, 'PROJXXXX')
    shutil.rmtree('PROJXXXX/RUN0/CLONE1')
    os.remove('PROJXXXX/RUN2/CLONE0/frame2.xtc')
    # made up project data

    pb = FahProjectBuilder('PROJXXXX', '.xtc', 'PROJXXXX/native.pdb')
    project = pb.get_project()
    project_ref = get("project_reference/project.builder/ProjectInfo.yaml")

    print project == project_ref
    assert project == project_ref

    os.chdir(cd)
    shutil.rmtree(td)
Example #10
0
from msmbuilder.project import FahProjectBuilder

pb = FahProjectBuilder('./fah_style_data', '.xtc',
                       './fah_style_data/native.pdb')
p = pb.convert()
print p
def run(projectfn, conf_filename, input_dir, source, min_length, stride,
        rmsd_cutoff, atom_indices, iext):

    # check if we are doing an update or a fresh run
    # if os.path.exists(projectfn):
    #     logger.info("Found project info file encoding previous work, running in update mode...")
    #     update = True
    # else:
    #     update = False
    #
    # logger.info("Looking for %s style data in %s", source, input_dir)
    # if update:
    #     raise NotImplementedError("Ack! Update mode is not yet ready yet.")

    # if the source is fah, we'll use some special FaH specific loading functions
    # to (1) try to recover in case of errors and (2) load the specific directory
    # hierarchy of FaH (RUN/CLONE/GEN/frame.xtc)
    if os.path.exists(projectfn):
        project = Project.load_from(projectfn)
        logger.warn(
            "%s exists, will modify it and update the trajectories in %s",
            projectfn, '/'.join(project._traj_paths[0].split('/')[:-1]))
    else:
        project = None

    if source.startswith('file'):
        pb = ProjectBuilder(input_dir,
                            input_traj_ext=iext,
                            conf_filename=conf_filename,
                            stride=stride,
                            project=project,
                            atom_indices=atom_indices)
    elif source == 'fah':
        pb = FahProjectBuilder(input_dir,
                               input_traj_ext=iext,
                               conf_filename=conf_filename,
                               stride=stride,
                               project=project,
                               atom_indices=atom_indices)
    else:
        raise ValueError("Invalid argument for source: %s" % source)

    # check that trajectories to not go farther than a certain RMSD
    # from the PDB. Useful to check for blowing up or other numerical
    # instabilities
    if rmsd_cutoff is not None:
        # TODO: this is going to use ALL of the atom_indices, including hydrogen. This is
        # probably not the desired functionality
        # KAB: Apparently needed to use correctly subsetted atom_indices here to avoid an error
        validator = validators.RMSDExplosionValidator(
            conf_filename, max_rmsd=rmsd_cutoff, atom_indices=atom_indices)
        pb.add_validator(validator)

    # Only accept trajectories with more snapshots than min_length.
    if min_length > 0:
        validator = validators.MinLengthValidator(min_length)
        pb.add_validator(validator)

    # everyone wants to be centered
    pb.add_validator(validators.TrajCenterer())

    pb.get_project().save(projectfn)
    assert os.path.exists(projectfn), '%s does not exist' % projectfn
    logger.info("Finished data conversion successfully.")
    logger.info("Generated: %s, Trajectories/", projectfn)

    return
Example #12
0
from msmbuilder.project import FahProjectBuilder

pb = FahProjectBuilder('./fah_style_data', '.xtc', './fah_style_data/native.pdb')
p = pb.convert()
print p