Repository navigation
Closed
Copy link
Description
Description
The current LevelManager class has grown too large and handles multiple responsibilities, including managing levels, beads, coordinates, dihedrals, matrices, forces, and torques. This makes the code difficult to maintain, test, and extend.
This task aims to modularize the class into focused components and introduce a graph/DAG-based representation of hierarchical dependencies. This will simplify computations, reduce repeated loops, and make it easier to add new entropy estimates in the future.
Scope
- Split
LevelManagerinto multiple classes:LevelHierarchy: manages levels and beads.CoordinateSystem: computes axes, average positions, and coordinate transformations.StructuralAnalysis: handles dihedrals and structural metrics.MatrixOperations: handles submatrices and matrix utilities.ForceTorqueManager: calculates weighted forces and torques.
- Implement a DAG-based computation order for hierarchical entropy calculations.
- Refactor existing methods into these classes without changing external behavior.
- Ensure
LevelManageracts only as a coordinator. - Update internal documentation and APIs.
Tasks
- Map current
LevelManagermethods to the proposed modular classes. - Implement
LevelHierarchyto manage levels and beads. - Implement
CoordinateSystemfor axes and position calculations. - Implement
StructuralAnalysisfor dihedral and structural calculations. - Implement
MatrixOperationsfor submatrix and matrix handling. - Implement
ForceTorqueManagerfor weighted force and torque calculations. - Introduce DAG-based representation of levels and beads to pre-map dependencies.
- Update
LevelManagerto coordinate modular components and DAG-based computation. - Unit test each new class independently.
- Document new architecture and DAG-based workflow.
Benefits
- Single Responsibility Principle: Each class has one clear responsibility.
- Testability: Easier to write unit tests and verify calculations.
- Maintainability: Refactoring or adding new features is safer and easier.
- Scalability: DAG ensures correct computation order and reduces redundant calculations.
- Future-Proofing: Adding new entropy estimates is straightforward using existing modular classes and DAG traversal.
Metadata
Metadata
Assignees
Labels
feature requestNew feature or request
Activity
harryswift01 commentedon Oct 30, 2025
After an initial review of the existing codebase and an attempt to abstract functionality out of the
Levelsclass, this is a proposed file and class structure aimed at reducing complexity and preventing further class bloat.harryswift01 commentedon Oct 30, 2025
Mapping of existing
LevelManagerfunctions to the proposed modular classes:level_hierarchy.py →
LevelHierarchyget_beads()select_levels()coordinate_system.py →
CoordinateSystemget_avg_pos()get_axes()get_sphCoord_axes()dihedral_analysis.py →
DihedralAnalysisget_dihedrals()compute_dihedral_conformations()build_conformational_states()matrix_operations.py →
MatrixOperationscreate_submatrix()filter_zero_rows_columns()get_matrices()force_torque_manager.py →
ForceTorqueManagerget_weighted_forces()get_weighted_torques()build_covariance_matrices()level_manager.py →
LevelManager__init__()This layout breaks down the original monolithic
LevelManagerinto clear, single-responsibility components.skfegan commentedon Nov 5, 2025
One change - I think what you have as StructuralAnalysis should be DihedralAnalysis and then we will add a new class for Neighbours.
the build_covariance_matrices() function should go with the get_weighted_forces() and get_weighted_torques()
harryswift01 commentedon Nov 5, 2025
This sounds good, I can make those changes now.