Exemplo n.º 1
0
def main():
    """ Entry point for the aizynthcli command
    """
    args = _get_arguments()
    if args.nproc:
        return _multiprocess_smiles(args)

    multi_smiles = os.path.exists(args.smiles)

    file_level_logging = logging.DEBUG if args.log_to_file else None
    setup_logger(logging.INFO, file_level_logging)

    finder = AiZynthFinder(configfile=args.config)
    _select_stocks(finder, args)
    finder.expansion_policy.select(args.policy
                                   or finder.expansion_policy.items[0])
    try:
        finder.filter_policy.select(args.policy)
    except KeyError:
        pass

    if multi_smiles:
        _process_multi_smiles(args.smiles, finder, args.output)
    else:
        _process_single_smiles(args.smiles, finder, args.output)
Exemplo n.º 2
0
def _multiprocess_smiles(args: argparse.Namespace) -> None:
    def create_cmd(index, filename):
        cmd_args = [
            "aizynthcli",
            "--smiles",
            filename,
            "--config",
            args.config,
            "--output",
            hdf_files[index - 1],
        ]
        if args.policy:
            cmd_args.extend(["--policy", args.policy])
        if args.stocks:
            cmd_args.append("--stocks")
            cmd_args.extend(args.stocks)
        if args.cluster:
            cmd_args.append("--cluster")
        return cmd_args

    if not os.path.exists(args.smiles):
        raise ValueError(
            "For multiprocessing execution the --smiles argument needs to be a filename"
        )

    setup_logger(logging.INFO)
    filenames = split_file(args.smiles, args.nproc)
    hdf_files = [tempfile.mktemp(suffix=".hdf") for _ in range(args.nproc)]
    start_processes(filenames, "aizynthcli", create_cmd)

    if not all(os.path.exists(filename) for filename in hdf_files):
        raise FileNotFoundError(
            "Not all output files produced. Please check the individual log files: 'aizynthcli*.log'"
        )
    cat_hdf_files(hdf_files, args.output or "output.hdf5")
Exemplo n.º 3
0
 def __init__(self, configfile, setup=True):
     setup_logger(logging.INFO)
     self.finder = AiZynthFinder(configfile=configfile)
     self._input = dict()
     self._output = dict()
     self._buttons = dict()
     if setup:
         self.setup()
Exemplo n.º 4
0
 def __init__(self, configfile: str, setup: bool = True) -> None:
     setup_logger(logging.INFO)
     self.finder = AiZynthFinder(configfile=configfile)
     self._input: StrDict = dict()
     self._output: StrDict = dict()
     self._buttons: StrDict = dict()
     if setup:
         self.setup()
Exemplo n.º 5
0
 def __init__(self, configfile: str, setup: bool = True) -> None:
     # pylint: disable=used-before-assignment
     setup_logger(logging.INFO)
     self.finder = AiZynthFinder(configfile=configfile)
     self._input: StrDict = dict()
     self._output: StrDict = dict()
     self._buttons: StrDict = dict()
     if setup:
         self.setup()
Exemplo n.º 6
0
def main():
    """ Entry point for the aizynthcli command
    """
    args = _get_arguments()
    multi_smiles = os.path.exists(args.smiles)

    file_level_logging = logging.DEBUG if args.log_to_file else None
    setup_logger(logging.INFO, file_level_logging)

    finder = AiZynthFinder(configfile=args.config)
    _select_stocks(finder, args)
    finder.policy.select_policy(args.policy
                                or finder.policy.available_policies()[0])

    if multi_smiles:
        _process_multi_smiles(args.smiles, finder, args.output)
    else:
        _process_single_smiles(args.smiles, finder, args.output)
Exemplo n.º 7
0
def main() -> None:
    """Entry point for the aizynthcli command"""
    args = _get_arguments()
    if args.nproc:
        _multiprocess_smiles(args)
        return

    multi_smiles = os.path.exists(args.smiles)

    file_level_logging = logging.DEBUG if args.log_to_file else None
    setup_logger(logging.INFO, file_level_logging)

    finder = AiZynthFinder(configfile=args.config)
    _select_stocks(finder, args)
    finder.expansion_policy.select(args.policy
                                   or finder.expansion_policy.items[0])
    finder.filter_policy.select(args.filter)

    func = _process_multi_smiles if multi_smiles else _process_single_smiles
    func(args.smiles, finder, args.output, args.cluster,
         args.route_distance_model)