コード例 #1
0
ファイル: test_wham.py プロジェクト: team-mayes/md_utils
 def testWriteRmsd(self):
     directory_name = None
     try:
         directory_name = tempfile.mkdtemp()
         rfname = os.path.join(directory_name, EVEN_KEY)
         write_rmsd(EVEN_DATA, rfname)
         self.assertAlmostEqual(EVEN_DATA, read_rmsd(rfname))
     finally:
         shutil.rmtree(directory_name)
コード例 #2
0
ファイル: test_wham.py プロジェクト: jiaozihao18/md_utils
 def testWriteRmsd(self):
     directory_name = None
     try:
         directory_name = tempfile.mkdtemp()
         rfname = os.path.join(directory_name, EVEN_KEY)
         write_rmsd(EVEN_DATA, rfname)
         self.assertAlmostEqual(EVEN_DATA, read_rmsd(rfname))
     finally:
         shutil.rmtree(directory_name)
コード例 #3
0
def write_avg_rmsd(tgt_dir, rmsd, overwrite=False):
    """
    Writes out all of the described RMSD files into the given target directory.

    :param tgt_dir: The data where the files will go.
    :param rmsd: A dict of an array of floats keyed by file name.
    :param overwrite: Whether to overwrite existing files.
    """
    for rmsd_fname, data in rmsd.items():
        f_name = os.path.join(tgt_dir, rmsd_fname)
        if allow_write(f_name, overwrite=overwrite):
            write_rmsd(data, f_name)
コード例 #4
0
ファイル: wham_block.py プロジェクト: team-mayes/md_utils
def write_avg_rmsd(tgt_dir, rmsd, overwrite=False):
    """
    Writes out all of the described RMSD files into the given target directory.

    :param tgt_dir: The data where the files will go.
    :param rmsd: A dict of an array of floats keyed by file name.
    :param overwrite: Whether to overwrite existing files.
    """
    for rmsd_fname, data in rmsd.items():
        f_name = os.path.join(tgt_dir, rmsd_fname)
        if allow_write(f_name, overwrite=overwrite):
            write_rmsd(data, f_name)
コード例 #5
0
ファイル: wham_split.py プロジェクト: jiaozihao18/md_utils
def rmsd_split(meta_file,
               steps,
               tpl_dir=DEF_TPL_DIR,
               overwrite=False,
               base_dir=None):
    """
    Reads the given meta file, fetches the RMSD files in the inventory, and creates a succession
    of directories that split the original RMSD files into a larger number of chunks for each step
    such that step 1 will create a split of 2 in 01_01 and 01_02, etc.

    :param meta_file: The initial meta file.
    :param steps: The number of averaging steps to perform.
    :param tpl_dir: The directory that contains the submit templates.
    :param overwrite: Whether to overwrite existing files.
    :param base_dir: The base directory to write to (defaults to the meta file's dir)
    """
    meta = read_meta(meta_file)
    rmsd = read_meta_rmsd(meta)
    sub_tpl_base = read_tpl(os.path.join(tpl_dir, DEF_BASE_SUBMIT_TPL))
    sub_tpl_line = read_tpl(os.path.join(tpl_dir, DEF_PART_LINE_SUBMIT_TPL))

    if not base_dir:
        base_dir = meta[DIR_KEY]
    for step in range(1, steps + 1):
        for rmsd_fname, data in rmsd.items():
            data_len = len(data)
            chunk_num = step + 1
            chunk_size = math.floor(data_len / chunk_num)
            logger.debug(STEP_DBG_MSG, step, data_len, rmsd_fname, chunk_num,
                         chunk_size)

            rmsd_chunks = [ch for ch in chunk(data, chunk_size, list)]
            for step_part in range(1, chunk_num + 1):
                rmsd_tgt_dir = os.path.join(
                    base_dir, SPLIT_DIR_FMT.format(step, step_part))
                if not os.path.exists(rmsd_tgt_dir):
                    os.makedirs(rmsd_tgt_dir)
                f_name = os.path.join(rmsd_tgt_dir, rmsd_fname)
                if allow_write(f_name, overwrite=overwrite):
                    write_rmsd(rmsd_chunks[step_part - 1], f_name)

        write_meta(base_dir, meta, step, overwrite)
        write_submit(base_dir, sub_tpl_base, sub_tpl_line, step, overwrite)
コード例 #6
0
ファイル: wham_split.py プロジェクト: team-mayes/md_utils
def rmsd_split(meta_file, steps, tpl_dir=DEF_TPL_DIR, overwrite=False, base_dir=None):
    """
    Reads the given meta file, fetches the RMSD files in the inventory, and creates a succession
    of directories that split the original RMSD files into a larger number of chunks for each step
    such that step 1 will create a split of 2 in 01_01 and 01_02, etc.

    :param meta_file: The initial meta file.
    :param steps: The number of averaging steps to perform.
    :param tpl_dir: The directory that contains the submit templates.
    :param overwrite: Whether to overwrite existing files.
    :param base_dir: The base directory to write to (defaults to the meta file's dir)
    """
    meta = read_meta(meta_file)
    rmsd = read_meta_rmsd(meta)
    sub_tpl_base = read_tpl(os.path.join(tpl_dir, DEF_BASE_SUBMIT_TPL))
    sub_tpl_line = read_tpl(os.path.join(tpl_dir, DEF_PART_LINE_SUBMIT_TPL))

    if not base_dir:
        base_dir = meta[DIR_KEY]
    for step in range(1, steps + 1):
        for rmsd_fname, data in rmsd.items():
            data_len = len(data)
            chunk_num = step + 1
            chunk_size = math.floor(data_len / chunk_num)
            logger.debug(STEP_DBG_MSG, step, data_len, rmsd_fname, chunk_num, chunk_size)

            rmsd_chunks = [ch for ch in chunk(data, chunk_size, list)]
            for step_part in range(1, chunk_num + 1):
                rmsd_tgt_dir = os.path.join(base_dir, SPLIT_DIR_FMT.
                                            format(step, step_part))
                if not os.path.exists(rmsd_tgt_dir):
                    os.makedirs(rmsd_tgt_dir)
                f_name = os.path.join(rmsd_tgt_dir, rmsd_fname)
                if allow_write(f_name, overwrite=overwrite):
                    write_rmsd(rmsd_chunks[step_part - 1], f_name)

        write_meta(base_dir, meta, step, overwrite)
        write_submit(base_dir, sub_tpl_base, sub_tpl_line, step, overwrite)