How maxhwardg/mrnafold works
Main Components
• Build/Development Infrastructure:
– CMake configuration for building the C++ source (located in cpp_src with separate subdirectories for the executable and the mwmrna_lib library).
– Build directory and out-of-source build process.
• Core C++ Engine:
– The “mwmrna_lib” library encapsulates most of the logic with modules for codon graph construction (codon_graph.hpp, codon_graph_fold.hpp, codon_graph_trace.hpp), RNA structure analysis (rna.hpp, structure.hpp), energy calculations (energy_calculator.hpp, energy_model.hpp, energy_semiring.hpp), logging, parallel processing, and protein handling.
– The “fold_codon_graph” executable in the cpp_src/exe directory uses this library to drive mRNA folding, reading configuration parameters and producing folded sequences.
• Input/Configuration Layer:
– Config files in the “configs” directory that include parameters such as the amino acid sequence (aa_seq), suboptimal-folding parameters, multithreading options, UTRs, and codon restrictions.
– Codon tables in the “codon_tables” folder provide external data inputs for codon usage (e.g., human and mouse codon tables).
• Python Interface:
– A Python runner, fold_codons.py in the “pysrc” directory, which provides a convenient function interface to call the compiled binaries. It also integrates with external packages like ViennaRNA for result evaluation.
• External Dependencies:
– Libraries/tools like the C++20 standard library (including parallel features), Intel TBB, and external Python dependency (ViennaRNA) for evaluation.
Relationships and Data Flow
• The client/user initiates the process by either running the C++ executable directly (passing a config file) or via the Python script.
• The configuration file is read by the executable to set up the runtime parameters, including which codon table to use (default is baked-in for human, but others can be specified).
• The “fold_codon_graph” executable (the driver) invokes underlying functions from the mwmrna_lib library. Within this library:
– The codon graph modules build the graph representation of the mRNA structure.
– Energy calculators and scoring mechanisms compute the MFE, CAI, and optionally incorporate randomness for suboptimal sampling.
– Multithreading is used if enabled, allowing different sampling rounds to be executed in parallel.
• The result—multiple folded mRNA sequences along with scores and alternative structures—gets output to the console or captured by the Python interface for further evaluation or integration.
Architectural Patterns and Design Principles
• Layered Design: The project separates concerns between configuration/input, core algorithm (library), and user interfaces (CLI executable and Python script).
• Extensibility and Integration: The system is designed so that the Python wrapper integrates with the successful compiled C++ backend and also depends on external packages for additional functionality (e.g., ViennaRNA).
• Configurable Workflow: The numerous configuration parameters illustrate that users can dynamically adjust behavior, making it important to show an isolated “Configuration Parser/Manager” component.
Relevant Technologies, Frameworks, and Libraries
• C++20 with modern constructs and the standard library for multithreading.
• CMake as the build system.
• Intel TBB (if used) for parallelism.
• Python and the ViennaRNA library as part of the interface layer.
• Additionally, external codon frequency tables and configuration files provide input—which could be highlighted as data resources.
Elements
• Each component should be clearly labeled (e.g., “Configuration Manager”, “Codon Graph Module”, “Energy Calculator”, “Folding Driver Executable”, “Python Interface”).
– Rectangles for executables and libraries.
• Annotations explaining inter-module interactions: for example, indicate that the “fold_codon_graph” driver calls functions from “mwmrna_lib” which in turn uses “codon_graph”, “energy_calculator”, “parallel processing” and “logging”.
Putting It All Together
– Branch into two user interface paths: direct C++ executable and the Python runner.
– The next layer is “Configuration Processing” which consumes config files from the “configs” directory and codon tables from the “codon_tables” directory.
– Then detail the “Core C++ Engine” with subcomponents:
• “mwmrna_lib” with codon graph, energy evaluation, and structure processing.
• “fold_codon_graph” as the main driver interfacing with the library.
– Finally, show the output layer where optimized mRNA sequences, complete with MFE, CAI, and structure information, are returned to the user or passed back to the Python interface.
– Optionally, add an “External Dependencies” node to show integration with third-party libraries/tools (C++ standard library, Intel TBB, ViennaRNA, etc.).