Skip to content

Commit 1f89c62

Browse files
committed
able to control whether to resume processing or overwrite
1 parent 1b51b32 commit 1f89c62

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

alphafold3_pytorch/inputs.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ def pdb_dataset_to_atom_inputs(
224224
indices: Iterable | None = None,
225225
return_atom_dataset = False,
226226
n_jobs: int = 8,
227-
parallel_kwargs: dict = dict()
227+
parallel_kwargs: dict = dict(),
228+
overwrite_existing: bool = False,
228229
) -> Path | AtomDataset:
229230

230231
if not exists(output_atom_folder):
@@ -243,16 +244,20 @@ def pdb_dataset_to_atom_inputs(
243244
molecule_to_atom_input
244245
)
245246

247+
def should_process_pdb_input(index):
248+
atom_input_path = output_atom_folder / f'{index}.pt'
249+
return not atom_input_path.exists() or overwrite_existing
250+
246251
@delayed
247252
def pdb_input_to_atom_file(index, path):
248253
pdb_input = pdb_dataset[index]
249254

250255
atom_input = to_atom_input_fn(pdb_input)
251-
atom_input_path = path / f'{index}.pt'
252256

257+
atom_input_path = path / f'{index}.pt'
253258
atom_input_to_file(atom_input, atom_input_path)
254259

255-
Parallel(n_jobs = n_jobs, **parallel_kwargs)(pdb_input_to_atom_file(index, output_atom_folder) for index in indices)
260+
Parallel(n_jobs = n_jobs, **parallel_kwargs)(pdb_input_to_atom_file(index, output_atom_folder) for index in filter(should_process_pdb_input, indices))
256261

257262
if not return_atom_dataset:
258263
return output_atom_folder

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "alphafold3-pytorch"
3-
version = "0.2.54"
3+
version = "0.2.55"
44
description = "Alphafold 3 - Pytorch"
55
authors = [
66
{ name = "Phil Wang", email = "[email protected]" }

tests/configs/trainer_with_atom_dataset_created_from_pdb.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ dataset_config:
6161
convert_pdb_to_atom: true
6262
pdb_to_atom_kwargs:
6363
n_jobs: 1
64+
overwrite_existing: true
6465

0 commit comments

Comments
 (0)