-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglob_load.py
More file actions
35 lines (27 loc) · 861 Bytes
/
glob_load.py
File metadata and controls
35 lines (27 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from pymol import cmd
import glob
import os
def glob_load(pattern, quiet=0):
"""
Load all files matching a glob pattern.
USAGE:
glob_load pattern
EXAMPLES:
glob_load *.pdb
glob_load /path/to/folder/*.cif
glob_load nipah_pT10_*.cif
"""
files = glob.glob(os.path.expanduser(pattern))
if not files:
print(f"Error: No files found matching pattern: {pattern}")
return
if not quiet:
print(f"Loading {len(files)} file(s)...")
for filepath in files:
object_name = os.path.splitext(os.path.basename(filepath))[0]
cmd.load(filepath, object_name)
if not quiet:
print(f" Loaded: {object_name}")
if not quiet:
print(f"Successfully loaded {len(files)} structure(s)")
cmd.extend("glob_load", glob_load)