Closed keitaroyam closed 3 years ago
It's a known problem, but I don't know what would be a good solution. I see two options: 1) decide what is important to have and store it in Structure, 2) when writing cif file, start from the original cif Document and modify only selected categories.
What do you do with the structure between reading and writing?
For the moment I apply translation for all coordinates and modify _struct_ncs_oper. I am happy with the option 2.
I added function update_mmcif_block() that should be able to do this, see https://gemmi.readthedocs.io/en/latest/mol.html#id3
In your case it would be:
groups = gemmi.MmcifOutputGroups(False)
groups.ncs = True
groups.atoms = True
I haven't tested it much and I suspect that it doesn't do a sensible thing for all combinations of parameters.
Thanks! I did the following, and it looks almost perfect.
import gemmi
structure = gemmi.read_structure("refmac1.mmcif")
groups = gemmi.MmcifOutputGroups(False)
groups.ncs = True
groups.atoms = True
doc = gemmi.cif.read("refmac1.mmcif")
block = doc.find_block(structure.info["_entry.id"])
structure.update_mmcif_block(block, groups)
doc.write_file('tst.cif')
The only difference is that file following records were lost, I need to check if it is ok.
_atom_site.auth_atom_id
_atom_site.auth_comp_id
_atom_site.calc_flag
_atom_site.group_pdb
_atom_site.pdbx_pdb_atom_name
_atom_site.pdbx_pdb_residue_name
_atom_site.pdbx_pdb_residue_no
_atom_site.auth_atom_id _atom_site.auth_comp_id
I skipped these two intentionally. They are always identical with the corresponding _atom_site.label_*_id
.
_atom_site.calc_flag
I should add this. It haven't been used by the wwPDB until recently. But I vaguely remember this flag being discussed during mmCIF WG meetings this year. And I see it's already used in 7ATL. So I guess I should adapt gemmi to read and write calc_flag.
_atom_site.group_pdb
This is not particularly useful, because Refmac (and many other programs) assign HETATM differently than the software used by wwPDB. The difference is that the latter uses HETATM also for not natural residues in polymer. But I could add it if needed.
_atom_site.pdbx_pdb_atom_name _atom_site.pdbx_pdb_residue_name _atom_site.pdbx_pdb_residue_no
I think Refmac should stop writing these.
Thank you. I am happy if _atom_site.calc_flag is added (to indicate riding hydrogen or not). I noticed atom_site.pdbx_tls_group_id was not kept. Can you add this?
ok, I added both calc_flag and pdbx_tls_group_id
Thanks!
Hello!
I is it possible to also include _atom_site.group_pdb in the properties handled by update_mmcif_block() please? I have some analysis where that information is useful to me.
Thanks by advance !
@xvlaurent ok, I added an option for _atom_site.group_pdb
st = ...
groups = gemmi.MmcifOutputGroups(True)
groups.group_pdb = True
doc = gemmi.cif.Document()
block = doc.add_new_block('new')
st.update_mmcif_block(block, groups)
doc.write_file('out.cif')
Thanks for your work !
Opening refmac mmcif by
gemmi.read_structure("refmac.mmcif")
and saving it bymake_mmcif_document().write_file("foo.mmcif")
results in loss of some records. Can gemmi keep them? If it is too much trouble I can work on it. Currently, following records are lost.