alphafold3-pytorch 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ TYPECHECK=True
@@ -0,0 +1,36 @@
1
+ # This workflow will upload a Python Package using Twine when a release is created
2
+ # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ release:
13
+ types: [published]
14
+
15
+ jobs:
16
+ deploy:
17
+
18
+ runs-on: ubuntu-latest
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v2
24
+ with:
25
+ python-version: '3.x'
26
+ - name: Install dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ pip install build
30
+ - name: Build package
31
+ run: python -m build
32
+ - name: Publish package
33
+ uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
34
+ with:
35
+ user: __token__
36
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,21 @@
1
+ name: Pytest
2
+ on: push
3
+
4
+ jobs:
5
+ build:
6
+
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v4
11
+ - name: Set up Python 3.10
12
+ uses: actions/setup-python@v5
13
+ with:
14
+ python-version: "3.10"
15
+ - name: Install dependencies
16
+ run: |
17
+ python -m pip install --upgrade pip
18
+ python -m pip install -e .[test]
19
+ - name: Test with pytest
20
+ run: |
21
+ python -m pytest tests/
@@ -0,0 +1,162 @@
1
+ .env
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # poetry
100
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104
+ #poetry.lock
105
+
106
+ # pdm
107
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108
+ #pdm.lock
109
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110
+ # in version control.
111
+ # https://pdm.fming.dev/#use-with-ide
112
+ .pdm.toml
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Phil Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,133 @@
1
+ Metadata-Version: 2.3
2
+ Name: alphafold3-pytorch
3
+ Version: 0.0.1
4
+ Summary: Alphafold 3 - Pytorch
5
+ Project-URL: Homepage, https://pypi.org/project/alphafold3-pytorch/
6
+ Project-URL: Repository, https://github.com/lucidrains/alphafold3-pytorch
7
+ Author-email: Phil Wang <lucidrains@gmail.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2024 Phil Wang
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Keywords: artificial intelligence,deep learning,protein structure prediction
31
+ Classifier: Development Status :: 4 - Beta
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Python :: 3.8
35
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
36
+ Requires-Python: >=3.8
37
+ Requires-Dist: beartype
38
+ Requires-Dist: einops>=0.8.0
39
+ Requires-Dist: einx>=0.2.2
40
+ Requires-Dist: environs
41
+ Requires-Dist: jaxtyping>=0.2.28
42
+ Requires-Dist: torch>=2.1
43
+ Requires-Dist: tqdm
44
+ Provides-Extra: examples
45
+ Provides-Extra: test
46
+ Requires-Dist: pytest; extra == 'test'
47
+ Description-Content-Type: text/markdown
48
+
49
+ <img src="./alphafold3.png" width="450px"></img>
50
+
51
+ ## Alphafold 3 - Pytorch (wip)
52
+
53
+ Implementation of <a href="https://www.nature.com/articles/s41586-024-07487-w">Alphafold 3</a> in Pytorch
54
+
55
+ Getting a fair number of emails. You can chat with me about this work <a href="https://discord.gg/x6FuzQPQXY">here</a>
56
+
57
+ ## Install
58
+
59
+ ```bash
60
+ $ pip install alphafold3-pytorch
61
+ ```
62
+
63
+ ## Usage
64
+
65
+ ```python
66
+ import torch
67
+ from alphafold3_pytorch import Alphafold3
68
+
69
+ alphafold3 = Alphafold3(
70
+ dim_atom_inputs = 77,
71
+ dim_additional_residue_feats = 33,
72
+ dim_template_feats = 44
73
+ )
74
+
75
+ # mock inputs
76
+
77
+ seq_len = 16
78
+ atom_seq_len = seq_len * 27
79
+
80
+ atom_inputs = torch.randn(2, atom_seq_len, 77)
81
+ atom_mask = torch.ones((2, atom_seq_len)).bool()
82
+ atompair_feats = torch.randn(2, atom_seq_len, atom_seq_len, 16)
83
+ additional_residue_feats = torch.randn(2, seq_len, 33)
84
+
85
+ template_feats = torch.randn(2, 2, seq_len, seq_len, 44)
86
+ template_mask = torch.ones((2, 2)).bool()
87
+
88
+ msa = torch.randn(2, 7, seq_len, 64)
89
+
90
+ # train
91
+
92
+ loss = alphafold3(
93
+ num_recycling_steps = 2,
94
+ atom_inputs = atom_inputs,
95
+ atom_mask = atom_mask,
96
+ atompair_feats = atompair_feats,
97
+ additional_residue_feats = additional_residue_feats,
98
+ msa = msa,
99
+ templates = template_feats,
100
+ template_mask = template_mask
101
+ )
102
+
103
+ loss.backward()
104
+
105
+ ```
106
+
107
+ ## Citations
108
+
109
+ ```bibtex
110
+ @article{Abramson2024-fj,
111
+ title = "Accurate structure prediction of biomolecular interactions with
112
+ {AlphaFold} 3",
113
+ author = "Abramson, Josh and Adler, Jonas and Dunger, Jack and Evans,
114
+ Richard and Green, Tim and Pritzel, Alexander and Ronneberger,
115
+ Olaf and Willmore, Lindsay and Ballard, Andrew J and Bambrick,
116
+ Joshua and Bodenstein, Sebastian W and Evans, David A and Hung,
117
+ Chia-Chun and O'Neill, Michael and Reiman, David and
118
+ Tunyasuvunakool, Kathryn and Wu, Zachary and {\v Z}emgulyt{\.e},
119
+ Akvil{\.e} and Arvaniti, Eirini and Beattie, Charles and
120
+ Bertolli, Ottavia and Bridgland, Alex and Cherepanov, Alexey and
121
+ Congreve, Miles and Cowen-Rivers, Alexander I and Cowie, Andrew
122
+ and Figurnov, Michael and Fuchs, Fabian B and Gladman, Hannah and
123
+ Jain, Rishub and Khan, Yousuf A and Low, Caroline M R and Perlin,
124
+ Kuba and Potapenko, Anna and Savy, Pascal and Singh, Sukhdeep and
125
+ Stecula, Adrian and Thillaisundaram, Ashok and Tong, Catherine
126
+ and Yakneen, Sergei and Zhong, Ellen D and Zielinski, Michal and
127
+ {\v Z}{\'\i}dek, Augustin and Bapst, Victor and Kohli, Pushmeet
128
+ and Jaderberg, Max and Hassabis, Demis and Jumper, John M",
129
+ journal = "Nature",
130
+ month = may,
131
+ year = 2024
132
+ }
133
+ ```
@@ -0,0 +1,85 @@
1
+ <img src="./alphafold3.png" width="450px"></img>
2
+
3
+ ## Alphafold 3 - Pytorch (wip)
4
+
5
+ Implementation of <a href="https://www.nature.com/articles/s41586-024-07487-w">Alphafold 3</a> in Pytorch
6
+
7
+ Getting a fair number of emails. You can chat with me about this work <a href="https://discord.gg/x6FuzQPQXY">here</a>
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ $ pip install alphafold3-pytorch
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```python
18
+ import torch
19
+ from alphafold3_pytorch import Alphafold3
20
+
21
+ alphafold3 = Alphafold3(
22
+ dim_atom_inputs = 77,
23
+ dim_additional_residue_feats = 33,
24
+ dim_template_feats = 44
25
+ )
26
+
27
+ # mock inputs
28
+
29
+ seq_len = 16
30
+ atom_seq_len = seq_len * 27
31
+
32
+ atom_inputs = torch.randn(2, atom_seq_len, 77)
33
+ atom_mask = torch.ones((2, atom_seq_len)).bool()
34
+ atompair_feats = torch.randn(2, atom_seq_len, atom_seq_len, 16)
35
+ additional_residue_feats = torch.randn(2, seq_len, 33)
36
+
37
+ template_feats = torch.randn(2, 2, seq_len, seq_len, 44)
38
+ template_mask = torch.ones((2, 2)).bool()
39
+
40
+ msa = torch.randn(2, 7, seq_len, 64)
41
+
42
+ # train
43
+
44
+ loss = alphafold3(
45
+ num_recycling_steps = 2,
46
+ atom_inputs = atom_inputs,
47
+ atom_mask = atom_mask,
48
+ atompair_feats = atompair_feats,
49
+ additional_residue_feats = additional_residue_feats,
50
+ msa = msa,
51
+ templates = template_feats,
52
+ template_mask = template_mask
53
+ )
54
+
55
+ loss.backward()
56
+
57
+ ```
58
+
59
+ ## Citations
60
+
61
+ ```bibtex
62
+ @article{Abramson2024-fj,
63
+ title = "Accurate structure prediction of biomolecular interactions with
64
+ {AlphaFold} 3",
65
+ author = "Abramson, Josh and Adler, Jonas and Dunger, Jack and Evans,
66
+ Richard and Green, Tim and Pritzel, Alexander and Ronneberger,
67
+ Olaf and Willmore, Lindsay and Ballard, Andrew J and Bambrick,
68
+ Joshua and Bodenstein, Sebastian W and Evans, David A and Hung,
69
+ Chia-Chun and O'Neill, Michael and Reiman, David and
70
+ Tunyasuvunakool, Kathryn and Wu, Zachary and {\v Z}emgulyt{\.e},
71
+ Akvil{\.e} and Arvaniti, Eirini and Beattie, Charles and
72
+ Bertolli, Ottavia and Bridgland, Alex and Cherepanov, Alexey and
73
+ Congreve, Miles and Cowen-Rivers, Alexander I and Cowie, Andrew
74
+ and Figurnov, Michael and Fuchs, Fabian B and Gladman, Hannah and
75
+ Jain, Rishub and Khan, Yousuf A and Low, Caroline M R and Perlin,
76
+ Kuba and Potapenko, Anna and Savy, Pascal and Singh, Sukhdeep and
77
+ Stecula, Adrian and Thillaisundaram, Ashok and Tong, Catherine
78
+ and Yakneen, Sergei and Zhong, Ellen D and Zielinski, Michal and
79
+ {\v Z}{\'\i}dek, Augustin and Bapst, Victor and Kohli, Pushmeet
80
+ and Jaderberg, Max and Hassabis, Demis and Jumper, John M",
81
+ journal = "Nature",
82
+ month = may,
83
+ year = 2024
84
+ }
85
+ ```
Binary file
@@ -0,0 +1,50 @@
1
+ from alphafold3_pytorch.attention import (
2
+ Attention,
3
+ Attend
4
+ )
5
+
6
+ from alphafold3_pytorch.alphafold3 import (
7
+ TemplateEmbedder,
8
+ PreLayerNorm,
9
+ AdaptiveLayerNorm,
10
+ ConditionWrapper,
11
+ OuterProductMean,
12
+ MSAPairWeightedAveraging,
13
+ TriangleMultiplication,
14
+ AttentionPairBias,
15
+ TriangleAttention,
16
+ Transition,
17
+ MSAModule,
18
+ PairformerStack,
19
+ DiffusionTransformer,
20
+ DiffusionModule,
21
+ ElucidatedAtomDiffusion,
22
+ InputFeatureEmbedder,
23
+ ConfidenceHead,
24
+ DistogramHead,
25
+ Alphafold3
26
+ )
27
+
28
+ __all__ = [
29
+ Attention,
30
+ Attend,
31
+ TemplateEmbedder,
32
+ PreLayerNorm,
33
+ AdaptiveLayerNorm,
34
+ ConditionWrapper,
35
+ OuterProductMean,
36
+ MSAPairWeightedAveraging,
37
+ TriangleMultiplication,
38
+ AttentionPairBias,
39
+ TriangleAttention,
40
+ Transition,
41
+ MSAModule,
42
+ PairformerStack,
43
+ DiffusionTransformer,
44
+ DiffusionModule,
45
+ ElucidatedAtomDiffusion,
46
+ InputFeatureEmbedder,
47
+ ConfidenceHead,
48
+ DistogramHead,
49
+ Alphafold3
50
+ ]