本文整理匯總了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 ###')
示例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 ###')
示例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))
示例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)
示例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')
示例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))
示例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
示例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
示例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')
示例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)
示例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
示例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
示例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)
示例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