Skip to content

Commit

Permalink
remove files before writing lib (custom kinfraglib)
Browse files Browse the repository at this point in the history
  • Loading branch information
kabu00002 committed Jun 10, 2024
1 parent ec4c3ae commit 7763beb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions kinfraglib/filters/retro.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import multiprocessing as mp
import os
import pandas as pd
import requests
import redo
Expand Down Expand Up @@ -1387,6 +1388,13 @@ def save_fragment_library_to_sdfs(path_output, fragment_library_concat):
path_output = Path(path_output)
path_output.mkdir(parents=True, exist_ok=True)

subpockets = ["AP", "SE", "FP", "GA", "B1", "B2", "X"]
# remove all {subpocket}.sdf files before writing to avoid death files
for subpocket in subpockets:
# check if files {subpocket}.sdf exists
if (path_output / f"{subpocket}.sdf").exists():
os.remove(path_output / f"{subpocket}.sdf")

for subpocket, fragments in fragment_library_concat.groupby("subpocket"):
with Chem.SDWriter(str(path_output / f"{subpocket}.sdf")) as w:
for mol in fragments.ROMol_original:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1245,8 +1245,8 @@
"Checking if all fragment pairs were requested..\n",
"All fragment pairs were requested.\n",
"Done.\n",
"CPU times: user 9min 37s, sys: 4.41 s, total: 9min 41s\n",
"Wall time: 11min 50s\n"
"CPU times: user 12min 9s, sys: 6.03 s, total: 12min 15s\n",
"Wall time: 15min 43s\n"
]
}
],
Expand Down

0 comments on commit 7763beb

Please sign in to comment.