def test_find_spacegroup(self): self.assertEqual(gemmi.SpaceGroup('P21212').hm, 'P 21 21 2') self.assertEqual(gemmi.find_spacegroup_by_name('P21').hm, 'P 1 21 1') self.assertEqual(gemmi.find_spacegroup_by_name('P 2').hm, 'P 1 2 1') def check_xhm(name, xhm): self.assertEqual(gemmi.SpaceGroup(name).xhm(), xhm) check_xhm('R 3 2', 'R 3 2:H') check_xhm('R 3 2:h', 'R 3 2:H') check_xhm('R32:H', 'R 3 2:H') check_xhm('H32', 'R 3 2:H') check_xhm('R 3 2:R', 'R 3 2:R') check_xhm('P6', 'P 6') check_xhm('P 6', 'P 6') check_xhm('P65', 'P 65') check_xhm('I1211', 'I 1 21 1') check_xhm('Aem2', 'A b m 2') check_xhm('C c c e', 'C c c a:1') check_xhm('i2', 'I 1 2 1') check_xhm('I 41/A', 'I 41/a:1') check_xhm('I -4 2 D', 'I -4 2 d') check_xhm('P 1 21/c 1', 'P 1 21/c 1') check_xhm('P 21 21 2 A', 'P 21212(a)') check_xhm('B 2', 'B 1 1 2') self.assertRaises(ValueError, gemmi.SpaceGroup, 'i3') self.assertEqual(gemmi.find_spacegroup_by_number(5).hm, 'C 1 2 1') self.assertEqual(gemmi.SpaceGroup(4005).hm, 'I 1 2 1') self.assertIsNone(gemmi.find_spacegroup_by_name('abc'))
def __setstate__(self, state): data = state["data"] spacegroup = state["spacegroup"] unit_cell = state["unit_cell"] mtz = gemmi.Mtz() mtz.spacegroup = gemmi.find_spacegroup_by_number(spacegroup) mtz.cell.set( unit_cell[0], unit_cell[1], unit_cell[2], unit_cell[3], unit_cell[4], unit_cell[5], ) datasets = state["datasets"] columns = state["columns"] for dataset_id, dataset_label in datasets.items(): mtz.add_dataset(dataset_label) dataset_columns = columns[dataset_id] for column_name, column_type in dataset_columns.items(): mtz.add_column(column_name, column_type) mtz.set_data(data) self.mtz = mtz
def compare_short_names_with_symop_lib(): for line in open('symop.lib'): if line and not line[0].isspace(): fields = line.partition('!')[0].split(None, 6) #spacegroups = shlex.split(fields[-1]) g = gemmi.find_spacegroup_by_number(int(fields[0])) if fields[3] != g.short_name(): print('[%s] %s %s' % (g.xhm(), g.short_name(), fields[3]))