biotite-dev / biotite

A comprehensive library for computational molecular biology
https://www.biotite-python.org
BSD 3-Clause "New" or "Revised" License
581 stars 92 forks source link

Passing empty array leads to malformed PDBx file #582

Closed padix-key closed 4 weeks ago

padix-key commented 1 month ago

Setting CIFData with an empty array is currently not caught, although the CIF format does not allow empty categories. This may happen rather often implicitly when setting a structure with an empty BondList (not None, but length 0). This is an example of a resulting malformed CIF file:

data_structure
#
loop_
_struct_conn.id 
_struct_conn.conn_type_id 
_struct_conn.pdbx_value_order 
_struct_conn.ptnr1_label_asym_id 
_struct_conn.ptnr2_label_asym_id 
_struct_conn.ptnr1_label_comp_id 
_struct_conn.ptnr2_label_comp_id 
_struct_conn.ptnr1_label_seq_id 
_struct_conn.ptnr2_label_seq_id 
_struct_conn.ptnr1_label_atom_id 
_struct_conn.ptnr2_label_atom_id 
_struct_conn.pdbx_ptnr1_PDB_ins_code 
_struct_conn.pdbx_ptnr2_PDB_ins_code 
#
loop_
_chem_comp_bond.comp_id 
_chem_comp_bond.atom_id_1 
_chem_comp_bond.atom_id_2 
_chem_comp_bond.value_order 
_chem_comp_bond.pdbx_aromatic_flag 
_chem_comp_bond.pdbx_stereo_config 
_chem_comp_bond.pdbx_ordinal 
#
_atom_site.group_PDB            HETATM
_atom_site.type_symbol          MG
_atom_site.label_atom_id        A0
_atom_site.label_alt_id         .
_atom_site.label_comp_id        LIG
_atom_site.label_asym_id        ''
_atom_site.label_entity_id      1
_atom_site.label_seq_id         0
_atom_site.pdbx_PDB_ins_code    .
_atom_site.auth_seq_id          0
_atom_site.auth_comp_id         LIG
_atom_site.auth_asym_id         ''
_atom_site.auth_atom_id         A0
_atom_site.pdbx_formal_charge   +2
_atom_site.Cartn_x              4.776
_atom_site.Cartn_y              33.728
_atom_site.Cartn_z              19.216
_atom_site.pdbx_PDB_model_num   1
_atom_site.id                   1
#