当前位置: 首页>>代码示例>>Python>>正文


Python DataStructs.TanimotoSimilarity方法代码示例

本文整理汇总了Python中rdkit.DataStructs.TanimotoSimilarity方法的典型用法代码示例。如果您正苦于以下问题:Python DataStructs.TanimotoSimilarity方法的具体用法?Python DataStructs.TanimotoSimilarity怎么用?Python DataStructs.TanimotoSimilarity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rdkit.DataStructs的用法示例。


在下文中一共展示了DataStructs.TanimotoSimilarity方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reward_target_molecule_similarity

# 需要导入模块: from rdkit import DataStructs [as 别名]
# 或者: from rdkit.DataStructs import TanimotoSimilarity [as 别名]
def reward_target_molecule_similarity(mol, target, radius=2, nBits=2048,
                                      useChirality=True):
    """
    Reward for a target molecule similarity, based on tanimoto similarity
    between the ECFP fingerprints of the x molecule and target molecule
    :param mol: rdkit mol object
    :param target: rdkit mol object
    :return: float, [0.0, 1.0]
    """
    x = rdMolDescriptors.GetMorganFingerprintAsBitVect(mol, radius=radius,
                                                        nBits=nBits,
                                                        useChirality=useChirality)
    target = rdMolDescriptors.GetMorganFingerprintAsBitVect(target,
                                                            radius=radius,
                                                        nBits=nBits,
                                                        useChirality=useChirality)
    return DataStructs.TanimotoSimilarity(x, target)


### TERMINAL VALUE REWARDS ### 
开发者ID:bowenliu16,项目名称:rl_graph_generation,代码行数:22,代码来源:molecule.py

示例2: doSimilarityWeightedAdAnalysis

# 需要导入模块: from rdkit import DataStructs [as 别名]
# 或者: from rdkit.DataStructs import TanimotoSimilarity [as 别名]
def doSimilarityWeightedAdAnalysis(model_name, rdkit_mols):
	global ad_settings
	ad_idx = []
	known = []
	ad_data = getAdData(model_name)
	required_threshold = np.percentile(ad_data[:,5],ad_settings)
	for mol_idx, m in enumerate(rdkit_mols):
		ad_flag = False
		#only check for known compounds if set in options (True means dont check)
		if options.known: k_flag = False
		else: k_flag = True
		for training_instance in ad_data:
			sim = DataStructs.TanimotoSimilarity(m,training_instance[0])
			if sim == 1.0 and k_flag == False:
				known.append([mol_idx,training_instance[1]])
				k_flag = True
			weight = sim/(training_instance[2]*training_instance[3])
			if weight >= required_threshold and ad_flag != True:
				ad_idx.append(mol_idx)
				ad_flag = True
			#if compound is in AD and no need to check accross all comps for known then break
			if k_flag == True and ad_flag == True: break
	return ad_idx, np.array(known)

#return target prediction information for first and second files (p1,p2) 
开发者ID:lhm30,项目名称:PIDGINv3,代码行数:27,代码来源:predict_enriched.py

示例3: similarity

# 需要导入模块: from rdkit import DataStructs [as 别名]
# 或者: from rdkit.DataStructs import TanimotoSimilarity [as 别名]
def similarity(a, b):
    if a is None or b is None: 
        return 0.0
    amol = Chem.MolFromSmiles(a)
    bmol = Chem.MolFromSmiles(b)
    if amol is None or bmol is None:
        return 0.0

    fp1 = AllChem.GetMorganFingerprintAsBitVect(amol, 2, nBits=2048, useChirality=False)
    fp2 = AllChem.GetMorganFingerprintAsBitVect(bmol, 2, nBits=2048, useChirality=False)
    return DataStructs.TanimotoSimilarity(fp1, fp2) 
开发者ID:wengong-jin,项目名称:hgraph2graph,代码行数:13,代码来源:properties.py

示例4: similarity

# 需要导入模块: from rdkit import DataStructs [as 别名]
# 或者: from rdkit.DataStructs import TanimotoSimilarity [as 别名]
def similarity(a, b, chiral=False):
    if a is None or b is None: 
        return 0.0
    amol = Chem.MolFromSmiles(a)
    bmol = Chem.MolFromSmiles(b)
    if amol is None or bmol is None:
        return 0.0

    fp1 = AllChem.GetMorganFingerprintAsBitVect(amol, 2, nBits=2048, useChirality=chiral)
    fp2 = AllChem.GetMorganFingerprintAsBitVect(bmol, 2, nBits=2048, useChirality=chiral)
    return DataStructs.TanimotoSimilarity(fp1, fp2) 
开发者ID:wengong-jin,项目名称:hgraph2graph,代码行数:13,代码来源:stereo.py

示例5: __call__

# 需要导入模块: from rdkit import DataStructs [as 别名]
# 或者: from rdkit.DataStructs import TanimotoSimilarity [as 别名]
def __call__(self, smile):
        mol = Chem.MolFromSmiles(smile)
        if mol:
            fp = AllChem.GetMorganFingerprint(mol, 2, useCounts=True, useFeatures=True)
            score = DataStructs.TanimotoSimilarity(self.query_fp, fp)
            score = min(score, self.k) / self.k
            return float(score)
        return 0.0 
开发者ID:MarcusOlivecrona,项目名称:REINVENT,代码行数:10,代码来源:scoring_functions.py

示例6: __init__

# 需要导入模块: from rdkit import DataStructs [as 别名]
# 或者: from rdkit.DataStructs import TanimotoSimilarity [as 别名]
def __init__(self, fp_func=None, sim_func=None, fp_cache_maxsize=None, sim_cache_maxsize=None):
        self._fp_func = fp_func if fp_func else Chem.RDKFingerprint
        assert callable(self._fp_func), 'fp_func must be callable or None'
        self._sim_func = sim_func if sim_func else DataStructs.TanimotoSimilarity
        assert callable(self._sim_func), 'sim_func must be callable or None'
        self._fp_cache = Cache(fp_cache_maxsize)
        self._sim_cache = Cache(sim_cache_maxsize) 
开发者ID:UCLCheminformatics,项目名称:ScaffoldGraph,代码行数:9,代码来源:representation.py

示例7: doSimilarityWeightedAdAnalysis

# 需要导入模块: from rdkit import DataStructs [as 别名]
# 或者: from rdkit.DataStructs import TanimotoSimilarity [as 别名]
def doSimilarityWeightedAdAnalysis(model_name):
	global rdkit_mols, ad_settings
	ad_idx = []
	known = []
	ad_data = getAdData(model_name)
	required_threshold = np.percentile(ad_data[:,5],ad_settings)
	for mol_idx, m in enumerate(rdkit_mols):
		ad_flag = True
		#only check for known compounds if set in options (True means check)
		if options.known: k_flag = True
		else: k_flag = False
		for training_instance in ad_data:
			sim = DataStructs.TanimotoSimilarity(m,training_instance[0])
			#check if input=train & need to check input=train
			if sim == 1.0 and k_flag == True:
				known.append([mol_idx,training_instance[1]])
				k_flag = False
			weight = sim/(training_instance[2]*training_instance[3])
			#if comp in AD & no comp already in AD
			if weight >= required_threshold and ad_flag == True:
				ad_idx.append(mol_idx)
				ad_flag = False
			#if compound is in AD and no need to check accross all comps for known then break
			if k_flag == False and ad_flag == False: break
	return ad_idx, np.array(known)

#get smiles from training set of model 
开发者ID:lhm30,项目名称:PIDGINv3,代码行数:29,代码来源:predict.py


注:本文中的rdkit.DataStructs.TanimotoSimilarity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。