From 050f1bd33d71c8f59d6af87e0a91b185c1f94f41 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Aug 2023 10:14:47 +0200 Subject: [PATCH 1/4] Bump tornado from 6.3.2 to 6.3.3 in /requirements (#332) Bumps [tornado](https://github.com/tornadoweb/tornado) from 6.3.2 to 6.3.3. - [Changelog](https://github.com/tornadoweb/tornado/blob/master/docs/releases.rst) - [Commits](https://github.com/tornadoweb/tornado/compare/v6.3.2...v6.3.3) --- updated-dependencies: - dependency-name: tornado dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/requirements-macOS-latest-3.9.txt | 2 +- requirements/requirements-ubuntu-latest-3.9.txt | 2 +- requirements/requirements-windows-latest-3.9.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements/requirements-macOS-latest-3.9.txt b/requirements/requirements-macOS-latest-3.9.txt index f9f52eff..e8b015a4 100644 --- a/requirements/requirements-macOS-latest-3.9.txt +++ b/requirements/requirements-macOS-latest-3.9.txt @@ -213,7 +213,7 @@ toposort==1.10 # via symfit torch==2.0.1 # via pyhdx (pyproject.toml) -tornado==6.3.2 +tornado==6.3.3 # via # bokeh # distributed diff --git a/requirements/requirements-ubuntu-latest-3.9.txt b/requirements/requirements-ubuntu-latest-3.9.txt index a789a14f..e5765c11 100644 --- a/requirements/requirements-ubuntu-latest-3.9.txt +++ b/requirements/requirements-ubuntu-latest-3.9.txt @@ -246,7 +246,7 @@ torch==2.0.1 # via # pyhdx (pyproject.toml) # triton -tornado==6.3.2 +tornado==6.3.3 # via # bokeh # distributed diff --git a/requirements/requirements-windows-latest-3.9.txt b/requirements/requirements-windows-latest-3.9.txt index 58f87d4f..d6ec8dec 100644 --- a/requirements/requirements-windows-latest-3.9.txt +++ b/requirements/requirements-windows-latest-3.9.txt @@ -217,7 +217,7 @@ toposort==1.10 # via symfit torch==2.0.1 # via pyhdx (pyproject.toml) -tornado==6.3.2 +tornado==6.3.3 # via # bokeh # distributed From 880227ba8a9660d9ab9d919e0b9558f642676cd5 Mon Sep 17 00:00:00 2001 From: Jochem Smit Date: Thu, 17 Aug 2023 16:06:17 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 193d35b8..a95fe6af 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,12 @@ Please refer to the [docs](https://pyhdx.readthedocs.io/en/stable/) for more det ## Web Application The PyHDX web application is currently hosted at: -~~http://pyhdx.jhsmit.org~~ https://gather-mega-fioricet-ruled.trycloudflare.com/ +http://pyhdx.jhsmit.org A test file can be downloaded from [here](https://github.com/raw/Jhsmit/PyHDX/master/tests/test_data/input/ecSecB_apo.csv) and [here](https://github.com/raw/Jhsmit/PyHDX/master/tests/test_data/input/ecSecB_dimer.csv>) (right click, save as). A beta version might be available at: -~~http://pyhdx-beta.jhsmit.org~~ https://risk-percentage-hacker-birds.trycloudflare.com/ +http://pyhdx-beta.jhsmit.org The latest beta docs are found [here](https://pyhdx.readthedocs.io/en/latest/) From 11aaf17b4185fb14585d5a6e0bfea1741dc52c5a Mon Sep 17 00:00:00 2001 From: Jochem Smit Date: Fri, 25 Aug 2023 13:41:41 +0200 Subject: [PATCH 3/4] Bump hdxms datasets (#333) * update install docs * comment * bump hdxms-datasets version * bump pinned requirements * chore: fmt black --- docs/installation.md | 16 ++++--- pyhdx/batch_processing.py | 9 ++-- pyhdx/cli.py | 6 +++ pyhdx/config.py | 1 + pyhdx/datasets.py | 2 +- pyhdx/fileIO.py | 4 +- pyhdx/plot.py | 2 +- pyhdx/process.py | 4 +- pyhdx/support.py | 1 + pyhdx/web/controllers.py | 43 ++++++++++-------- pyproject.toml | 2 +- .../requirements-macOS-latest-3.9.txt | 26 ++++++----- .../requirements-ubuntu-latest-3.9.txt | 30 +++++++------ .../requirements-windows-latest-3.9.txt | 26 ++++++----- templates/02_load_from_yaml.py | 8 ++-- templates/03_initial_guesses.py | 4 +- tests/test_fileIO.py | 5 +-- tests/test_fitting.py | 44 ++++++++++++------- 18 files changed, 138 insertions(+), 95 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 3659af54..1e573537 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -62,11 +62,11 @@ This will start a Dask cluster on the scheduler address as specified in the PyHD ## Install from source -Create a new conda environment: +Create a new conda environment in a local `.venv` folder: ```bash -conda create --name py39_pyhdx python=3.9 -conda activate py39_pyhdx +conda create --prefix ./.venv python=3.9 +conda activate ./.venv ``` Clone the GitHub repository: @@ -75,13 +75,17 @@ git clone https://github.com/Jhsmit/PyHDX cd PyHDX ``` -Dependencies can then be installed with `poetry` +You can install the dependencies from the pinned requirement files for your OS with pip: ```bash - $ poetry install --all-extras +$ pip install -r requirements/requirements--3.9.txt ``` -Use `--all-extras` if you plan to use the web interface. +Then to editable install PyHDX: + +```bash +$ pip install -e . +``` ### Running from source diff --git a/pyhdx/batch_processing.py b/pyhdx/batch_processing.py index fd6008f7..05de9aa5 100644 --- a/pyhdx/batch_processing.py +++ b/pyhdx/batch_processing.py @@ -29,7 +29,9 @@ class DataFile(object): filepath_or_buffer: Union[Path, StringIO] def __post_init__(self): - warnings.warn("Will be removed in favour of the `hdxms-datasets` package ", DeprecationWarning) + warnings.warn( + "Will be removed in favour of the `hdxms-datasets` package ", DeprecationWarning + ) @cached_property def data(self) -> pd.DataFrame: @@ -62,8 +64,9 @@ def __init__( # filter_kwargs: Optional[dict[str, Any]] = None, # correction_kwargs: Optional[dict[str, Any]] = None, ) -> None: - - warnings.warn("Will be removed in favour of the `hdxms-datasets` package ", DeprecationWarning) + warnings.warn( + "Will be removed in favour of the `hdxms-datasets` package ", DeprecationWarning + ) self.hdx_spec = hdx_spec self.data_files: dict[str, DataFile] = {} diff --git a/pyhdx/cli.py b/pyhdx/cli.py index c73bbb90..dda7645d 100644 --- a/pyhdx/cli.py +++ b/pyhdx/cli.py @@ -11,6 +11,8 @@ from pyhdx.datasets import DataVault app = typer.Typer() + + @app.command() def serve( scheduler_address: Optional[str] = typer.Option(None, help="Address for dask scheduler to use"), @@ -61,6 +63,8 @@ def serve( datasets_app = typer.Typer(help="Manage HDX datasets") + + @datasets_app.command() def fetch(num: int = typer.Option(10, min=1, help="Maximum number of datasets to download")): """Update the datasets from the PyHDX repository""" @@ -72,6 +76,7 @@ def fetch(num: int = typer.Option(10, min=1, help="Maximum number of datasets to for data_id in tqdm(todo): vault.fetch_dataset(data_id) + @datasets_app.command() def clear(): """Clear the local dataset cache""" @@ -81,6 +86,7 @@ def clear(): app.add_typer(datasets_app, name="datasets") + @app.callback() def callback(): pass diff --git a/pyhdx/config.py b/pyhdx/config.py index d12a3a39..faa22ead 100644 --- a/pyhdx/config.py +++ b/pyhdx/config.py @@ -146,6 +146,7 @@ def context(self, settings: dict) -> Generator[PyHDXConfig, None, None]: finally: cfg.conf = original_config + def valid_config() -> bool: """Checks if the current config file in the user home directory is a valid config file for the current pyhdx version. diff --git a/pyhdx/datasets.py b/pyhdx/datasets.py index 1b1afaf5..a2d9071b 100644 --- a/pyhdx/datasets.py +++ b/pyhdx/datasets.py @@ -1 +1 @@ -from hdxms_datasets import * \ No newline at end of file +from hdxms_datasets import * diff --git a/pyhdx/fileIO.py b/pyhdx/fileIO.py index b7d38602..85207352 100644 --- a/pyhdx/fileIO.py +++ b/pyhdx/fileIO.py @@ -80,7 +80,9 @@ def read_header(file_obj: Union[TextIO, BinaryIO], comment: str = "#") -> List[s return header -def parse_header(filepath_or_buffer: Union[Path[str], str, StringIO, BytesIO], comment: str = "#") -> dict: +def parse_header( + filepath_or_buffer: Union[Path[str], str, StringIO, BytesIO], comment: str = "#" +) -> dict: """ Reads the header from a file and returns JSON metadata from header lines marked as comment. diff --git a/pyhdx/plot.py b/pyhdx/plot.py index b0c41152..97ee3693 100644 --- a/pyhdx/plot.py +++ b/pyhdx/plot.py @@ -615,7 +615,6 @@ def linear_bars( sort=False, **figure_kwargs, ): - # input data should always be 3 levels # grouping is done by the first level # second level gives each bar @@ -1142,6 +1141,7 @@ def get(self, item, default=None): return default +# should be a frozen dataclas CMAP_NORM_DEFAULTS = ColorTransforms() diff --git a/pyhdx/process.py b/pyhdx/process.py index 83f01394..37139592 100644 --- a/pyhdx/process.py +++ b/pyhdx/process.py @@ -255,7 +255,9 @@ def filter_peptides( """ - warnings.warn("`filter_peptides` will be moved to the `hdxms-datasets` package", DeprecationWarning) + warnings.warn( + "`filter_peptides` will be moved to the `hdxms-datasets` package", DeprecationWarning + ) if state: df = df[df["state"] == state] diff --git a/pyhdx/support.py b/pyhdx/support.py index dd88a409..4e85b0ad 100644 --- a/pyhdx/support.py +++ b/pyhdx/support.py @@ -848,6 +848,7 @@ def array_intersection(arrays: Iterable[np.ndarray], fields: Iterable[str]) -> l return selected + # https://stackoverflow.com/questions/31174295/getattr-and-setattr-on-nested-subobjects-chained-properties def rsetattr(obj, attr, val): pre, _, post = attr.rpartition(".") diff --git a/pyhdx/web/controllers.py b/pyhdx/web/controllers.py index 28df83c1..763090c4 100644 --- a/pyhdx/web/controllers.py +++ b/pyhdx/web/controllers.py @@ -47,7 +47,8 @@ from pyhdx.datasets import HDXDataSet, DataVault, DataFile from pyhdx.fitting_torch import TorchFitResultSet from pyhdx.models import ( - PeptideUptakeModel, HDXMeasurement, + PeptideUptakeModel, + HDXMeasurement, ) from pyhdx.plot import ( dG_scatter_figure, @@ -293,7 +294,9 @@ class PeptideFileInputControl(PyHDXControlPanel): batch_file = param.Parameter(doc="Batch file input:") - dataset_id = param.Selector(label="Dataset ID", doc="Dataset ID to load from hdxms-datasets database") + dataset_id = param.Selector( + label="Dataset ID", doc="Dataset ID to load from hdxms-datasets database" + ) nd_control = param.Boolean( default=False, precedence=-1, doc="Whether to allow users to input a ND control" @@ -410,7 +413,7 @@ def __init__(self, parent, **params): todo = list(missing_datasets)[:num] for data_id in tqdm(todo): self.data_vault.fetch_dataset(data_id) - self.param['dataset_id'].objects = self.data_vault.datasets + self.param["dataset_id"].objects = self.data_vault.datasets if self.data_vault.datasets: self.dataset_id = self.data_vault.datasets[0] @@ -512,19 +515,17 @@ def _update_mode(self): "measurement_name", "download_spec_button", }, - "Batch": { - "input_files_label", - "input_files", - "batch_file", - "batch_file_label" - }, + "Batch": {"input_files_label", "input_files", "batch_file", "batch_file_label"}, "Database": { "dataset_id", - } + }, } - #widget_dict.pop(self.input_mode) - excluded = set.union(*(v for k, v in widget_dict.items() if k != self.input_mode)) - widget_dict[self.input_mode] + # widget_dict.pop(self.input_mode) + excluded = ( + set.union(*(v for k, v in widget_dict.items() if k != self.input_mode)) + - widget_dict[self.input_mode] + ) # # # if self.input_mode == "Manual": @@ -814,7 +815,9 @@ def _action_load_datasets(self) -> None: """Load all specified HDX measurements""" if self.input_mode == "Manual": data_src = self.data_file_history - dataset = HDXDataSet(data_id=uuid.uuid4().hex, data_files=data_src, hdx_spec=self.hdx_spec) + dataset = HDXDataSet( + data_id=uuid.uuid4().hex, data_files=data_src, hdx_spec=self.hdx_spec + ) elif self.input_mode == "Batch": if self.hdxm_list: self.parent.logger.info("Cannot add data in batch after manually inputting data") @@ -831,7 +834,9 @@ def _action_load_datasets(self) -> None: self.state_spec = hdx_spec["states"] self.data_spec = hdx_spec["data_files"] - dataset = HDXDataSet(data_id=uuid.uuid4().hex, data_files=data_src, hdx_spec=self.hdx_spec) + dataset = HDXDataSet( + data_id=uuid.uuid4().hex, data_files=data_src, hdx_spec=self.hdx_spec + ) self.param["hdxm_list"].objects = dataset.states elif self.input_mode == "Database": if self.dataset_id is None: @@ -841,18 +846,18 @@ def _action_load_datasets(self) -> None: self.parent.logger.info(f"Loaded dataset {dataset.data_id} from hdxms database") try: - authors = ", ".join([author['name'] for author in dataset.metadata['authors']]) + authors = ", ".join([author["name"] for author in dataset.metadata["authors"]]) self.parent.logger.info(f"Author(s): {authors}") except KeyError: pass - publications = dataset.metadata.get('publications', []) + publications = dataset.metadata.get("publications", []) if publications: for pub in publications: - pub_str = pub['title'] - if 'DOI' in pub: + pub_str = pub["title"] + if "DOI" in pub: pub_str += f' ([{pub["DOI"]}](https://doi.org/{pub["DOI"]}))' - elif 'URL' in pub: + elif "URL" in pub: pub_str += f' ([URL]({pub["URL"]}))' self.parent.logger.info("Publication: " + pub_str) else: diff --git a/pyproject.toml b/pyproject.toml index 24affefe..66da0a26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "param", "pyyaml", "omegaconf", - "hdxms-datasets>=0.1.2", + "hdxms-datasets>=0.1.3", ] dynamic = ["version"] diff --git a/requirements/requirements-macOS-latest-3.9.txt b/requirements/requirements-macOS-latest-3.9.txt index e8b015a4..e886ad2e 100644 --- a/requirements/requirements-macOS-latest-3.9.txt +++ b/requirements/requirements-macOS-latest-3.9.txt @@ -17,7 +17,7 @@ certifi==2023.7.22 # via requests charset-normalizer==3.2.0 # via requests -click==8.1.6 +click==8.1.7 # via # dask # distributed @@ -33,21 +33,21 @@ colorcet==3.0.1 # pyhdx (pyproject.toml) cycler==0.11.0 # via matplotlib -dask==2023.8.0 +dask==2023.8.1 # via # distributed # pyhdx (pyproject.toml) -distributed==2023.8.0 +distributed==2023.8.1 # via pyhdx (pyproject.toml) filelock==3.12.2 # via torch fsspec==2023.6.0 # via dask -hdxms-datasets==0.1.2 +hdxms-datasets==0.1.3 # via pyhdx (pyproject.toml) hdxrate==0.2.0 # via pyhdx (pyproject.toml) -holoviews==1.17.0 +holoviews==1.17.1 # via # hvplot # pyhdx (pyproject.toml) @@ -66,7 +66,7 @@ jinja2==3.1.2 # bokeh # distributed # torch -kiwisolver==1.4.4 +kiwisolver==1.4.5 # via matplotlib lazy-loader==0.3 # via scikit-image @@ -110,7 +110,7 @@ omegaconf==2.3.0 # via # hdxms-datasets # pyhdx (pyproject.toml) -packaging==22.0 +packaging==23.1 # via # bokeh # dask @@ -120,7 +120,7 @@ packaging==22.0 # hvplot # pyhdx (pyproject.toml) # scikit-image -pandas==1.5.3 +pandas==2.0.3 # via # hdxms-datasets # holoviews @@ -163,7 +163,7 @@ python-dateutil==2.8.2 # pandas pytz==2023.3 # via pandas -pyviz-comms==2.3.2 +pyviz-comms==3.0.0 # via # holoviews # panel @@ -183,7 +183,7 @@ requests==2.31.0 # panel scikit-image==0.21.0 # via pyhdx (pyproject.toml) -scipy==1.11.1 +scipy==1.11.2 # via # pyhdx (pyproject.toml) # scikit-image @@ -202,7 +202,7 @@ sympy==1.12 # torch tblib==2.0.0 # via distributed -tifffile==2023.7.18 +tifffile==2023.8.12 # via scikit-image toolz==0.12.0 # via @@ -217,7 +217,7 @@ tornado==6.3.3 # via # bokeh # distributed -tqdm==4.65.0 +tqdm==4.66.1 # via # panel # pyhdx (pyproject.toml) @@ -229,6 +229,8 @@ typing-extensions==4.7.1 # panel # torch # typer +tzdata==2023.3 + # via pandas urllib3==2.0.4 # via # distributed diff --git a/requirements/requirements-ubuntu-latest-3.9.txt b/requirements/requirements-ubuntu-latest-3.9.txt index e5765c11..a977c99d 100644 --- a/requirements/requirements-ubuntu-latest-3.9.txt +++ b/requirements/requirements-ubuntu-latest-3.9.txt @@ -17,7 +17,7 @@ certifi==2023.7.22 # via requests charset-normalizer==3.2.0 # via requests -click==8.1.6 +click==8.1.7 # via # dask # distributed @@ -26,7 +26,7 @@ cloudpickle==2.2.1 # via # dask # distributed -cmake==3.27.1 +cmake==3.27.2 # via triton colorcet==3.0.1 # via @@ -35,11 +35,11 @@ colorcet==3.0.1 # pyhdx (pyproject.toml) cycler==0.11.0 # via matplotlib -dask==2023.8.0 +dask==2023.8.1 # via # distributed # pyhdx (pyproject.toml) -distributed==2023.8.0 +distributed==2023.8.1 # via pyhdx (pyproject.toml) filelock==3.12.2 # via @@ -47,11 +47,11 @@ filelock==3.12.2 # triton fsspec==2023.6.0 # via dask -hdxms-datasets==0.1.2 +hdxms-datasets==0.1.3 # via pyhdx (pyproject.toml) hdxrate==0.2.0 # via pyhdx (pyproject.toml) -holoviews==1.17.0 +holoviews==1.17.1 # via # hvplot # pyhdx (pyproject.toml) @@ -70,7 +70,7 @@ jinja2==3.1.2 # bokeh # distributed # torch -kiwisolver==1.4.4 +kiwisolver==1.4.5 # via matplotlib lazy-loader==0.3 # via scikit-image @@ -141,7 +141,7 @@ omegaconf==2.3.0 # via # hdxms-datasets # pyhdx (pyproject.toml) -packaging==22.0 +packaging==23.1 # via # bokeh # dask @@ -151,7 +151,7 @@ packaging==22.0 # hvplot # pyhdx (pyproject.toml) # scikit-image -pandas==1.5.3 +pandas==2.0.3 # via # hdxms-datasets # holoviews @@ -194,7 +194,7 @@ python-dateutil==2.8.2 # pandas pytz==2023.3 # via pandas -pyviz-comms==2.3.2 +pyviz-comms==3.0.0 # via # holoviews # panel @@ -214,7 +214,7 @@ requests==2.31.0 # panel scikit-image==0.21.0 # via pyhdx (pyproject.toml) -scipy==1.11.1 +scipy==1.11.2 # via # pyhdx (pyproject.toml) # scikit-image @@ -233,7 +233,7 @@ sympy==1.12 # torch tblib==2.0.0 # via distributed -tifffile==2023.7.18 +tifffile==2023.8.12 # via scikit-image toolz==0.12.0 # via @@ -250,7 +250,7 @@ tornado==6.3.3 # via # bokeh # distributed -tqdm==4.65.0 +tqdm==4.66.1 # via # panel # pyhdx (pyproject.toml) @@ -264,13 +264,15 @@ typing-extensions==4.7.1 # panel # torch # typer +tzdata==2023.3 + # via pandas urllib3==2.0.4 # via # distributed # requests webencodings==0.5.1 # via bleach -wheel==0.41.1 +wheel==0.41.2 # via # nvidia-cublas-cu11 # nvidia-cuda-cupti-cu11 diff --git a/requirements/requirements-windows-latest-3.9.txt b/requirements/requirements-windows-latest-3.9.txt index d6ec8dec..357bb0e3 100644 --- a/requirements/requirements-windows-latest-3.9.txt +++ b/requirements/requirements-windows-latest-3.9.txt @@ -17,7 +17,7 @@ certifi==2023.7.22 # via requests charset-normalizer==3.2.0 # via requests -click==8.1.6 +click==8.1.7 # via # dask # distributed @@ -37,21 +37,21 @@ colorcet==3.0.1 # pyhdx (pyproject.toml) cycler==0.11.0 # via matplotlib -dask==2023.8.0 +dask==2023.8.1 # via # distributed # pyhdx (pyproject.toml) -distributed==2023.8.0 +distributed==2023.8.1 # via pyhdx (pyproject.toml) filelock==3.12.2 # via torch fsspec==2023.6.0 # via dask -hdxms-datasets==0.1.2 +hdxms-datasets==0.1.3 # via pyhdx (pyproject.toml) hdxrate==0.2.0 # via pyhdx (pyproject.toml) -holoviews==1.17.0 +holoviews==1.17.1 # via # hvplot # pyhdx (pyproject.toml) @@ -70,7 +70,7 @@ jinja2==3.1.2 # bokeh # distributed # torch -kiwisolver==1.4.4 +kiwisolver==1.4.5 # via matplotlib lazy-loader==0.3 # via scikit-image @@ -114,7 +114,7 @@ omegaconf==2.3.0 # via # hdxms-datasets # pyhdx (pyproject.toml) -packaging==22.0 +packaging==23.1 # via # bokeh # dask @@ -124,7 +124,7 @@ packaging==22.0 # hvplot # pyhdx (pyproject.toml) # scikit-image -pandas==1.5.3 +pandas==2.0.3 # via # hdxms-datasets # holoviews @@ -167,7 +167,7 @@ python-dateutil==2.8.2 # pandas pytz==2023.3 # via pandas -pyviz-comms==2.3.2 +pyviz-comms==3.0.0 # via # holoviews # panel @@ -187,7 +187,7 @@ requests==2.31.0 # panel scikit-image==0.21.0 # via pyhdx (pyproject.toml) -scipy==1.11.1 +scipy==1.11.2 # via # pyhdx (pyproject.toml) # scikit-image @@ -206,7 +206,7 @@ sympy==1.12 # torch tblib==2.0.0 # via distributed -tifffile==2023.7.18 +tifffile==2023.8.12 # via scikit-image toolz==0.12.0 # via @@ -221,7 +221,7 @@ tornado==6.3.3 # via # bokeh # distributed -tqdm==4.65.0 +tqdm==4.66.1 # via # panel # pyhdx (pyproject.toml) @@ -233,6 +233,8 @@ typing-extensions==4.7.1 # panel # torch # typer +tzdata==2023.3 + # via pandas urllib3==2.0.4 # via # distributed diff --git a/templates/02_load_from_yaml.py b/templates/02_load_from_yaml.py index 49b4237f..4d744c69 100644 --- a/templates/02_load_from_yaml.py +++ b/templates/02_load_from_yaml.py @@ -17,7 +17,7 @@ hdx_spec = yaml.safe_load(yaml_stream) input_dir = current_dir.parent / "tests" / "test_data" / "input" -#%% +# %% dataset = HDXDataSet.from_spec( hdx_spec, @@ -26,9 +26,9 @@ print(dataset.describe()) -#%% +# %% # Load an HDX measurement by state name -hdxm = HDXMeasurement.from_dataset(dataset, state='SecB_tetramer') +hdxm = HDXMeasurement.from_dataset(dataset, state="SecB_tetramer") print(hdxm) print(hdxm.timepoints) @@ -39,6 +39,6 @@ print(hdxm.timepoints) -#%% +# %% hdxm_set = HDXMeasurementSet.from_dataset(dataset) print(hdxm_set) diff --git a/templates/03_initial_guesses.py b/templates/03_initial_guesses.py index 5ca40111..f5ff3684 100644 --- a/templates/03_initial_guesses.py +++ b/templates/03_initial_guesses.py @@ -27,7 +27,9 @@ hdxm = HDXMeasurement.from_dataset(dataset, state=name) # Save sequence info + intrinsic rates - dataframe_to_file(output_dir / f"{name}_intrinsic_rates.csv", hdxm.coverage.protein, fmt='pprint') + dataframe_to_file( + output_dir / f"{name}_intrinsic_rates.csv", hdxm.coverage.protein, fmt="pprint" + ) fr = fit_rates_weighted_average(hdxm, client=client) dataframe_to_file(output_dir / f"{name}_rates_guess.csv", fr.output) diff --git a/tests/test_fileIO.py b/tests/test_fileIO.py index 911cdc2a..8bd8a161 100644 --- a/tests/test_fileIO.py +++ b/tests/test_fileIO.py @@ -40,9 +40,7 @@ def hdxm() -> HDXMeasurement: peptides_corrected = correct_d_uptake(peptides_control) temperature, pH = 273.15 + 30, 8.0 - hdxm = HDXMeasurement( - peptides_corrected, temperature=temperature, pH=pH, c_term=155 - ) + hdxm = HDXMeasurement(peptides_corrected, temperature=temperature, pH=pH, c_term=155) return hdxm @@ -122,6 +120,7 @@ def test_read_write_tables(tmp_path): assert len(lines) == 38 assert lines[0].strip() == pyhdx.VERSION_STRING + def test_load_save_fitresult(tmp_path, fit_result: TorchFitResult, hdxm: HDXMeasurement): # todo missing read batch result test diff --git a/tests/test_fitting.py b/tests/test_fitting.py index 454bc976..73fcc8d3 100644 --- a/tests/test_fitting.py +++ b/tests/test_fitting.py @@ -43,8 +43,8 @@ def dataset() -> HDXDataSet: hdx_spec = yaml.safe_load(yaml_pth.read_text()) # add truncated tetramer state - hdx_spec['states']['SecB_tetramer_red'] = copy.deepcopy(hdx_spec['states']['SecB_tetramer']) - hdx_spec['states']['SecB_tetramer_red']['peptides']['experiment']['query'] = ["stop < 40"] + hdx_spec["states"]["SecB_tetramer_red"] = copy.deepcopy(hdx_spec["states"]["SecB_tetramer"]) + hdx_spec["states"]["SecB_tetramer_red"]["peptides"]["experiment"]["query"] = ["stop < 40"] dataset = HDXDataSet.from_spec(hdx_spec, data_dir=input_dir) @@ -53,24 +53,24 @@ def dataset() -> HDXDataSet: @pytest.fixture() def hdxm_apo(dataset: HDXDataSet) -> HDXMeasurement: - with cfg.context({'analysis.drop_first': 1}): - hdxm = HDXMeasurement.from_dataset(dataset, state="SecB_tetramer", d_percentage=100.) + with cfg.context({"analysis.drop_first": 1}): + hdxm = HDXMeasurement.from_dataset(dataset, state="SecB_tetramer", d_percentage=100.0) return hdxm @pytest.fixture() def hdxm_dimer(dataset: HDXDataSet) -> HDXMeasurement: - with cfg.context({'analysis.drop_first': 1}): - hdxm = HDXMeasurement.from_dataset(dataset, state="SecB_dimer", d_percentage=100.) + with cfg.context({"analysis.drop_first": 1}): + hdxm = HDXMeasurement.from_dataset(dataset, state="SecB_dimer", d_percentage=100.0) return hdxm @pytest.fixture() def hdxm_apo_red(dataset: HDXDataSet) -> HDXMeasurement: - with cfg.context({'analysis.drop_first': 1}): - hdxm = HDXMeasurement.from_dataset(dataset, state="SecB_tetramer_red", d_percentage=100.) + with cfg.context({"analysis.drop_first": 1}): + hdxm = HDXMeasurement.from_dataset(dataset, state="SecB_tetramer_red", d_percentage=100.0) return hdxm @@ -260,16 +260,28 @@ def test_batch_fit(hdxm_apo: HDXMeasurement, hdxm_dimer: HDXMeasurement, tmp_pat assert errors.shape == (hdx_set.Ns, hdx_set.Np, hdx_set.Nt) test = fr_global.get_peptide_mse().fillna(-1) - name_mapping = {'SecB his dimer apo': 'SecB_dimer', 'SecB WT apo': 'SecB_tetramer'} - ref = csv_to_dataframe(output_dir / "ecSecB_batch_peptide_mse.csv").fillna(-1).rename(columns=name_mapping) + name_mapping = {"SecB his dimer apo": "SecB_dimer", "SecB WT apo": "SecB_tetramer"} + ref = ( + csv_to_dataframe(output_dir / "ecSecB_batch_peptide_mse.csv") + .fillna(-1) + .rename(columns=name_mapping) + ) assert_frame_equal(test, ref, atol=1e-1, rtol=5e-1) test = fr_global.get_residue_mse().fillna(-1) - ref = csv_to_dataframe(output_dir / "ecSecB_batch_residue_mse.csv").fillna(-1).rename(columns=name_mapping) + ref = ( + csv_to_dataframe(output_dir / "ecSecB_batch_residue_mse.csv") + .fillna(-1) + .rename(columns=name_mapping) + ) assert_frame_equal(test, ref, atol=1e-1, rtol=5e-1) test = fr_global.losses.fillna(-1) - ref = csv_to_dataframe(output_dir / "ecSecB_batch_loss.csv").fillna(-1).rename(columns=name_mapping) + ref = ( + csv_to_dataframe(output_dir / "ecSecB_batch_loss.csv") + .fillna(-1) + .rename(columns=name_mapping) + ) assert_frame_equal(test, ref, atol=1e-3, rtol=1e-2) # test alignment fit @@ -281,11 +293,11 @@ def test_batch_fit(hdxm_apo: HDXMeasurement, hdxm_dimer: HDXMeasurement, tmp_pat hdx_set.add_alignment(list(mock_alignment.values())) gibbs_guess = hdx_set[0].guess_deltaG(guess["rate"]) # Guesses from first measurement - aligned_result = fit_gibbs_global_batch_aligned( - hdx_set, gibbs_guess, r1=2, r2=5, epochs=1000 - ) + aligned_result = fit_gibbs_global_batch_aligned(hdx_set, gibbs_guess, r1=2, r2=5, epochs=1000) output = aligned_result.output - check_df = csv_to_dataframe(output_dir / "ecSecB_batch_aligned.csv").rename(columns=name_mapping) + check_df = csv_to_dataframe(output_dir / "ecSecB_batch_aligned.csv").rename( + columns=name_mapping + ) states = ["SecB_tetramer", "SecB_dimer"] for state in states: From 4f2e7fa72e09deff18f1f80c80c4f372ffb664df Mon Sep 17 00:00:00 2001 From: Jochem Smit Date: Tue, 26 Sep 2023 15:35:27 +0200 Subject: [PATCH 4/4] Bump hdxms datasets (#334) * update install docs * comment * bump hdxms-datasets version * bump pinned requirements * chore: fmt black