Skip to content

Commit

Permalink
Update functions.py
Browse files Browse the repository at this point in the history
added threads argument to the from_simles and from_mdl functions, to have more control over function execution.
  • Loading branch information
dinabandhu50 authored Sep 2, 2022
1 parent 901772d commit b19fe65
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions padelpy/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -151,15 +152,19 @@ 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


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
Expand All @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit b19fe65

Please sign in to comment.