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


Python RDLogger.logger方法代码示例

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


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

示例1: configure_worker

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def configure_worker(options={}, **kwargs):
    if 'queues' not in options:
        return
    if CORRESPONDING_QUEUE not in options['queues'].split(','):
        return
    print('### STARTING UP A NEAREST NEIGHBOR CONTEXT RECOMMENDER WORKER ###')

    global recommender

    # Setting logging low
    from rdkit import RDLogger
    lg = RDLogger.logger()
    lg.setLevel(RDLogger.CRITICAL)
    try:
        recommender = NNContextRecommender()
        recommender.load_nn_model(model_path=gc.CONTEXT_REC[
                                  'model_path'], info_path=gc.CONTEXT_REC['info_path'])
    except Exception as e:
        print(e)
    print('Loaded context recommendation model')

    print('### NEAREST NEIGHBOR CONTEXT RECOMMENDER STARTED UP ###') 
开发者ID:connorcoley,项目名称:ASKCOS,代码行数:24,代码来源:cr_nn_worker.py

示例2: configure_worker

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def configure_worker(options={}, **kwargs):
    if 'queues' not in options:
        return
    if CORRESPONDING_QUEUE not in options['queues'].split(','):
        return
    print('### STARTING UP A NEURAL NETWORK CONTEXT RECOMMENDER WORKER ###')

    global recommender

    # Setting logging low
    from rdkit import RDLogger
    lg = RDLogger.logger()
    lg.setLevel(RDLogger.CRITICAL)
    try:
        recommender = NeuralNetContextRecommender()
        recommender.load()
    except Exception as e:
        print(e)
    print('Loaded context recommendation model')

    print('### NEURAL NETWORK CONTEXT RECOMMENDER STARTED UP ###') 
开发者ID:connorcoley,项目名称:ASKCOS,代码行数:23,代码来源:cr_network_worker.py

示例3: write_scaffold

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def write_scaffold(self, scaffold):
        subscaffolds = ', '.join([str(s.id) for s in scaffold.subscaffolds])
        if self.args.sdf:
            molecule = MolFromSmiles(scaffold.smiles)
            if molecule is not None:
                molecule.SetProp('_Name', str(scaffold.id))
                molecule.SetIntProp('HIERARCHY', scaffold.hierarchy)
                molecule.SetProp('SMILES', scaffold.smiles)
                molecule.SetProp('SUBSCAFFOLDS', subscaffolds)
                self.output.write(molecule)
            else:
                logger.warning(f'Failed to parse scaffold: {scaffold.smiles}')
        else:
            self.output.write('{0}\t{1}\t{2}\t{3}\n'.format(
                scaffold.id,
                scaffold.hierarchy,
                scaffold.smiles,
                subscaffolds)) 
开发者ID:UCLCheminformatics,项目名称:ScaffoldGraph,代码行数:20,代码来源:operations.py

示例4: select

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def select(self):
        if not self.args.sdf:
            self.output.write('ID\tHIERARCHY\tSMILES\tSUBSCAFFOLDS\n')
        self.load_query()
        logger.info('Processing query...')
        reader = ScaffoldFileIterator(self.g_input, reverse=True)
        for scaffold in reader:
            match = False
            if scaffold.smiles in self.query:
                match = True
            if scaffold.id in self.matching_parents:
                match = True
            if match is True:
                self.count += 1
                self.write_scaffold(scaffold)
                for s in scaffold.subscaffolds:
                    self.matching_parents.add(s.id) 
开发者ID:UCLCheminformatics,项目名称:ScaffoldGraph,代码行数:19,代码来源:operations.py

示例5: load_query

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def load_query(self):
        logger.info('Reading molecular query...')
        file = None
        fmt = file_format(self.q_input)
        if fmt == 'SMI':
            supplier = smiles.read_smiles_file(self.q_input)
        elif fmt == 'SDF':
            rdlogger.setLevel(4)
            file = open(self.q_input, 'rb')
            supplier = sdf.read_sdf(file)
        else:
            raise ValueError('input file format not currently supported')
        for molecule in supplier:
            if molecule is not None:
                s = get_murcko_scaffold(molecule)
                self.query.add(MolToSmiles(s))
        if file is not None:
            file.close()
        logger.info(f'Read {len(self.query)} query scaffolds') 
开发者ID:UCLCheminformatics,项目名称:ScaffoldGraph,代码行数:21,代码来源:operations.py

示例6: select_cli

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def select_cli(args):
    """Command line function for selecting a subset using a molecular query"""

    if not args.silent:
        print(start_message.format(command='Select',
                                   input=[args.input_graph, args.input_query],
                                   output=args.output))
    start = time.time()
    with SelectCLI(args) as selector:
        selector.select()

    logger.info('Scaffold Graph Selection Operation Complete.')
    elapsed = datetime.timedelta(seconds=round(time.time() - start))

    if not args.silent:
        print(stop_message_sel.format(command='Select',
                                      scaffolds=selector.count,
                                      time=elapsed, output=args.output)) 
开发者ID:UCLCheminformatics,项目名称:ScaffoldGraph,代码行数:20,代码来源:operations.py

示例7: get_scaffold_frags

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def get_scaffold_frags(frag):
    """Get fragments from a disconnected structure.
    Used by fragmentation methods."""
    try:
        # frag.ClearComputedProps()
        # frag.UpdatePropertyCache()
        # Chem.GetSymmSSSR(frag)
        partial_sanitization(frag)
    except ValueError as e:
        # This error is caught as dissecting an aromatic ring system,
        # may lead to an undefined state where the resultant system
        # is no longer aromatic. We make no attempt to prevent this
        # but log it for reference.
        # This behaviour may be desirable for a scaffold tree and is
        # equivalent to the behavior of SNG (I believe...)
        logger.debug(e)
        return set()
    frags = {Scaffold(f) for f in GetMolFrags(frag, True, False)}
    return frags 
开发者ID:UCLCheminformatics,项目名称:ScaffoldGraph,代码行数:21,代码来源:fragment.py

示例8: calculate_internal_pairwise_similarities

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def calculate_internal_pairwise_similarities(smiles_list: Collection[str]) -> np.array:
    """
    Computes the pairwise similarities of the provided list of smiles against itself.

    Returns:
        Symmetric matrix of pairwise similarities. Diagonal is set to zero.
    """
    if len(smiles_list) > 10000:
        logger.warning(f'Calculating internal similarity on large set of '
                       f'SMILES strings ({len(smiles_list)})')

    mols = get_mols(smiles_list)
    fps = get_fingerprints(mols)
    nfps = len(fps)

    similarities = np.zeros((nfps, nfps))

    for i in range(1, nfps):
        sims = DataStructs.BulkTanimotoSimilarity(fps[i], fps[:i])
        similarities[i, :i] = sims
        similarities[:i, i] = sims

    return similarities 
开发者ID:BenevolentAI,项目名称:guacamol,代码行数:25,代码来源:chemistry.py

示例9: disable_rdkit_logging

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def disable_rdkit_logging():
    """
    Disables RDKit whiny logging.
    """
    import rdkit.RDLogger as rkl
    logger = rkl.logger()
    logger.setLevel(rkl.ERROR)

    import rdkit.rdBase as rkrb
    rkrb.DisableLog('rdApp.error') 
开发者ID:undeadpixel,项目名称:reinvent-randomized,代码行数:12,代码来源:chem.py

示例10: aggregate

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def aggregate(self):
        if not self.args.sdf:
            self.output.write('ID\tHIERARCHY\tSMILES\tSUBSCAFFOLDS\n')
        for file in self.inputs:
            logger.info(f'Processing file: {file}...')
            with open(file, 'r') as fw:
                self.process_file(fw) 
开发者ID:UCLCheminformatics,项目名称:ScaffoldGraph,代码行数:9,代码来源:operations.py

示例11: _construct

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def _construct(self, molecules, ring_cutoff=10, progress=False, annotate=True):
        """
        Private method for graph construction, called by constructors

        Parameters
        ----------
        molecules: iterable of rdkit molecules for processing
        ring_cutoff: ignore molecules with more than the specified number
            of rings to avoid extended processing times (default: 10)
        annotate: if True write an annotated murcko scaffold SMILES string to each
            molecule edge (molecule --> scaffold)
        progress: if True show a progress bar monitoring progress (default: False)
        """
        rdlogger.setLevel(4)  # Suppress the RDKit logs
        progress = progress is False
        desc = self.__class__.__name__
        for molecule in tqdm(molecules, disable=progress, desc=desc, miniters=1, dynamic_ncols=True):
            if molecule is None:  # logged in suppliers
                continue
            init_molecule_name(molecule)
            if CalcNumRings(molecule) > ring_cutoff:
                name = molecule.GetProp('_Name')
                logger.warning(f'Molecule {name} filtered (> {ring_cutoff} rings)')
                continue
            rdmolops.RemoveStereochemistry(molecule)
            scaffold = Scaffold(get_murcko_scaffold(molecule))
            if scaffold:  # Checks that a scaffold has at least 1 atom
                annotation = None
                if annotate:
                    annotation = get_annotated_murcko_scaffold(molecule, scaffold.mol, False)
                self.add_scaffold_node(scaffold)
                self.add_molecule_node(molecule)
                self.add_molecule_edge(molecule, scaffold, annotation=annotation)
                if scaffold.rings.count > 1:
                    self._recursive_constructor(scaffold)
            else:
                name = molecule.GetProp('_Name')
                logger.warning(f'No top level scaffold for molecule {name}')
        rdlogger.setLevel(3)  # Enable the RDKit logs 
开发者ID:UCLCheminformatics,项目名称:ScaffoldGraph,代码行数:41,代码来源:graph.py

示例12: calculate_pairwise_similarities

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def calculate_pairwise_similarities(smiles_list1: List[str], smiles_list2: List[str]) -> np.array:
    """
    Computes the pairwise ECFP4 tanimoto similarity of the two smiles containers.

    Returns:
        Pairwise similarity matrix as np.array
    """
    if len(smiles_list1) > 10000 or len(smiles_list2) > 10000:
        logger.warning(f'Calculating similarity between large sets of '
                       f'SMILES strings ({len(smiles_list1)} x {len(smiles_list2)})')

    mols1 = get_mols(smiles_list1)
    fps1 = get_fingerprints(mols1)

    mols2 = get_mols(smiles_list2)
    fps2 = get_fingerprints(mols2)

    similarities = []

    for fp1 in fps1:
        sims = DataStructs.BulkTanimotoSimilarity(fp1, fps2)

        similarities.append(sims)

    similarities = np.array(similarities)

    return similarities 
开发者ID:BenevolentAI,项目名称:guacamol,代码行数:29,代码来源:chemistry.py

示例13: get_mols

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def get_mols(smiles_list: Iterable[str]) -> Iterable[Chem.Mol]:
    for i in smiles_list:
        try:
            mol = Chem.MolFromSmiles(i)
            if mol is not None:
                yield mol
        except Exception as e:
            logger.warning(e) 
开发者ID:BenevolentAI,项目名称:guacamol,代码行数:10,代码来源:chemistry.py

示例14: _calculate_pc_descriptors

# 需要导入模块: from rdkit import RDLogger [as 别名]
# 或者: from rdkit.RDLogger import logger [as 别名]
def _calculate_pc_descriptors(smiles: str, pc_descriptors: List[str]) -> np.array:
    calc = MoleculeDescriptors.MolecularDescriptorCalculator(pc_descriptors)

    mol = Chem.MolFromSmiles(smiles)
    if mol is None:
        return None
    _fp = calc.CalcDescriptors(mol)
    _fp = np.array(_fp)
    mask = np.isfinite(_fp)
    if (mask == 0).sum() > 0:
        logger.warning(f'{smiles} contains an NAN physchem descriptor')
        _fp[~mask] = 0

    return _fp 
开发者ID:BenevolentAI,项目名称:guacamol,代码行数:16,代码来源:chemistry.py


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