def write(self):
if not self._have_lock:<EOL><INDENT>raise LockError("<STR_LIT>")<EOL><DEDENT>out = [item[<NUM_LIT:2>] for item in self._heap if (isfinite(item[<NUM_LIT:2>]) and item[<NUM_LIT:2>] in self._data)]<EOL>missing = set(self._data.keys()).difference(out)<EOL>out = [self._data[seq] for seq in out]<EOL>out.extend(self._data[seq] for seq in missing)<EOL>outdict = {"<STR_LIT>": out}<EOL>try:<EOL><INDENT>outdict['<STR_LIT>'] = self.resdatetime<EOL><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT>json_string = json.dumps(outdict, ensure_ascii=False, sort_keys=True).replace('<STR_LIT>', '<STR_LIT>') + '<STR_LIT:\n>'<EOL>with open(self._jsonfile, '<STR_LIT:w>') as f:<EOL><INDENT>f.write(json_string)<EOL><DEDENT>del json_string <EOL>if self._txtfile:<EOL><INDENT>txt_string = '<STR_LIT>'.join(str(ali)+'<STR_LIT:\n>' for ali in sorted(out, key=lambda ali: ali.seq) if ali.is_minimally_valid())<EOL>with open(self._txtfile, '<STR_LIT:w>') as f:<EOL><INDENT>f.write(txt_string)<EOL><DEDENT>del txt_string<EOL><DEDENT>del out<EOL>
Finalize self to file. Totally overwrites old data with current data.