Skip to content

Commit

Permalink
Comply with output directory flag from argparse
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed May 8, 2024
1 parent fa4d652 commit bd1fc3e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyMBE.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def check_if_name_is_defined_in_df(self, name, pmb_type_to_be_defined):
if name in self.df['name'].unique():
current_object_type = self.df[self.df['name']==name].pmb_type.values[0]
if current_object_type != pmb_type_to_be_defined:
raise ValueError ((f"The name {name} is already defined in the df with a pmb_type = {current_object_type}, pymMBE does not support objects with the same name but different pmb_types"))
raise ValueError (f"The name {name} is already defined in the df with a pmb_type = {current_object_type}, pymMBE does not support objects with the same name but different pmb_types")
return True
else:
return False
Expand Down
12 changes: 7 additions & 5 deletions samples/Beyer2024/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
The scripts in this folder are designed to reproduce the data and plots showcased in our publication [1].
The scripts in this folder are designed to reproduce the data and plots showcased in our publication [^1].
To reproduce the data, one simply needs to run the following script:
```bash
```sh
python3 create_paper_data.py --fig_label 7a --mode long-run --plot
```
where the previous line will run the script to produce Fig. 7a in Ref.[1] The user can use the argparse argument `--fig_label` to create any of the plots that we presented in that publication as benchmarks: 7a, 7b, 7c, 8a, 8b, 9. The argparse `--mode` controls the statiscal accuracy (i.e. the number of samples) that the script measures. The mode `long-run` should be used to generate data with the same statistical accuracy than in Ref.[1]. The mode `short-run` can be used for a shorter run for testing or to trying out the scripts for each of our benchmarks:
where the previous line will run the script to produce Fig. 7a in Ref.[^1] The user can use the argparse argument `--fig_label` to create any of the plots that we presented in that publication as benchmarks: 7a, 7b, 7c, 8a, 8b, 9. The argparse `--mode` controls the statiscal accuracy (i.e. the number of samples) that the script measures. The mode `long-run` should be used to generate data with the same statistical accuracy than in Ref.[^1]. The mode `short-run` can be used for a shorter run for testing or to trying out the scripts for each of our benchmarks:

- peptide.py: for the peptide benchmarks
- globular_protein.py: for the globular protein benchmarks
- weak_polyelectrolyte_dialysis.py: for the weak polyelectrolyte dialysis benchmarks
The optional argparse argument `--plot` controls if the scripts generates the corresponding plot or if the data is simply stored to file. We note that the format of the plots can differ from that of our publication [1]. This scripts are part of the continous integration (CI) scheme of the pyMBE library and they are used to ensure that any stable version of the library reproduces the benchmarks.

The optional argparse argument `--plot` controls if these scripts generate the corresponding plot or if the data is simply stored to file. We note that the format of the plots can differ from that of our publication [^1]. Theses scripts are part of the continous integration (CI) scheme of the pyMBE library and they are used to ensure that any stable version of the library reproduces the benchmarks.


[1] Beyer, D., Torres, P. B., Pineda, S. P., Narambuena, C. F., Grad, J. N., Košovan, P., & Blanco, P. M. (2024). pyMBE: the Python-based Molecule Builder for ESPResSo. arXiv preprint [arXiv:2401.14954](https://arxiv.org/abs/2401.14954).
[^1]: Beyer, D., Torres, P. B., Pineda, S. P., Narambuena, C. F., Grad, J.-N., Košovan, P., & Blanco, P. M. (2024). pyMBE: the Python-based Molecule Builder for ESPResSo. arXiv preprint [arXiv:2401.14954](https://arxiv.org/abs/2401.14954).
2 changes: 1 addition & 1 deletion samples/salt_solution_gcmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,4 @@
particle_id_list = pmb.df.loc[~pmb.df['molecule_id'].isna()].particle_id.dropna().to_list()

#Save the pyMBE dataframe in a CSV file
pmb.write_pmb_df(filename='df.csv')
pmb.write_pmb_df(filename=f'{data_path}/df.csv')
12 changes: 7 additions & 5 deletions testsuite/read-write-df_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import ast
import tempfile
import espressomd
import pandas as pd

Expand Down Expand Up @@ -88,12 +89,13 @@
# Copy the pmb.df into a new DF for the unit test
stored_df = pmb.df.copy()

# Write the pymbe DF to a csv file
df_filename = 'df-example_molecule.csv'
pmb.write_pmb_df (filename = df_filename)
with tempfile.TemporaryDirectory() as tmp_directory:
# Write the pymbe DF to a csv file
df_filename = f'{tmp_directory}/df-example_molecule.csv'
pmb.write_pmb_df (filename = df_filename)

# Read the same pyMBE df from a csv a load it in pyMBE
read_df = pmb.read_pmb_df(filename = df_filename)
# Read the same pyMBE df from a csv a load it in pyMBE
read_df = pmb.read_pmb_df(filename = df_filename)

# Preprocess data for the Unit Test
# The espresso bond object must be converted to a dict in order to compare them using assert_frame_equal
Expand Down

0 comments on commit bd1fc3e

Please sign in to comment.