Skip to content

Commit c3b8be2

Browse files
committed
Merge branch 'mod_type_of_json' into 'main'
[fix] Modify the value type of the covalent_bonds field in json_maker See merge request molecule/protenix!38
2 parents eae8b55 + 31f982d commit c3b8be2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

protenix/data/json_maker.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ def merge_covalent_bonds(
4545
for bond_dict in covalent_bonds:
4646
bond_unique_string = []
4747
entity_counts = (
48-
all_entity_counts[bond_dict["left_entity"]],
49-
all_entity_counts[bond_dict["right_entity"]],
48+
all_entity_counts[str(bond_dict["left_entity"])],
49+
all_entity_counts[str(bond_dict["right_entity"])],
5050
)
5151
for i in ["left", "right"]:
5252
for j in ["entity", "position", "atom"]:
5353
k = f"{i}_{j}"
54-
bond_unique_string.append(bond_dict[k])
54+
bond_unique_string.append(str(bond_dict[k]))
5555
bond_unique_string = "_".join(bond_unique_string)
5656
bonds_recorder[bond_unique_string].append(bond_dict)
5757
bonds_entity_counts[bond_unique_string] = entity_counts
@@ -220,10 +220,10 @@ def atom_array_to_input_json(
220220
for idx, i in enumerate(["left", "right"]):
221221
atom = atom_array[atoms[idx]]
222222
positon = atom.res_id
223-
bond_dict[f"{i}_entity"] = label_entity_id_to_entity_id_in_json[
224-
atom.label_entity_id
225-
]
226-
bond_dict[f"{i}_position"] = str(positon)
223+
bond_dict[f"{i}_entity"] = int(
224+
label_entity_id_to_entity_id_in_json[atom.label_entity_id]
225+
)
226+
bond_dict[f"{i}_position"] = int(positon)
227227
bond_dict[f"{i}_atom"] = atom.atom_name
228228
bond_dict[f"{i}_copy"] = int(atom.copy_id)
229229

protenix/data/json_to_feature.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def add_bonds_between_entities(self, atom_array: AtomArray) -> AtomArray:
185185
bond_atoms = []
186186
for i in ["left", "right"]:
187187
entity_id = int(bond_info_dict[f"{i}_entity"])
188-
copy_id = bond_info_dict.get(f"{i}_copy")
188+
copy_id = int(bond_info_dict.get(f"{i}_copy"))
189189
position = int(bond_info_dict[f"{i}_position"])
190190
atom_name = bond_info_dict[f"{i}_atom"]
191191

0 commit comments

Comments
 (0)