From 8646467215b7882e37b13596452a0ae996d359a5 Mon Sep 17 00:00:00 2001 From: David Beyer Date: Mon, 20 Jan 2025 16:06:33 +0100 Subject: [PATCH 1/3] Add parsing test --- testsuite/CTestTestfile.cmake | 1 + testsuite/parsing_test.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 testsuite/parsing_test.py diff --git a/testsuite/CTestTestfile.cmake b/testsuite/CTestTestfile.cmake index 853d701..f51f671 100644 --- a/testsuite/CTestTestfile.cmake +++ b/testsuite/CTestTestfile.cmake @@ -57,6 +57,7 @@ pymbe_add_test(PATH define_and_create_molecules_unit_tests.py) pymbe_add_test(PATH create_molecule_position_test.py) pymbe_add_test(PATH seed_test.py) pymbe_add_test(PATH read-write-df_test.py) +pymbe_add_test(PATH parsing_test.py) pymbe_add_test(PATH parameter_test.py) pymbe_add_test(PATH henderson_hasselbalch_tests.py) pymbe_add_test(PATH calculate_net_charge_unit_test.py) diff --git a/testsuite/parsing_test.py b/testsuite/parsing_test.py new file mode 100644 index 0000000..db65765 --- /dev/null +++ b/testsuite/parsing_test.py @@ -0,0 +1,29 @@ +# +# 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 . + +# Create an instance of pyMBE library +import pyMBE +pmb = pyMBE.pymbe_library(seed=42) + +print ('*** Unit tests: check that parse_sequence_from_file works correctly ***') + +test_sequence = " , 'AAAAA','B ',' C', 'D''D', 'EEEEEE'" +reference_parsed_sequence = ["AAAAA", "B", "C", "DD"] +assert pmb.parse_sequence_from_file(test_sequence) == reference_parsed_sequence + +print("*** Unit test passed***") From c223e52b6c653342048b56b2869dfffb3206bb11 Mon Sep 17 00:00:00 2001 From: David Beyer Date: Tue, 21 Jan 2025 14:24:37 +0100 Subject: [PATCH 2/3] Remove parse_sequence_from_file --- pyMBE.py | 19 ------------------- testsuite/CTestTestfile.cmake | 1 - testsuite/parsing_test.py | 29 ----------------------------- 3 files changed, 49 deletions(-) delete mode 100644 testsuite/parsing_test.py diff --git a/pyMBE.py b/pyMBE.py index 534c7dc..76f338c 100644 --- a/pyMBE.py +++ b/pyMBE.py @@ -289,9 +289,6 @@ def calculate_HH(self, molecule_name, pH_list=None, pka_set=None): Z_HH.append(Z) else: # Molecule has a sequence - if not isinstance(sequence, list): - # If the df has been read by file, the sequence needs to be parsed. - sequence = self.parse_sequence_from_file(sequence=sequence) for name in sequence: if name in pka_set.keys(): if pka_set[name]['acidity'] == 'acidic': @@ -2318,22 +2315,6 @@ def load_pka_set(self, filename, verbose=False, overwrite=True): overwrite=overwrite) return - def parse_sequence_from_file(self,sequence): - """ - Parses the given sequence such that it can be used in pyMBE. This function has to be used if the df was read from a file. - - Args: - sequence(`str`): sequence to be parsed - - Returns: - sequence(`lst`): parsed sequence - """ - sequence = sequence.replace(' ', '') - sequence = sequence.replace("'", '') - sequence = sequence.split(",")[1:-1] - return sequence - - def propose_unused_type(self): """ diff --git a/testsuite/CTestTestfile.cmake b/testsuite/CTestTestfile.cmake index f51f671..853d701 100644 --- a/testsuite/CTestTestfile.cmake +++ b/testsuite/CTestTestfile.cmake @@ -57,7 +57,6 @@ pymbe_add_test(PATH define_and_create_molecules_unit_tests.py) pymbe_add_test(PATH create_molecule_position_test.py) pymbe_add_test(PATH seed_test.py) pymbe_add_test(PATH read-write-df_test.py) -pymbe_add_test(PATH parsing_test.py) pymbe_add_test(PATH parameter_test.py) pymbe_add_test(PATH henderson_hasselbalch_tests.py) pymbe_add_test(PATH calculate_net_charge_unit_test.py) diff --git a/testsuite/parsing_test.py b/testsuite/parsing_test.py deleted file mode 100644 index db65765..0000000 --- a/testsuite/parsing_test.py +++ /dev/null @@ -1,29 +0,0 @@ -# -# 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 . - -# Create an instance of pyMBE library -import pyMBE -pmb = pyMBE.pymbe_library(seed=42) - -print ('*** Unit tests: check that parse_sequence_from_file works correctly ***') - -test_sequence = " , 'AAAAA','B ',' C', 'D''D', 'EEEEEE'" -reference_parsed_sequence = ["AAAAA", "B", "C", "DD"] -assert pmb.parse_sequence_from_file(test_sequence) == reference_parsed_sequence - -print("*** Unit test passed***") From 3a151612923464bdd8b8706ef34b3656f003c55a Mon Sep 17 00:00:00 2001 From: blancoapa Date: Tue, 21 Jan 2025 15:09:00 +0100 Subject: [PATCH 3/3] update CHANGELOG --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83d6d4e..61e2e78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Code of conduct of our community `CODE_OF_CONDUCT.md`, adhering to the Contributor Covenant v2.1 (#104) - New optional argument `backbone_vector` enabling to build molecules along an input vector using `pmb.create_molecule` and `pmb.create_pmb_object` (#99) -- Unit testing for reaction methods (#86) - New boolean flag `--ideal` as argparse argument of `samples/globular_protein.py` enabling to run the script without setting up interactions. - Unit tests for `pmb.create_protein`, `pmb.enable_motion_of_rigid_object`, `pmb.protein_sequence_parser`, `pmb.define_protein`, `pmb.read_protein_vtf_in_df` (#101) - Library `lattice.py`, a general builder for crystaline lattices. This library is part of on-going project to support hydrogels in pyMBE. (#93) @@ -38,6 +37,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - NumPy 2, Pandas 2 and the development version of ESPResSo are now fully supported. (#106) - Fixed several deprecated paths and function names in `tutorials/pyMBE_tutorial.ipynb`. (#77, #78, #79, #80, #81) +### Removed +- `pmb.parse_sequence_from_file` has been removed since it is no longer necesary to parse the sequence from pmb.df (#110) + ## [0.8.0] - 2024-06-18 ### Added