1+ import warnings
2+
13import numpy as np
24import pandas as pd
35import anytree
46import alphaquant .utils .utils as aqutils
57import 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
128import alphaquant .plotting .fcviz as aq_plot_fc
139import alphaquant .plotting .colors as aq_plot_colors
1410
1713aqconfig .setup_logging ()
1814LOGGER = 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
2129class 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):
8698class 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
0 commit comments