def __init__(self, file_object=None, file_path=None, cif_model=None, data_structure_builder=None, data_block_name=None, base_array_info=None, style="classic", **kwds): assert file_object is None or cif_model is None if data_structure_builder is None: data_structure_builders = (builders.miller_array_builder, builders.crystal_structure_builder) else: assert data_structure_builder in ( builders.miller_array_builder, builders.crystal_structure_builder) data_structure_builders = (data_structure_builder, ) self.xray_structures = OrderedDict() self.miller_arrays = OrderedDict() self.original_arrays = OrderedDict() if cif_model is None: cif_model = reader(file_path=file_path, file_object=file_object).model() if not len(cif_model): raise Sorry("No data block found in CIF") if data_block_name is not None and not data_block_name in cif_model: if (file_path is None): msg = 'Unknown CIF data block name: "%s"' % data_block_name else: msg = 'Unknown CIF data block name "%s" in file: "%s"' % ( data_block_name, file_path) raise RuntimeError(msg) errors = [] wavelengths = {} for key, block in cif_model.items(): if data_block_name is not None and key != data_block_name: continue for builder in data_structure_builders: if builder == builders.crystal_structure_builder: if '_atom_site_fract_x' in block or '_atom_site_Cartn_x' in block: self.xray_structures.setdefault( key, builder(block).structure) elif builder == builders.miller_array_builder: block_wavelengths = builders.get_wavelengths(block) if (block_wavelengths is not None): wavelengths = block_wavelengths if base_array_info is not None: base_array_info = base_array_info.customized_copy( labels=[key]) if ('_refln_index_h' in block or '_refln.index_h' in block or '_diffrn_refln' in block): b = builder(block, base_array_info=base_array_info, wavelengths=wavelengths, style=style) self.miller_arrays.setdefault(key, b.arrays()) self.original_arrays.setdefault(key, b.origarrays())
def __init__(self, file_object=None, file_path=None, cif_model=None, data_structure_builder=None, data_block_name=None, base_array_info=None, **kwds): assert file_object is None or cif_model is None if data_structure_builder is None: data_structure_builders = ( builders.miller_array_builder, builders.crystal_structure_builder) else: assert data_structure_builder in ( builders.miller_array_builder, builders.crystal_structure_builder) data_structure_builders = (data_structure_builder,) self.xray_structures = OrderedDict() self.miller_arrays = OrderedDict() if cif_model is None: cif_model = reader(file_path=file_path, file_object=file_object).model() if not len(cif_model): raise Sorry("No data block found in CIF") if data_block_name is not None and not data_block_name in cif_model: if (file_path is None): msg = 'Unknown CIF data block name: "%s"' % data_block_name else: msg = 'Unknown CIF data block name "%s" in file: "%s"' % ( data_block_name, file_path) raise RuntimeError(msg) errors = [] wavelengths = {} for key, block in cif_model.items(): if data_block_name is not None and key != data_block_name: continue for builder in data_structure_builders: if builder == builders.crystal_structure_builder: if '_atom_site_fract_x' in block or '_atom_site_Cartn_x' in block: self.xray_structures.setdefault(key, builder(block).structure) elif builder == builders.miller_array_builder: block_wavelengths = builders.get_wavelengths(block) if (block_wavelengths is not None) : wavelengths = block_wavelengths if base_array_info is not None: base_array_info = base_array_info.customized_copy(labels=[key]) if ( '_refln_index_h' in block or '_refln.index_h' in block or '_diffrn_refln' in block ): self.miller_arrays.setdefault( key, builder(block, base_array_info=base_array_info, wavelengths=wavelengths).arrays())