How molecularai/aizynthfinder works
Main components
• Core Modules:
• Chem Module: Classes for molecules, reactions, and serialization (located in aizynthfinder/chem).
• Context Module: Handles configuration, reaction expansion policies, filter strategies, scoring, and stock queries (under aizynthfinder/context). This module manages the various settings and models (neural networks or static policies) that drive the search algorithms.
• Search Module: Houses several search algorithms (MCTS, breadth-first, DFPN, retrostar) that implement retrosynthetic tree search strategies (located in aizynthfinder/search and its sub-folders). Each subdirectory corresponds to a different algorithmic approach.
• Analysis Module: Provides tools for visualizing and analyzing the reaction tree (found in aizynthfinder/analysis) and includes templates for rendering reaction trees.
• Interfaces Module: Comprises user-facing integrations including CLI (aizynthfinder/interfaces/aizynthcli.py), a GUI (aizynthfinder/interfaces/gui), and an app interface (aizynthfinder/interfaces/aizynthapp.py). This is the layer through which end-users interact with the tool.
• Tools & Utilities: Scripts for various supportive actions (like downloading data or generating stocks) in aizynthfinder/tools and utilities in aizynthfinder/utils.
• Auxiliary Components:
• Plugins: Additional customization points/extensions (in the plugins directory).
• Data/Templates: Default configuration files (in aizynthfinder/data) and documentation (in docs).
• CI/CD Infrastructure: GitHub workflows for tests, docs generation, and package publishing (in .github/workflows).
• Testing Suite: A robust test suite (in tests directory) covering each module and integration aspects.
Relationships and interactions
• Configuration & Setup: Show a block for “Configuration/Context” feeding into both the search module (by guiding policies, scorers, and stock queries) and core algorithm execution.
• Search Engine:
• “Retrosynthetic Search Engine” which is at the heart of the system. Inside it, indicate the different algorithms (MCTS, breadth-first, DFPN, retrostar) and show that they all operate on a central “Reaction Tree” (which can be represented as a central shared data structure).
• Link the “Chem” components to this engine to signal that molecule definitions, reactions, and serialization flow into the search process.
• Analysis & Visualization:
• An Analysis component that takes the output from the search engine (the generated reaction trees) and, using utility components (such as tree visualization templates), creates visual representations.
• External Data Dependency:
• Tools/Utility Functions: Auxiliary services (e.g., make_stock, download_public_data) which integrate with the main system for setup and maintenance tasks.
Architectural/Design Patterns and Technologies
• That the design leverages a modular and component-based architecture, which eases extensibility (plugins, multiple search strategies).
• Separation of concerns: Each module (e.g., chem, context, search, interfaces) has a well-defined purpose.
• Mention that the system follows a fairly layered design, where the front-end (interfaces) interacts with the business logic (search algorithms and policy components), which in turn relies on domain-specific modules (chemistry operations, scoring, and analysis).