MobleyLab / blues

Applications of nonequilibrium candidate Monte Carlo (NCMC) to ligand binding mode sampling
https://mobleylab-blues.readthedocs.io/en/latest
MIT License
33 stars 16 forks source link

TypeError with LoadParm Using "structure.restart" Property #141

Closed tannerbobak closed 6 years ago

tannerbobak commented 6 years ago

After adding a path to a .rst7 file in the simulation configuration YAML, a type error is generated stating LoadParm() got an unexpected keyword argument 'restart'. The full stack trace is as follows:

ERROR: [settings.set_Parameters] LoadParm() got an unexpected keyword argument 'restart'
Traceback (most recent call last):
  File "/home/tabo5518/.local/lib/python3.5/site-packages/blues-0.2.1-py3.5.egg/blues/settings.py", line 282, in set_Parameters
    config = Settings.set_Structure(config)
  File "/home/tabo5518/.local/lib/python3.5/site-packages/blues-0.2.1-py3.5.egg/blues/settings.py", line 72, in set_Structure
    structure = parmed.load_file(**config['structure'])
  File "/home/tabo5518/.conda/envs/blues-nathan/lib/python3.5/site-packages/parmed/formats/registry.py", line 197, in load_file
    return cls.parse(filename, *args, **kwargs)
  File "/home/tabo5518/.conda/envs/blues-nathan/lib/python3.5/site-packages/parmed/amber/amberformat.py", line 359, in parse
    return LoadParm(filename, *args, **kwargs)
TypeError: LoadParm() got an unexpected keyword argument 'restart'
Traceback (most recent call last):
  File "iodotoluene_rotmove.py", line 8, in <module>
    cfg = Settings('iodotoluene_rotmove_cuda.yaml').asDict()
  File "/home/tabo5518/.local/lib/python3.5/site-packages/blues-0.2.1-py3.5.egg/blues/settings.py", line 30, in __init__
    config = Settings.set_Parameters(config)
  File "/home/tabo5518/.local/lib/python3.5/site-packages/blues-0.2.1-py3.5.egg/blues/settings.py", line 291, in set_Parameters
    raise e
  File "/home/tabo5518/.local/lib/python3.5/site-packages/blues-0.2.1-py3.5.egg/blues/settings.py", line 282, in set_Parameters
    config = Settings.set_Structure(config)
  File "/home/tabo5518/.local/lib/python3.5/site-packages/blues-0.2.1-py3.5.egg/blues/settings.py", line 72, in set_Structure
    structure = parmed.load_file(**config['structure'])
  File "/home/tabo5518/.conda/envs/blues-nathan/lib/python3.5/site-packages/parmed/formats/registry.py", line 197, in load_file
    return cls.parse(filename, *args, **kwargs)
  File "/home/tabo5518/.conda/envs/blues-nathan/lib/python3.5/site-packages/parmed/amber/amberformat.py", line 359, in parse
    return LoadParm(filename, *args, **kwargs)
TypeError: LoadParm() got an unexpected keyword argument 'restart'

The setup of the structure property in the YAML file looks like this:

structure:
  filename: 3iodo.prmtop
  xyz: 3iodo-eq.inpcrd
  restart: /home/tabo5518/t4-iodotoluene/t4-iodotoluene.rst7
nathanmlim commented 6 years ago

Thanks for posting this issue. It's an easy fix, but have a couple of other things to take care of first before I can get to this. Below is the quick work around I've sent you via Slack, that I'll post here for reference:

First, remove the restart line from the YAML file. Then in your launching python script like example_rotmove.py

Get the parmed.Structure from the configuration dict and overwrite the box, velocities, and positions from the restart file:

import parmed

# Parse a YAML configuration, return as Dict
cfg = Settings('rotmove_cuda.yaml').asDict()
structure = cfg['Structure']

restart = parmed.amber.Rst7(restart)
structure.positions = restart.positions
structure.velocities = restart.velocities
structure.box = restart.box

Another note about restarts is that the iteration number isn't stored in the restart file, so the total number of iterations you have run is something you will have to keep track of manually. I believe it is possible to store this information into the restart file if it does use the NetCDF4 format. So it may be a possibility in the future.