diff --git a/.github/workflows/pip_installation.yml b/.github/workflows/pip_installation.yml index 3c501f3c..e1382590 100644 --- a/.github/workflows/pip_installation.yml +++ b/.github/workflows/pip_installation.yml @@ -22,16 +22,15 @@ jobs: with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} - install-script: pip_install.sh stable,tests alphabase ${{ matrix.python-version }} ${{ matrix.os }} + install-script: pip_install.sh stable,tests loose_installation: name: Test loose pip installation on ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest, macos-latest-xlarge] - python-version: [3.9] uses: ./.github/workflows/_run_tests.yml with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} - install-script: pip_install.sh tests alphabase ${{ matrix.python-version }} ${{ matrix.os }} + install-script: pip_install.sh tests diff --git a/README.md b/README.md index eb27730a..435b08d9 100644 --- a/README.md +++ b/README.md @@ -97,25 +97,11 @@ be compatible with: pip install "alphabase[stable]" ``` -**NOTE**: You might need to run `pip install -U pip` before installing +NOTE: You might need to run `pip install -U pip` before installing AlphaBase like this. Also note the double quotes `"`. If you are using the `quant_reader` module, it is advisable to add the `dask-stable` or `dask` extras to speed up processing large files. - -**NOTE for macOS users**: Due to compilation issues with PyTables on macOS, you may encounter build errors when installing AlphaBase. -These may include - -- `ERROR:: Could not find a local HDF5 installation` -- `ERROR: Failed building wheel for tables` - -If this happens, install PyTables via conda/mamba first: -```bash -conda install -c conda-forge pytables -# or -mamba install -c conda-forge pytables -``` -Then proceed with the pip installation of AlphaBase. - +You need to install the `hdf` extra option of the package to be able to read alphapept protein group matrices in hdf format. For those who are really adventurous, it is also possible to directly install any branch (e.g. `@main`) with any extras diff --git a/alphabase/pg_reader/alphapept_pg_reader.py b/alphabase/pg_reader/alphapept_pg_reader.py index c915e1e7..226af066 100644 --- a/alphabase/pg_reader/alphapept_pg_reader.py +++ b/alphabase/pg_reader/alphapept_pg_reader.py @@ -22,6 +22,9 @@ class AlphaPeptPGReader(PGReaderBase): AlphaPept protein group matrices contain both raw intensities and LFQ-corrected intensities. The LFQ-corrected intensities are marked by an `_LFQ` suffix. + In order to read alphapept `.hdf` output, please install the package with extra optional + dependencies `pip install "alphabase[hdf]"`. + Example: ------- Get example data diff --git a/misc/pip_install.sh b/misc/pip_install.sh index e65bc8f8..b3c3ce2f 100644 --- a/misc/pip_install.sh +++ b/misc/pip_install.sh @@ -8,7 +8,6 @@ set -e -u INSTALL_TYPE=$1 # stable, loose, etc.. ENV_NAME=${2:-alphabase} PYTHON_VERSION=${3:-3.9} -OS=${4:-nan} conda create -n $ENV_NAME python=$PYTHON_VERSION -y @@ -18,12 +17,6 @@ else INSTALL_STRING="[${INSTALL_TYPE}]" fi -# pytables has known issues on MacOS for pg-readers - install from conda -# https://github.com/PyTables/PyTables/issues/219#issuecomment-24117053 -if [[ "$OS" = "macOS-latest" || "$OS" = "macos-latest-xlarge" ]]; then - conda install -n $ENV_NAME -c conda-forge pytables -y -fi - # print pip environment for reproducibility conda run -n $ENV_NAME --no-capture-output pip freeze diff --git a/pyproject.toml b/pyproject.toml index 99c09a7b..0ff3df2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,7 @@ dependencies = {file = ["requirements/requirements_loose.txt"]} optional-dependencies.stable = { file = ["requirements/requirements.txt" ] } optional-dependencies.dask = { file = ["requirements/requirements_dask_loose.txt" ] } optional-dependencies.dask-stable = { file = ["requirements/requirements_dask.txt" ] } +optional-dependencies.hdf = { file = ["requirements/requirements_hdf_loose.txt" ] } optional-dependencies.tests = { file = ["requirements/requirements_tests.txt" ] } optional-dependencies.development = { file = [ "requirements/requirements_development.txt", diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 204f0829..f27dba2a 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -17,4 +17,3 @@ pyteomics==4.7.5 pyyaml==6.0.2 lxml==5.3.0 # required by pyteomics rdkit==2024.3.3 -tables==3.9.2 # required to read HDF files, latest version compatible with 3.9 diff --git a/requirements/requirements_hdf_loose.txt b/requirements/requirements_hdf_loose.txt new file mode 100644 index 00000000..bfae4ced --- /dev/null +++ b/requirements/requirements_hdf_loose.txt @@ -0,0 +1,2 @@ +# Dependencies required for running the "loose" version of alphabase with hdf support for the alphapept PG reader. +tables diff --git a/requirements/requirements_loose.txt b/requirements/requirements_loose.txt index 17f6e4e1..9c9f3764 100644 --- a/requirements/requirements_loose.txt +++ b/requirements/requirements_loose.txt @@ -15,4 +15,3 @@ pyteomics pyyaml lxml rdkit -tables diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index ce29948e..edc4ff3e 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,5 +1,6 @@ """Shared logic for integration tests.""" +import importlib.util import os from pathlib import Path @@ -8,6 +9,14 @@ from alphabase.tools.data_downloader import DataShareDownloader +TABLES_PACKAGE_UNAVAILABLE = importlib.util.find_spec("tables") is None + + +pytest.mark.optional_pytables_dependency = pytest.mark.skipif( + TABLES_PACKAGE_UNAVAILABLE, + reason="pytables package not installed. Install with `pip install alphabase[hdf]`", +) + def get_remote_data_with_ref( url: str, ref_url: str, directory: Path @@ -132,6 +141,7 @@ def example_alphapept_csv(tmp_path) -> tuple[Path, pd.DataFrame]: return file_path, reference +@pytest.mark.optional_pytables_dependency @pytest.fixture(scope="function") def example_alphapept_hdf(tmp_path) -> tuple[Path, pd.DataFrame]: """Get and parse real alphapept protein group report matrix.""" diff --git a/tests/integration/test_pg_readers.py b/tests/integration/test_pg_readers.py index 13875838..4fdfcd45 100644 --- a/tests/integration/test_pg_readers.py +++ b/tests/integration/test_pg_readers.py @@ -51,6 +51,7 @@ def test_import_csv_file_equivalent( pd.testing.assert_frame_equal(result_df, reference) + @pytest.mark.optional_pytables_dependency def test_import_hdf_file_equivalent( self, example_alphapept_hdf: tuple[str, pd.DataFrame] ): @@ -105,6 +106,7 @@ def test_import_csv_file( PGCols.DECOY_INDICATOR, ] + @pytest.mark.optional_pytables_dependency @pytest.mark.parametrize( ("measurement_regex", "expected_shape", "expected_colums"), [