aksell commited on
Commit
2d77790
1 Parent(s): 5563518

Use Python 3.10.5

Browse files
Files changed (6) hide show
  1. .python-version +1 -1
  2. README.md +1 -0
  3. hexviz/attention.py +2 -3
  4. hexviz/models.py +3 -4
  5. poetry.lock +2 -48
  6. pyproject.toml +1 -1
.python-version CHANGED
@@ -1 +1 @@
1
- 3.8.9
 
1
+ 3.10.5
README.md CHANGED
@@ -5,6 +5,7 @@ colorFrom: green
5
  colorTo: purple
6
  sdk: streamlit
7
  sdk_version: 1.17.0
 
8
  app_file: ./hexviz/🧬Attention_Visualization.py
9
  pinned: true
10
  tags: ["protein language models", "attention analysis", "protein structure", "biology"]
 
5
  colorTo: purple
6
  sdk: streamlit
7
  sdk_version: 1.17.0
8
+ python_version: 3.10.5
9
  app_file: ./hexviz/🧬Attention_Visualization.py
10
  pinned: true
11
  tags: ["protein language models", "attention analysis", "protein structure", "biology"]
hexviz/attention.py CHANGED
@@ -1,5 +1,4 @@
1
  from io import StringIO
2
- from typing import List, Optional
3
  from urllib import request
4
 
5
  import requests
@@ -40,7 +39,7 @@ def get_pdb_from_seq(sequence: str) -> str:
40
  pdb_str = res.text
41
  return pdb_str
42
 
43
- def get_chains(structure: Structure) -> List[str]:
44
  """
45
  Get list of chains in a structure
46
  """
@@ -127,7 +126,7 @@ def unidirectional_avg_filtered(attention, layer, head, threshold):
127
  return unidirectional_avg_for_head
128
 
129
  @st.cache
130
- def get_attention_pairs(pdb_str: str, layer: int, head: int, chain_ids: Optional[str] = None ,threshold: int = 0.2, model_type: ModelType = ModelType.TAPE_BERT, top_n: int = 2):
131
  structure = PDBParser().get_structure("pdb", StringIO(pdb_str))
132
  if chain_ids:
133
  chains = [ch for ch in structure.get_chains() if ch.id in chain_ids]
 
1
  from io import StringIO
 
2
  from urllib import request
3
 
4
  import requests
 
39
  pdb_str = res.text
40
  return pdb_str
41
 
42
+ def get_chains(structure: Structure) -> list[str]:
43
  """
44
  Get list of chains in a structure
45
  """
 
126
  return unidirectional_avg_for_head
127
 
128
  @st.cache
129
+ def get_attention_pairs(pdb_str: str, layer: int, head: int, chain_ids: str | None ,threshold: int = 0.2, model_type: ModelType = ModelType.TAPE_BERT, top_n: int = 2):
130
  structure = PDBParser().get_structure("pdb", StringIO(pdb_str))
131
  if chain_ids:
132
  chains = [ch for ch in structure.get_chains() if ch.id in chain_ids]
hexviz/models.py CHANGED
@@ -1,5 +1,4 @@
1
  from enum import Enum
2
- from typing import Tuple
3
 
4
  import streamlit as st
5
  import torch
@@ -22,20 +21,20 @@ class Model:
22
 
23
 
24
  @st.cache
25
- def get_tape_bert() -> Tuple[TAPETokenizer, ProteinBertModel]:
26
  tokenizer = TAPETokenizer()
27
  model = ProteinBertModel.from_pretrained('bert-base', output_attentions=True)
28
  return tokenizer, model
29
 
30
  @st.cache
31
- def get_zymctrl() -> Tuple[AutoTokenizer, GPT2LMHeadModel]:
32
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
33
  tokenizer = AutoTokenizer.from_pretrained('nferruz/ZymCTRL')
34
  model = GPT2LMHeadModel.from_pretrained('nferruz/ZymCTRL').to(device)
35
  return tokenizer, model
36
 
37
  @st.cache
38
- def get_prot_bert() -> Tuple[BertTokenizer, BertForMaskedLM]:
39
  tokenizer = BertTokenizer.from_pretrained("Rostlab/prot_bert", do_lower_case=False )
40
  model = BertForMaskedLM.from_pretrained("Rostlab/prot_bert")
41
  return tokenizer, model
 
1
  from enum import Enum
 
2
 
3
  import streamlit as st
4
  import torch
 
21
 
22
 
23
  @st.cache
24
+ def get_tape_bert() -> tuple[TAPETokenizer, ProteinBertModel]:
25
  tokenizer = TAPETokenizer()
26
  model = ProteinBertModel.from_pretrained('bert-base', output_attentions=True)
27
  return tokenizer, model
28
 
29
  @st.cache
30
+ def get_zymctrl() -> tuple[AutoTokenizer, GPT2LMHeadModel]:
31
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
32
  tokenizer = AutoTokenizer.from_pretrained('nferruz/ZymCTRL')
33
  model = GPT2LMHeadModel.from_pretrained('nferruz/ZymCTRL').to(device)
34
  return tokenizer, model
35
 
36
  @st.cache
37
+ def get_prot_bert() -> tuple[BertTokenizer, BertForMaskedLM]:
38
  tokenizer = BertTokenizer.from_pretrained("Rostlab/prot_bert", do_lower_case=False )
39
  model = BertForMaskedLM.from_pretrained("Rostlab/prot_bert")
40
  return tokenizer, model
poetry.lock CHANGED
@@ -122,17 +122,6 @@ category = "main"
122
  optional = false
123
  python-versions = "*"
124
 
125
- [[package]]
126
- name = "backports.zoneinfo"
127
- version = "0.2.1"
128
- description = "Backport of the standard library zoneinfo module"
129
- category = "main"
130
- optional = false
131
- python-versions = ">=3.6"
132
-
133
- [package.extras]
134
- tzdata = ["tzdata"]
135
-
136
  [[package]]
137
  name = "beautifulsoup4"
138
  version = "4.11.2"
@@ -510,21 +499,6 @@ docs = ["sphinx (>=3.5)", "jaraco.packaging (>=9)", "rst.linker (>=1.9)", "furo"
510
  perf = ["ipython"]
511
  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)"]
512
 
513
- [[package]]
514
- name = "importlib-resources"
515
- version = "5.12.0"
516
- description = "Read resources from Python packages"
517
- category = "main"
518
- optional = false
519
- python-versions = ">=3.7"
520
-
521
- [package.dependencies]
522
- zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""}
523
-
524
- [package.extras]
525
- docs = ["sphinx (>=3.5)", "jaraco.packaging (>=9)", "rst.linker (>=1.9)", "furo", "sphinx-lint", "jaraco.tidelift (>=1.4)"]
526
- testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "flake8 (<5)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)", "pytest-flake8"]
527
-
528
  [[package]]
529
  name = "iniconfig"
530
  version = "2.0.0"
@@ -706,10 +680,8 @@ python-versions = ">=3.7"
706
  attrs = ">=17.4.0"
707
  fqdn = {version = "*", optional = true, markers = "extra == \"format-nongpl\""}
708
  idna = {version = "*", optional = true, markers = "extra == \"format-nongpl\""}
709
- importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""}
710
  isoduration = {version = "*", optional = true, markers = "extra == \"format-nongpl\""}
711
  jsonpointer = {version = ">1.13", optional = true, markers = "extra == \"format-nongpl\""}
712
- pkgutil-resolve-name = {version = ">=1.3.10", markers = "python_version < \"3.9\""}
713
  pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2"
714
  rfc3339-validator = {version = "*", optional = true, markers = "extra == \"format-nongpl\""}
715
  rfc3986-validator = {version = ">0.1.0", optional = true, markers = "extra == \"format-nongpl\""}
@@ -729,7 +701,6 @@ optional = false
729
  python-versions = ">=3.8"
730
 
731
  [package.dependencies]
732
- importlib-metadata = {version = ">=4.8.3", markers = "python_version < \"3.10\""}
733
  jupyter-core = ">=4.12,<5.0.0 || >=5.1.0"
734
  python-dateutil = ">=2.8.2"
735
  pyzmq = ">=23.0"
@@ -923,7 +894,6 @@ python-versions = ">=3.8"
923
  contourpy = ">=1.0.1"
924
  cycler = ">=0.10"
925
  fonttools = ">=4.22.0"
926
- importlib-resources = {version = ">=3.2.0", markers = "python_version < \"3.10\""}
927
  kiwisolver = ">=1.0.1"
928
  numpy = ">=1.20"
929
  packaging = ">=20.0"
@@ -1036,7 +1006,6 @@ python-versions = ">=3.7"
1036
  beautifulsoup4 = "*"
1037
  bleach = "*"
1038
  defusedxml = "*"
1039
- importlib-metadata = {version = ">=3.6", markers = "python_version < \"3.10\""}
1040
  jinja2 = ">=3.0"
1041
  jupyter-core = ">=4.7"
1042
  jupyterlab-pygments = "*"
@@ -1259,7 +1228,6 @@ python-versions = ">=3.8"
1259
 
1260
  [package.dependencies]
1261
  numpy = [
1262
- {version = ">=1.20.3", markers = "python_version < \"3.10\""},
1263
  {version = ">=1.21.0", markers = "python_version >= \"3.10\""},
1264
  {version = ">=1.23.2", markers = "python_version >= \"3.11\""},
1265
  ]
@@ -1320,14 +1288,6 @@ python-versions = ">=3.7"
1320
  docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-issues (>=3.0.1)", "sphinx-removed-in", "sphinxext-opengraph"]
1321
  tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"]
1322
 
1323
- [[package]]
1324
- name = "pkgutil-resolve-name"
1325
- version = "1.3.10"
1326
- description = "Resolve a name to an object."
1327
- category = "main"
1328
- optional = false
1329
- python-versions = ">=3.6"
1330
-
1331
  [[package]]
1332
  name = "platformdirs"
1333
  version = "3.1.1"
@@ -1552,7 +1512,6 @@ optional = false
1552
  python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7"
1553
 
1554
  [package.dependencies]
1555
- "backports.zoneinfo" = {version = "*", markers = "python_version >= \"3.6\" and python_version < \"3.9\""}
1556
  tzdata = {version = "*", markers = "python_version >= \"3.6\""}
1557
 
1558
  [[package]]
@@ -1646,7 +1605,6 @@ python-versions = ">=3.7.0"
1646
  [package.dependencies]
1647
  markdown-it-py = ">=2.2.0,<3.0.0"
1648
  pygments = ">=2.13.0,<3.0.0"
1649
- typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9\""}
1650
 
1651
  [package.extras]
1652
  jupyter = ["ipywidgets (>=7.5.1,<9)"]
@@ -2119,7 +2077,6 @@ optional = false
2119
  python-versions = ">=3.6"
2120
 
2121
  [package.dependencies]
2122
- "backports.zoneinfo" = {version = "*", markers = "python_version < \"3.9\""}
2123
  pytz-deprecation-shim = "*"
2124
  tzdata = {version = "*", markers = "platform_system == \"Windows\""}
2125
 
@@ -2238,8 +2195,8 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "flake8 (<5)", "pytest-co
2238
 
2239
  [metadata]
2240
  lock-version = "1.1"
2241
- python-versions = ">=3.8.9,<3.9.7 || >3.9.7,<4.0.0"
2242
- content-hash = "4583c3e7b0104de5e04c6438baa75cacda39164b118e28c71828ab1aa7a5eb13"
2243
 
2244
  [metadata.files]
2245
  altair = []
@@ -2279,7 +2236,6 @@ backcall = [
2279
  {file = "backcall-0.2.0-py2.py3-none-any.whl", hash = "sha256:fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255"},
2280
  {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"},
2281
  ]
2282
- "backports.zoneinfo" = []
2283
  beautifulsoup4 = []
2284
  biopython = []
2285
  bleach = []
@@ -2321,7 +2277,6 @@ gitpython = []
2321
  huggingface-hub = []
2322
  idna = []
2323
  importlib-metadata = []
2324
- importlib-resources = []
2325
  iniconfig = []
2326
  ipykernel = []
2327
  ipyspeck = []
@@ -2394,7 +2349,6 @@ pickleshare = [
2394
  {file = "pickleshare-0.7.5.tar.gz", hash = "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca"},
2395
  ]
2396
  pillow = []
2397
- pkgutil-resolve-name = []
2398
  platformdirs = []
2399
  pluggy = [
2400
  {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
 
122
  optional = false
123
  python-versions = "*"
124
 
 
 
 
 
 
 
 
 
 
 
 
125
  [[package]]
126
  name = "beautifulsoup4"
127
  version = "4.11.2"
 
499
  perf = ["ipython"]
500
  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)"]
501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
502
  [[package]]
503
  name = "iniconfig"
504
  version = "2.0.0"
 
680
  attrs = ">=17.4.0"
681
  fqdn = {version = "*", optional = true, markers = "extra == \"format-nongpl\""}
682
  idna = {version = "*", optional = true, markers = "extra == \"format-nongpl\""}
 
683
  isoduration = {version = "*", optional = true, markers = "extra == \"format-nongpl\""}
684
  jsonpointer = {version = ">1.13", optional = true, markers = "extra == \"format-nongpl\""}
 
685
  pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2"
686
  rfc3339-validator = {version = "*", optional = true, markers = "extra == \"format-nongpl\""}
687
  rfc3986-validator = {version = ">0.1.0", optional = true, markers = "extra == \"format-nongpl\""}
 
701
  python-versions = ">=3.8"
702
 
703
  [package.dependencies]
 
704
  jupyter-core = ">=4.12,<5.0.0 || >=5.1.0"
705
  python-dateutil = ">=2.8.2"
706
  pyzmq = ">=23.0"
 
894
  contourpy = ">=1.0.1"
895
  cycler = ">=0.10"
896
  fonttools = ">=4.22.0"
 
897
  kiwisolver = ">=1.0.1"
898
  numpy = ">=1.20"
899
  packaging = ">=20.0"
 
1006
  beautifulsoup4 = "*"
1007
  bleach = "*"
1008
  defusedxml = "*"
 
1009
  jinja2 = ">=3.0"
1010
  jupyter-core = ">=4.7"
1011
  jupyterlab-pygments = "*"
 
1228
 
1229
  [package.dependencies]
1230
  numpy = [
 
1231
  {version = ">=1.21.0", markers = "python_version >= \"3.10\""},
1232
  {version = ">=1.23.2", markers = "python_version >= \"3.11\""},
1233
  ]
 
1288
  docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-issues (>=3.0.1)", "sphinx-removed-in", "sphinxext-opengraph"]
1289
  tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"]
1290
 
 
 
 
 
 
 
 
 
1291
  [[package]]
1292
  name = "platformdirs"
1293
  version = "3.1.1"
 
1512
  python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7"
1513
 
1514
  [package.dependencies]
 
1515
  tzdata = {version = "*", markers = "python_version >= \"3.6\""}
1516
 
1517
  [[package]]
 
1605
  [package.dependencies]
1606
  markdown-it-py = ">=2.2.0,<3.0.0"
1607
  pygments = ">=2.13.0,<3.0.0"
 
1608
 
1609
  [package.extras]
1610
  jupyter = ["ipywidgets (>=7.5.1,<9)"]
 
2077
  python-versions = ">=3.6"
2078
 
2079
  [package.dependencies]
 
2080
  pytz-deprecation-shim = "*"
2081
  tzdata = {version = "*", markers = "platform_system == \"Windows\""}
2082
 
 
2195
 
2196
  [metadata]
2197
  lock-version = "1.1"
2198
+ python-versions = "^3.10"
2199
+ content-hash = "79f191c2f3cc09035f7d0f543aa08c44c0a39de462336ca23eeea26ac29218de"
2200
 
2201
  [metadata.files]
2202
  altair = []
 
2236
  {file = "backcall-0.2.0-py2.py3-none-any.whl", hash = "sha256:fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255"},
2237
  {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"},
2238
  ]
 
2239
  beautifulsoup4 = []
2240
  biopython = []
2241
  bleach = []
 
2277
  huggingface-hub = []
2278
  idna = []
2279
  importlib-metadata = []
 
2280
  iniconfig = []
2281
  ipykernel = []
2282
  ipyspeck = []
 
2349
  {file = "pickleshare-0.7.5.tar.gz", hash = "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca"},
2350
  ]
2351
  pillow = []
 
2352
  platformdirs = []
2353
  pluggy = [
2354
  {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
pyproject.toml CHANGED
@@ -5,7 +5,7 @@ description = "Visualize and analyze attention patterns for protein language mod
5
  authors = ["Aksel Lenes <aksel.lenes@gmail.com>"]
6
 
7
  [tool.poetry.dependencies]
8
- python = ">=3.8.9,<3.9.7 || >3.9.7,<4.0.0"
9
  streamlit = "1.17"
10
  stmol = "^0.0.9"
11
  biopython = "^1.81"
 
5
  authors = ["Aksel Lenes <aksel.lenes@gmail.com>"]
6
 
7
  [tool.poetry.dependencies]
8
+ python = "^3.10"
9
  streamlit = "1.17"
10
  stmol = "^0.0.9"
11
  biopython = "^1.81"