How markusorsi/pdga works
Project Type and Purpose
• PDGA is a modular genetic algorithm framework focused on peptide design. It uses genetic operators (fitness, selection, crossover, mutation) to iteratively generate peptide sequences with desired properties.
• The README highlights that the project handles building blocks (chemical monomers, N-terminal caps, branches, additional blocks) and modular genetic operators. The design encourages flexibility via interchangeable modules and configuration through CLI.
File Structure
• Key Directories/Files:
• bblocks: Contains CSV files with chemical building blocks and the BuildingBlockManager (bbmanager.py) responsible for data loading and sequence translation.
• operators: Contains subdirectories for each type of genetic operator:
▸ crossover: Different crossover implementations (e.g., single point, skip).
▸ fitness: Various fitness functions (e.g., atompair, map4c, mxfp).
▸ mutation: Mutation operators.
▸ selection: Selection strategies (maximize, minimize, randomize).
• config.py: Default configuration settings.
• main.py and pdga.py: Serve as entry points and core implementation of the genetic algorithm.
• utils.py: Implements the ResultsHandler, which manages the output and logging of experimental hits.
• logs and results: Directories for logging experiments and storing output CSVs respectively.
• Architectural Indicators:
• Clear separation of concerns: building blocks handling, genetic operator implementations, configuration, main algorithm core, and results processing.
• Modular design enabling easy swapping of components.
a. Main Components:
• Configuration & CLI: Represented by config.py and command-line argument parsing in main.py.
• Building Block Manager: Module in bblocks (bbmanager.py) that loads CSV files and manages building block data.
• Genetic Algorithm Core (PDGA): Central component (pdga.py) that orchestrates population initialization, iteration across generations, and integration of genetic operators.
▸ Selection (operators/selection)
▸ Fitness Evaluation (operators/fitness)
▸ Crossover (operators/crossover)
▸ Mutation (operators/mutation)
• Results Handler: Shown as the component managed by utils.py, linked to the results directory, responsible for aggregating hit sequences.
• Logging: Represented with the logs folder where experiment logs are stored.
b. Relationships and Interactions:
• The Building Block Manager is called early in the process to load peptide building block data from the CSV files.
• The PDGA core engine then creates an initial population and, for each generation, sequentially uses:
• The selection operator to choose parent candidates.
• Crossover and mutation operators to generate offspring.
• Fitness functions to evaluate each individual’s performance against the target query.
• After each iteration (or at a predefined cutoff), the Results Handler collects sequences that meet the fitness threshold and writes them to CSV files in the results directory.
• Logging of operations occurs throughout and is stored in the logs directory.
c. Architectural Patterns and Design Principles:
• Modularity: Organize genetic operators and building block management as swappable modules.
• Separation of Concerns: Each primary component (data management, genetic operations, output handling) handles a clearly defined responsibility.
• Extensibility: The design supports plugging in new operators or modifying configurations with minimal changes.
• Configuration-Driven: The system is designed to be activated and adapted through both CLI arguments and configuration files (config.py).
d. Technologies and Frameworks:
• Language: Python (version 3.9.5 as indicated by the badge).
• Dependencies: Listed in requirements.txt.
• CSV for data (the building block files) and standard logging mechanisms.
• Basic command-line interface for flexible parameter configuration.
Final Advice
• Be very thorough in capturing the interaction between modules.
• Avoid oversimplification – even if the algorithm is iterative and modular, break down each stage (data input, processing, and output) with individual nodes.
• Review the README and file structure to ensure all critical components, such as the modular operators and configuration settings, are included.