# Path: msibi/state.py
# class State(object):
#     """A single state used as part of a multistate optimization.
# 
#     Attributes
#     ----------
#     k : float
#         Boltzmann's  constant in specified units.
#     T : float
#         Temperature in kelvin.
#     traj : md.Trajectory
#         The trajectory associated with this state.
#     backup_trajectory : bool
#         True if each query trajectory is backed up (default=False)
# 
#     """
# 
#     def __init__(self, kT, state_dir='', traj_file=None, top_file=None,
#                  name=None, backup_trajectory=False):
#         self.kT = kT
#         self.state_dir = state_dir
# 
#         if not traj_file:
#             self.traj_path = os.path.join(state_dir, 'query.dcd')
#         if top_file:
#             self.top_path = os.path.join(state_dir, top_file)
# 
#         self.traj = None
#         if not name:
#             name = 'state-{0:.3f}'.format(self.kT)
#         self.name = name
# 
#         self.backup_trajectory = backup_trajectory
# 
#     def reload_query_trajectory(self):
#         """Reload the query trajectory. """
#         if self.top_path:
#             self.traj = md.load(self.traj_path, top=self.top_path)
#         else:
#             self.traj = md.load(self.traj_path)
# 
#     def save_runscript(self, table_potentials, table_width, engine='hoomd',
#                        runscript='hoomd_run_template.py'):
#         """Save the input script for the MD engine. """
# 
#         header = list()
# 
#         if self.HOOMD_VERSION == 1:
#             HOOMD_HEADER = HOOMD1_HEADER
#         elif self.HOOMD_VERSION == 2:
#             HOOMD_HEADER = HOOMD2_HEADER
# 
#         header.append(HOOMD_HEADER.format('start.hoomdxml', self.kT, table_width))
#         for type1, type2, potential_file in table_potentials:
#             header.append(HOOMD_TABLE_ENTRY.format(**locals()))
#         header = ''.join(header)
#         with open(os.path.join(self.state_dir, runscript)) as fh:
#             body = ''.join(fh.readlines())
# 
#         runscript_file = os.path.join(self.state_dir, 'run.py')
#         with open(runscript_file, 'w') as fh:
#             fh.write(header)
#             fh.write(body)
# 
# Path: msibi/utils/general.py
# def get_fn(name):
#     """Get the full path to one of the reference files shipped for testing.
# 
#     This function is taken straight from MDTraj (see https://github.com/mdtraj/mdtraj).
#     In the source distribution, these files are in ``msibi/utils/reference``,
#     but on istallation, they're moved to somewhere in the user's python
#     site-packages directory.
# 
#     Parameters
#     ----------
#     name : str
#         Name of the file ot load (with respecto to the reference/ directory).
# 
#     Examples
#     ________
#     >>> import mdtraj as md
#     >>> t = md.load(get_fun('final.hoomdxml'))
#     """
# 
#     fn = resource_filename('msibi', os.path.join('utils', 'reference', name))
# 
#     if not os.path.exists(fn):
#         raise ValueError('Sorry! %s does not exist. If you just '
#                          'added it, you\'ll have to re install' % fn)
# 
#     return fn


import pytest
from msibi.state import State
from msibi.utils.general import get_fn



@pytest.mark.skipif(True, reason='Needs implementing!')
def test_init():
    pass


def test_reload_query_trajectory():
    state_dir = get_fn('state0/')
    state = State(1.987e-3*500.0, state_dir=state_dir, top_file='sys.hoomdxml',
                  name='state0')
    state.reload_query_trajectory()

# Path: msibi/state.py
# class State(object):
#     """A single state used as part of a multistate optimization.
# 
#     Attributes
#     ----------
#     k : float
#         Boltzmann's  constant in specified units.
#     T : float
#         Temperature in kelvin.
#     traj : md.Trajectory
#         The trajectory associated with this state.
#     backup_trajectory : bool
#         True if each query trajectory is backed up (default=False)
# 
#     """
# 
#     def __init__(self, kT, state_dir='', traj_file=None, top_file=None,
#                  name=None, backup_trajectory=False):
#         self.kT = kT
#         self.state_dir = state_dir
# 
#         if not traj_file:
#             self.traj_path = os.path.join(state_dir, 'query.dcd')
#         if top_file:
#             self.top_path = os.path.join(state_dir, top_file)
# 
#         self.traj = None
#         if not name:
#             name = 'state-{0:.3f}'.format(self.kT)
#         self.name = name
# 
#         self.backup_trajectory = backup_trajectory
# 
#     def reload_query_trajectory(self):
#         """Reload the query trajectory. """
#         if self.top_path:
#             self.traj = md.load(self.traj_path, top=self.top_path)
#         else:
#             self.traj = md.load(self.traj_path)
# 
#     def save_runscript(self, table_potentials, table_width, engine='hoomd',
#                        runscript='hoomd_run_template.py'):
#         """Save the input script for the MD engine. """
# 
#         header = list()
# 
#         if self.HOOMD_VERSION == 1:
#             HOOMD_HEADER = HOOMD1_HEADER
#         elif self.HOOMD_VERSION == 2:
#             HOOMD_HEADER = HOOMD2_HEADER
# 
#         header.append(HOOMD_HEADER.format('start.hoomdxml', self.kT, table_width))
#         for type1, type2, potential_file in table_potentials:
#             header.append(HOOMD_TABLE_ENTRY.format(**locals()))
#         header = ''.join(header)
#         with open(os.path.join(self.state_dir, runscript)) as fh:
#             body = ''.join(fh.readlines())
# 
#         runscript_file = os.path.join(self.state_dir, 'run.py')
#         with open(runscript_file, 'w') as fh:
#             fh.write(header)
#             fh.write(body)
# 
# Path: msibi/utils/general.py
# def get_fn(name):
#     """Get the full path to one of the reference files shipped for testing.
# 
#     This function is taken straight from MDTraj (see https://github.com/mdtraj/mdtraj).
#     In the source distribution, these files are in ``msibi/utils/reference``,
#     but on istallation, they're moved to somewhere in the user's python
#     site-packages directory.
# 
#     Parameters
#     ----------
#     name : str
#         Name of the file ot load (with respecto to the reference/ directory).
# 
#     Examples
#     ________
#     >>> import mdtraj as md
#     >>> t = md.load(get_fun('final.hoomdxml'))
#     """
# 
#     fn = resource_filename('msibi', os.path.join('utils', 'reference', name))
# 
#     if not os.path.exists(fn):
#         raise ValueError('Sorry! %s does not exist. If you just '
#                          'added it, you\'ll have to re install' % fn)
# 
#     return fn


# Path: msibi/tests/test_state.py
import pytest
from msibi.state import State
from msibi.utils.general import get_fn




@pytest.mark.skipif(True, reason='Needs implementing!')
def test_init():
    pass


def test_reload_query_trajectory():
    state_dir = get_fn('state0/')
    state = State(1.987e-3*500.0, state_dir=state_dir, top_file='sys.hoomdxml',
                  name='state0')
    state.reload_query_trajectory()

    assert(state.traj)