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


Python Descriptors.MolLogP方法代码示例

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


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

示例1: filter_smiles

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def filter_smiles(sml):
    try:
        m = Chem.MolFromSmiles(sml)
        logp = Descriptors.MolLogP(m)
        mol_weight = Descriptors.MolWt(m)
        num_heavy_atoms = Descriptors.HeavyAtomCount(m)
        atom_num_list = [atom.GetAtomicNum() for atom in m.GetAtoms()]
        is_organic = set(atom_num_list) <= ORGANIC_ATOM_SET
        if ((logp > -5) & (logp < 7) & 
            (mol_weight > 12) & (mol_weight < 600) &
            (num_heavy_atoms > 3) & (num_heavy_atoms < 50) &
            is_organic ):
            return Chem.MolToSmiles(m)
        else:
            return float('nan')
    except:
        return float('nan') 
开发者ID:jrwnter,项目名称:cddd,代码行数:19,代码来源:preprocessing.py

示例2: evaluate

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def evaluate(self, lst_in):
        """
        Evaluate structure alerts on a list of SMILES
        :param lst_in: input list of [SMILES, Name]
        :return: list of alerts matched or "OK"
        """
        smiles, name = lst_in
        mol = Chem.MolFromSmiles(smiles)
        if mol is None:
            return [smiles, name, 'INVALID', -999, -999, -999, -999, -999]
        desc_list = [MolWt(mol), MolLogP(mol), NumHDonors(mol), NumHAcceptors(mol), TPSA(mol),
                     CalcNumRotatableBonds(mol)]
        for row in self.rule_list:
            patt, max_val, desc = row
            if len(mol.GetSubstructMatches(patt)) > max_val:
                return [smiles, name] + [desc + " > %d" % (max_val)] + desc_list
        return [smiles, name] + ["OK"] + desc_list 
开发者ID:PatWalters,项目名称:rd_filters,代码行数:19,代码来源:rd_filters.py

示例3: penalized_logp

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def penalized_logp(s):
    if s is None: return -100.0
    mol = Chem.MolFromSmiles(s)
    if mol is None: return -100.0

    logP_mean = 2.4570953396190123
    logP_std = 1.434324401111988
    SA_mean = -3.0525811293166134
    SA_std = 0.8335207024513095
    cycle_mean = -0.0485696876403053
    cycle_std = 0.2860212110245455

    log_p = Descriptors.MolLogP(mol)
    SA = -sascorer.calculateScore(mol)

    # cycle score
    cycle_list = nx.cycle_basis(nx.Graph(Chem.rdmolops.GetAdjacencyMatrix(mol)))
    if len(cycle_list) == 0:
        cycle_length = 0
    else:
        cycle_length = max([len(j) for j in cycle_list])
    if cycle_length <= 6:
        cycle_length = 0
    else:
        cycle_length = cycle_length - 6
    cycle_score = -cycle_length

    normalized_log_p = (log_p - logP_mean) / logP_std
    normalized_SA = (SA - SA_mean) / SA_std
    normalized_cycle = (cycle_score - cycle_mean) / cycle_std
    return normalized_log_p + normalized_SA + normalized_cycle 
开发者ID:wengong-jin,项目名称:hgraph2graph,代码行数:33,代码来源:properties.py

示例4: reward_target_logp

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def reward_target_logp(mol, target,ratio=0.5,max=4):
    """
    Reward for a target log p
    :param mol: rdkit mol object
    :param target: float
    :return: float (-inf, max]
    """
    x = MolLogP(mol)
    reward = -1 * np.abs((x - target)/ratio) + max
    return reward 
开发者ID:bowenliu16,项目名称:rl_graph_generation,代码行数:12,代码来源:molecule.py

示例5: get_mol_props

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def get_mol_props(mol: AllChem.Mol):
    """
    Get the properties of a molecule.
    """
    logP = Descriptors.MolLogP(mol)
    tpsa = rdMolDescriptors.CalcTPSA(mol)
    alpha = rdMolDescriptors.CalcHallKierAlpha(mol)
    MR = Descriptors.MolMR(mol)
    asa = rdMolDescriptors.CalcLabuteASA(mol)
    return [logP, tpsa, alpha, MR, asa] 
开发者ID:john-bradshaw,项目名称:molecule-chef,代码行数:12,代码来源:rdkit_general_ops.py

示例6: get_descriptors

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def get_descriptors(sml):
    try:
        m = Chem.MolFromSmiles(sml)
        descriptor_list = []
        descriptor_list.append(Descriptors.MolLogP(m))
        descriptor_list.append(Descriptors.MolMR(m)) #ok
        descriptor_list.append(Descriptors.BalabanJ(m))
        descriptor_list.append(Descriptors.NumHAcceptors(m)) #ok
        descriptor_list.append(Descriptors.NumHDonors(m)) #ok
        descriptor_list.append(Descriptors.NumValenceElectrons(m))
        descriptor_list.append(Descriptors.TPSA(m)) # nice
        return descriptor_list
    except:
        return [np.float("nan")] * 7 
开发者ID:jrwnter,项目名称:cddd,代码行数:16,代码来源:preprocessing.py

示例7: create_feature_df

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def create_feature_df(smiles_df):
    temp = list(zip(*smiles_df['canonical_smiles'].map(get_descriptors)))
    columns = ["MolLogP", "MolMR", "BalabanJ", "NumHAcceptors", "NumHDonors", "NumValenceElectrons", "TPSA"]
    df = pd.DataFrame(columns=columns)
    for i, c in enumerate(columns):
        df.loc[:, c] = temp[i]
    df = (df - df.mean(axis=0, numeric_only=True)) / df.std(axis=0, numeric_only=True)
    df = smiles_df.join(df)
    return df 
开发者ID:jrwnter,项目名称:cddd,代码行数:11,代码来源:preprocessing.py

示例8: logP_score

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def logP_score(m):
  try:
  	logp = Descriptors.MolLogP(m)
  except:
    print (m, Chem.MolToSmiles(m))
    sys.exit('failed to make a molecule')

  SA_score = -sascorer.calculateScore(m)
  #cycle_list = nx.cycle_basis(nx.Graph(rdmolops.GetAdjacencyMatrix(m)))
  cycle_list = m.GetRingInfo().AtomRings() #remove networkx dependence
  if len(cycle_list) == 0:
      cycle_length = 0
  else:
      cycle_length = max([ len(j) for j in cycle_list ])
  if cycle_length <= 6:
      cycle_length = 0
  else:
      cycle_length = cycle_length - 6
  cycle_score = -cycle_length
  #print cycle_score
  #print SA_score
  #print logp
  SA_score_norm=(SA_score-SA_mean)/SA_std
  logp_norm=(logp-logP_mean)/logP_std
  cycle_score_norm=(cycle_score-cycle_mean)/cycle_std
  score_one = SA_score_norm + logp_norm + cycle_score_norm
  
  return score_one 
开发者ID:jensengroup,项目名称:GB-GA,代码行数:30,代码来源:scoring_functions.py

示例9: logP

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def logP(mol: Mol) -> float:
    return Descriptors.MolLogP(mol) 
开发者ID:BenevolentAI,项目名称:guacamol,代码行数:4,代码来源:descriptors.py

示例10: logP

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def logP(smile, train_smiles=None):
    try:
        low_logp = -2.12178879609
        high_logp = 6.0429063424
        logp = Crippen.MolLogP(Chem.MolFromSmiles(smile))
        val = remap(logp, low_logp, high_logp)
        val = np.clip(val, 0.0, 1.0)
        return val
    except ValueError:
        return 0.0

#====== druglikeliness 
开发者ID:gablg1,项目名称:ORGAN,代码行数:14,代码来源:mol_metrics.py

示例11: properties

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def properties(mol):
    """
    Calculates the properties that are required to calculate the QED descriptor.
    """
    matches = []
    if mol is None:
        raise WrongArgument("properties(mol)", "mol argument is \'None\'")
    x = [0] * 9
    # MW
    x[0] = Descriptors.MolWt(mol)
    # ALOGP
    x[1] = Descriptors.MolLogP(mol)
    for hba in Acceptors:                                                        # HBA
        if mol.HasSubstructMatch(hba):
            matches = mol.GetSubstructMatches(hba)
            x[2] += len(matches)
    x[3] = Descriptors.NumHDonors(
        mol)                                            # HBD
    # PSA
    x[4] = Descriptors.TPSA(mol)
    x[5] = Descriptors.NumRotatableBonds(
        mol)                                    # ROTB
    x[6] = Chem.GetSSSR(Chem.DeleteSubstructs(
        deepcopy(mol), AliphaticRings))    # AROM
    for alert in StructuralAlerts:                                                # ALERTS
        if (mol.HasSubstructMatch(alert)):
            x[7] += 1
    ro5_failed = 0
    if x[3] > 5:
        ro5_failed += 1  # HBD
    if x[2] > 10:
        ro5_failed += 1  # HBA
    if x[0] >= 500:
        ro5_failed += 1
    if x[1] > 5:
        ro5_failed += 1
    x[8] = ro5_failed
    return x 
开发者ID:gablg1,项目名称:ORGAN,代码行数:40,代码来源:mol_metrics.py

示例12: reward_penalized_log_p

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def reward_penalized_log_p(mol):
    """
    Reward that consists of log p penalized by SA and # long cycles,
    as described in (Kusner et al. 2017). Scores are normalized based on the
    statistics of 250k_rndm_zinc_drugs_clean.smi dataset
    :param mol: rdkit mol object
    :return: float
    """
    # normalization constants, statistics from 250k_rndm_zinc_drugs_clean.smi
    logP_mean = 2.4570953396190123
    logP_std = 1.434324401111988
    SA_mean = -3.0525811293166134
    SA_std = 0.8335207024513095
    cycle_mean = -0.0485696876403053
    cycle_std = 0.2860212110245455

    log_p = MolLogP(mol)
    SA = -calculateScore(mol)

    # cycle score
    cycle_list = nx.cycle_basis(nx.Graph(
        Chem.rdmolops.GetAdjacencyMatrix(mol)))
    if len(cycle_list) == 0:
        cycle_length = 0
    else:
        cycle_length = max([len(j) for j in cycle_list])
    if cycle_length <= 6:
        cycle_length = 0
    else:
        cycle_length = cycle_length - 6
    cycle_score = -cycle_length

    normalized_log_p = (log_p - logP_mean) / logP_std
    normalized_SA = (SA - SA_mean) / SA_std
    normalized_cycle = (cycle_score - cycle_mean) / cycle_std

    return normalized_log_p + normalized_SA + normalized_cycle


# # TEST compare with junction tree paper examples from Figure 7
# assert round(reward_penalized_log_p(Chem.MolFromSmiles('ClC1=CC=C2C(C=C(C('
#                                                        'C)=O)C(C(NC3=CC(NC('
#                                                        'NC4=CC(C5=C('
#                                                        'C)C=CC=C5)=CC=C4)=O)=CC=C3)=O)=C2)=C1')), 2) == 5.30
# assert round(reward_penalized_log_p(Chem.MolFromSmiles('CC(NC1=CC(C2=CC=CC('
#                                                        'NC(NC3=CC=CC(C4=CC('
#                                                        'F)=CC=C4)=C3)=O)=C2)=CC=C1)=O')), 2) == 4.49
# assert round(reward_penalized_log_p(Chem.MolFromSmiles('ClC(C('
#                                                        'Cl)=C1)=CC=C1NC2=CC=CC=C2C(NC(NC3=C(C(NC4=C(Cl)C=CC=C4)=S)C=CC=C3)=O)=O')), 2) == 4.93 
开发者ID:bowenliu16,项目名称:rl_graph_generation,代码行数:51,代码来源:molecule.py

示例13: get_normalized_values

# 需要导入模块: from rdkit.Chem import Descriptors [as 别名]
# 或者: from rdkit.Chem.Descriptors import MolLogP [as 别名]
def get_normalized_values():
    fname = '/home/bowen/pycharm_deployment_directory/rl_graph_generation/gym-molecule/gym_molecule/dataset/250k_rndm_zinc_drugs_clean.smi'
    with open(fname) as f:
        smiles = f.readlines()

    for i in range(len(smiles)):
        smiles[i] = smiles[i].strip()
    smiles_rdkit = []

    for i in range(len(smiles)):
        smiles_rdkit.append(Chem.MolToSmiles(Chem.MolFromSmiles(smiles[i])))
    print(i)

    logP_values = []
    for i in range(len(smiles)):
        logP_values.append(MolLogP(Chem.MolFromSmiles(smiles_rdkit[i])))
    print(i)

    SA_scores = []
    for i in range(len(smiles)):
        SA_scores.append(
            -calculateScore(Chem.MolFromSmiles(smiles_rdkit[i])))
    print(i)

    cycle_scores = []
    for i in range(len(smiles)):
        cycle_list = nx.cycle_basis(nx.Graph(
            Chem.rdmolops.GetAdjacencyMatrix(Chem.MolFromSmiles(smiles_rdkit[
                                                                  i]))))
        if len(cycle_list) == 0:
            cycle_length = 0
        else:
            cycle_length = max([len(j) for j in cycle_list])
        if cycle_length <= 6:
            cycle_length = 0
        else:
            cycle_length = cycle_length - 6
        cycle_scores.append(-cycle_length)
    print(i)

    SA_scores_normalized = (np.array(SA_scores) - np.mean(SA_scores)) / np.std(
        SA_scores)
    logP_values_normalized = (np.array(logP_values) - np.mean(
        logP_values)) / np.std(logP_values)
    cycle_scores_normalized = (np.array(cycle_scores) - np.mean(
        cycle_scores)) / np.std(cycle_scores)

    return np.mean(SA_scores), np.std(SA_scores), np.mean(
        logP_values), np.std(logP_values), np.mean(
        cycle_scores), np.std(cycle_scores)




# smile = 'C'*38 
开发者ID:bowenliu16,项目名称:rl_graph_generation,代码行数:57,代码来源:molecule.py


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