Skip to content

Commit b8fbfe3

Browse files
committed
Merge branch 'cif-curly-brackets'
* process CIFs with curly-bracket values Resolve #38.
2 parents 0e95c09 + c51f523 commit b8fbfe3

File tree

3 files changed

+131
-1
lines changed

3 files changed

+131
-1
lines changed

src/diffpy/structure/parsers/p_cif.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,9 @@ def _parseCifDataSource(self, datasource):
309309
self.stru = None
310310
try:
311311
with _suppressCifParserOutput():
312-
self.ciffile = CifFile(datasource)
312+
# Use `grammar` option to digest values with curly-brackets.
313+
# Ref: https://bitbucket.org/jamesrhester/pycifrw/issues/19
314+
self.ciffile = CifFile(datasource, grammar='auto')
313315
for blockname in self.ciffile.keys():
314316
self._parseCifBlock(blockname)
315317
# stop after reading the first structure
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#------------------------------------------------------------------------------
2+
#$Date: 2016-02-16 22:30:59 +0200 (Tue, 16 Feb 2016) $
3+
#$Revision: 176467 $
4+
#$URL: svn://www.crystallography.net/cod/cif/4/34/14/4341415.cif $
5+
#------------------------------------------------------------------------------
6+
#
7+
# This file is available in the Crystallography Open Database (COD),
8+
# http://www.crystallography.net/
9+
#
10+
# All data on this site have been placed in the public domain by the
11+
# contributors.
12+
#
13+
data_4341415
14+
loop_
15+
_publ_author_name
16+
'Bernal, Fabian L.'
17+
'Yusenko, Kirill V.'
18+
'Sottmann, Jonas'
19+
'Drathen, Christina'
20+
'Guignard, J\'er\'emy'
21+
'L\/ovvik, Ole Martin'
22+
'Crichton, Wilson A.'
23+
'Margadonna, Serena'
24+
_publ_section_title
25+
;
26+
Perovskite to Postperovskite Transition in NaFeF3
27+
;
28+
_journal_name_full 'Inorganic Chemistry'
29+
_journal_page_first 141029080759008
30+
_journal_paper_doi 10.1021/ic502224y
31+
_journal_year 2014
32+
_chemical_formula_analytical NaFeF3
33+
_chemical_formula_moiety NaFeF3
34+
_chemical_formula_structural NaFeF3
35+
_chemical_formula_sum 'F3 Fe Na'
36+
_chemical_formula_weight 135.84
37+
_space_group_IT_number 63
38+
_symmetry_cell_setting orthorhombic
39+
_symmetry_space_group_name_Hall '-C 2c 2'
40+
_symmetry_space_group_name_H-M 'C m c m'
41+
_audit_update_record
42+
;
43+
2014-09-10 # Formatted by publCIF
44+
45+
;
46+
_cell_angle_alpha 90.0
47+
_cell_angle_beta 90.0
48+
_cell_angle_gamma 90.0
49+
_cell_formula_units_Z 4
50+
_cell_length_a 3.13774(4)
51+
_cell_length_b 10.20870(10)
52+
_cell_length_c 7.45875(9)
53+
_cell_measurement_temperature 300
54+
_cell_volume 238.921(5)
55+
_computing_structure_refinement GSAS
56+
_diffrn_ambient_temperature 300
57+
_diffrn_measurement_device_type ID31
58+
_diffrn_radiation_type synchrotron
59+
_diffrn_radiation_wavelength 0.3999
60+
_pd_block_id 2014-09-10T16:28|PPV_RT_phase1|BaAs_233-2||
61+
_pd_phase_name 'NaFeF3 FM001 RT ID09 ESRF'
62+
_refine_ls_goodness_of_fit_all 1.33
63+
_refine_ls_matrix_type full
64+
_refine_ls_number_parameters 23
65+
_refine_ls_number_restraints 0
66+
_refine_ls_shift/su_max 0.07
67+
_refine_ls_shift/su_mean 0.01
68+
_cod_data_source_file ic502224y_si_002.cif
69+
_cod_data_source_block PPV_RT_phase_1
70+
_cod_original_cell_volume 238.921(4)
71+
_cod_original_formula_sum F3FeNa
72+
_cod_database_code 4341415
73+
#BEGIN Tags that were not found in dictionaries:
74+
_publcif_datablock.id {15d6793f-0b54-44dd-81a5-d864469fb48d}
75+
#END Tags that were not found in dictionaries
76+
loop_
77+
_symmetry_equiv_pos_site_id
78+
_symmetry_equiv_pos_as_xyz
79+
1 +x,+y,+z
80+
2 -x,+y,+z
81+
3 +x,-y,+z+1/2
82+
4 -x,-y,+z+1/2
83+
-1 -x,-y,-z
84+
-2 +x,-y,-z
85+
-3 -x,+y,-z+1/2
86+
-4 +x,+y,-z+1/2
87+
101 +x+1/2,+y+1/2,+z
88+
102 -x+1/2,+y+1/2,+z
89+
103 +x+1/2,-y+1/2,+z+1/2
90+
104 -x+1/2,-y+1/2,+z+1/2
91+
-101 -x+1/2,-y+1/2,-z
92+
-102 +x+1/2,-y+1/2,-z
93+
-103 -x+1/2,+y+1/2,-z+1/2
94+
-104 +x+1/2,+y+1/2,-z+1/2
95+
loop_
96+
_atom_site_type_symbol
97+
_atom_site_label
98+
_atom_site_fract_x
99+
_atom_site_fract_y
100+
_atom_site_fract_z
101+
_atom_site_occupancy
102+
_atom_site_thermal_displace_type
103+
_atom_site_U_iso_or_equiv
104+
_atom_site_symmetry_multiplicity
105+
Na Na 0.0 0.7457 0.25 1.0 Uiso 0.01658 4
106+
Fe Fe 0.0 0.0 0.0 1.0 Uiso 0.00792 4
107+
F F1 0.0 0.0842 0.25 1.0 Uiso 0.01837 4
108+
F F2 0.0 0.6278 0.94370 1.0 Uiso 0.02025 8
109+
loop_
110+
_pd_block_diffractogram_id
111+
2014-09-10T16:28|PPV_RT_H_01|BaAs_233-2|PPV
112+
#BEGIN Loops that were not found in dictionaries:
113+
loop_
114+
_publcif_info_datablock.id
115+
_publcif_info_datablock.publ_exptl
116+
_publcif_info_datablock.publ_geom
117+
_publcif_info_datablock.structure
118+
{15d6793f-0b54-44dd-81a5-d864469fb48d} y ? y
119+
{f121c8c0-c58f-4149-a4e0-8a727689246c} n y y
120+
#END Loops that were not found in dictionaries

src/diffpy/structure/tests/testp_cif.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,14 @@ def test_adp_aniso_label(self):
365365
return
366366

367367

368+
def test_curly_brace(self):
369+
"verify loading of a CIF file with unquoted curly brace"
370+
ptest = self.ptest
371+
stru = ptest.parseFile(datafile('curlybrackets.cif'))
372+
self.assertEqual(20, len(stru))
373+
return
374+
375+
368376
def test_getParser(self):
369377
"""Test passing of eps keyword argument by getParser function.
370378
"""

0 commit comments

Comments
 (0)