boltz-vsynthes 1.0.30__py3-none-any.whl → 1.0.31__py3-none-any.whl

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.
@@ -1059,6 +1059,7 @@ def parse_boltz_schema( # noqa: C901, PLR0915, PLR0912
1059
1059
 
1060
1060
  # Check if any affinity ligand is present
1061
1061
  affinity_ligands = set()
1062
+ affinity_proteins = set()
1062
1063
  properties = schema.get("properties", [])
1063
1064
  if properties and not boltz_2:
1064
1065
  msg = "Affinity prediction is only supported for Boltz2!"
@@ -1069,7 +1070,6 @@ def parse_boltz_schema( # noqa: C901, PLR0915, PLR0912
1069
1070
  if prop_type == "affinity":
1070
1071
  binder = prop["affinity"]["binder"]
1071
1072
  if not isinstance(binder, str):
1072
- # TODO: support multi residue ligands and ccd's
1073
1073
  msg = "Binder must be a single chain."
1074
1074
  raise ValueError(msg)
1075
1075
 
@@ -1077,18 +1077,21 @@ def parse_boltz_schema( # noqa: C901, PLR0915, PLR0912
1077
1077
  msg = f"Could not find binder with name {binder} in the input!"
1078
1078
  raise ValueError(msg)
1079
1079
 
1080
- if chain_name_to_entity_type[binder] != "ligand":
1080
+ # Allow both protein and ligand as binders
1081
+ if chain_name_to_entity_type[binder] == "protein":
1082
+ affinity_proteins.add(binder)
1083
+ elif chain_name_to_entity_type[binder] == "ligand":
1084
+ affinity_ligands.add(binder)
1085
+ else:
1081
1086
  msg = (
1082
- f"Chain {binder} is not a ligand! "
1083
- "Affinity is currently only supported for ligands."
1087
+ f"Chain {binder} is not a protein or ligand! "
1088
+ "Affinity is currently only supported for proteins and ligands."
1084
1089
  )
1085
1090
  raise ValueError(msg)
1086
1091
 
1087
- affinity_ligands.add(binder)
1088
-
1089
- # Check only one affinity ligand is present
1090
- if len(affinity_ligands) > 1:
1091
- msg = "Only one affinity ligand is currently supported!"
1092
+ # Check if any affinity binder is present
1093
+ if len(affinity_proteins) + len(affinity_ligands) > 1:
1094
+ msg = "Only one affinity binder is currently supported!"
1092
1095
  raise ValueError(msg)
1093
1096
 
1094
1097
  # Go through entities and parse them
@@ -1111,12 +1114,15 @@ def parse_boltz_schema( # noqa: C901, PLR0915, PLR0912
1111
1114
  elif isinstance(item[entity_type]["id"], list):
1112
1115
  ids.extend(item[entity_type]["id"])
1113
1116
 
1114
- # Check if any affinity ligand is present
1117
+ # Check if any affinity binder is present
1115
1118
  if len(ids) == 1:
1116
- affinity = ids[0] in affinity_ligands
1119
+ affinity = ids[0] in affinity_ligands or ids[0] in affinity_proteins
1117
1120
  elif (len(ids) > 1) and any(x in affinity_ligands for x in ids):
1118
1121
  msg = "Cannot compute affinity for a ligand that has multiple copies!"
1119
1122
  raise ValueError(msg)
1123
+ elif (len(ids) > 1) and any(x in affinity_proteins for x in ids):
1124
+ # If binder is a protein, allow multiple ligands
1125
+ affinity = True
1120
1126
  else:
1121
1127
  affinity = False
1122
1128
 
@@ -1215,7 +1221,7 @@ def parse_boltz_schema( # noqa: C901, PLR0915, PLR0912
1215
1221
  )
1216
1222
 
1217
1223
  # Parse a non-polymer
1218
- elif (entity_type == "ligand") and ("ccd" in items[0][entity_type]):
1224
+ elif (entity_type == "ligand") and "ccd" in (items[0][entity_type]):
1219
1225
  seq = items[0][entity_type]["ccd"]
1220
1226
 
1221
1227
  if isinstance(seq, str):
@@ -1307,60 +1313,6 @@ def parse_boltz_schema( # noqa: C901, PLR0915, PLR0912
1307
1313
  "cyclic", False
1308
1314
  ), "Cyclic flag is not supported for ligands"
1309
1315
 
1310
- elif (entity_type == "ligand") and ("sdf" in items[0][entity_type]):
1311
- # Handle SDF file
1312
- sdf_path = Path(items[0][entity_type]["sdf"])
1313
- from boltz.data.parse.sdf import parse_sdf
1314
- target = parse_sdf(sdf_path, ccd, mol_dir)
1315
- mol = target["sequences"][0]["ligand"]["smiles"]
1316
-
1317
- if affinity:
1318
- mol = standardize(mol)
1319
-
1320
- mol = AllChem.MolFromSmiles(mol)
1321
- mol = AllChem.AddHs(mol)
1322
-
1323
- # Set atom names
1324
- canonical_order = AllChem.CanonicalRankAtoms(mol)
1325
- for atom, can_idx in zip(mol.GetAtoms(), canonical_order):
1326
- atom_name = atom.GetSymbol().upper() + str(can_idx + 1)
1327
- if len(atom_name) > 4:
1328
- msg = (
1329
- f"{mol} has an atom with a name longer than "
1330
- f"4 characters: {atom_name}."
1331
- )
1332
- raise ValueError(msg)
1333
- atom.SetProp("name", atom_name)
1334
-
1335
- success = compute_3d_conformer(mol)
1336
- if not success:
1337
- msg = f"Failed to compute 3D conformer for {mol}"
1338
- raise ValueError(msg)
1339
-
1340
- mol_no_h = AllChem.RemoveHs(mol, sanitize=False)
1341
- affinity_mw = AllChem.Descriptors.MolWt(mol_no_h) if affinity else None
1342
- extra_mols[f"LIG{ligand_id}"] = mol_no_h
1343
- residue = parse_ccd_residue(
1344
- name=f"LIG{ligand_id}",
1345
- ref_mol=mol,
1346
- res_idx=0,
1347
- )
1348
-
1349
- ligand_id += 1
1350
- parsed_chain = ParsedChain(
1351
- entity=entity_id,
1352
- residues=[residue],
1353
- type=const.chain_type_ids["NONPOLYMER"],
1354
- cyclic_period=0,
1355
- sequence=None,
1356
- affinity=affinity,
1357
- affinity_mw=affinity_mw,
1358
- )
1359
-
1360
- assert not items[0][entity_type].get(
1361
- "cyclic", False
1362
- ), "Cyclic flag is not supported for ligands"
1363
-
1364
1316
  else:
1365
1317
  msg = f"Invalid entity type: {entity_type}"
1366
1318
  raise ValueError(msg)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: boltz-vsynthes
3
- Version: 1.0.30
3
+ Version: 1.0.31
4
4
  Summary: Boltz for VSYNTHES
5
5
  Requires-Python: <3.13,>=3.10
6
6
  Description-Content-Type: text/markdown
@@ -40,7 +40,7 @@ boltz/data/parse/mmcif.py,sha256=25kEXCkx-OuaawAs7cdz0fxdRu5_CCO0AV00u84PrjQ,368
40
40
  boltz/data/parse/mmcif_with_constraints.py,sha256=WHYZckSqUwu-Nb9vmVmxHmC7uxwVrF7AVUeVKsc5wGQ,51473
41
41
  boltz/data/parse/pdb.py,sha256=iybk4p2UgUy_ABGprDq_xxyPSdm1HAZsGTM0lhxVEwM,1654
42
42
  boltz/data/parse/pdb_download.py,sha256=wge-scX-lOatX0q83W1wOsaql99rYp-6uGWSHEc995M,2718
43
- boltz/data/parse/schema.py,sha256=kNu28U2_MGiecwWNlcxgaDH3WOcO0P-q2LdoSPSb66w,63826
43
+ boltz/data/parse/schema.py,sha256=9H7ZJpKb22KHXmfJAjG_0jz7VbZ1LAYt5eVp34_nwVw,62176
44
44
  boltz/data/parse/sdf.py,sha256=fs3MQVClDcCzxJaeVYiDuoh-fUrYc8Tcd5Bz8ws3FKI,2052
45
45
  boltz/data/parse/yaml.py,sha256=GRFRMtDD4PQ4PIpA_S1jj0vRaEu2LlZd_g4rN1zUrNo,1505
46
46
  boltz/data/sample/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -107,9 +107,9 @@ boltz/model/optim/scheduler.py,sha256=nB4jz0CZ4pR4n08LQngExL_pNycIdYI8AXVoHPnZWQ
107
107
  boltz/model/potentials/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
108
108
  boltz/model/potentials/potentials.py,sha256=vev8Vjfs-ML1hyrdv_R8DynG4wSFahJ6nzPWp7CYQqw,17507
109
109
  boltz/model/potentials/schedules.py,sha256=m7XJjfuF9uTX3bR9VisXv1rvzJjxiD8PobXRpcBBu1c,968
110
- boltz_vsynthes-1.0.30.dist-info/licenses/LICENSE,sha256=8GZ_1eZsUeG6jdqgJJxtciWzADfgLEV4LY8sKUOsJhc,1102
111
- boltz_vsynthes-1.0.30.dist-info/METADATA,sha256=LCqHhIkKBAtMf8t6kbT4xoPr54lLZb86Tuy9KOgWYdc,7171
112
- boltz_vsynthes-1.0.30.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
113
- boltz_vsynthes-1.0.30.dist-info/entry_points.txt,sha256=n5a5I35ntu9lmyr16oZgHPFY0b0YxjiixY7m7nbMTLc,41
114
- boltz_vsynthes-1.0.30.dist-info/top_level.txt,sha256=MgU3Jfb-ctWm07YGMts68PMjSh9v26D0gfG3dFRmVFA,6
115
- boltz_vsynthes-1.0.30.dist-info/RECORD,,
110
+ boltz_vsynthes-1.0.31.dist-info/licenses/LICENSE,sha256=8GZ_1eZsUeG6jdqgJJxtciWzADfgLEV4LY8sKUOsJhc,1102
111
+ boltz_vsynthes-1.0.31.dist-info/METADATA,sha256=4hMLLLOG2rXQo4bR4F_kU_jxyKnOVVQhrXiwwsHxDtk,7171
112
+ boltz_vsynthes-1.0.31.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
113
+ boltz_vsynthes-1.0.31.dist-info/entry_points.txt,sha256=n5a5I35ntu9lmyr16oZgHPFY0b0YxjiixY7m7nbMTLc,41
114
+ boltz_vsynthes-1.0.31.dist-info/top_level.txt,sha256=MgU3Jfb-ctWm07YGMts68PMjSh9v26D0gfG3dFRmVFA,6
115
+ boltz_vsynthes-1.0.31.dist-info/RECORD,,