Example #1
0
def test_get_tachyon_path(tachyon_func):
    '''Test finding the path to the tachyon renderer.
    This needs to work for Mac and Linux
    '''
    tachyon_func.side_effect = lambda i: i.is_file()

    # Set up a directory that mocks the linux VMD directory
    _tmp_dir = tempfile.TemporaryDirectory()
    tmp_dir = Path(_tmp_dir.name)
    tachyon_dir = tmp_dir / 'lib/tachyon'
    tachyon_dir.mkdir(parents=True)
    tachyon_path = tachyon_dir / 'tachyon_LINUXAMD64'
    tachyon_path.touch()
    vmd_dir = tmp_dir / 'LINUXAMD64'
    vmd_dir.mkdir()
    vmd_path = vmd_dir / 'vmd_LINUXAMD64'
    vmd_path.touch()

    # Test the linux get_tachyon_path
    path = IO.get_tachyon_path(vmd_path)
    assert path == tachyon_path
    del _tmp_dir

    # Set up the Mac directory
    _tmp_dir = tempfile.TemporaryDirectory()
    tmp_dir = Path(_tmp_dir.name)
    tachyon_path = tmp_dir / 'tachyon_MACOSXARM64'
    vmd_path = tmp_dir / 'vmd_MACOSXARM64'
    tachyon_path.touch()

    # Test the Mac Path
    path = IO.get_tachyon_path(vmd_path)
    assert path == tachyon_path
Example #2
0
def init_tcl_dict(all_settings):
    all_settings['tcl']['any_extra_raw_tcl_code'] = ""
    all_settings['tcl']['isoval'] = all_settings['isosurface_to_plot']
    all_settings['tcl']['Ccol'] = all_settings['carbon_color']
    all_settings['tcl']['Hcol'] = all_settings['hydrogen_color']
    all_settings['tcl']['zoom_val'] = all_settings['zoom_value']
    #all_settings['tcl']['mol_id']   =  0
    all_settings['tcl']['Necol'] = all_settings['neon_color']
    all_settings['tcl']['atom_style'] = all_settings['mol_style']
    all_settings['tcl']['mol_material'] = all_settings['mol_material']
    all_settings['tcl']['iso_material'] = all_settings['iso_material']
    all_settings['tcl']['time_step'] = '" "'
    all_settings['tcl']['iso_type'] = 0
    all_settings['tcl']['density_color'] = str(
        all_settings['density_iso_col']).replace("(", '"').replace(
            ")", '"').replace(",", '')
    all_settings['tcl']['imag_pos_col'] = str(
        all_settings['pos_imag_iso_col']).replace("(", '"').replace(
            ")", '"').replace(",", '')
    all_settings['tcl']['imag_neg_col'] = str(
        all_settings['neg_imag_iso_col']).replace("(", '"').replace(
            ")", '"').replace(",", '')
    all_settings['tcl']['real_pos_col'] = str(
        all_settings['pos_real_iso_col']).replace("(", '"').replace(
            ")", '"').replace(",", '')
    all_settings['tcl']['real_neg_col'] = str(
        all_settings['neg_real_iso_col']).replace("(", '"').replace(
            ")", '"').replace(",", '')
    all_settings['tcl']['maxX'] = all_settings['xdims'][1]
    all_settings['tcl']['minX'] = all_settings['xdims'][0]
    all_settings['tcl']['maxY'] = all_settings['ydims'][1]
    all_settings['tcl']['minY'] = all_settings['ydims'][0]
    all_settings['tcl']['maxZ'] = all_settings['zdims'][1]
    all_settings['tcl']['minZ'] = all_settings['zdims'][0]
    all_settings['tcl']['tachyon_path'] = io.get_tachyon_path(
        all_settings['vmd_exe'])

    imgSize = all_settings['img_size']
    if type(imgSize) == str:
        if imgSize.lower() == 'auto':
            if all_settings['calibrate']:
                imgSize = [1000, 1000]
            else:
                imgSize = [650, 650]
        else:
            raise SystemExit("Unknown setting %s for the `img_size'" % imgSize)
    all_settings['tcl']['pic_sizex'] = imgSize[0]
    all_settings['tcl']['pic_sizey'] = imgSize[1]

    all_settings['tcl']['backgrnd_mols'] = ""
    if all_settings['background_mols']:
        all_settings['tcl']['bckg_mols_on_off'] = ''
    else:
        all_settings['tcl']['bckg_mols_on_off'] = '#'
    if all_settings['show_box']:
        all_settings['tcl']['iso_type'] = 2
    all_settings['tcl'] = txt_lib.tcl_3D_input(
        all_settings['background_color'], ['R', 'G', 'B'], all_settings['tcl'],
        "backgrnd_")
    all_settings['tcl'] = txt_lib.tcl_3D_input(all_settings['translate_by'],
                                               ['x', 'y', 'z'],
                                               all_settings['tcl'], "trans_")
    all_settings['tcl'] = txt_lib.tcl_3D_input([0, 0, 0], ['x', 'y', 'z'],
                                               all_settings['tcl'],
                                               "time_lab_")
    all_settings['tcl'] = txt_lib.tcl_3D_input(all_settings['rotation'],
                                               ['x', 'y', 'z'],
                                               all_settings['tcl'], "rot")
    all_settings['tcl']['pic_filename'] = {}
    # set this in settings
    all_settings['tcl']['vmd_log_file'] = all_settings['vmd_log_file']