Skip to content

Commit a08889a

Browse files
committed
make alphamap optional and update installation instructions
1 parent be61df0 commit a08889a

14 files changed

Lines changed: 64 additions & 17 deletions

.github/workflows/e2e_tests_quick.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ jobs:
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030
os: ${{ matrix.os }}
31-
install-script: ./pip_install.sh tests,gui,dask
31+
install-script: ./pip_install.sh tests,gui,dask,alphamap
3232
test-script: ./run_e2e_tests_quick.sh

.github/workflows/e2e_tests_quick_multiple_platforms.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
with:
3030
python-version: ${{ matrix.python-version }}
3131
os: ${{ matrix.os }}
32-
install-script: ./pip_install.sh stable,tests,gui,dask-stable
32+
install-script: ./pip_install.sh stable,tests,gui,dask-stable,alphamap-stable
3333
test-script: ./run_e2e_tests_quick.sh
3434

3535
run-unit-tests-loose:
@@ -43,5 +43,5 @@ jobs:
4343
with:
4444
python-version: ${{ matrix.python-version }}
4545
os: ${{ matrix.os }}
46-
install-script: ./pip_install.sh tests,gui,dask
46+
install-script: ./pip_install.sh tests,gui,dask,alphamap
4747
test-script: ./run_e2e_tests_quick.sh

.github/workflows/install_and_unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ jobs:
3030
with:
3131
python-version: ${{ matrix.python-version }}
3232
os: ${{ matrix.os }}
33-
install-script: ./pip_install.sh tests,gui,dask
33+
install-script: ./pip_install.sh tests,gui,dask,alphamap
3434
test-script: ./run_unit_tests.sh

.github/workflows/install_and_unit_tests_multiple_platforms.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
os: ${{ matrix.os }}
29-
install-script: ./pip_install.sh stable,tests,gui,dask-stable
29+
install-script: ./pip_install.sh stable,tests,gui,dask-stable,alphamap-stable
3030
test-script: ./run_unit_tests.sh
3131

3232
run-unit-tests-loose:
@@ -40,5 +40,5 @@ jobs:
4040
with:
4141
python-version: ${{ matrix.python-version }}
4242
os: ${{ matrix.os }}
43-
install-script: ./pip_install.sh tests,gui,dask
43+
install-script: ./pip_install.sh tests,gui,dask,alphamap
4444
test-script: ./run_unit_tests.sh

.github/workflows/run_example_nbs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ jobs:
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030
os: ${{ matrix.os }}
31-
install-script: ./pip_install.sh tests,gui,dask
31+
install-script: ./pip_install.sh tests,gui,dask,alphamap
3232
test-script: ./run_example_notebooks.sh

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ or the version with a pinned dependency (recommended)
114114
pip install "alphaquant[dask-stable]"
115115
```
116116

117+
For AlphaMap visualization features (sequence alignment plots), install the optional alphamap extra:
118+
119+
```bash
120+
pip install "alphaquant[alphamap]"
121+
```
122+
or the version with a pinned dependency (recommended)
123+
```bash
124+
pip install "alphaquant[alphamap-stable]"
125+
```
126+
117127
### Developer installation
118128

119129
AlphaQuant can also be installed in editable (i.e. developer) mode with a few `bash` commands. This allows to fully customize the software and even modify the source code to your specific needs. When an editable Python package is installed, its source code is stored in a transparent location of your choice. While optional, it is advised to first (create and) navigate to e.g. a general software folder:

alphaquant/plotting/alphamapviz.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1+
import warnings
2+
13
import numpy as np
24
import pandas as pd
35
import anytree
46
import alphaquant.utils.utils as aqutils
57
import alphaquant.resources.database_loader as aq_db_loader
6-
7-
8-
import alphamap.preprocessing
9-
import alphamap.organisms_data
10-
import alphamap.sequenceplot
11-
import alphamap.uniprot_integration
128
import alphaquant.plotting.fcviz as aq_plot_fc
139
import alphaquant.plotting.colors as aq_plot_colors
1410

@@ -17,13 +13,31 @@
1713
aqconfig.setup_logging()
1814
LOGGER = logging.getLogger(__name__)
1915

16+
try:
17+
import alphamap.preprocessing
18+
import alphamap.organisms_data
19+
import alphamap.sequenceplot
20+
import alphamap.uniprot_integration
21+
HAS_ALPHAMAP = True
22+
except ModuleNotFoundError:
23+
warnings.warn(
24+
"Dependency 'alphamap' not installed. If you want to use its functionality, install alphaquant with the 'alphamap' extra."
25+
)
26+
HAS_ALPHAMAP = False
27+
2028

2129
class AlphaMapVisualizer:
2230
def __init__(self, condition1, condition2, results_directory, samplemap_file,
2331
order_along_protein_sequence = True, organism = 'Human',colorlist = aq_plot_colors.AlphaQuantColorMap().colorlist, tree_level = 'seq',
2432
protein_identifier = 'gene_symbol', label_rotation = 90, add_stripplot = False,
2533
narrowing_factor_for_fcplot = 1/14, rescale_factor_x = 1.0, rescale_factor_y = 2):
26-
34+
35+
if not HAS_ALPHAMAP:
36+
raise ImportError(
37+
"alphamap is required for AlphaMapVisualizer. "
38+
"Install it with: pip install \"alphaquant[alphamap]\""
39+
)
40+
2741
"""
2842
Initializes an object for visualizing peptide fold changes and AlphaMap sequence alignment.
2943
This class allows for the visualization of different proteins by using the visualize_protein method
@@ -86,6 +100,11 @@ def visualize_protein(self, protein):
86100
class AlphaMapDfGenerator:
87101

88102
def __init__(self, condpair_node, gene2protein_mapper, organism = 'Human', colorlist = []):
103+
if not HAS_ALPHAMAP:
104+
raise ImportError(
105+
"alphamap is required for AlphaMapDfGenerator. "
106+
"Install it with: pip install \"alphaquant[alphamap]\""
107+
)
89108
self._condpair_node = condpair_node
90109
self._gene2protein_mapper = gene2protein_mapper
91110

alphaquant/plotting/fcviz.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
import alphaquant.cluster.cluster_utils as aqclustutils
44
import alphaquant.plotting.base_functions as aq_plot_base
55
import alphaquant.config.variables as aqvars
6-
import alphamap.organisms_data
76
import alphaquant.utils.utils as aq_utils
87
import alphaquant.resources.database_loader as aq_db_loader
98
import re
109

10+
try:
11+
import alphamap.organisms_data
12+
HAS_ALPHAMAP = True
13+
except ModuleNotFoundError:
14+
HAS_ALPHAMAP = False
15+
1116
def _format_tree_label_string(labelstring: str) -> str:
1217
"""Local copy of the tree label formatter to avoid circular imports.
1318
@@ -198,6 +203,11 @@ def _load_sequences(self):
198203

199204

200205
def get_pyteomics_fasta(organism = 'Human'):
206+
if not HAS_ALPHAMAP:
207+
raise ImportError(
208+
"alphamap is required for get_pyteomics_fasta. "
209+
"Install it with: pip install \"alphaquant[alphamap]\""
210+
)
201211
return alphamap.organisms_data.import_fasta(organism)
202212

203213
class CondpairQuantificationInfo():

alphaquant/ui/dashboard_parts_plots_proteoforms.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ def _on_load_alphamap_clicked(self, event):
365365
self.visualization_elements.visible = True
366366
self.viz_warning_pane.object = "" # Clear any previous warnings
367367

368+
except ImportError as import_error:
369+
print("ImportError initializing visualizers:", str(import_error))
370+
error_msg = f"AlphaMap is not installed. Install it with: pip install \"alphaquant[alphamap]\""
371+
self.viz_warning_pane.object = f"### Note\n{error_msg}"
372+
self.visualization_elements.visible = False
373+
368374
except Exception as viz_error:
369375
print("Error initializing visualizers:", str(viz_error))
370376
print("Exception type:", type(viz_error))

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ optional-dependencies = { stable = { file = ["requirements/requirements.txt",
5555
] }, development = { file = ["requirements/requirements_development.txt", "requirements/requirements_tests.txt",
5656
] }, dask = { file = [ "requirements/requirements_dask_loose.txt",
5757
] }, dask-stable = { file = [ "requirements/requirements_dask.txt",
58+
] }, alphamap = { file = [ "requirements/requirements_alphamap_loose.txt",
59+
] }, alphamap-stable = { file = [ "requirements/requirements_alphamap.txt",
5860
] }}
5961

6062
version = {attr = "alphaquant.__version__"}

0 commit comments

Comments
 (0)