aksell commited on
Commit
f8402f9
1 Parent(s): 08dc5f2

Add get_structure

Browse files
poetry.lock CHANGED
@@ -137,6 +137,17 @@ soupsieve = ">1.2"
137
  html5lib = ["html5lib"]
138
  lxml = ["lxml"]
139
 
 
 
 
 
 
 
 
 
 
 
 
140
  [[package]]
141
  name = "bleach"
142
  version = "6.0.0"
@@ -271,6 +282,17 @@ category = "main"
271
  optional = false
272
  python-versions = ">=3.6"
273
 
 
 
 
 
 
 
 
 
 
 
 
274
  [[package]]
275
  name = "executing"
276
  version = "1.2.0"
@@ -347,6 +369,14 @@ docs = ["sphinx (>=3.5)", "jaraco.packaging (>=9)", "rst.linker (>=1.9)", "furo"
347
  perf = ["ipython"]
348
  testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "flake8 (<5)", "pytest-cov", "pytest-enabler (>=1.3)", "packaging", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)", "pytest-flake8", "importlib-resources (>=1.3)"]
349
 
 
 
 
 
 
 
 
 
350
  [[package]]
351
  name = "ipykernel"
352
  version = "6.21.3"
@@ -971,6 +1001,18 @@ python-versions = ">=3.7"
971
  docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx-autodoc-typehints (>=1.22,!=1.23.4)", "sphinx (>=6.1.3)"]
972
  test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)", "pytest (>=7.2.1)"]
973
 
 
 
 
 
 
 
 
 
 
 
 
 
974
  [[package]]
975
  name = "prometheus-client"
976
  version = "0.16.0"
@@ -1104,6 +1146,26 @@ category = "main"
1104
  optional = false
1105
  python-versions = ">=3.7"
1106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1107
  [[package]]
1108
  name = "python-dateutil"
1109
  version = "2.8.2"
@@ -1389,6 +1451,14 @@ category = "main"
1389
  optional = false
1390
  python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
1391
 
 
 
 
 
 
 
 
 
1392
  [[package]]
1393
  name = "tomlkit"
1394
  version = "0.11.6"
@@ -1569,7 +1639,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "flake8 (<5)", "pytest-co
1569
  [metadata]
1570
  lock-version = "1.1"
1571
  python-versions = "^3.10"
1572
- content-hash = "23a858c56f35b320a1eb54d146b830db79180c7be4a22c0e9afb55c0a7163f40"
1573
 
1574
  [metadata.files]
1575
  altair = []
@@ -1610,6 +1680,7 @@ backcall = [
1610
  {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"},
1611
  ]
1612
  beautifulsoup4 = []
 
1613
  bleach = []
1614
  blinker = []
1615
  cachetools = []
@@ -1633,6 +1704,7 @@ entrypoints = [
1633
  {file = "entrypoints-0.4-py3-none-any.whl", hash = "sha256:f174b5ff827504fd3cd97cc3f8649f3693f51538c7e4bdf3ef002c8429d42f9f"},
1634
  {file = "entrypoints-0.4.tar.gz", hash = "sha256:b706eddaa9218a19ebcd67b56818f05bb27589b1ca9e8d797b74affad4ccacd4"},
1635
  ]
 
1636
  executing = []
1637
  fastjsonschema = []
1638
  fqdn = []
@@ -1640,6 +1712,7 @@ gitdb = []
1640
  gitpython = []
1641
  idna = []
1642
  importlib-metadata = []
 
1643
  ipykernel = []
1644
  ipyspeck = []
1645
  ipython = []
@@ -1694,6 +1767,10 @@ pickleshare = [
1694
  ]
1695
  pillow = []
1696
  platformdirs = []
 
 
 
 
1697
  prometheus-client = []
1698
  prompt-toolkit = []
1699
  protobuf = []
@@ -1716,6 +1793,7 @@ pydeck = []
1716
  pygments = []
1717
  pympler = []
1718
  pyrsistent = []
 
1719
  python-dateutil = [
1720
  {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"},
1721
  {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"},
@@ -1789,6 +1867,10 @@ toml = [
1789
  {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
1790
  {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
1791
  ]
 
 
 
 
1792
  tomlkit = []
1793
  toolz = []
1794
  tornado = []
 
137
  html5lib = ["html5lib"]
138
  lxml = ["lxml"]
139
 
140
+ [[package]]
141
+ name = "biopython"
142
+ version = "1.81"
143
+ description = "Freely available tools for computational molecular biology."
144
+ category = "main"
145
+ optional = false
146
+ python-versions = ">=3.7"
147
+
148
+ [package.dependencies]
149
+ numpy = "*"
150
+
151
  [[package]]
152
  name = "bleach"
153
  version = "6.0.0"
 
282
  optional = false
283
  python-versions = ">=3.6"
284
 
285
+ [[package]]
286
+ name = "exceptiongroup"
287
+ version = "1.1.1"
288
+ description = "Backport of PEP 654 (exception groups)"
289
+ category = "dev"
290
+ optional = false
291
+ python-versions = ">=3.7"
292
+
293
+ [package.extras]
294
+ test = ["pytest (>=6)"]
295
+
296
  [[package]]
297
  name = "executing"
298
  version = "1.2.0"
 
369
  perf = ["ipython"]
370
  testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "flake8 (<5)", "pytest-cov", "pytest-enabler (>=1.3)", "packaging", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)", "pytest-flake8", "importlib-resources (>=1.3)"]
371
 
372
+ [[package]]
373
+ name = "iniconfig"
374
+ version = "2.0.0"
375
+ description = "brain-dead simple config-ini parsing"
376
+ category = "dev"
377
+ optional = false
378
+ python-versions = ">=3.7"
379
+
380
  [[package]]
381
  name = "ipykernel"
382
  version = "6.21.3"
 
1001
  docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx-autodoc-typehints (>=1.22,!=1.23.4)", "sphinx (>=6.1.3)"]
1002
  test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)", "pytest (>=7.2.1)"]
1003
 
1004
+ [[package]]
1005
+ name = "pluggy"
1006
+ version = "1.0.0"
1007
+ description = "plugin and hook calling mechanisms for python"
1008
+ category = "dev"
1009
+ optional = false
1010
+ python-versions = ">=3.6"
1011
+
1012
+ [package.extras]
1013
+ dev = ["pre-commit", "tox"]
1014
+ testing = ["pytest", "pytest-benchmark"]
1015
+
1016
  [[package]]
1017
  name = "prometheus-client"
1018
  version = "0.16.0"
 
1146
  optional = false
1147
  python-versions = ">=3.7"
1148
 
1149
+ [[package]]
1150
+ name = "pytest"
1151
+ version = "7.2.2"
1152
+ description = "pytest: simple powerful testing with Python"
1153
+ category = "dev"
1154
+ optional = false
1155
+ python-versions = ">=3.7"
1156
+
1157
+ [package.dependencies]
1158
+ attrs = ">=19.2.0"
1159
+ colorama = {version = "*", markers = "sys_platform == \"win32\""}
1160
+ exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""}
1161
+ iniconfig = "*"
1162
+ packaging = "*"
1163
+ pluggy = ">=0.12,<2.0"
1164
+ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
1165
+
1166
+ [package.extras]
1167
+ testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
1168
+
1169
  [[package]]
1170
  name = "python-dateutil"
1171
  version = "2.8.2"
 
1451
  optional = false
1452
  python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
1453
 
1454
+ [[package]]
1455
+ name = "tomli"
1456
+ version = "2.0.1"
1457
+ description = "A lil' TOML parser"
1458
+ category = "dev"
1459
+ optional = false
1460
+ python-versions = ">=3.7"
1461
+
1462
  [[package]]
1463
  name = "tomlkit"
1464
  version = "0.11.6"
 
1639
  [metadata]
1640
  lock-version = "1.1"
1641
  python-versions = "^3.10"
1642
+ content-hash = "1e79d688b56335b1eafcb169572e0b8983eff0cb2da5ece8807ae02316f25f12"
1643
 
1644
  [metadata.files]
1645
  altair = []
 
1680
  {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"},
1681
  ]
1682
  beautifulsoup4 = []
1683
+ biopython = []
1684
  bleach = []
1685
  blinker = []
1686
  cachetools = []
 
1704
  {file = "entrypoints-0.4-py3-none-any.whl", hash = "sha256:f174b5ff827504fd3cd97cc3f8649f3693f51538c7e4bdf3ef002c8429d42f9f"},
1705
  {file = "entrypoints-0.4.tar.gz", hash = "sha256:b706eddaa9218a19ebcd67b56818f05bb27589b1ca9e8d797b74affad4ccacd4"},
1706
  ]
1707
+ exceptiongroup = []
1708
  executing = []
1709
  fastjsonschema = []
1710
  fqdn = []
 
1712
  gitpython = []
1713
  idna = []
1714
  importlib-metadata = []
1715
+ iniconfig = []
1716
  ipykernel = []
1717
  ipyspeck = []
1718
  ipython = []
 
1767
  ]
1768
  pillow = []
1769
  platformdirs = []
1770
+ pluggy = [
1771
+ {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
1772
+ {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
1773
+ ]
1774
  prometheus-client = []
1775
  prompt-toolkit = []
1776
  protobuf = []
 
1793
  pygments = []
1794
  pympler = []
1795
  pyrsistent = []
1796
+ pytest = []
1797
  python-dateutil = [
1798
  {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"},
1799
  {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"},
 
1867
  {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
1868
  {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
1869
  ]
1870
+ tomli = [
1871
+ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
1872
+ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
1873
+ ]
1874
  tomlkit = []
1875
  toolz = []
1876
  tornado = []
protention/attention.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from io import StringIO
2
+ from urllib import request
3
+
4
+ from Bio.PDB import PDBParser, Structure
5
+
6
+
7
+ def get_structure(pdb_code: str) -> Structure:
8
+ """
9
+ Get structure from PDB
10
+ """
11
+ pdb_url = f"https://files.rcsb.org/download/{pdb_code}.pdb"
12
+ pdb_data = request.urlopen(pdb_url).read().decode("utf-8")
13
+ file = StringIO(pdb_data)
14
+ parser = PDBParser()
15
+ structure = parser.get_structure(pdb_code, file)
16
+ return structure
17
+
18
+
19
+ def get_attention(
20
+ pdb_code: str, chain_ids: list[str], layer: int, head: int, min_attn: float = 0.2
21
+ ):
22
+ """
23
+ Get attention from T5
24
+ """
25
+ # fetch structure
26
+ structure = get_structure(pdb_code)
27
+
28
+ # get model
29
+
30
+ # call model
31
+
32
+ # get attention
33
+
34
+ # extract attention
pyproject.toml CHANGED
@@ -8,8 +8,10 @@ authors = ["Aksel Lenes <[email protected]>"]
8
  python = "^3.10"
9
  streamlit = "^1.20.0"
10
  stmol = "^0.0.9"
 
11
 
12
  [tool.poetry.dev-dependencies]
 
13
 
14
  [build-system]
15
  requires = ["poetry-core>=1.0.0"]
 
8
  python = "^3.10"
9
  streamlit = "^1.20.0"
10
  stmol = "^0.0.9"
11
+ biopython = "^1.81"
12
 
13
  [tool.poetry.dev-dependencies]
14
+ pytest = "^7.2.2"
15
 
16
  [build-system]
17
  requires = ["poetry-core>=1.0.0"]
tests/__init__.py ADDED
File without changes
tests/test_attention.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from Bio.PDB.Structure import Structure
2
+
3
+ from protention.attention import get_structure
4
+
5
+
6
+ def test_get_structure():
7
+ pdb_id = "1AKE"
8
+ structure = get_structure(pdb_id)
9
+ assert structure is not None
10
+ assert isinstance(structure, Structure)