{"library":"openmm-mdanalysis-reporter","title":"OpenMM MDAnalysis Reporter","description":"The openmm-mdanalysis-reporter is a Python library that bridges OpenMM simulations with MDAnalysis. It allows users to create MDAnalysis Universe objects directly from OpenMM State objects and write trajectory data to any MDAnalysis-supported format, particularly the Universal Archive Format (UAF). The current version is 0.1, indicating an early development stage with an infrequent release cadence.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install openmm-mdanalysis-reporter"],"cli":null},"imports":["from openmm_mdanalysis_reporter import MDAnalysisReporter"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import openmm.app as app\nimport openmm as om\nfrom openmm_mdanalysis_reporter import MDAnalysisReporter\nimport os\n\n# Create a simple system (e.g., single atom, just for demonstration)\n# In a real scenario, you'd load a PDB/GMX file with app.PDBFile, etc.\nsystem = om.System()\nsystem.addParticle(1.0) # mass in amu\n\n# Create an integrator\nintegrator = om.VerletIntegrator(0.001) # 1 fs timestep\n\n# Create a simulation object\n# Use 'Reference' platform for broad compatibility without GPU\nplatform = om.Platform.getPlatformByName('Reference') \nsimulation = app.Simulation(system, integrator, platform)\nsimulation.context.setPositions([[0, 0, 0]]) # Set initial position\nsimulation.context.setVelocitiesToTemperature(300 * om.unit.kelvin) # Set initial velocities\n\n# Define output file path for the trajectory\noutput_file = \"trajectory.uaf\" # UAF is recommended for MDAnalysisReporter\n\n# Add the MDAnalysisReporter\n# Report every 10 steps, enforce periodic box (set to False for this non-periodic system)\n# For periodic systems, ensure system.setDefaultPeriodicBoxVectors is called.\nreporter = MDAnalysisReporter(output_file, 10, enforcePeriodicBox=False)\nsimulation.reporters.append(reporter)\n\nprint(f\"Running simulation and writing to {output_file}...\")\nsimulation.step(100) # Run for 100 steps\nprint(\"Simulation finished.\")\n\n# Optional: Load and inspect the generated trajectory with MDAnalysis\ntry:\n    import MDAnalysis as mda\n    u = mda.Universe(output_file)\n    print(f\"Loaded trajectory with {u.trajectory.n_frames} frames.\")\n    # Clean up the generated file\n    os.remove(output_file)\n    print(f\"Cleaned up {output_file}.\")\nexcept ImportError:\n    print(\"MDAnalysis not installed, skipping trajectory inspection and cleanup.\")\nexcept Exception as e:\n    print(f\"Error loading trajectory with MDAnalysis: {e}. Attempting cleanup.\")\n    if os.path.exists(output_file):\n        os.remove(output_file) # Still try to clean up\n","lang":"python","description":"This quickstart demonstrates how to set up a minimal OpenMM simulation and attach the `MDAnalysisReporter` to write trajectory data. It uses a simple single-particle system for brevity. For real simulations, you would load a PDB, define forces, and set proper periodic boundary conditions. The example also shows how to optionally load the generated `.uaf` file using MDAnalysis for verification.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}