continue if len(t.retrons) == 1: transforms.append(t) # Get a random sample of chemical compounds. sample = Sample(chemicals, size=args.size, rng_seed=args.seed) # Initialize data structures for stats gathering. keys = ['accepted', 'valid', 'total'] new_stats = dict(zip(keys, len(keys) * [0])) old_stats = dict(zip(keys, len(keys) * [0])) # For each chemical in the sample perform a single retrosynthetic step. reactions = {} disconnected_count = 0 for chem_rec in sample.get(): try: smi = chem_rec['smiles'].encode('ascii') except (AttributeError, KeyError): sys.stderr.write('Chemical {0} has no SMILES'.format(chem_rec['_id'])) continue # Ignore disconnected chemicals, e.g. such as c1cc([O-].[Na+])ccc1, # as we treat '.' (dot) as a compound separator. if '.' in smi: disconnected_count += 1 continue try: chem = Chemical(smi) except ValueError: