Пример #1
0
 def univ_pbc(self, tmp_path, path_test_data, universe_class):
     gro = path_test_data / 'spc2.gro'
     traj = path_test_data / 'spc2-traj-pbc.xtc'
     shutil.copy(gro, tmp_path)
     shutil.copy(traj, tmp_path)
     with cd(tmp_path):
         _univ = universe_class(gro.name, traj.name, temp=205.)
     return _univ
Пример #2
0
 def reu(self, path_test_data):
     from paratemp.re_universe import REUniverse
     path = path_test_data / 'spc-and-methanol-run'
     with cd(path):
         reu = REUniverse('TOPO/nvt0.tpr',
                          base_folder='.',
                          traj_glob='PT-out*.trr')
     return reu
Пример #3
0
 def test_read_data(self, univ, univ_w_a, tmp_path, capsys):
     """
     :type univ_w_a: paratemp.Universe
     :type univ: paratemp.Universe
     """
     with cd(tmp_path):
         univ_w_a.save_data()
         capsys.readouterr()  # just so it doesn't print
         univ.read_data()
     assert (univ_w_a.data == univ.data).all().all()
Пример #4
0
 def test_calculate_distances_read(self, univ_w_a, tmp_path, capsys):
     """
     :type univ_w_a: paratemp.Universe
     """
     with cd(tmp_path):
         univ_w_a.save_data()
         capsys.readouterr()
         univ_w_a._data = univ_w_a._init_dataframe()
         univ_w_a.calculate_distances(a='4 5')
         out, err = capsys.readouterr()
     assert out == 'Nothing (new) to calculate here.\n'
Пример #5
0
 def test_save_data_add_new(self, univ, univ_w_a, tmp_path, capsys):
     time = 'time_' + str(int(univ_w_a._last_time / 1000)) + 'ns'
     f_name = univ_w_a.trajectory.filename.replace('xtc', 'h5')
     with cd(tmp_path):
         univ_w_a.save_data()
         capsys.readouterr()
         univ.calculate_distances(b='4 5', save_data=False)
         univ.save_data()
         out, err = capsys.readouterr()
     assert out == 'Saved data to {f_name}[{time}]\n'.format(f_name=f_name,
                                                             time=time)
Пример #6
0
 def test_save_data(self, univ_w_a, tmp_path, capsys):
     time = 'time_' + str(int(univ_w_a._last_time / 1000)) + 'ns'
     f_name = univ_w_a.trajectory.filename.replace('xtc', 'h5')
     with cd(tmp_path):
         univ_w_a.save_data()
         out, err = capsys.readouterr()
         assert (tmp_path / f_name).exists()
         with pd.HDFStore(f_name) as store:
             df = store[time]
     assert out == 'Saved data to {f_name}[{time}]\n'.format(f_name=f_name,
                                                             time=time)
     assert np.allclose(df, univ_w_a.data)
Пример #7
0
 def test_read_data_no_data(self, univ, tmp_path, capsys):
     """
     :type univ: paratemp.Universe
     """
     time = 'time_' + str(int(univ._last_time / 1000)) + 'ns'
     f_name = univ.trajectory.filename.replace('xtc', 'h5')
     with cd(tmp_path):
         with pytest.raises(IOError,
                            match=r'This data does not exist!\n'
                            r'{}\[{}\]'.format(f_name, time)):
             univ.read_data()
         univ.read_data(ignore_no_data=True)
         out, err = capsys.readouterr()
     assert out == 'No data to read in {}[{}]\n'.format(f_name, time)
Пример #8
0
 def test_calculate_distances_save(self, univ, tmp_path, capsys):
     """
     :type univ: paratemp.Universe
     """
     time = 'time_' + str(int(univ._last_time / 1000)) + 'ns'
     f_name = univ.trajectory.filename.replace('xtc', 'h5')
     with cd(tmp_path):
         univ.calculate_distances(a='4 5')
         out, err = capsys.readouterr()
         assert (tmp_path / f_name).exists()
         with pd.HDFStore(f_name) as store:
             df = store[time]
     assert out == 'Saved data to {f_name}[{time}]\n'.format(f_name=f_name,
                                                             time=time)
     assert np.allclose(df, univ.data)
Пример #9
0
 def test_init(self, molecule_w_params, shift, box_length, include_gbsa,
               n_args):
     from paratemp.sim_setup import System
     mol, tmp_path = molecule_w_params
     with cd(tmp_path):
         system = System(*([mol] * n_args),
                         shift=shift,
                         box_length=box_length,
                         include_gbsa=include_gbsa)
         assert isinstance(system, System)
         assert system.n_molecules == n_args
         assert (hasattr(system, 'directory')
                 and isinstance(system.directory, pathlib.Path))
         assert (hasattr(system, 'name') and isinstance(system.name, str))
         assert repr(system) == ('<default System from {} '
                                 'Molecules>'.format(n_args))
Пример #10
0
start_dir = os.getcwd()
temp_dir = "cctempdir"
if not os.path.exists(temp_dir):
    os.makedirs(temp_dir)

edrs = glob('*.edr')
log_file = glob('*out*.log')[0]
colvar_files = glob('COLVAR*')

files_to_copy = edrs + [log_file] + colvar_files

for filename in files_to_copy:
    copyfile(filename, temp_dir+'/'+filename)

with cd(temp_dir):
    if len(colvar_files) == 0:
        print('No COLVAR files; ignoring that part.')
        with open(log_file, 'r') as f_log:
            final_time = None
            for line in f_log:
                try:
                    final_time = regex_time.match(line).group(1)
                    final_time = '{:.0f}'.format(float(final_time)/1000)
                except AttributeError:
                    continue
            if final_time is None:
                print("Couldn't find final time from log file.")
                final_time = 'unk'
    else:
        colvars = dict()