Skip to content

symmetry

point_group_symmetry_operatorsT module-attribute

point_group_symmetry_operatorsT: dict[str, ndarray] = unpickle(point_group_symmetry_operatorT_location)

A mapping of the point group name (in Hermann-Mauguin notation) to the corresponding symmetry operators Formatted as {'symmetry': rotations[N, 3, 3], ...} where the rotations are pre-transposed to match requirements of np.matmul(coords, rotation)

space_group_symmetry_operatorsT module-attribute

space_group_symmetry_operatorsT: dict[str, ndarray] = unpickle(space_group_symmetry_operatorT_location)

A mapping of the space group name (in Hermann-Mauguin notation) to the corresponding symmetry operators Formatted as {'symmetry': (rotations[N, 3, 3], translations[N, 1, 3]), ...} where the rotations are pre-transposed to match requirements of np.matmul(coords, rotation)

generate_cryst1_record

generate_cryst1_record(dimensions: tuple[float, float, float, float, float, float], space_group: str) -> str

Format the CRYST1 record from specified unit cell dimensions and space group for a .pdb file

Parameters:

  • dimensions (tuple[float, float, float, float, float, float]) –

    Containing a, b, c (Angstroms) alpha, beta, gamma (degrees)

  • space_group (str) –

    The space group of interest in compact format

Returns: The CRYST1 record

Source code in symdesign/utils/symmetry.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
def generate_cryst1_record(dimensions: tuple[float, float, float, float, float, float], space_group: str) -> str:
    """Format the CRYST1 record from specified unit cell dimensions and space group for a .pdb file

    Args:
        dimensions: Containing a, b, c (Angstroms) alpha, beta, gamma (degrees)
        space_group: The space group of interest in compact format
    Returns:
        The CRYST1 record
    """
    if space_group in space_group_cryst1_fmt_dict or space_group in space_group_hm_to_simple_dict:
        formatted_space_group = space_group_cryst1_fmt_dict.get(space_group, space_group)
    elif space_group in layer_group_cryst1_fmt_dict or space_group in layer_group_hm_to_simple_dict:
        formatted_space_group = layer_group_cryst1_fmt_dict.get(space_group, space_group)
        dimensions = list(dimensions)
        dimensions[2] = 1.
        dimensions[4] = dimensions[5] = 90.
    else:
        raise ValueError(
            f"The space group '{space_group}' isn't supported")

    try:
        return 'CRYST1{dim[0]:9.3f}{dim[1]:9.3f}{dim[2]:9.3f}{dim[3]:7.2f}{dim[4]:7.2f}{dim[5]:7.2f} {sg:<11s}{z:4d}\n'\
            .format(dim=dimensions, sg=formatted_space_group, z=space_group_number_operations[space_group])
    except TypeError:  # NoneType was passed
        raise ValueError(
            f"Can't {generate_cryst1_record.__name__} without passing 'dimensions'")

get_ptgrp_sym_op

get_ptgrp_sym_op(sym_type: str, expand_matrix_dir: Union[str, bytes] = os.path.join(putils.sym_op_location, 'POINT_GROUP_SYMM_OPERATORS')) -> List[List]

Get the symmetry operations for a specified point group oriented in the canonical orientation

Parameters:

  • sym_type (str) –

    The name of the symmetry

  • expand_matrix_dir (Union[str, bytes], default: join(sym_op_location, 'POINT_GROUP_SYMM_OPERATORS') ) –

    The disk location of a directory with symmetry name labeled expand matrices

Returns: The rotation matrices to perform point group expansion

Source code in symdesign/utils/symmetry.py
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
def get_ptgrp_sym_op(sym_type: str,
                     expand_matrix_dir: Union[str, bytes] = os.path.join(putils.sym_op_location,
                                                                         'POINT_GROUP_SYMM_OPERATORS')) -> List[List]:
    """Get the symmetry operations for a specified point group oriented in the canonical orientation

    Args:
        sym_type: The name of the symmetry
        expand_matrix_dir: The disk location of a directory with symmetry name labeled expand matrices
    Returns:
        The rotation matrices to perform point group expansion
    """
    expand_matrix_filepath = os.path.join(expand_matrix_dir, f'{sym_type}.txt')
    with open(expand_matrix_filepath, 'r') as f:
        line_count = 0
        rotation_matrices = []
        mat = []
        for line in f.readlines():
            line = line.split()
            if len(line) == 3:
                mat.append([float(s) for s in line])
                line_count += 1
                if line_count % 3 == 0:
                    rotation_matrices.append(mat)
                    mat = []

        return rotation_matrices