Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e_tests_quick_multiple_platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
install-script: ./pip_install.sh stable,tests,gui,dask-stable
install-script: ./pip_install.sh stable,tests,gui-stable,dask-stable
test-script: ./run_e2e_tests_quick.sh

run-unit-tests-loose:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
install-script: ./pip_install.sh stable,tests,gui,dask-stable
install-script: ./pip_install.sh stable,tests,gui-stable,dask-stable
test-script: ./run_unit_tests.sh

run-unit-tests-loose:
Expand Down
33 changes: 25 additions & 8 deletions alphaquant/plotting/alphamapviz.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import warnings

import numpy as np
import pandas as pd
import anytree
import alphaquant.utils.utils as aqutils
import alphaquant.resources.database_loader as aq_db_loader


import alphamap.preprocessing
import alphamap.organisms_data
import alphamap.sequenceplot
import alphamap.uniprot_integration
import alphaquant.plotting.fcviz as aq_plot_fc
import alphaquant.plotting.colors as aq_plot_colors

Expand All @@ -17,13 +13,24 @@
aqconfig.setup_logging()
LOGGER = logging.getLogger(__name__)

try:
import alphamap.preprocessing
import alphamap.organisms_data
import alphamap.sequenceplot
import alphamap.uniprot_integration
HAS_ALPHAMAP = True
except ModuleNotFoundError:
warnings.warn(
"Dependency 'alphamap' not installed. If you want to use its functionality, install it with `pip install \"alphaquant[alphamap]\"` ."
)
HAS_ALPHAMAP = False


class AlphaMapVisualizer:
def __init__(self, condition1, condition2, results_directory, samplemap_file,
order_along_protein_sequence = True, organism = 'Human',colorlist = aq_plot_colors.AlphaQuantColorMap().colorlist, tree_level = 'seq',
protein_identifier = 'gene_symbol', label_rotation = 90, add_stripplot = False,
narrowing_factor_for_fcplot = 1/14, rescale_factor_x = 1.0, rescale_factor_y = 2):

"""
Initializes an object for visualizing peptide fold changes and AlphaMap sequence alignment.
This class allows for the visualization of different proteins by using the visualize_protein method
Expand All @@ -47,7 +54,12 @@ def __init__(self, condition1, condition2, results_directory, samplemap_file,
identifier (str): Identifier for proteins. Can be 'gene_symbol' or 'uniprot_id'.

"""

if not HAS_ALPHAMAP:
raise ImportError(
"alphamap is required for AlphaMapVisualizer. "
"Install it with: pip install \"alphaquant[alphamap]\""
)

self._fc_visualizer = aq_plot_fc.FoldChangeVisualizer(condition1, condition2, results_directory, samplemap_file,
order_along_protein_sequence = order_along_protein_sequence, organism = organism, colorlist = colorlist,
tree_level = tree_level, protein_identifier = protein_identifier, label_rotation = label_rotation,
Expand Down Expand Up @@ -86,6 +98,11 @@ def visualize_protein(self, protein):
class AlphaMapDfGenerator:

def __init__(self, condpair_node, gene2protein_mapper, organism = 'Human', colorlist = []):
if not HAS_ALPHAMAP:
raise ImportError(
"alphamap is required for AlphaMapDfGenerator. "
"Install it with: pip install \"alphaquant[alphamap]\""
)
self._condpair_node = condpair_node
self._gene2protein_mapper = gene2protein_mapper

Expand Down
12 changes: 11 additions & 1 deletion alphaquant/plotting/fcviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
import alphaquant.cluster.cluster_utils as aqclustutils
import alphaquant.plotting.base_functions as aq_plot_base
import alphaquant.config.variables as aqvars
import alphamap.organisms_data
import alphaquant.utils.utils as aq_utils
import alphaquant.resources.database_loader as aq_db_loader
import re

try:
import alphamap.organisms_data
HAS_ALPHAMAP = True
except ModuleNotFoundError:
HAS_ALPHAMAP = False

def _format_tree_label_string(labelstring: str) -> str:
"""Local copy of the tree label formatter to avoid circular imports.

Expand Down Expand Up @@ -198,6 +203,11 @@ def _load_sequences(self):


def get_pyteomics_fasta(organism = 'Human'):
if not HAS_ALPHAMAP:
raise ImportError(
"alphamap is required for get_pyteomics_fasta. "
"Install it with: pip install \"alphaquant[alphamap]\""
)
return alphamap.organisms_data.import_fasta(organism)
Comment on lines +206 to 211
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation level suggests this is inside a function body, but Python typically uses 4 spaces per level. This line appears to be indented with 8 spaces when it should likely be 4 spaces to align with the function definition at line 205.

Suggested change
if not HAS_ALPHAMAP:
raise ImportError(
"alphamap is required for get_pyteomics_fasta. "
"Install it with: pip install \"alphaquant[alphamap]\""
)
return alphamap.organisms_data.import_fasta(organism)
if not HAS_ALPHAMAP:
raise ImportError(
"alphamap is required for get_pyteomics_fasta. "
"Install it with: pip install \"alphaquant[alphamap]\""
)
return alphamap.organisms_data.import_fasta(organism)

Copilot uses AI. Check for mistakes.

class CondpairQuantificationInfo():
Expand Down
6 changes: 6 additions & 0 deletions alphaquant/ui/dashboard_parts_plots_proteoforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ def _on_load_alphamap_clicked(self, event):
self.visualization_elements.visible = True
self.viz_warning_pane.object = "" # Clear any previous warnings

except ImportError as import_error:
print("ImportError initializing visualizers:", str(import_error))
error_msg = f"AlphaMap is not installed. Install it with: pip install \"alphaquant[alphamap]\""
self.viz_warning_pane.object = f"### Note\n{error_msg}"
self.visualization_elements.visible = False

except Exception as viz_error:
print("Error initializing visualizers:", str(viz_error))
print("Exception type:", type(viz_error))
Expand Down
1 change: 0 additions & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ lmfit==1.3.2
multiprocess==0.70.17
openpyxl==3.1.5
scikit-learn==1.6.1
alphamap==0.2.0
alphabase==1.6.0
pyarrow==19.0.0
1 change: 1 addition & 0 deletions requirements/requirements_gui.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
plotly==5.24.1
bokeh==3.6.2
panel==1.6.0
alphamap==0.2.0
1 change: 1 addition & 0 deletions requirements/requirements_gui_loose.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
plotly
bokeh
panel
alphamap
1 change: 0 additions & 1 deletion requirements/requirements_loose.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ multiprocess
openpyxl
scikit-learn
alphabase
alphamap
pyarrow
Loading