Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some dependencies optional #122

Merged
merged 3 commits into from
Nov 15, 2023
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
10 changes: 6 additions & 4 deletions .conda/arm64/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ requirements:
- wheel
- setuptools
run:
- numpy>=1.17
- numpy>=1.21,<1.25
- editdistance>=0.6.0
- Biopython==1.79
- click>=8.1.3
- biopandas>=0.4.1
- boto3==1.24.59
- boto3
- p-tqdm
- networkx==2.8.8
- einops
Expand All @@ -41,8 +41,10 @@ requirements:
- awscli==1.25.60
- bs4
- rcsbsearch
- tmtools
- fair-esm
- pyyaml
- rdkit
- pypdb
- joblib

about:
home: https://github.com/adaptyvbio/ProteinFlow
Expand Down
14 changes: 8 additions & 6 deletions .conda/default/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,28 @@ requirements:
- wheel
- setuptools
run:
- numpy>=1.17
- numpy>=1.21,<1.25
- editdistance>=0.6.0
- Biopython==1.79
- click>=8.1.3
- biopandas>=0.4.1
- boto3==1.24.59
- boto3=
- p-tqdm
- networkx==2.8.8
- einops
- pandas
- pytorch>=1.10.0
- biotite==0.35.0
- aiobotocore==2.4.2
- awscli==1.25.60
- aiobotocore
- awscli
- bs4
- rcsbsearch
- tmtools
- fair-esm
- mmseqs2
- foldseek
- pyyaml
- rdkit
- pypdb
- joblib

about:
home: https://github.com/adaptyvbio/ProteinFlow
Expand Down
39 changes: 39 additions & 0 deletions channeldata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"channeldata_version": 1,
"packages": {
"proteinflow": {
"activate.d": false,
"binary_prefix": false,
"deactivate.d": false,
"description": null,
"dev_url": "https://github.com/adaptyvbio/ProteinFlow",
"doc_source_url": null,
"doc_url": "https://adaptyvbio.github.io/ProteinFlow/",
"home": "https://github.com/adaptyvbio/ProteinFlow",
"icon_hash": null,
"icon_url": null,
"identifiers": null,
"keywords": null,
"license": "BSD-3-Clause",
"post_link": false,
"pre_link": false,
"pre_unlink": false,
"recipe_origin": null,
"run_exports": {},
"source_git_url": "https://github.com/adaptyvbio/ProteinFlow.git",
"source_url": null,
"subdirs": [
"linux-64"
],
"summary": "Versatile pipeline for processing protein structure data for deep learning applications.",
"tags": null,
"text_prefix": true,
"timestamp": 1700064405,
"version": "2.4.1"
}
},
"subdirs": [
"linux-64",
"noarch"
]
}
90 changes: 90 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<html>
<head>
<title>proteinflow</title>
<style type="text/css">
a, a:active {
text-decoration: none; color: blue;
}
a:visited {
color: #48468F;
}
a:hover, a:focus {
text-decoration: underline; color: red;
}
body {
background-color: #F5F5F5;
}
h2 {
margin-bottom: 12px;
}
th, td {
font: 100% monospace; text-align: left;
}
th {
font-weight: bold; padding-right: 14px; padding-bottom: 3px;
}
th.tight {
padding-right: 6px;
}
td {
padding-right: 14px;
}
td.tight {
padding-right: 8px;
}
td.s, th.s {
text-align: right;
}
td.summary {
white-space: nowrap;
overflow: hidden;
}
td.packagename {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
max-width: 180px;
padding-right: 8px;
}
td.version {
//white-space: nowrap;
overflow: hidden;
max-width: 90px;
padding-right: 8px;
}
table {
background-color: white;
border-top: 1px solid #646464;
border-bottom: 1px solid #646464;
padding-top: 10px;
padding-bottom: 14px;
}
address {
color: #787878;
padding-top: 10px;
}
</style>
</head>
<body>
<h2>proteinflow</h2>
<h3><a href="rss.xml">RSS Feed</a>&nbsp;&nbsp;&nbsp;<a href="channeldata.json">channeldata.json</a></h3>
<a href="linux-64">linux-64</a>&nbsp;&nbsp;&nbsp;<a href="noarch">noarch</a>&nbsp;&nbsp;&nbsp; <table>
<tr>
<th style="padding-right:18px;">Package</th>
<th>Latest Version</th>
<th>Doc</th>
<th>Dev</th>
<th>License</th>
<th class="tight">linux-64</th><th class="tight">noarch</th> <th>Summary</th>
</tr>
<tr>
<td class="packagename"><a href="https://github.com/adaptyvbio/ProteinFlow" alt="proteinflow">proteinflow</a></td>
<td class="version">2.4.1</td>
<td><a href="https://adaptyvbio.github.io/ProteinFlow/">doc</a></td>
<td><a href="https://github.com/adaptyvbio/ProteinFlow">dev</a></td>
<td class="tight">BSD-3-Clause</td>
<td>X</td><td></td> <td class="summary">Versatile pipeline for processing protein structure data for deep...</td>
</tr> </table>
<address>Updated: 2023-11-15 16:08:06 +0000 - Files: 1</address>
</body>
</html>
4 changes: 1 addition & 3 deletions install_optional.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ python -m pip install "fair-esm[esmfold]"
python -m pip install 'dllogger @ git+https://github.com/NVIDIA/dllogger.git'
python -m pip install 'openfold @ git+https://github.com/aqlaboratory/openfold.git@4b41059694619831a7db195b7e0988fc4ff3a307'

python -m pip install ablang igfold immunebuilder

python -m pip install -e .
python -m pip install ipykernel
# python -m pip install ipykernel
1 change: 1 addition & 0 deletions proteinflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
"split": False,
"cli": False,
"ligand": False,
"extra": False,
}
__docformat__ = "numpy"

Expand Down
25 changes: 20 additions & 5 deletions proteinflow/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,31 @@
from collections import defaultdict

import Bio.PDB
import MDAnalysis as mda
import numpy as np
import pandas as pd
import py3Dmol
from Bio import pairwise2
from biopandas.pdb import PandasPdb
from methodtools import lru_cache
from torch import Tensor, from_numpy

try:
import MDAnalysis as mda
except ImportError:
pass
try:
from methodtools import lru_cache
except ImportError:

def lru_cache():
"""Make a dummy decorator."""

def wrapper(func):
return func

return wrapper


from proteinflow.constants import (
_PMAP,
ACCENT_COLOR,
ALPHABET,
ALPHABET_REVERSE,
ATOM_MASKS,
Expand All @@ -52,6 +65,7 @@
_retrieve_chain_names,
)
from proteinflow.download import download_fasta, download_pdb
from proteinflow.extra import _get_view, requires_extra
from proteinflow.ligand import _get_ligands
from proteinflow.metrics import (
ablang_pll,
Expand Down Expand Up @@ -1979,6 +1993,7 @@ def align_structure(self, reference_pdb_path, save_pdb_path, chain_ids=None):
io.save(save_pdb_path)

@staticmethod
@requires_extra("MDAnalysis")
def combine_multiple_frames(files, output_path="combined.pdb"):
"""Combine multiple PDB files into a single multiframe PDB file.

Expand Down Expand Up @@ -2570,7 +2585,7 @@ def visualize(
accent_color=accent_color,
)
vis_string = "".join([str(x) for x in outstr])
view = py3Dmol.view(width=canvas_size[0], height=canvas_size[1])
view = _get_view(canvas_size)
view.addModelsAsFrames(vis_string)
for i, at in enumerate(outstr):
view.setStyle(
Expand Down
41 changes: 41 additions & 0 deletions proteinflow/extra.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Handling optional dependencies."""

try:
import py3Dmol
except ImportError:
pass

import sys


def requires_extra(module_name, install_name=None):
"""Generate a decorator to require an optional dependency for the given function.

Parameters
----------
module_name : str
Name of the module to check for
install_name : str, optional
Name of the module to install if it is not found. If not specified, `module_name` is used

"""
if install_name is None:
install_name = module_name

def decorator(func):
def wrapper(*args, **kwargs):
if module_name not in sys.modules:
raise ImportError(
f"{install_name} must be installed to use this function. "
f"Install it with `pip install {install_name}` or together with most other optional dependencies with `pip install proteinflow[processing]`."
)
return func(*args, **kwargs)

return wrapper

return decorator


@requires_extra("py3Dmol")
def _get_view(canvas_size):
return py3Dmol.view(width=canvas_size[0], height=canvas_size[1])
Loading
Loading