Skip to content

Commit

Permalink
Merge pull request #84 from MannLabs/decouple_from_structuremap
Browse files Browse the repository at this point in the history
decouple code from structuremap
  • Loading branch information
mschwoer authored Feb 18, 2025
2 parents 63fdc69 + 1a3fe7b commit beac4eb
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"extensions": ["ms-python.python",
"ms-azuretools.vscode-docker"],
"runServices": ["notebook", "jekyll", "watcher"],
"postStartCommand": "pip install -e ."
"postStartCommand": "pip install -e '.[structuremap]'"
}
5 changes: 3 additions & 2 deletions .github/workflows/publish_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ jobs:
run: |
conda create -n alphamap_pip_test python=3.8 -y
conda activate alphamap_pip_test
pip install "alphamap[stable]"
pip install "alphamap[stable,structuremap-stable]"
echo "TODO, this will run forever.."
#alphamap
python -c "import alphamap; print('OK')"
#alphamap # TODO: this will run forever..
conda deactivate
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,22 @@ The GUI of AlphaMap is a completely stand-alone tool that requires no knowledge
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 `!`*.

```bash
pip install alphamap[stable]
pip install alphamap[stable,structuremap-stable]
```
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:

```bash
pip install alphamap
pip install alphamap[structuremap]
```

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:

```bash
pip install --upgrade alphamap[stable]
pip install --upgrade alphamap[stable,structuremap-stable]
```

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.
Note: The `structuremap` extra can be omitted if use of `plot_3d_structuremap()` is not desired.
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.


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

* 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.
Expand Down
23 changes: 17 additions & 6 deletions alphamap/sequenceplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,13 @@ def plot_single_peptide_traces(df_plot,protein,fasta):
'U':'nan'}

# Cell
from structuremap.processing import download_alphafold_cif, download_alphafold_pae, format_alphafold_data, annotate_accessibility, get_smooth_score
try:
from structuremap.processing import download_alphafold_cif, download_alphafold_pae, format_alphafold_data, annotate_accessibility, get_smooth_score
HAS_STRUCTUREMAP = True
except ModuleNotFoundError:
HAS_STRUCTUREMAP = False
print("WARNING: dependency 'structuremap' is not installed.")


# Cell
def get_quality_category(s):
Expand Down Expand Up @@ -429,6 +435,9 @@ def get_alphafold_annotation(protein: str,
selected_features: list,
download_folder: str = tempfile.gettempdir()) -> pd.DataFrame:

if not HAS_STRUCTUREMAP:
raise ValueError("Please install alphamap with the 'structuremap' extra to use get_alphafold_annotation().")

alphafold_feature_dict = dict({'AlphaFold confidence':'quality',
'AlphaFold exposure':'nAA_12_70_pae',
'AlphaFold IDR':'AlphaFold IDR',
Expand Down Expand Up @@ -728,10 +737,12 @@ def plot_peptide_traces(df: pd.DataFrame or list,

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


alphafold_annotation = get_alphafold_annotation(protein = protein,
selected_features = selected_alphafold_features,
download_folder = download_folder)
if len(selected_alphafold_features) > 0:
alphafold_annotation = get_alphafold_annotation(protein = protein,
selected_features = selected_alphafold_features,
download_folder = download_folder)
else:
alphafold_annotation = pd.DataFrame()

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

return pdf_buf
return pdf_buf
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:

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

Expand All @@ -30,7 +30,7 @@ services:
- "4000:4000"
command: >
bash -c "cp -r docs_src docs
&& pip install .
&& pip install ".[structuremap]"
&& nbdev_build_docs && cd docs
&& bundle i
&& chmod -R u+rwx . && bundle exec jekyll serve --host 0.0.0.0"
2 changes: 1 addition & 1 deletion misc/one_click_macos/create_installer_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rm -rf dist
rm -rf build
pip install build
python -m build
pip install "dist/alphamap-0.1.13-py3-none-any.whl[stable]"
pip install "dist/alphamap-0.1.13-py3-none-any.whl[stable,structuremap-stable]"

conda list

Expand Down
2 changes: 1 addition & 1 deletion misc/one_click_windows/create_installer_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ call rmdir dist /s /q
call rmdir build /s /q
call python setup.py sdist bdist_wheel
call cd misc/one_click_windows
call pip install "../../dist/alphamap-0.1.13-py3-none-any.whl"
call pip install "../../dist/alphamap-0.1.13-py3-none-any.whl[stable,structuremap-stable]"
call pip install pyinstaller==4.2
call pyinstaller ../pyinstaller/alphamap.spec -y
call conda deactivate
Expand Down
2 changes: 1 addition & 1 deletion misc/one_click_windows/create_installer_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rm -rf build
pip install build
python -m build
cd misc/one_click_windows
pip install "../../dist/alphamap-0.1.13-py3-none-any.whl[stable]"
pip install "../../dist/alphamap-0.1.13-py3-none-any.whl[stable,structuremap-stable]"
pip install pyinstaller==5.6.2
# TODO https://stackoverflow.com/questions/54175042/python-3-7-anaconda-environment-import-ssl-dll-load-fail-error/60405693#60405693
pyinstaller ../pyinstaller/alphamap.spec -y
Expand Down
10 changes: 9 additions & 1 deletion nbs/SequencePlot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,12 @@
"outputs": [],
"source": [
"#export\n",
"from structuremap.processing import download_alphafold_cif, download_alphafold_pae, format_alphafold_data, annotate_accessibility, get_smooth_score"
"try:\n",
" from structuremap.processing import download_alphafold_cif, download_alphafold_pae, format_alphafold_data, annotate_accessibility, get_smooth_score\n",
" HAS_STRUCTUREMAP = True\n",
"except ModuleNotFoundError:\n",
" HAS_STRUCTUREMAP = False\n",
" print(\"WARNING: dependency 'structuremap' is not installed.\")"
]
},
{
Expand Down Expand Up @@ -630,6 +635,9 @@
" selected_features: list, \n",
" download_folder: str = tempfile.gettempdir()) -> pd.DataFrame:\n",
" \n",
" if not HAS_STRUCTUREMAP:\n",
" raise ValueError(\"Please install alphamap with the 'structuremap' extra to use get_alphafold_annotation().\")\n",
"\n",
" alphafold_feature_dict = dict({'AlphaFold confidence':'quality', \n",
" 'AlphaFold exposure':'nAA_12_70_pae', \n",
" 'AlphaFold IDR':'AlphaFold IDR',\n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"```bash\n",
"conda create -n alphamap python=3.8 -y\n",
"conda activate alphamap\n",
"pip install -e .\n",
"pip install -e \".[stable,structuremap-stable]\"\n",
"```\n",
"\n",
"* 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",
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ find = {}

[tool.setuptools.dynamic]
# https://stackoverflow.com/a/73600610
dependencies = {file = ["requirements_loose.txt"]}
optional-dependencies = { stable = { file = ["requirements_stable.txt"] }}
dependencies = {file = ["requirements/requirements_loose.txt"]}

optional-dependencies.stable = { file = ["requirements/requirements.txt"] }
optional-dependencies.structuremap = { file = ["requirements/requirements_structuremap_loose.txt"] }
optional-dependencies.structuremap-stable = { file = ["requirements/requirements_structuremap.txt"] }

version = {attr = "alphamap.__version__"}

[project.scripts]
Expand Down
1 change: 0 additions & 1 deletion requirements_stable.txt → requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ psutil==5.8.0
reportlab==3.5.59
kaleido==0.2.1
bokeh==2.2.2
structuremap==0.0.8
h5py==3.7.0
jinja2==2.11.3
markupsafe==2.0.1
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ psutil
reportlab
kaleido
bokeh
structuremap
h5py
1 change: 1 addition & 0 deletions requirements/requirements_structuremap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
structuremap==0.0.8
1 change: 1 addition & 0 deletions requirements/requirements_structuremap_loose.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
structuremap

0 comments on commit beac4eb

Please sign in to comment.