Skip to content

Commit

Permalink
Also write .fab files when extracting CIF contents
Browse files Browse the repository at this point in the history
  • Loading branch information
dkratzert committed Sep 30, 2024
1 parent 44d0410 commit 8eed462
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions finalcif/cif/cif_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ def _hkl_from_shelx(self) -> str:
print('No hkl data found in CIF!, {}'.format(e))
return ''

@property
def fab_file(self):
if self['_shelx_fab_file']:
return self['_shelx_fab_file']
return ''

@property
def hkl_as_cif(self) -> str:
return HKL(self.hkl_file, self.block.name, hklf_type=self.hklf_number).hkl_as_cif
Expand Down Expand Up @@ -823,7 +829,7 @@ def angles(self, without_H: bool = False) -> Generator:
publ_loop = self.block.find_loop('_geom_angle_publ_flag')
angle = namedtuple('angle', ('label1', 'label2', 'label3', 'angle_val', 'symm1', 'symm2'))
for label1, label2, label3, angle_val, symm1, symm2, publ in \
zip(label1, label2, label3, angle_val, symm1, symm2, publ_loop):
zip(label1, label2, label3, angle_val, symm1, symm2, publ_loop):
if (without_H and (self.ishydrogen(label1) or self.ishydrogen(label2) or
self.ishydrogen(label3)) or (self.yes_not_set(publ))):
continue
Expand Down Expand Up @@ -895,7 +901,7 @@ def hydrogen_bonds(self) -> Generator:
hydr = namedtuple('HydrogenBond', ('label_d', 'label_h', 'label_a', 'dist_dh', 'dist_ha', 'dist_da',
'angle_dha', 'symm'))
for label_d, label_h, label_a, dist_dh, dist_ha, dist_da, angle_dha, symm, publ in (
zip(label_d, label_h, label_a, dist_dh, dist_ha, dist_da, angle_dha, symm, publ_loop)):
zip(label_d, label_h, label_a, dist_dh, dist_ha, dist_da, angle_dha, symm, publ_loop)):
if self.yes_not_set(publ):
continue
if self.picometer:
Expand Down
5 changes: 5 additions & 0 deletions finalcif/tools/shred.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ def shred_cif(self) -> None:
suffix='_' + self._cif.block.name + '-finalcif.res')
hklfile_path = self._cif.finalcif_file_prefixed(prefix='',
suffix='_' + self._cif.block.name + '-finalcif.hkl')
fabfile_path = self._cif.finalcif_file_prefixed(prefix='',
suffix='_' + self._cif.block.name + '-finalcif.fab')
else:
resfile_path = self._cif.finalcif_file.with_suffix('.res')
hklfile_path = self._cif.finalcif_file.with_suffix('.hkl')
fabfile_path = self._cif.finalcif_file.with_suffix('.fab')
res_data = None
hkl_data = None
if not self._cif:
Expand All @@ -51,6 +54,8 @@ def shred_cif(self) -> None:
hkl_data = self.format_hkl_data(hkl_data)
if not self._write_hkl_file(hklfile_path, hkl_data):
return None
if fab_data := self._cif.fab_file:
self._write_hkl_file(fabfile_path, fab_data)
self._show_info(resfile_path, hklfile_path, res_data, hkl_data)

@staticmethod
Expand Down

0 comments on commit 8eed462

Please sign in to comment.