|
| 1 | +import warnings |
| 2 | + |
1 | 3 | import numpy as np |
2 | 4 | import pandas as pd |
3 | 5 | import anytree |
4 | 6 | import alphaquant.utils.utils as aqutils |
5 | 7 | 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 |
12 | 8 | import alphaquant.plotting.fcviz as aq_plot_fc |
13 | 9 | import alphaquant.plotting.colors as aq_plot_colors |
14 | 10 |
|
|
17 | 13 | aqconfig.setup_logging() |
18 | 14 | LOGGER = logging.getLogger(__name__) |
19 | 15 |
|
| 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 | + |
20 | 28 |
|
21 | 29 | class AlphaMapVisualizer: |
22 | 30 | def __init__(self, condition1, condition2, results_directory, samplemap_file, |
23 | 31 | order_along_protein_sequence = True, organism = 'Human',colorlist = aq_plot_colors.AlphaQuantColorMap().colorlist, tree_level = 'seq', |
24 | 32 | protein_identifier = 'gene_symbol', label_rotation = 90, add_stripplot = False, |
25 | 33 | 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 | + |
27 | 41 | """ |
28 | 42 | Initializes an object for visualizing peptide fold changes and AlphaMap sequence alignment. |
29 | 43 | This class allows for the visualization of different proteins by using the visualize_protein method |
@@ -86,6 +100,11 @@ def visualize_protein(self, protein): |
86 | 100 | class AlphaMapDfGenerator: |
87 | 101 |
|
88 | 102 | 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 | + ) |
89 | 108 | self._condpair_node = condpair_node |
90 | 109 | self._gene2protein_mapper = gene2protein_mapper |
91 | 110 |
|
|
0 commit comments