def write_and_read(self, st, via_cif): if via_cif: doc = st.make_mmcif_document() st = gemmi.make_structure_from_block(doc[0]) out_name = get_path_for_tempfile() st.write_pdb(out_name) return read_lines_and_remove(out_name)
def test_read_write(self): path = full_path('5e5z.mtz') mtz = gemmi.read_mtz_file(path) self.assertEqual(mtz.spacegroup.hm, 'P 1 21 1') out_name = get_path_for_tempfile() mtz.write_to_file(out_name) mtz2 = gemmi.read_mtz_file(out_name) os.remove(out_name) self.assertEqual(mtz2.spacegroup.hm, 'P 1 21 1')
def test_blank_chain(self): st = gemmi.read_pdb_string(BLANK_CHAIN_FRAGMENT) out_name = get_path_for_tempfile() st.write_minimal_pdb(out_name) out = read_lines_and_remove(out_name) # CRYST1 differs (50.000 not 50.00 and added P1). # ATOM lines have added element names. trimmed_out = [line[:66] for line in out[1:]] self.assertEqual(trimmed_out, BLANK_CHAIN_FRAGMENT.splitlines()[1:])
def write_and_read(self, st, via_cif): if via_cif: st.setup_entities() st.assign_label_seq_id() doc = st.make_mmcif_document() st = gemmi.make_structure_from_block(doc[0]) out_name = get_path_for_tempfile() st.write_pdb(out_name) return read_lines_and_remove(out_name)
def test_read_1pfe_cif(self): st = gemmi.read_structure(full_path('1pfe.cif.gz')) self.check_1pfe(st) # write structure to cif and read it back out_name = get_path_for_tempfile(suffix='.cif') st.make_mmcif_document().write_file(out_name) st2 = gemmi.read_structure(out_name) os.remove(out_name) self.check_1pfe(st2)
def test_read_write(self): path = full_path('5e5z.mtz') mtz = gemmi.read_mtz_file(path) self.assertEqual(mtz.spacegroup.hm, 'P 1 21 1') out_name = get_path_for_tempfile() mtz.write_to_file(out_name) mtz2 = gemmi.read_mtz_file(out_name) os.remove(out_name) self.assertEqual(mtz2.spacegroup.hm, 'P 1 21 1') if numpy is not None: self.assert_numpy_equal(numpy.array(mtz, copy=False), mtz.array) self.assert_numpy_equal(mtz.array, mtz2.array)