Skip to content

Commit beac4eb

Browse files
authored
Merge pull request #84 from MannLabs/decouple_from_structuremap
decouple code from structuremap
2 parents 63fdc69 + 1a3fe7b commit beac4eb

15 files changed

+50
-25
lines changed

.devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"extensions": ["ms-python.python",
1010
"ms-azuretools.vscode-docker"],
1111
"runServices": ["notebook", "jekyll", "watcher"],
12-
"postStartCommand": "pip install -e ."
12+
"postStartCommand": "pip install -e '.[structuremap]'"
1313
}

.github/workflows/publish_and_release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ jobs:
181181
run: |
182182
conda create -n alphamap_pip_test python=3.8 -y
183183
conda activate alphamap_pip_test
184-
pip install "alphamap[stable]"
184+
pip install "alphamap[stable,structuremap-stable]"
185185
echo "TODO, this will run forever.."
186-
#alphamap
186+
python -c "import alphamap; print('OK')"
187+
#alphamap # TODO: this will run forever..
187188
conda deactivate

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,22 @@ The GUI of AlphaMap is a completely stand-alone tool that requires no knowledge
3838
AlphaMap can be installed in an existing Python 3.8 environment with a single `bash` command. *This `bash` command can also be run directly from within a Jupyter notebook by prepending it with a `!`*.
3939

4040
```bash
41-
pip install alphamap[stable]
41+
pip install alphamap[stable,structuremap-stable]
4242
```
4343
The [stable] tag ensures you get the latest stable release with fixed dependencies. However, it can be omitted if you prefer more flexible dependency versions:
4444

4545
```bash
46-
pip install alphamap
46+
pip install alphamap[structuremap]
4747
```
4848

4949
When a new version of AlphaMap becomes available, the old version can easily be upgraded by running e.g. the command again with an additional `--upgrade` flag:
5050

5151
```bash
52-
pip install --upgrade alphamap[stable]
52+
pip install --upgrade alphamap[stable,structuremap-stable]
5353
```
5454

55-
NOTE: When installing with `pip`, UniProt information is not included. Upon first usage of a specific Organism, its information will be automatically downloaded from UniProt.
55+
Note: The `structuremap` extra can be omitted if use of `plot_3d_structuremap()` is not desired.
56+
Note: When installing with `pip`, UniProt information is not included. Upon first usage of a specific Organism, its information will be automatically downloaded from UniProt.
5657

5758

5859
### Developer
@@ -76,7 +77,7 @@ For any Python package, it is highly recommended to use a [conda virtual environ
7677
```bash
7778
conda create -n alphamap python=3.8 -y
7879
conda activate alphamap
79-
pip install -e ".[stable]"
80+
pip install -e ".[stable,structuremap-stable]"
8081
```
8182

8283
* By using the editable flag `-e`, all modifications to the AlphaMap [source code folder](alphamap) are directly reflected when running AlphaMap. Note that the AlphaMap folder cannot be moved and/or renamed if an editable version is installed.

alphamap/sequenceplot.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,13 @@ def plot_single_peptide_traces(df_plot,protein,fasta):
398398
'U':'nan'}
399399

400400
# Cell
401-
from structuremap.processing import download_alphafold_cif, download_alphafold_pae, format_alphafold_data, annotate_accessibility, get_smooth_score
401+
try:
402+
from structuremap.processing import download_alphafold_cif, download_alphafold_pae, format_alphafold_data, annotate_accessibility, get_smooth_score
403+
HAS_STRUCTUREMAP = True
404+
except ModuleNotFoundError:
405+
HAS_STRUCTUREMAP = False
406+
print("WARNING: dependency 'structuremap' is not installed.")
407+
402408

403409
# Cell
404410
def get_quality_category(s):
@@ -429,6 +435,9 @@ def get_alphafold_annotation(protein: str,
429435
selected_features: list,
430436
download_folder: str = tempfile.gettempdir()) -> pd.DataFrame:
431437

438+
if not HAS_STRUCTUREMAP:
439+
raise ValueError("Please install alphamap with the 'structuremap' extra to use get_alphafold_annotation().")
440+
432441
alphafold_feature_dict = dict({'AlphaFold confidence':'quality',
433442
'AlphaFold exposure':'nAA_12_70_pae',
434443
'AlphaFold IDR':'AlphaFold IDR',
@@ -728,10 +737,12 @@ def plot_peptide_traces(df: pd.DataFrame or list,
728737

729738
y_max = y_max + (len(selected_proteases)/2)
730739

731-
732-
alphafold_annotation = get_alphafold_annotation(protein = protein,
733-
selected_features = selected_alphafold_features,
734-
download_folder = download_folder)
740+
if len(selected_alphafold_features) > 0:
741+
alphafold_annotation = get_alphafold_annotation(protein = protein,
742+
selected_features = selected_alphafold_features,
743+
download_folder = download_folder)
744+
else:
745+
alphafold_annotation = pd.DataFrame()
735746

736747
if alphafold_annotation.empty:
737748
#print('no alphafold')
@@ -1356,4 +1367,4 @@ def create_pdf_report(proteins: list,
13561367
#with open("file.pdf", "wb") as file:
13571368
# file.write(pdf_buf.getvalue())
13581369

1359-
return pdf_buf
1370+
return pdf_buf

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515

1616
notebook:
1717
<<: *fastai
18-
command: bash -c "pip install -e . && jupyter notebook --allow-root --no-browser --ip=0.0.0.0 --port=8080 --NotebookApp.token='' --NotebookApp.password=''"
18+
command: bash -c "pip install -e '.[structuremap]' && jupyter notebook --allow-root --no-browser --ip=0.0.0.0 --port=8080 --NotebookApp.token='' --NotebookApp.password=''"
1919
ports:
2020
- "8080:8080"
2121

@@ -30,7 +30,7 @@ services:
3030
- "4000:4000"
3131
command: >
3232
bash -c "cp -r docs_src docs
33-
&& pip install .
33+
&& pip install ".[structuremap]"
3434
&& nbdev_build_docs && cd docs
3535
&& bundle i
3636
&& chmod -R u+rwx . && bundle exec jekyll serve --host 0.0.0.0"

misc/one_click_macos/create_installer_macos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ rm -rf dist
1212
rm -rf build
1313
pip install build
1414
python -m build
15-
pip install "dist/alphamap-0.1.13-py3-none-any.whl[stable]"
15+
pip install "dist/alphamap-0.1.13-py3-none-any.whl[stable,structuremap-stable]"
1616

1717
conda list
1818

misc/one_click_windows/create_installer_windows.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ call rmdir dist /s /q
1515
call rmdir build /s /q
1616
call python setup.py sdist bdist_wheel
1717
call cd misc/one_click_windows
18-
call pip install "../../dist/alphamap-0.1.13-py3-none-any.whl"
18+
call pip install "../../dist/alphamap-0.1.13-py3-none-any.whl[stable,structuremap-stable]"
1919
call pip install pyinstaller==4.2
2020
call pyinstaller ../pyinstaller/alphamap.spec -y
2121
call conda deactivate

misc/one_click_windows/create_installer_windows.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ rm -rf build
88
pip install build
99
python -m build
1010
cd misc/one_click_windows
11-
pip install "../../dist/alphamap-0.1.13-py3-none-any.whl[stable]"
11+
pip install "../../dist/alphamap-0.1.13-py3-none-any.whl[stable,structuremap-stable]"
1212
pip install pyinstaller==5.6.2
1313
# TODO https://stackoverflow.com/questions/54175042/python-3-7-anaconda-environment-import-ssl-dll-load-fail-error/60405693#60405693
1414
pyinstaller ../pyinstaller/alphamap.spec -y

nbs/SequencePlot.ipynb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,12 @@
578578
"outputs": [],
579579
"source": [
580580
"#export\n",
581-
"from structuremap.processing import download_alphafold_cif, download_alphafold_pae, format_alphafold_data, annotate_accessibility, get_smooth_score"
581+
"try:\n",
582+
" from structuremap.processing import download_alphafold_cif, download_alphafold_pae, format_alphafold_data, annotate_accessibility, get_smooth_score\n",
583+
" HAS_STRUCTUREMAP = True\n",
584+
"except ModuleNotFoundError:\n",
585+
" HAS_STRUCTUREMAP = False\n",
586+
" print(\"WARNING: dependency 'structuremap' is not installed.\")"
582587
]
583588
},
584589
{
@@ -630,6 +635,9 @@
630635
" selected_features: list, \n",
631636
" download_folder: str = tempfile.gettempdir()) -> pd.DataFrame:\n",
632637
" \n",
638+
" if not HAS_STRUCTUREMAP:\n",
639+
" raise ValueError(\"Please install alphamap with the 'structuremap' extra to use get_alphafold_annotation().\")\n",
640+
"\n",
633641
" alphafold_feature_dict = dict({'AlphaFold confidence':'quality', \n",
634642
" 'AlphaFold exposure':'nAA_12_70_pae', \n",
635643
" 'AlphaFold IDR':'AlphaFold IDR',\n",

nbs/index.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"```bash\n",
103103
"conda create -n alphamap python=3.8 -y\n",
104104
"conda activate alphamap\n",
105-
"pip install -e .\n",
105+
"pip install -e \".[stable,structuremap-stable]\"\n",
106106
"```\n",
107107
"\n",
108108
"* By using the editable flag `-e`, all modifications to the AlphaMap [source code folder](alphamap) are directly reflected when running AlphaMap. Note that the AlphaMap folder cannot be moved and/or renamed if an editable version is installed.\n",

0 commit comments

Comments
 (0)