当前位置: 首页>>代码示例>>Python>>正文


Python glob.glob方法代码示例

本文整理汇总了Python中glob.glob.glob方法的典型用法代码示例。如果您正苦于以下问题:Python glob.glob方法的具体用法?Python glob.glob怎么用?Python glob.glob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在glob.glob的用法示例。


在下文中一共展示了glob.glob方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_pyscript

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def save_pyscript(tmpdir, isotype="isosurface"):
    homof = glob(os.path.join(tmpdir, 'Psi*_HOMO.cube'))[0]
    lumof = glob(os.path.join(tmpdir, 'Psi*_LUMO.cube'))[0]
    with open("frontier.py", "w") as f:
        f.write('from pymol import *\n')
        f.write('cmd.load("{0}", "HOMO")\n'.format(homof))
        f.write('cmd.load("{0}", "LUMO")\n'.format(lumof))
        f.write('cmd.load("{0}")\n'.format(os.path.join(tmpdir, "target.mol")))
        if isotype == "isomesh":        
            f.write('cmd.isomesh("HOMO_A", "HOMO", -0.02)\n')
            f.write('cmd.isomesh("HOMO_B", "HOMO", 0.02)\n')
            f.write('cmd.isomesh("LUMO_A", "LUMO", 0.02)\n')
            f.write('cmd.isomesh("LUMO_B", "LUMO", -0.02)\n')
        else:
            f.write('cmd.isosurface("HOMO_A", "HOMO", -0.02)\n')
            f.write('cmd.isosurface("HOMO_B", "HOMO", 0.02)\n')
            f.write('cmd.isosurface("LUMO_A", "LUMO", 0.02)\n')
            f.write('cmd.isosurface("LUMO_B", "LUMO", -0.02)\n')            
        f.write('cmd.color("blue", "HOMO_A")\n')       
        f.write('cmd.color("red", "HOMO_B")\n')       
        f.write('cmd.color("blue", "LUMO_A")\n')
        f.write('cmd.color("red", "LUMO_B")\n')
        f.write('cmd.disable("LUMO_A")\n')              
        f.write('cmd.disable("LUMO_B")\n') 
开发者ID:Mishima-syk,项目名称:psikit,代码行数:26,代码来源:pymol_helper.py

示例2: _average

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _average(args):
    from glob import glob
    from .io import load_locs, NoMetadataFileError
    from picasso.gui import average

    kwargs = {"iterations": args.iterations, "oversampling": args.oversampling}
    paths = glob(args.file)
    if paths:
        for path in paths:
            print("Averaging {}".format(path))
            try:
                locs, info = load_locs(path)
            except NoMetadataFileError:
                continue
            kwargs["path_basename"] = os.path.splitext(path)[0] + "_avg"
            average(locs, info, **kwargs) 
开发者ID:jungmannlab,项目名称:picasso,代码行数:18,代码来源:__main__.py

示例3: _hdf2visp

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _hdf2visp(path, pixel_size):
    from glob import glob

    paths = glob(path)
    if paths:
        from .io import load_locs
        import os.path
        from numpy import savetxt

        for path in paths:
            print("Converting {}".format(path))
            locs, info = load_locs(path)
            locs = locs[["x", "y", "z", "photons", "frame"]].copy()
            locs.x *= pixel_size
            locs.y *= pixel_size
            outname = os.path.splitext(path)[0] + ".3d"
            savetxt(
                outname,
                locs,
                fmt=["%.1f", "%.1f", "%.1f", "%.1f", "%d"],
                newline="\r\n",
            ) 
开发者ID:jungmannlab,项目名称:picasso,代码行数:24,代码来源:__main__.py

示例4: _hdf2csv

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _hdf2csv(path):
    from glob import glob
    import pandas as pd
    from tqdm import tqdm as _tqdm
    from os.path import isdir

    if isdir(path):
        paths = glob(path + "/*.hdf5")
    else:
        paths = glob(path)
    if paths:
        import os.path

        for path in _tqdm(paths):
            base, ext = os.path.splitext(path)
            if ext == ".hdf5":
                print("Converting {}".format(path))
                out_path = base + ".csv"
                locs = pd.read_hdf(path)
                print("A total of {} rows loaded".format(len(locs)))
                locs.to_csv(out_path, sep=",", encoding="utf-8")
    print("Complete.") 
开发者ID:jungmannlab,项目名称:picasso,代码行数:24,代码来源:__main__.py

示例5: _cluster_combine

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _cluster_combine(files):
    import glob

    paths = glob.glob(files)
    if paths:
        from . import io, postprocess

        for path in paths:
            try:
                locs, info = io.load_locs(path)
            except io.NoMetadataFileError:
                continue
            combined_locs = postprocess.cluster_combine(locs)
            base, ext = os.path.splitext(path)
            combined_info = {"Generated by": "Picasso Combine"}
            info.append(combined_info)
            io.save_locs(base + "_comb.hdf5", combined_locs, info) 
开发者ID:jungmannlab,项目名称:picasso,代码行数:19,代码来源:__main__.py

示例6: _cluster_combine_dist

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _cluster_combine_dist(files):
    import glob

    paths = glob.glob(files)
    if paths:
        from . import io, postprocess

        for path in paths:
            try:
                locs, info = io.load_locs(path)
            except io.NoMetadataFileError:
                continue
            combinedist_locs = postprocess.cluster_combine_dist(locs)
            base, ext = os.path.splitext(path)
            cluster_combine_dist_info = {"Generated by": "Picasso Combineidst"}
            info.append(cluster_combine_dist_info)
            io.save_locs(base + "_cdist.hdf5", combinedist_locs, info) 
开发者ID:jungmannlab,项目名称:picasso,代码行数:19,代码来源:__main__.py

示例7: _density

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _density(files, radius):
    import glob

    paths = glob.glob(files)
    if paths:
        from . import io, postprocess

        for path in paths:
            locs, info = io.load_locs(path)
            locs = postprocess.compute_local_density(locs, info, radius)
            base, ext = os.path.splitext(path)
            density_info = {
                "Generated by": "Picasso Density",
                "Radius": radius,
            }
            info.append(density_info)
            io.save_locs(base + "_density.hdf5", locs, info) 
开发者ID:jungmannlab,项目名称:picasso,代码行数:19,代码来源:__main__.py

示例8: _dbscan

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _dbscan(files, radius, min_density):
    import glob
    paths = glob.glob(files)
    if paths:
        from . import io, postprocess
        from h5py import File

        for path in paths:
            print("Loading {} ...".format(path))
            locs, info = io.load_locs(path)
            clusters, locs = postprocess.dbscan(locs, radius, min_density)
            base, ext = os.path.splitext(path)
            dbscan_info = {
                "Generated by": "Picasso DBSCAN",
                "Radius": radius,
                "Minimum local density": min_density,
            }
            info.append(dbscan_info)
            io.save_locs(base + "_dbscan.hdf5", locs, info)
            with File(base + "_dbclusters.hdf5", "w") as clusters_file:
                clusters_file.create_dataset("clusters", data=clusters)
            print("Clustering executed. Results are saved in: \n" + base + "_dbscan.hdf5" +
                  "\n" + base + "_dbclusters.hdf5") 
开发者ID:jungmannlab,项目名称:picasso,代码行数:25,代码来源:__main__.py

示例9: _hdbscan

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _hdbscan(files, min_cluster, min_samples):
    import glob
    paths = glob.glob(files)
    if paths:
        from . import io, postprocess
        from h5py import File

        for path in paths:
            print("Loading {} ...".format(path))
            locs, info = io.load_locs(path)
            clusters, locs = postprocess.hdbscan(locs, min_cluster, min_samples)
            base, ext = os.path.splitext(path)
            hdbscan_info = {
                "Generated by": "Picasso HDBSCAN",
                "Min. cluster": min_cluster,
                "Min. samples": min_samples,
            }
            info.append(hdbscan_info)
            io.save_locs(base + "_hdbscan.hdf5", locs, info)
            with File(base + "_hdbclusters.hdf5", "w") as clusters_file:
                clusters_file.create_dataset("clusters", data=clusters)
            print("Clustering executed. Results are saved in: \n" + base + "_hdbscan.hdf5" +
                  "\n" + base + "_hdbclusters.hdf5") 
开发者ID:jungmannlab,项目名称:picasso,代码行数:25,代码来源:__main__.py

示例10: _nneighbor

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _nneighbor(files):
    import glob
    import h5py as _h5py
    import numpy as np
    from scipy.spatial import distance

    paths = glob.glob(files)
    if paths:
        for path in paths:
            print("Loading {} ...".format(path))
            with _h5py.File(path, "r") as locs_file:
                locs = locs_file["clusters"][...]
            clusters = np.rec.array(locs, dtype=locs.dtype)
            points = np.array(clusters[["com_x", "com_y"]].tolist())
            alldist = distance.cdist(points, points)
            alldist[alldist == 0] = float("inf")
            minvals = np.amin(alldist, axis=0)
            base, ext = os.path.splitext(path)
            out_path = base + "_minval.txt"
            np.savetxt(out_path, minvals, newline="\r\n")
            print("Saved filest o: {}".format(out_path)) 
开发者ID:jungmannlab,项目名称:picasso,代码行数:23,代码来源:__main__.py

示例11: _groupprops

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _groupprops(files):
    import glob

    paths = glob.glob(files)
    if paths:
        from .io import load_locs, save_datasets
        from .postprocess import groupprops
        from os.path import splitext

        for path in paths:
            locs, info = load_locs(path)
            groups = groupprops(locs)
            base, ext = splitext(path)
            save_datasets(
                base + "_groupprops.hdf5", info, locs=locs, groups=groups
            ) 
开发者ID:jungmannlab,项目名称:picasso,代码行数:18,代码来源:__main__.py

示例12: _pair_correlation

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def _pair_correlation(files, bin_size, r_max):
    from glob import glob

    paths = glob(files)
    if paths:
        from .io import load_locs
        from .postprocess import pair_correlation
        from matplotlib.pyplot import plot, style, show, xlabel, ylabel, title

        style.use("ggplot")
        for path in paths:
            print("Loading {}...".format(path))
            locs, info = load_locs(path)
            print("Calculating pair-correlation...")
            bins_lower, pc = pair_correlation(locs, info, bin_size, r_max)
            plot(bins_lower - bin_size / 2, pc)
            xlabel("r (pixel)")
            ylabel("pair-correlation (pixel^-2)")
            title(
                "Pair-correlation. Bin size: {}, R max: {}".format(
                    bin_size, r_max
                )
            )
            show() 
开发者ID:jungmannlab,项目名称:picasso,代码行数:26,代码来源:__main__.py

示例13: load_test_data

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def load_test_data(FLAGS):
    label_files = glob(os.path.join(FLAGS.test_data_local, '*.txt'))
    test_data = np.ndarray((len(label_files), FLAGS.input_size, FLAGS.input_size, 3),
                           dtype=np.uint8)
    img_names = []
    test_labels = []
    for index, file_path in enumerate(label_files):
        with codecs.open(file_path, 'r', 'utf-8') as f:
            line = f.readline()
        line_split = line.strip().split(', ')
        if len(line_split) != 2:
            print('%s contain error lable' % os.path.basename(file_path))
            continue
        img_names.append(line_split[0])
        test_data[index] = preprocess_img(os.path.join(FLAGS.test_data_local, line_split[0]), FLAGS.input_size)
        test_labels.append(int(line_split[1]))
    return img_names, test_data, test_labels 
开发者ID:Yangget,项目名称:garbage_classify,代码行数:19,代码来源:eval.py

示例14: folder_contents_list

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def folder_contents_list(path):
    '''returns a list of folder contents'''
    folder_contents = glob.glob(os.path.join(path, '**'), recursive = True)
    folder_contents = [x.replace('{}/'.format(path),'') for x in folder_contents ]
    folder_contents = folder_contents[1:] ## the first element is the path name
    return(folder_contents)


# In[7]: 
开发者ID:edickie,项目名称:ciftify,代码行数:11,代码来源:ciftify_integration_tests.py

示例15: get_latest_file

# 需要导入模块: from glob import glob [as 别名]
# 或者: from glob.glob import glob [as 别名]
def get_latest_file(root_dir):
    """Returns path to latest file in a directory."""
    list_of_files = glob.glob(os.path.join(root_dir, '*'))
    latest_file = max(list_of_files, key=os.path.getctime)
    return latest_file 
开发者ID:vsitzmann,项目名称:scene-representation-networks,代码行数:7,代码来源:util.py


注:本文中的glob.glob.glob方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。