diff --git a/src/bundles/alphafold/src/database.py b/src/bundles/alphafold/src/database.py
index c97a2171f..b48b3f3e9 100644
|
a
|
b
|
from chimerax.core.settings import Settings
|
| 18 | 18 | class _AlphaFoldDatabaseSettings(Settings): |
| 19 | 19 | EXPLICIT_SAVE = { |
| 20 | 20 | 'database_url': 'https://alphafold.ebi.ac.uk/files/AF-{uniprot_id}-F1-model_v{version}.cif', |
| 21 | | 'database_version': '2', |
| | 21 | 'database_version': '3', |
| 22 | 22 | 'last_update_time': 0.0, # seconds since 1970 epoch |
| 23 | 23 | 'update_interval': 86400.0, # seconds |
| 24 | 24 | 'update_url': 'https://www.rbvi.ucsf.edu/chimerax/data/status/alphafold_database.json', |
diff --git a/src/bundles/alphafold/src/fetch.py b/src/bundles/alphafold/src/fetch.py
index c74a059a3..bb6915490 100644
|
a
|
b
|
def alphafold_fetch(session, uniprot_id, color_confidence=True,
|
| 58 | 58 | |
| 59 | 59 | if pae: |
| 60 | 60 | from .pae import alphafold_pae |
| 61 | | alphafold_pae(session, structure = models[0], uniprot_id = uniprot_id) |
| | 61 | alphafold_pae(session, structure = models[0], uniprot_id = uniprot_id, version=version) |
| 62 | 62 | |
| 63 | 63 | return models, status |
| 64 | 64 | |
diff --git a/src/bundles/alphafold/src/pae.py b/src/bundles/alphafold/src/pae.py
index c9799c7a5..e1d2904c2 100644
|
a
|
b
|
def read_json_pae_matrix(path):
|
| 862 | 862 | raise UserError(f'JSON file "{path}" is not AlphaFold predicted aligned error data, expected a top level list') |
| 863 | 863 | d = j[0] |
| 864 | 864 | |
| 865 | | valid = (isinstance(d, dict) and 'residue1' in d and 'residue2' in d and 'distance' in d) |
| | 865 | valid = (isinstance(d, dict) and 'residue1' in d and 'residue2' in d and 'distance' in d) or (isinstance(d, dict) and 'predicted_aligned_error' in d) |
| 866 | 866 | if not valid: |
| 867 | 867 | from chimerax.core.errors import UserError |
| 868 | 868 | raise UserError(f'JSON file "{path}" is not AlphaFold predicted aligned error data, expected a dictionary with keys "residue1", "residue2" and "distance"') |
| 869 | 869 | |
| 870 | 870 | # Read distance errors into numpy array |
| 871 | 871 | from numpy import array, zeros, float32, int32 |
| 872 | | r1 = array(d['residue1'], dtype=int32) |
| 873 | | r2 = array(d['residue2'], dtype=int32) |
| 874 | | ea = array(d['distance'], dtype=float32) |
| 875 | | # me = d['max_predicted_aligned_error'] |
| 876 | | n = r1.max() |
| 877 | | pae = zeros((n,n), float32) |
| 878 | | pae[r1-1,r2-1] = ea |
| | 872 | if 'predicted_aligned_error' in d: |
| | 873 | pae = array(d['predicted_aligned_error'], dtype=float32) |
| | 874 | pae[pae==0] = 0.2 # Avoid divide-by-zero warnings in domain parsing |
| | 875 | else: |
| | 876 | r1 = array(d['residue1'], dtype=int32) |
| | 877 | r2 = array(d['residue2'], dtype=int32) |
| | 878 | ea = array(d['distance'], dtype=float32) |
| | 879 | # me = d['max_predicted_aligned_error'] |
| | 880 | n = r1.max() |
| | 881 | pae = zeros((n,n), float32) |
| | 882 | pae[r1-1,r2-1] = ea |
| 879 | 883 | |
| 880 | 884 | return pae |
| 881 | 885 | |
| … |
… |
def set_pae_domain_residue_attribute(residues, clusters):
|
| 997 | 1001 | # ----------------------------------------------------------------------------- |
| 998 | 1002 | # |
| 999 | 1003 | def alphafold_pae(session, structure = None, file = None, uniprot_id = None, |
| 1000 | | palette = None, range = None, plot = None, divider_lines = None, |
| | 1004 | version = None, palette = None, range = None, plot = None, divider_lines = None, |
| 1001 | 1005 | color_domains = False, connect_max_pae = 5, cluster = 0.5, min_size = 10): |
| 1002 | 1006 | '''Load AlphaFold predicted aligned error file and show plot or color domains.''' |
| 1003 | 1007 | |
| 1004 | 1008 | if uniprot_id: |
| 1005 | 1009 | from .database import alphafold_pae_url |
| 1006 | | pae_url = alphafold_pae_url(session, uniprot_id) |
| | 1010 | pae_url = alphafold_pae_url(session, uniprot_id, database_version=version) |
| 1007 | 1011 | file_name = pae_url.split('/')[-1] |
| 1008 | 1012 | from chimerax.core.fetch import fetch_file |
| 1009 | 1013 | file = fetch_file(session, pae_url, 'AlphaFold PAE %s' % uniprot_id, |