本文整理汇总了Python中pathos.multiprocessing.ProcessingPool.map_sync方法的典型用法代码示例。如果您正苦于以下问题:Python ProcessingPool.map_sync方法的具体用法?Python ProcessingPool.map_sync怎么用?Python ProcessingPool.map_sync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pathos.multiprocessing.ProcessingPool
的用法示例。
在下文中一共展示了ProcessingPool.map_sync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _featurize_complexes
# 需要导入模块: from pathos.multiprocessing import ProcessingPool [as 别名]
# 或者: from pathos.multiprocessing.ProcessingPool import map_sync [as 别名]
def _featurize_complexes(self, df, featurizer, parallel=True,
worker_pool=None):
"""Generates circular fingerprints for dataset."""
protein_pdbs = list(df["protein_pdb"])
ligand_pdbs = list(df["ligand_pdb"])
complexes = zip(ligand_pdbs, protein_pdbs)
def featurize_wrapper(ligand_protein_pdb_tuple):
ligand_pdb, protein_pdb = ligand_protein_pdb_tuple
print("Featurizing %s" % ligand_pdb[0:2])
molecule_features = featurizer.featurize_complexes([ligand_pdb], [protein_pdb])
return molecule_features
if worker_pool is None:
features = []
for ligand_protein_pdb_tuple in zip(ligand_pdbs, protein_pdbs):
features.append(featurize_wrapper(ligand_protein_pdb_tuple))
else:
if worker_pool is None:
worker_pool = ProcessingPool(mp.cpu_count())
features = worker_pool.map(featurize_wrapper,
zip(ligand_pdbs, protein_pdbs))
else:
features = worker_pool.map_sync(featurize_wrapper,
zip(ligand_pdbs, protein_pdbs))
#features = featurize_wrapper(zip(ligand_pdbs, protein_pdbs))
df[featurizer.__class__.__name__] = list(features)
示例2: _featurize_compounds
# 需要导入模块: from pathos.multiprocessing import ProcessingPool [as 别名]
# 或者: from pathos.multiprocessing.ProcessingPool import map_sync [as 别名]
def _featurize_compounds(self, df, featurizer, parallel=True,
worker_pool=None):
"""Featurize individual compounds.
Given a featurizer that operates on individual chemical compounds
or macromolecules, compute & add features for that compound to the
features dataframe
"""
sample_smiles = df["smiles"].tolist()
if worker_pool is None:
features = []
for ind, smiles in enumerate(sample_smiles):
if ind % self.log_every_n == 0:
log("Featurizing sample %d" % ind, self.verbose)
mol = Chem.MolFromSmiles(smiles)
features.append(featurizer.featurize([mol]))
else:
def featurize_wrapper(smiles, dilled_featurizer):
print("Featurizing %s" % smiles)
mol = Chem.MolFromSmiles(smiles)
featurizer = dill.loads(dilled_featurizer)
feature = featurizer.featurize([mol])
return feature
if worker_pool is None:
dilled_featurizer = dill.dumps(featurizer)
worker_pool = ProcessingPool(mp.cpu_count())
featurize_wrapper_partial = partial(featurize_wrapper,
dilled_featurizer=dilled_featurizer)
features = []
for smiles in sample_smiles:
features.append(featurize_wrapper_partial(smiles))
else:
features = worker_pool.map_sync(featurize_wrapper,
sample_smiles)
df[featurizer.__class__.__name__] = features