Skip to content

Commit 2018578

Browse files
authored
Merge pull request #861 from padix-key/issue-860
Always use continuous atom IDs
2 parents 5fde24b + 42204ba commit 2018578

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/biotite/structure/io/pdbx/convert.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ def set_structure(
865865
866866
This will save the coordinates, the mandatory annotation categories
867867
and the optional annotation categories
868-
``atom_id``, ``b_factor``, ``occupancy`` and ``charge``.
868+
``b_factor``, ``occupancy`` and ``charge``.
869869
If the atom array (stack) contains the annotation ``'atom_id'``,
870870
these values will be used for atom numbering instead of continuous
871871
numbering.
@@ -950,8 +950,6 @@ def set_structure(
950950
atom_site["auth_atom_id"] = atom_site["label_atom_id"]
951951

952952
annot_categories = array.get_annotation_categories()
953-
if "atom_id" in annot_categories:
954-
atom_site["id"] = np.copy(array.atom_id)
955953
if "b_factor" in annot_categories:
956954
atom_site["B_iso_or_equiv"] = np.copy(array.b_factor)
957955
if "occupancy" in annot_categories:
@@ -1019,9 +1017,9 @@ def set_structure(
10191017
np.arange(1, array.stack_depth() + 1, dtype=np.int32),
10201018
repeats=array.array_length(),
10211019
)
1022-
if "atom_id" not in annot_categories:
1023-
# Count from 1
1024-
atom_site["id"] = np.arange(1, len(atom_site["group_PDB"]) + 1)
1020+
# `atom_site.id` values must be unique across all models
1021+
# -> Use continuous numbering
1022+
atom_site["id"] = np.arange(1, atom_site.row_count + 1)
10251023
block["atom_site"] = atom_site
10261024

10271025
# Write box into file

0 commit comments

Comments
 (0)