From b19fe65a2295e4e5e6e94572c0afaa6e796ba1fc Mon Sep 17 00:00:00 2001 From: Dinabandhu Date: Fri, 2 Sep 2022 11:03:22 +0530 Subject: [PATCH 1/6] Update functions.py added threads argument to the from_simles and from_mdl functions, to have more control over function execution. --- padelpy/functions.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/padelpy/functions.py b/padelpy/functions.py index f4675c8..30e2d7e 100644 --- a/padelpy/functions.py +++ b/padelpy/functions.py @@ -28,7 +28,7 @@ def from_smiles(smiles, output_csv: str = None, descriptors: bool = True, - fingerprints: bool = False, timeout: int = 60) -> OrderedDict: + fingerprints: bool = False, timeout: int = 60, threads: int = -1 ) -> OrderedDict: """ from_smiles: converts SMILES string to QSPR descriptors/fingerprints Args: @@ -75,7 +75,8 @@ def from_smiles(smiles, output_csv: str = None, descriptors: bool = True, d_3d=descriptors, fingerprints=fingerprints, sp_timeout=timeout, - retainorder=True + retainorder=True, + threads = threads ) break except RuntimeError as exception: @@ -125,7 +126,7 @@ def from_smiles(smiles, output_csv: str = None, descriptors: bool = True, def from_mdl(mdl_file: str, output_csv: str = None, descriptors: bool = True, - fingerprints: bool = False, timeout: int = 60) -> list: + fingerprints: bool = False, timeout: int = 60, threads: int = -1) -> list: """ from_mdl: converts MDL file into QSPR descriptors/fingerprints; multiple molecules may be represented in the MDL file @@ -151,7 +152,9 @@ def from_mdl(mdl_file: str, output_csv: str = None, descriptors: bool = True, output_csv=output_csv, descriptors=descriptors, fingerprints=fingerprints, - timeout=timeout) + timeout=timeout, + threads=threads + ) return rows @@ -159,7 +162,9 @@ def from_sdf(sdf_file: str, output_csv: str = None, descriptors: bool = True, fingerprints: bool = False, - timeout: int = 60) -> list: + timeout: int = 60, + threads: int = -1 + ) -> list: """ Converts sdf file into QSPR descriptors/fingerprints. Multiple molecules may be represented in the sdf file @@ -185,12 +190,14 @@ def from_sdf(sdf_file: str, output_csv=output_csv, descriptors=descriptors, fingerprints=fingerprints, - timeout=timeout) + timeout=timeout, + threads=threads + ) return rows def _from_mdl_lower(mol_file: str, output_csv: str = None, descriptors: bool = True, - fingerprints: bool = False, timeout: int = 60) -> list: + fingerprints: bool = False, timeout: int = 60, threads: int = -1) -> list: save_csv = True if output_csv is None: save_csv = False @@ -209,7 +216,8 @@ def _from_mdl_lower(mol_file: str, output_csv: str = None, descriptors: bool = T d_2d=descriptors, d_3d=descriptors, fingerprints=fingerprints, - sp_timeout=timeout + sp_timeout=timeout, + threads=threads ) break except RuntimeError as exception: From 797cab0e4f59823ac919e30fecd9d4622d5813c1 Mon Sep 17 00:00:00 2001 From: Dinabandhu Date: Fri, 2 Sep 2022 11:28:52 +0530 Subject: [PATCH 2/6] Update README.md added documentation --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b2b27d2..709d806 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,9 @@ desc_fp = from_smiles('CCC', fingerprints=True) # only calculate fingerprints fingerprints = from_smiles('CCC', fingerprints=True, descriptors=False) +# setting number of threads, this uses one cpu thread to compute descriptors +descriptors = from_smiles(['CCC', 'CCCC'], threads = 1) + # save descriptors to a CSV file _ = from_smiles('CCC', output_csv='descriptors.csv') ``` From 6b05a6aa8bf376be5ef15a45d21a9b5b6a9f1ae0 Mon Sep 17 00:00:00 2001 From: Dinabandhu Date: Fri, 2 Sep 2022 11:32:41 +0530 Subject: [PATCH 3/6] Update README.md updated documantation --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 709d806..455e694 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ desc_fp = from_smiles('CCC', fingerprints=True) # only calculate fingerprints fingerprints = from_smiles('CCC', fingerprints=True, descriptors=False) -# setting number of threads, this uses one cpu thread to compute descriptors +# setting the number of threads, this uses one cpu thread to compute descriptors descriptors = from_smiles(['CCC', 'CCCC'], threads = 1) # save descriptors to a CSV file @@ -73,6 +73,9 @@ desc_fp = from_mdl('mols.mdl', fingerprints=True) # only calculate fingerprints fingerprints = from_mdl('mols.mdl', fingerprints=True, descriptors=False) +# setting the number of threads, this uses one cpu thread to compute descriptors +desc_fp = from_mdl('mols.mdl', threads=1) + # save descriptors to a CSV file _ = from_mdl('mols.mdl', output_csv='descriptors.csv') ``` @@ -95,6 +98,9 @@ desc_fp = from_sdf('mols.sdf', fingerprints=True) # only calculate fingerprints fingerprints = from_sdf('mols.sdf', fingerprints=True, descriptors=False) +# setting the number of threads, this uses one cpu thread to compute descriptors +desc_fp = from_mdl('mols.sdf', threads=1) + # save descriptors to a CSV file _ = from_sdf('mols.sdf', output_csv='descriptors.csv') ``` From 4a84763698b730c9bb1ec03cb405bc7aef5bade7 Mon Sep 17 00:00:00 2001 From: Travis Kessler Date: Thu, 8 Sep 2022 18:53:54 -0400 Subject: [PATCH 4/6] Update functions.py --- padelpy/functions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/padelpy/functions.py b/padelpy/functions.py index b2d567f..52008e8 100644 --- a/padelpy/functions.py +++ b/padelpy/functions.py @@ -88,7 +88,6 @@ def from_smiles(smiles, fingerprints=fingerprints, sp_timeout=timeout, retainorder=True, - threads = threads maxruntime=maxruntime, retainorder=True, threads=threads From 0d4d5d9bdf1d12ad00c22834ff592d0b90993aa8 Mon Sep 17 00:00:00 2001 From: Travis Kessler Date: Thu, 8 Sep 2022 18:56:39 -0400 Subject: [PATCH 5/6] Update functions.py --- padelpy/functions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/padelpy/functions.py b/padelpy/functions.py index 52008e8..a4ce892 100644 --- a/padelpy/functions.py +++ b/padelpy/functions.py @@ -195,6 +195,7 @@ def from_sdf(sdf_file: str, timeout: int = 60, maxruntime: int = -1, threads: int = -1 + ) -> list: """ Converts sdf file into QSPR descriptors/fingerprints. Multiple molecules may be represented in the sdf file From 537411a521d28d4aa315c59390e81c3c9db67649 Mon Sep 17 00:00:00 2001 From: Travis Kessler Date: Thu, 8 Sep 2022 18:58:41 -0400 Subject: [PATCH 6/6] Update functions.py --- padelpy/functions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/padelpy/functions.py b/padelpy/functions.py index a4ce892..41372d8 100644 --- a/padelpy/functions.py +++ b/padelpy/functions.py @@ -89,7 +89,6 @@ def from_smiles(smiles, sp_timeout=timeout, retainorder=True, maxruntime=maxruntime, - retainorder=True, threads=threads ) break