Skip to content

Commit 5314c5c

Browse files
:> reduction adjustments
:> search configs
1 parent c371a2e commit 5314c5c

4 files changed

Lines changed: 30 additions & 17 deletions

File tree

mxtaltools/dataset_utils/construction/featurization_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def crystal_filter(crystal,
315315
if any([len(component.atoms) == 0 for component in crystal.molecule.components]):
316316
return False, None, None, "Not all components have atoms"
317317
if len(reduced_crystal.asymmetric_unit_molecule.heavy_atoms) != len(
318-
crystal.molecule.heavy_atoms): # could make this done Z'-by-Z'
318+
crystal.asymmetric_unit_molecule.heavy_atoms): # could make this done Z'-by-Z'
319319
return False, None, None, "Aunit and mol heavy atoms disagree"
320320
if len(reduced_crystal.molecule.components) != crystal.z_prime:
321321
return False, None, None, "Z' != mol components"

mxtaltools/dataset_utils/construction/featurize_cif_chunks.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def process_chunk(chunk, chunk_ind, use_filenames_for_identifiers, protonation_s
124124
crystal_dict = extract_custom_cif_data(cif_path, crystal_dict)
125125

126126
"check sym ops"
127-
try:
127+
try: # todo upgrade this to detect if sym ops are identical but out of order
128128
sym_ops_are_standard = np.all(np.stack(SYM_OPS[crystal_dict['space_group_number']]) == np.stack(
129129
crystal_dict['symmetry_operators']))
130130
except ValueError: # sometimes, there are not even the correct multiplicity of space group indexing
@@ -399,14 +399,23 @@ def crystal_rebuild_checks(aunit_centroid,
399399
# protonation_state='deprotonated')
400400

401401
process_cifs_to_chunks(n_chunks=1,
402-
cifs_path=r"D:\crystal_datasets\nehzor",
403-
chunks_path='D:/crystal_datasets/nehzor/',
404-
chunk_prefix='nehzor',
402+
cifs_path=r"D:\crystal_datasets\nacjaf\nikos\round_2_cc_optimized_filtered",
403+
chunks_path='D:/crystal_datasets/nacjaf/',
404+
chunk_prefix='nacjaf',
405405
use_filenames_for_identifiers=False,
406-
target_identifiers=['NEHZOR','NEHZOR01'],
406+
target_identifiers=None,
407407
filter_by_targets=False,
408408
protonation_state='protonated')
409409

410+
# process_cifs_to_chunks(n_chunks=1,
411+
# cifs_path=r"D:\crystal_datasets\nehzor",
412+
# chunks_path='D:/crystal_datasets/nehzor/',
413+
# chunk_prefix='nehzor',
414+
# use_filenames_for_identifiers=False,
415+
# target_identifiers=['NEHZOR','NEHZOR01'],
416+
# filter_by_targets=False,
417+
# protonation_state='protonated')
418+
410419
# process_cifs_to_chunks(n_chunks=1,
411420
# cifs_path=r"D:\crystal_datasets\mipcas",
412421
# chunks_path='D:/crystal_datasets/',

mxtaltools/dataset_utils/data_class_methods/crystal_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def mono_reduction_penalty(self, cell_lengths, cell_angles, margin):
441441
# enforces our reduction scheme
442442
a, b, c = cell_lengths.unbind(dim=1)
443443
al, be, ga = cell_angles.unbind(dim=1)
444-
be_min_cos = (- a / 2 / c).clamp(min=-1)
444+
be_min_cos = (- a / c).clamp(min=-1)
445445
be_max_cos = 0
446446
beta_error = self.bounding_penalty(be.cos(), be_min_cos, be_max_cos, margin=margin)
447447

mxtaltools/dataset_utils/data_class_methods/crystal_ops.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from mxtaltools.common.ase_interface import ase_write_cif
1010
from mxtaltools.common.geometry_utils import enforce_crystal_system, batch_compute_fractional_transform, \
11-
cart2sph_rotvec, sph2cart_rotvec, crystal_parameter_distmat, sph_rotvec2lat, lat2sph_rotvec
11+
cart2sph_rotvec, sph2cart_rotvec, crystal_parameter_distmat, sph_rotvec2lat, lat2sph_rotvec, fractional_transform
1212
from mxtaltools.common.utils import softplus_shift, log_rescale_positive, get_point_density
1313
from mxtaltools.constants.asymmetric_units import ASYM_UNITS
1414
from mxtaltools.constants.space_group_info import SYM_OPS, LATTICE_TYPE
@@ -1513,26 +1513,27 @@ def compute_standard_cell(self, return_transform: bool = False):
15131513
target_params = self.full_cell_parameters()
15141514
std_params = []
15151515
permutations = []
1516-
1517-
for p in target_params:
1516+
self.pose_aunit()
1517+
self.build_unit_cell()
1518+
for ind, p in enumerate(target_params):
15181519
cellpar = p[:6].clone().numpy()
15191520
cellpar[3:] *= (180 / np.pi)
15201521

15211522
lattice = cellpar_to_cell(cellpar)
15221523
# dummy atom (needed for spglib)
1523-
positions = [[0, 0, 0]]
1524-
numbers = [1]
1524+
# positions = [[0, 0, 0]]
1525+
# numbers = [1]
1526+
positions = fractional_transform(self.unit_cell_pos[self.unit_cell_batch == ind], self.T_cf[ind])
1527+
numbers = self.z[self.batch == ind].repeat(self.sym_mult[ind]).numpy().tolist()
15251528
cell = (lattice, positions, numbers)
15261529
lattice_std, positions_std, numbers_std = spglib.standardize_cell(
15271530
cell,
15281531
to_primitive=False,
15291532
no_idealize=False
15301533
)
1531-
#lengths_old = np.linalg.norm(lattice, axis=1)
1532-
#lengths_new = np.linalg.norm(lattice_std, axis=1)
1533-
#perm = [np.argmin(np.abs(lengths_old - l)) for l in lengths_new]
1534-
P = np.linalg.inv(lattice) @ lattice_std
15351534
cellpar_std = cell_to_cellpar(lattice_std)
1535+
1536+
P = np.linalg.inv(lattice) @ lattice_std
15361537
std_params.append(cellpar_std)
15371538
permutations.append(P)
15381539
if return_transform:
@@ -1544,7 +1545,10 @@ def write_to_cif(self, inds, mode, path):
15441545
ase_write_cif(self, inds, path, mode)
15451546

15461547
'''
1547-
positions = fractional_transform(self.unit_cell_pos[self.unit_cell_batch == ind], self.T_cf[0])
1548+
from mxtaltools.common.geometry_utils import fractional_transform
1549+
self.pose_aunit()
1550+
self.build_unit_cell()
1551+
positions = fractional_transform(self.unit_cell_pos[self.unit_cell_batch == ind], self.T_cf[ind])
15481552
numbers = self.z[self.batch == ind].repeat(self.sym_mult[ind]).numpy().tolist()
15491553
cell = (lattice, positions, numbers)
15501554
lattice_std, positions_std, numbers_std = spglib.standardize_cell(

0 commit comments

Comments
 (0)