Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coordinate interval update #28

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gamd/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def serialize(self, root):
assign_tag(xml_energy_tags, "interval", self.energy_interval)
xml_coordinates_tags = ET.SubElement(root, "coordinates")
assign_tag(xml_coordinates_tags, "file-type", self.coordinates_file_type)
assign_tag(xml_coordinates_tags, "interval", self.coordinates_interval)
xml_statistics_tags = ET.SubElement(root, "statistics")
assign_tag(xml_statistics_tags, "interval", self.statistics_interval)
return
Expand Down
9 changes: 7 additions & 2 deletions gamd/gamdSimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""
import os

import mdtraj
import parmed
import openmm as openmm
import openmm.app as openmm_app
Expand All @@ -25,7 +26,10 @@


def load_pdb_positions_and_box_vectors(pdb_coords_filename, need_box):
positions = openmm_app.PDBFile(pdb_coords_filename)
try:
positions = openmm_app.PDBxFile(pdb_coords_filename) # More consistency with large systems
except:
positions = openmm_app.PDBFile(pdb_coords_filename)
pdb_parmed = parmed.load_file(pdb_coords_filename)
if need_box:
assert pdb_parmed.box_vectors is not None, "No box vectors "\
Expand Down Expand Up @@ -265,7 +269,8 @@ def createGamdSimulation(self, config, platform_name, device_index):

elif config.outputs.reporting.coordinates_file_type == "pdb":
gamdSimulation.traj_reporter = openmm_app.PDBReporter

elif config.outputs.reporting.coordinates_file_type == "h5":
gamdSimulation.traj_reporter = mdtraj.reporters.HDF5Reporter
else:
raise Exception("Reporter type not found:",
config.outputs.reporting.coordinates_file_type)
Expand Down
3 changes: 3 additions & 0 deletions gamd/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ def parse_outputs_tag(tag):
if coordinates_tag.tag == "file-type":
outputs_config.reporting.coordinates_file_type \
= assign_tag(coordinates_tag, str).lower()
elif coordinates_tag.tag == "interval":
outputs_config.reporting.coordinates_interval \
= assign_tag(coordinates_tag, int)
else:
print("Warning: parameter in XML not found in "
"coordinates tag. Spelling error?",
Expand Down
4 changes: 4 additions & 0 deletions gamd/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import subprocess
import sys

import mdtraj
import openmm.unit as unit
import openmm.app as openmm_app

Expand Down Expand Up @@ -250,6 +251,9 @@ def register_trajectory_reporter(self, restart):
elif traj_reporter == openmm_app.PDBReporter:
simulation.reporters.append(traj_reporter(
traj_name, self.config.outputs.reporting.coordinates_interval))
elif traj_reporter == mdtraj.reporters.HDF5Reporter:
simulation.reporters.append(traj_reporter(
traj_name, self.config.outputs.reporting.coordinates_interval))

def register_state_data_reporter(self, restart):
if self.state_data_reporter_enabled:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

# Additional entries you may want simply uncomment the lines you want and fill in the data
# url='http://www.my_package.com', # Website
install_requires=["numpy", "parmed", "pytest", "matplotlib"],
install_requires=["numpy", "parmed", "pytest", "matplotlib", "mdtraj"],
# Required packages, pulls from pip if needed; do not use for Conda deployment
# platforms=['Linux',
# 'Mac OS-X',
Expand Down