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

adopted peptide.py to work with the current version of block_analyze,… #95

Open
wants to merge 6 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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ sudo apt install python3-venv
To set up pyMBE, the users need to install its virtual environment, install its Python dependencies and configure the path to the ESPResSo build folder as follows:

```sh
python3 -m venv pymbe
source pymbe/bin/activate
python3 maintainer/configure_venv.py --espresso_path=/home/user/espresso/build # adapt path
python3 -m venv pymbe # creates a local folder named pymbe, which contains the virtual environment
source pymbe/bin/activate # activates the pymbe venv
python3 maintainer/configure_venv.py --espresso_path=/home/user/espresso/build # please, adapt the espresso path accordingly
python3 -m pip install -r requirements.txt
deactivate
python3 simulation_script.py # run the espresso simulation script
deactivate # deactivate the virtual environment
```

We highlight that the path `/home/user/espresso/build` is just an example of a possible
Expand Down
14 changes: 13 additions & 1 deletion lib/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ def add_data_to_df(df, data_dict, index):
index=index)])
return updated_df

def analyze_time_series(path_to_datafolder, filename_extension= ".csv", minus_separator = False,):
def analyze_time_series(path_to_datafolder, filename_extension= ".csv", minus_separator = False, ignore_files=None):
"""
Analyzes all time series stored in `path_to_datafolder` using the block binning method.

Args:
path_to_datafolder(`str`): path to the folder with the files with the time series
filename_extension(`str`): extension of the file. Defaults to ".csv"
minus_separator(`bool`): switch to enable the minus as a separator. Defaults to False.
ignore_files(`lst`): list of filenames to be ignored for the bining analysis.

Returns:
data(`Pandas.Dataframe`): Dataframe with the time averages of all the time series in the datafolder.
Expand All @@ -59,10 +60,21 @@ def analyze_time_series(path_to_datafolder, filename_extension= ".csv", minus_se

"""
data=pd.DataFrame()
if ignore_files is None:
ignore_files=[]
with os.scandir(path_to_datafolder) as subdirectory:
# Gather all data
for subitem in subdirectory:
if subitem.is_file():
ignore_file=False
for file in ignore_files:
if set(file.split()) == set(subitem.name.split()):
ignore_file=True
if ignore_file:
continue
print(subitem.name)
from time import sleep
sleep(5)
if filename_extension in subitem.name:
# Get parameters from the file name
data_dict=get_params_from_file_name(file_name=subitem.name,
Expand Down
33 changes: 33 additions & 0 deletions samples/analyze_time_series.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright (C) 2024 pyMBE-dev team
#
# This file is part of pyMBE.
#
# pyMBE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyMBE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import argparse
from lib import analysis

parser = argparse.ArgumentParser(description='Sample script analyze time series from the other sample scripts using the binning method.')
parser.add_argument('--data_folder',
type=str,
required=True,
help='path to the data folder with the time series')
args = parser.parse_args()

# Read and analyze time series
analyzed_data=analysis.analyze_time_series(path_to_datafolder=args.data_folder,
ignore_files=["analyzed_data.csv"])
analyzed_data.to_csv(f"{args.data_folder}/analyzed_data.csv",
index=False)
Loading