Add production run python scripts#26
Conversation
Reviewer's Guide by SourceryThis PR adds production run Python scripts and analysis tools for DNA-protein simulations. The main changes include adding a new production run script with comprehensive simulation setup, modifying the DNA analysis script to remove protein-related code, and adding new analysis tools for computing DNA twist angles. Sequence diagram for DNA-Protein Simulation SetupsequenceDiagram
participant User
participant Script
participant OpenMM
participant DNA
participant Protein
participant ForceField
participant Simulation
User->>Script: Run simulation script
Script->>OpenMM: Initialize platform
Script->>DNA: Create DNA object
Script->>Protein: Create Protein object
Script->>ForceField: Create force field
ForceField->>Simulation: Create system
Script->>Simulation: Initialize simulation
Simulation->>Simulation: Add forces
Simulation->>Simulation: Run simulation steps
Simulation->>User: Output results
Sequence diagram for DNA Twist Angle ComputationsequenceDiagram
participant User
participant Script
participant DNA
participant ComputeTwist
User->>Script: Run twist computation script
Script->>DNA: Load DNA structure
Script->>ComputeTwist: Compute twist angles
ComputeTwist->>Script: Return twist angles
Script->>User: Output twist angles
Class diagram for DNA and Protein SimulationclassDiagram
class DNA {
+fromCoarsePDB(file: str)
+periodic: bool
}
class Protein {
+fromCoarsePDB(file: str, sequence: str)
+setup_virtual_sites(system)
+periodic: bool
}
class ForceField {
+createSystem(topology)
}
class Simulation {
+context: Context
+reporters: list
+step(steps: int)
+minimizeEnergy()
+loadCheckpoint(file: str)
}
class Context {
+setPositions(positions)
+setVelocitiesToTemperature(temperature)
+getState(getEnergy: bool, groups: int)
}
class Integrator {
+setTemperature(temperature)
}
class Platform {
+getPlatformByName(name: str)
+setPropertyDefaultValue(property: str, value: str)
}
DNA --> ForceField
Protein --> ForceField
ForceField --> Simulation
Simulation --> Context
Simulation --> Integrator
Simulation --> Platform
Context --> Integrator
Context --> Platform
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @stevenluo22 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider removing hardcoded paths (e.g. '/home/sl206/Programs/openawsem') and using environment variables or configuration files instead for better portability
- There is significant code duplication between the analysis scripts - consider refactoring common functionality into shared utility modules
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| force = s.getForce(i) | ||
| force_name="CMMotionRemover" | ||
|
|
||
| #Add 3SPN2 forces |
There was a problem hiding this comment.
issue (complexity): Consider extracting force calculation logic into a shared ForceCalculator module
The force calculation logic is duplicated between this file and compute_twist.py. To reduce complexity and maintenance burden, consider extracting the common force calculations into a shared module:
# force_calculator.py
class ForceCalculator:
@staticmethod
def setup_3spn2_forces(dna, system):
forces = {}
for force_name in open3SPN2.forces:
force = open3SPN2.forces[force_name](dna)
if force_name in ['BasePair','CrossStacking']:
force.addForce(system)
else:
system.addForce(force)
forces[force_name] = force
return forces
@staticmethod
def setup_awsem_forces(protein, dna, system, frags_dir, fragment_file):
forces = {}
# Move existing AWSEM force setup here
return forcesThen both files can use this shared logic:
# In analysis script
forces = {}
forces.update(ForceCalculator.setup_3spn2_forces(dna, s))
forces.update(ForceCalculator.setup_awsem_forces(protein, dna, s, args.AWSEM, args.fragment))This maintains all functionality while reducing code duplication and making future maintenance easier.
|
Newest commits have segregated relatively duplicate amongst forces terms code into separate forces_setup.py so you don't need to change the forces terms code multiple times across multiple scripts. This removes potential future errors down the road where one script (say run script) had modified inclusion of forces terms and another script forgot to modify (say analysis script). And also updated and cleaned the info.dat generation file in the analysis script. Ensure to modify or at least check the analysis script, the info.dat generation parts, if you edit or customize the forces_setup.py file from the original. The info.dat file is verified to have Total Energies be the same as the intended terms (not Q or Rg) as of latest revisions. |
…dds log of forces_setup.py into output sub-directory; fixes energy output log to output subdirectory; updates default steps to 1e7
Add new line to output after Caution message.
Add production run python scripts as well as other ancillary example scripts
Summary by Sourcery
Add new Python scripts for production runs and protein-DNA analysis, enhancing the simulation capabilities and force calculations in the DNA analysis scripts.
New Features:
Enhancements: