From 96edb9d65f6f36d55bfa161d53bb5ae58de75db3 Mon Sep 17 00:00:00 2001 From: Blair Lyons Date: Wed, 17 Jul 2024 11:10:40 -0700 Subject: [PATCH 1/5] make centering cytosim fibers optional --- simulariumio/cytosim/cytosim_converter.py | 5 ++++- simulariumio/cytosim/cytosim_data.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/simulariumio/cytosim/cytosim_converter.py b/simulariumio/cytosim/cytosim_converter.py index a0d43383..76c0414a 100644 --- a/simulariumio/cytosim/cytosim_converter.py +++ b/simulariumio/cytosim/cytosim_converter.py @@ -192,6 +192,7 @@ def _parse_objects( overall_line: int, total_lines: int, scale_factor: float = None, + center_fibers: bool = False, ) -> Tuple[Dict[str, Any], List[int], int]: """ Parse a Cytosim output file containing objects @@ -277,7 +278,8 @@ def _parse_objects( result, scale_factor = TrajectoryConverter.scale_agent_data( result, scale_factor ) - result = TrajectoryConverter.center_fiber_positions(result) + if center_fibers: + result = TrajectoryConverter.center_fiber_positions(result) result.n_timesteps = time_index + 1 return (result, used_unique_IDs, overall_line, scale_factor) @@ -319,6 +321,7 @@ def _read(self, input_data: CytosimData) -> TrajectoryData: overall_line, total_lines, input_data.meta_data.scale_factor, + input_data.center_fibers, ) except Exception as e: raise InputDataError(f"Error reading input cytosim data: {e}") diff --git a/simulariumio/cytosim/cytosim_data.py b/simulariumio/cytosim/cytosim_data.py index 5caff4d9..6a6e80a2 100644 --- a/simulariumio/cytosim/cytosim_data.py +++ b/simulariumio/cytosim/cytosim_data.py @@ -19,6 +19,7 @@ class CytosimData: meta_data: MetaData draw_fiber_points: bool plots: List[Dict[str, Any]] + center_fibers: bool def __init__( self, @@ -26,6 +27,7 @@ def __init__( meta_data: MetaData = None, draw_fiber_points: bool = False, plots: List[Dict[str, Any]] = None, + center_fibers: bool = False, ): """ This object holds simulation trajectory outputs @@ -50,8 +52,12 @@ def __init__( plots : List[Dict[str, Any]] (optional) An object containing plot data already in Simularium format + center_fibers : bool + Set the position of each fiber as the center of its points? + Otherwise set it to zero. """ self.object_info = object_info self.meta_data = meta_data if meta_data is not None else MetaData() self.draw_fiber_points = draw_fiber_points self.plots = plots if plots is not None else [] + self.center_fibers = center_fibers From 03b9353ef3be49bbb7b6ca2936bbe447d7233925 Mon Sep 17 00:00:00 2001 From: ascibisz Date: Mon, 29 Jul 2024 14:22:40 -0700 Subject: [PATCH 2/5] use python 3.10 instead of 3.8 for main build --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46ba1e8b..992ec90f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9] + python-version: [3.9, "3.10"] os: [ubuntu-latest] steps: From 1731074775f1f6e7edfd48ced43ca4b6f2d354ae Mon Sep 17 00:00:00 2001 From: ascibisz Date: Mon, 29 Jul 2024 15:06:11 -0700 Subject: [PATCH 3/5] update readdy version --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index 2cbb7f68..28cd9726 100644 --- a/environment.yml +++ b/environment.yml @@ -2,5 +2,5 @@ name: anaconda-client-env channels: - conda-forge dependencies: - - readdy==2.0.9 + - readdy - numpy>=1.20 From 61ed7c0c30d9813452753af476a1e0566c4ffd45 Mon Sep 17 00:00:00 2001 From: ascibisz Date: Mon, 29 Jul 2024 15:20:25 -0700 Subject: [PATCH 4/5] update readme to reflect current supported versions of Python --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed487fe5..41729d2f 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Rendering capabilities planned for future: ## Installation **Install Requires:** -* Requires Python 3.7, 3.8, or 3.9 +* Requires Python 3.9 or 3.10 * If ReaDDy trajectories will be converted, the ReaDDy python package must be installed: (add conda forge channel if it's not already: `conda config --add channels conda-forge`) From 5359adfddd758f859a4f2c4ffa1d1025d98108dc Mon Sep 17 00:00:00 2001 From: Blair Lyons Date: Mon, 29 Jul 2024 16:04:15 -0700 Subject: [PATCH 5/5] fix cytosim tests --- simulariumio/tests/converters/test_cytosim_converter.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/simulariumio/tests/converters/test_cytosim_converter.py b/simulariumio/tests/converters/test_cytosim_converter.py index fee4535b..134bed1a 100644 --- a/simulariumio/tests/converters/test_cytosim_converter.py +++ b/simulariumio/tests/converters/test_cytosim_converter.py @@ -30,6 +30,7 @@ ), ) }, + center_fibers=True, ) converter = CytosimConverter(data) results = JsonWriter.format_trajectory_data(converter._data) @@ -93,6 +94,7 @@ def test_typeMapping_default(typeMapping, expected_typeMapping): ), ) }, + center_fibers=True, ) converter_meta_data = CytosimConverter(data_with_metadata) results_meta_data = JsonWriter.format_trajectory_data(converter_meta_data._data) @@ -144,6 +146,7 @@ def test_box_size_provided(box_size, expected_box_size): }, ) }, + center_fibers=True, ) converter_display_data = CytosimConverter(data_with_display_data) results_display_data = JsonWriter.format_trajectory_data(converter_display_data._data) @@ -328,6 +331,7 @@ def test_agent_ids(): ), ), }, + center_fibers=True, ) # load the data from Cytosim output .txt files cytosim_data = {} @@ -358,6 +362,7 @@ def test_input_file_error(): ), ) }, + center_fibers=True, ) with pytest.raises(InputDataError): CytosimConverter(malformed_data) @@ -374,6 +379,7 @@ def test_input_file_error(): ), ) }, + center_fibers=True, ) with pytest.raises(InputDataError): CytosimConverter(wrong_file)