Skip to content

Commit

Permalink
Also add moiety formula after checkcif
Browse files Browse the repository at this point in the history
  • Loading branch information
dkratzert committed Sep 10, 2023
1 parent 28d0764 commit c3f01b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion finalcif/appwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,12 @@ def do_offline_checkcif(self) -> None:
runner.tick.connect(self.append_to_ciflog_without_newline)
runner.finished.connect(lambda: self.ui.CheckcifButton.setEnabled(True))
runner.run_process()
app.processEvents()
runner.formula.connect(self.add_moiety_furmula)

def add_moiety_furmula(self, formula_moiety):
moiety = self.ui.cif_main_table.getTextFromKey(key='_chemical_formula_moiety', col=Column.CIF)
if formula_moiety and moiety in ['', '?'] and not self.cif.is_multi_cif:
self.ui.cif_main_table.setText(key='_chemical_formula_moiety', txt=formula_moiety, column=Column.EDIT)

def append_to_ciflog_without_newline(self, text: str = '') -> None:
self.ui.CheckCifLogPlainTextEdit.moveCursor(QtGui.QTextCursor.End)
Expand Down
2 changes: 2 additions & 0 deletions finalcif/tools/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

class PlatonRunner(QtCore.QObject):
finished = QtCore.pyqtSignal(bool)
formula = QtCore.pyqtSignal(str)
tick = QtCore.pyqtSignal(str)

def __init__(self, parent, output_widget: QPlainTextEdit, log_widget: QPlainTextEdit, cif_file: Path):
Expand Down Expand Up @@ -80,6 +81,7 @@ def _parse_chk_file(self):
for num, line in enumerate(self.chk_file_text.splitlines(keepends=False)):
if line.startswith('# MoietyFormula'):
self.formula_moiety = ' '.join(line.split(' ')[2:])
self.formula.emit(self.formula_moiety)
if line.startswith('# Z'):
self.Z = line[19:24].strip(' ')

Expand Down

0 comments on commit c3f01b0

Please sign in to comment.