1
|
|
|
import pytest |
2
|
|
|
import os |
3
|
|
|
import amd |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
@pytest.fixture(scope='module') |
7
|
|
|
def cif_paths(root_dir): |
8
|
|
|
|
9
|
|
|
cif_names = [ |
10
|
|
|
'cubic', |
11
|
|
|
'T2_experimental', |
12
|
|
|
] |
13
|
|
|
|
14
|
|
|
return {name: os.path.join(root_dir, f'{name}.cif') for name in cif_names} |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
def test_CifReader(cif_paths, reference_data): |
18
|
|
|
|
19
|
|
|
for name in cif_paths: |
20
|
|
|
|
21
|
|
|
references = reference_data[name] |
22
|
|
|
read_in = list(amd.CifReader(cif_paths[name], show_warnings=True)) |
23
|
|
|
|
24
|
|
|
if (not len(references) == len(read_in)) or len(read_in) == 0: |
25
|
|
|
pytest.fail(f'There are {len(references)} references, but {len(read_in)} structures were read.') |
26
|
|
|
|
27
|
|
|
for s, s_ in zip(read_in, references): |
28
|
|
|
if not s == s_: |
29
|
|
|
pytest.fail(f'Structure {s.name} read with CifReader disagrees with reference.') |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
@pytest.fixture(scope='module') |
33
|
|
|
def asym_unit_test_cif_path(root_dir): |
34
|
|
|
return os.path.join(root_dir, 'OJIGOG.cif') |
35
|
|
|
|
36
|
|
|
def test_CifReader_equiv_structs(asym_unit_test_cif_path): |
37
|
|
|
|
38
|
|
|
pdds = [amd.PDD(struct, 100) for struct in amd.CifReader(asym_unit_test_cif_path, show_warnings=False)] |
39
|
|
|
|
40
|
|
|
if amd.emd(pdds[0], pdds[1]) > 0: |
41
|
|
|
pytest.fail(f'Asymmetric structure was read differently than identical expanded version.') |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
@pytest.fixture(scope='module') |
45
|
|
|
def equiv_sites_cif_path(root_dir): |
46
|
|
|
return os.path.join(root_dir, 'BABMUQ.cif') |
47
|
|
|
|
48
|
|
|
def test_equiv_sites(equiv_sites_cif_path): |
49
|
|
|
|
50
|
|
|
pdds = [amd.PDD(s, 100) for s in amd.CifReader(equiv_sites_cif_path, show_warnings=False)] |
51
|
|
|
|
52
|
|
|
if amd.PDD_pdist(pdds): |
53
|
|
|
pytest.fail(f'Equivalent structures by symmetry differ by PDD.') |
54
|
|
|
|