當前位置: 首頁>>代碼示例>>Python>>正文


Python Descriptors.MolWt方法代碼示例

本文整理匯總了Python中rdkit.Chem.Descriptors.MolWt方法的典型用法代碼示例。如果您正苦於以下問題:Python Descriptors.MolWt方法的具體用法?Python Descriptors.MolWt怎麽用?Python Descriptors.MolWt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rdkit.Chem.Descriptors的用法示例。


在下文中一共展示了Descriptors.MolWt方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: filter_smiles

# 需要導入模塊: from rdkit.Chem import Descriptors [as 別名]
# 或者: from rdkit.Chem.Descriptors import MolWt [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 MolWt [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: preprocessMolecule

# 需要導入模塊: from rdkit.Chem import Descriptors [as 別名]
# 或者: from rdkit.Chem.Descriptors import MolWt [as 別名]
def preprocessMolecule(inp):
	def checkC(mm):
		mwt = Descriptors.MolWt(mm)
		for atom in mm.GetAtoms():
			if atom.GetAtomicNum() == 6 and 100 <= mwt <= 1000: return True
		return False
	def checkHm(mm):
		for atom in mm.GetAtoms():
			if atom.GetAtomicNum() in [2,10,13,18]: return False
			if 21 <= atom.GetAtomicNum() <= 32: return False
			if 36 <= atom.GetAtomicNum() <= 52: return False
			if atom.GetAtomicNum() >= 54: return False
		return True
	try: std_mol = standardise.run(inp)
	except standardise.StandardiseException: return None
	if not std_mol or checkHm(std_mol) == False or checkC(std_mol) == False: return None
	else: return std_mol

#preprocess exception to catch 
開發者ID:lhm30,項目名稱:PIDGINv3,代碼行數:21,代碼來源:predict_enriched.py

示例4: weight

# 需要導入模塊: from rdkit.Chem import Descriptors [as 別名]
# 或者: from rdkit.Chem.Descriptors import MolWt [as 別名]
def weight(mol):
    """
    Computes molecular weight for given molecule.
    Returns float,
    """
    return Descriptors.MolWt(mol) 
開發者ID:molecularsets,項目名稱:moses,代碼行數:8,代碼來源:utils.py

示例5: molwt

# 需要導入模塊: from rdkit.Chem import Descriptors [as 別名]
# 或者: from rdkit.Chem.Descriptors import MolWt [as 別名]
def molwt(self):
        return Descriptors.MolWt(self.Mol) 
開發者ID:oddt,項目名稱:oddt,代碼行數:4,代碼來源:rdk.py

示例6: mol_weight

# 需要導入模塊: from rdkit.Chem import Descriptors [as 別名]
# 或者: from rdkit.Chem.Descriptors import MolWt [as 別名]
def mol_weight(mol: Mol) -> float:
    return Descriptors.MolWt(mol) 
開發者ID:BenevolentAI,項目名稱:guacamol,代碼行數:4,代碼來源:descriptors.py

示例7: properties

# 需要導入模塊: from rdkit.Chem import Descriptors [as 別名]
# 或者: from rdkit.Chem.Descriptors import MolWt [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

示例8: logP_mw

# 需要導入模塊: from rdkit.Chem import Descriptors [as 別名]
# 或者: from rdkit.Chem.Descriptors import MolWt [as 別名]
def logP_mw(fnames, is_active=False):
    """ logP and molecular weight calculation for logP ~ MW chemical space visualization

    Arguments:
        fnames (list): List of file paths that contains CANONICAL_SMILES (, LOGP and MWT
            if it contains the logP and molecular weight for each molecule).
        is_active (bool, optional): selecting only active ligands (True) or all of the molecules (False)
            if it is true, the molecule with PCHEMBL_VALUE >= 6.5 or SCORE > 0.5 will be selected.
            (Default: False)

    Returns:
        df (DataFrame): The table contains three columns;
            molecular weight, logP and index of file name in the fnames
    """
    df = pd.DataFrame()
    for i, fname in enumerate(fnames):
        print(fname)
        sub = pd.read_table(fname)
        sub['LABEL'] = i
        if 'PCHEMBL_VALUE' in sub.columns:
            sub = sub[sub.PCHEMBL_VALUE >= (6.5 if is_active else 0)]
        elif 'SCORE' in sub.columns:
            sub = sub[sub.SCORE > (0.5 if is_active else 0)]
        sub = sub.drop_duplicates(subset='CANONICAL_SMILES')
        if not ('LOGP' in sub.columns and 'MWT' in sub.columns):
            # If the the table does not contain LOGP and MWT
            # it will calculate these coefficients with RDKit.
            logp, mwt = [], []
            for i, row in sub.iterrows():
                try:
                    mol = Chem.MolFromSmiles(row.CANONICAL_SMILES)
                    x, y = desc.MolWt(mol), Crippen.MolLogP(mol)
                    logp.append(y)
                    mwt.append(x)
                except:
                    sub = sub.drop(i)
                    print(row.CANONICAL_SMILES)
            sub['LOGP'], sub['MWT'] = logp, mwt
        df = df.append(sub[['MWT', 'LOGP', 'LABEL']])
    return df 
開發者ID:XuhanLiu,項目名稱:DrugEx,代碼行數:42,代碼來源:metric.py

示例9: calc_esol_descriptors

# 需要導入模塊: from rdkit.Chem import Descriptors [as 別名]
# 或者: from rdkit.Chem.Descriptors import MolWt [as 別名]
def calc_esol_descriptors(self, mol):
        """
        Calcuate mw,logp,rotors and aromatic proportion (ap)
        :param mol: input molecule
        :return: named tuple with descriptor values
        """
        mw = Descriptors.MolWt(mol)
        logp = Crippen.MolLogP(mol)
        rotors = Lipinski.NumRotatableBonds(mol)
        ap = self.calc_ap(mol)
        return self.Descriptor(mw=mw, logp=logp, rotors=rotors, ap=ap) 
開發者ID:PatWalters,項目名稱:solubility,代碼行數:13,代碼來源:esol.py

示例10: PhyChem

# 需要導入模塊: from rdkit.Chem import Descriptors [as 別名]
# 或者: from rdkit.Chem.Descriptors import MolWt [as 別名]
def PhyChem(smiles):
    """ Calculating the 19D physicochemical descriptors for each molecules,
    the value has been normalized with Gaussian distribution.

    Arguments:
        smiles (list): list of SMILES strings.
    Returns:
        props (ndarray): m X 19 matrix as nomalized PhysChem descriptors.
            m is the No. of samples
    """
    props = []
    for smile in smiles:
        mol = Chem.MolFromSmiles(smile)
        try:
            MW = desc.MolWt(mol)
            LOGP = Crippen.MolLogP(mol)
            HBA = Lipinski.NumHAcceptors(mol)
            HBD = Lipinski.NumHDonors(mol)
            rotable = Lipinski.NumRotatableBonds(mol)
            amide = AllChem.CalcNumAmideBonds(mol)
            bridge = AllChem.CalcNumBridgeheadAtoms(mol)
            heteroA = Lipinski.NumHeteroatoms(mol)
            heavy = Lipinski.HeavyAtomCount(mol)
            spiro = AllChem.CalcNumSpiroAtoms(mol)
            FCSP3 = AllChem.CalcFractionCSP3(mol)
            ring = Lipinski.RingCount(mol)
            Aliphatic = AllChem.CalcNumAliphaticRings(mol)
            aromatic = AllChem.CalcNumAromaticRings(mol)
            saturated = AllChem.CalcNumSaturatedRings(mol)
            heteroR = AllChem.CalcNumHeterocycles(mol)
            TPSA = MolSurf.TPSA(mol)
            valence = desc.NumValenceElectrons(mol)
            mr = Crippen.MolMR(mol)
            # charge = AllChem.ComputeGasteigerCharges(mol)
            prop = [MW, LOGP, HBA, HBD, rotable, amide, bridge, heteroA, heavy, spiro,
                    FCSP3, ring, Aliphatic, aromatic, saturated, heteroR, TPSA, valence, mr]
        except:
            print(smile)
            prop = [0] * 19
        props.append(prop)
    props = np.array(props)
    props = Scaler().fit_transform(props)
    return props 
開發者ID:XuhanLiu,項目名稱:DrugEx,代碼行數:45,代碼來源:metric.py


注:本文中的rdkit.Chem.Descriptors.MolWt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。