Skip to content

Commit

Permalink
Bugfix find command when spaces in filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Townshend committed Jul 19, 2022
1 parent 60cd14a commit 0783041
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions atom3d/datasets/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def get(self, idx):
else:
PTGDataset = None


def serialize(x, serialization_format):
"""
Serializes dataset `x` in format given by `serialization_format` (pkl, json, msgpack).
Expand Down Expand Up @@ -492,16 +492,16 @@ def make_lmdb_dataset(dataset, output_lmdb,
txn.put(b'serialization_format', serialization_format.encode())
txn.put(b'id_to_idx', serialize(id_to_idx, serialization_format))

def write_lmdb_as_pdb(lmdb_dir, output_dir):

def write_lmdb_as_pdb(lmdb_dir, output_dir):
"""
Write structures from an LMDB dataset to PDB files.
:param lmdb_dir: Path of the directory with the LMDB dataset.
:type lmdb_dir: str
:param output_dir: Path of the directory to save the PDB files.
:type output_dir: str
"""
data = LMDBDataset(lmdb_dir)
for d in data:
Expand All @@ -515,8 +515,8 @@ def write_lmdb_as_pdb(lmdb_dir, output_dir):
os.makedirs(output_dir, exist_ok=True)
# Write the structure to a PDB file
fo.write_pdb(output_dir+'/'+output, structure)


def extract_coordinates_as_numpy_arrays(dataset, indices=None, atom_frames=['atoms'], drop_elements=[]):
"""Convert the molecules from a dataset to a dictionary of numpy arrays.
Labels are not processed; they are handled differently for every dataset.
Expand Down
4 changes: 2 additions & 2 deletions atom3d/util/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ def find_files(path, suffix, relative=None):
:rtype: list[Path]
"""
if not relative:
find_cmd = r"find {:} -regex '.*\.{:}' | sort".format(path, suffix)
find_cmd = r"find '{:}' -regex '.*\.{:}' | sort".format(path, suffix)
else:
find_cmd = r"cd {:}; find . -regex '.*\.{:}' | cut -d '/' -f 2- | sort" \
.format(path, suffix)
out = subprocess.Popen(
find_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
cwd=os.getcwd(), shell=True)
(stdout, stderr) = out.communicate()
name_list = stdout.decode().split()
name_list = stdout.decode().rstrip('\n').split('\n')
name_list.sort()
return [Path(x) for x in name_list]

Expand Down

0 comments on commit 0783041

Please sign in to comment.