Skip to content

Commit 23b084b

Browse files
authored
syncing covalent bonds (#280)
1 parent e8117a2 commit 23b084b

File tree

7 files changed

+40
-8
lines changed

7 files changed

+40
-8
lines changed

esm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.2.2.post2"
1+
__version__ = "3.2.3"

esm/sdk/base_forge_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ async def _async_post(
128128
except Exception as e:
129129
raise ESMProteinError(
130130
error_code=500,
131-
error_msg=f"Failed to submit request to {endpoint}. Error: {e}",
131+
error_msg=f"Failed to submit request to {endpoint}. Error: {str(e)}",
132132
)
133133

134134
def _post(
@@ -158,5 +158,5 @@ def _post(
158158
except Exception as e:
159159
raise ESMProteinError(
160160
error_code=500,
161-
error_msg=f"Failed to submit request to {endpoint}. Error: {e}",
161+
error_msg=f"Failed to submit request to {endpoint}. Error: {str(e)}",
162162
)

esm/utils/msa/filter_sequences.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import tempfile
23
from pathlib import Path
34

@@ -53,7 +54,9 @@ def hhfilter(
5354
qsc: float = -20.0,
5455
binary: str = "hhfilter",
5556
) -> list[int]:
56-
with tempfile.TemporaryDirectory(dir="/dev/shm") as tempdirname:
57+
with tempfile.TemporaryDirectory(
58+
dir="/dev/shm" if os.path.exists("/dev/shm") else None
59+
) as tempdirname:
5760
tempdir = Path(tempdirname)
5861
fasta_file = tempdir / "input.fasta"
5962
fasta_file.write_text(

esm/utils/structure/input_builder.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,22 @@ class PocketConditioning:
5050
contacts: list[tuple[str, int]]
5151

5252

53+
@dataclass
54+
class CovalentBond:
55+
chain_id1: str
56+
res_idx1: int
57+
atom_idx1: int
58+
chain_id2: str
59+
res_idx2: int
60+
atom_idx2: int
61+
62+
5363
@dataclass
5464
class StructurePredictionInput:
5565
sequences: Sequence[ProteinInput | RNAInput | DNAInput | LigandInput]
5666
pocket: PocketConditioning | None = None
5767
distogram_conditioning: list[DistogramConditioning] | None = None
68+
covalent_bonds: list[CovalentBond] | None = None
5869

5970

6071
def serialize_structure_prediction_input(all_atom_input: StructurePredictionInput):
@@ -92,4 +103,20 @@ def create_chain_data(seq_input, chain_type: str) -> dict[str, Any]:
92103
else:
93104
raise ValueError(f"Unsupported sequence input type: {type(seq_input)}")
94105

95-
return {"sequences": sequences}
106+
result: dict[str, Any] = {"sequences": sequences}
107+
108+
# Add covalent bonds if present
109+
if all_atom_input.covalent_bonds is not None:
110+
result["covalent_bonds"] = [
111+
{
112+
"chain_id1": bond.chain_id1,
113+
"res_idx1": bond.res_idx1,
114+
"atom_idx1": bond.atom_idx1,
115+
"chain_id2": bond.chain_id2,
116+
"res_idx2": bond.res_idx2,
117+
"atom_idx2": bond.atom_idx2,
118+
}
119+
for bond in all_atom_input.covalent_bonds
120+
]
121+
122+
return result

esm/utils/structure/molecular_complex.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class MolecularComplexResult:
3535
pair_chains_iptm: torch.Tensor | None = None
3636
output_embedding_sequence: torch.Tensor | None = None
3737
output_embedding_pair_pooled: torch.Tensor | None = None
38+
residue_index: torch.Tensor | None = None
39+
entity_id: torch.Tensor | None = None
3840

3941

4042
@dataclass

pixi.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "esm"
3-
version = "3.2.2.post2"
3+
version = "3.2.3"
44
description = "EvolutionaryScale open model repository"
55
readme = "README.md"
66
requires-python = ">=3.12,<3.13"

0 commit comments

Comments
 (0)