Skip to content

Commit 90917e3

Browse files
authored
Merge pull request #121 from MannLabs/make-alphamap-optional
make alphamap optional and update installation instructions
2 parents c4e3c9b + acc9573 commit 90917e3

9 files changed

Lines changed: 46 additions & 13 deletions

.github/workflows/e2e_tests_quick_multiple_platforms.yml

Lines changed: 1 addition & 1 deletion
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-stable,dask-stable
3333
test-script: ./run_e2e_tests_quick.sh
3434

3535
run-unit-tests-loose:

.github/workflows/install_and_unit_tests_multiple_platforms.yml

Lines changed: 1 addition & 1 deletion
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-stable,dask-stable
3030
test-script: ./run_unit_tests.sh
3131

3232
run-unit-tests-loose:

alphaquant/plotting/alphamapviz.py

Lines changed: 25 additions & 8 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,24 @@
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 it with `pip install \"alphaquant[alphamap]\"` ."
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-
2734
"""
2835
Initializes an object for visualizing peptide fold changes and AlphaMap sequence alignment.
2936
This class allows for the visualization of different proteins by using the visualize_protein method
@@ -47,7 +54,12 @@ def __init__(self, condition1, condition2, results_directory, samplemap_file,
4754
identifier (str): Identifier for proteins. Can be 'gene_symbol' or 'uniprot_id'.
4855
4956
"""
50-
57+
if not HAS_ALPHAMAP:
58+
raise ImportError(
59+
"alphamap is required for AlphaMapVisualizer. "
60+
"Install it with: pip install \"alphaquant[alphamap]\""
61+
)
62+
5163
self._fc_visualizer = aq_plot_fc.FoldChangeVisualizer(condition1, condition2, results_directory, samplemap_file,
5264
order_along_protein_sequence = order_along_protein_sequence, organism = organism, colorlist = colorlist,
5365
tree_level = tree_level, protein_identifier = protein_identifier, label_rotation = label_rotation,
@@ -86,6 +98,11 @@ def visualize_protein(self, protein):
8698
class AlphaMapDfGenerator:
8799

88100
def __init__(self, condpair_node, gene2protein_mapper, organism = 'Human', colorlist = []):
101+
if not HAS_ALPHAMAP:
102+
raise ImportError(
103+
"alphamap is required for AlphaMapDfGenerator. "
104+
"Install it with: pip install \"alphaquant[alphamap]\""
105+
)
89106
self._condpair_node = condpair_node
90107
self._gene2protein_mapper = gene2protein_mapper
91108

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))

requirements/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ lmfit==1.3.2
1212
multiprocess==0.70.17
1313
openpyxl==3.1.5
1414
scikit-learn==1.6.1
15-
alphamap==0.2.0
1615
alphabase==1.6.0
1716
pyarrow==19.0.0

requirements/requirements_gui.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
plotly==5.24.1
22
bokeh==3.6.2
33
panel==1.6.0
4+
alphamap==0.2.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
plotly
22
bokeh
33
panel
4+
alphamap

requirements/requirements_loose.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ multiprocess
1313
openpyxl
1414
scikit-learn
1515
alphabase
16-
alphamap
1716
pyarrow

0 commit comments

Comments
 (0)