Skip to content

Commit

Permalink
Merge pull request #14 from Kolaru/read_geometry
Browse files Browse the repository at this point in the history
Add example of using the package to read geometry from a CIF file.
  • Loading branch information
jamesrhester authored Dec 20, 2024
2 parents 3fcfa27 + 1b4472f commit 7ba4a04
Show file tree
Hide file tree
Showing 4 changed files with 374 additions and 0 deletions.
285 changes: 285 additions & 0 deletions examples/parse_geometry/7706719.cif
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
#------------------------------------------------------------------------------
#$Date: 2021-04-05 17:55:09 +0300 (Mon, 05 Apr 2021) $
#$Revision: 263781 $
#$URL: file:///home/coder/svn-repositories/cod/cif/7/70/67/7706719.cif $
#------------------------------------------------------------------------------
#
# This file is available in the Crystallography Open Database (COD),
# http://www.crystallography.net/
#
# All data on this site have been placed in the public domain by the
# contributors.
#
data_7706719
loop_
_publ_author_name
'Awwadi, Firas F.'
'Alwahsh, Manal I.'
'Turnbull, Mark M.'
'Landee, Christopher P.'
'Twamley, Brendan'
_publ_section_title
;
Two new canted antiferromagnetic systems: magnetic, theoretical, and
crystallographic studies on trans-bis(2-iodopyridine)dihalocopper(ii).
;
_journal_issue 12
_journal_name_full
'Dalton transactions (Cambridge, England : 2003)'
_journal_page_first 4167
_journal_page_last 4178
_journal_paper_doi 10.1039/d0dt04071a
_journal_volume 50
_journal_year 2021
_chemical_formula_sum 'C10 H8 Br2 Cu I2 N2'
_chemical_formula_weight 633.34
_space_group_IT_number 15
_space_group_name_Hall '-C 2yc'
_space_group_name_H-M_alt 'C 1 2/c 1'
_symmetry_cell_setting monoclinic
_symmetry_space_group_name_H-M 'C 1 2/c 1'
_atom_sites_solution_hydrogens geom
_atom_sites_solution_primary direct
_atom_sites_solution_secondary difmap
_audit_creation_method 'CrysAlisPro 1.171.38.46 (Rigaku OD, 2015)'
_audit_update_record
;
2020-10-10 deposited with the CCDC. 2021-03-01 downloaded from the CCDC.
;
_cell_angle_alpha 90.00
_cell_angle_beta 108.162(7)
_cell_angle_gamma 90.00
_cell_formula_units_Z 4
_cell_length_a 15.5605(10)
_cell_length_b 7.9626(4)
_cell_length_c 12.9489(7)
_cell_measurement_reflns_used 1246
_cell_measurement_temperature 293(2)
_cell_measurement_theta_max 29.0240
_cell_measurement_theta_min 3.6100
_cell_volume 1524.46(16)
_computing_cell_refinement 'CrysAlisPro 1.171.38.46 (Rigaku OD, 2015)'
_computing_data_collection 'CrysAlisPro 1.171.38.46 (Rigaku OD, 2015)'
_computing_data_reduction 'CrysAlisPro 1.171.38.46 (Rigaku OD, 2015)'
_computing_molecular_graphics 'shelxtl, Bruker,2002'
_computing_publication_material 'shelxtl, Bruker,2002'
_computing_structure_refinement 'shelxtl, Bruker,2002'
_computing_structure_solution 'shelxtl, Bruker,2002'
_diffrn_ambient_temperature 293(2)
_diffrn_detector_area_resol_mean 16.0534
_diffrn_measured_fraction_theta_full 0.998
_diffrn_measured_fraction_theta_max 0.998
_diffrn_measurement_device_type 'Xcalibur, Eos'
_diffrn_measurement_method '\w scans'
_diffrn_radiation_monochromator graphite
_diffrn_radiation_source 'fine-focus sealed tube'
_diffrn_radiation_type MoK\a
_diffrn_radiation_wavelength 0.71073
_diffrn_reflns_av_R_equivalents 0.0223
_diffrn_reflns_av_sigmaI/netI 0.0358
_diffrn_reflns_limit_h_max 18
_diffrn_reflns_limit_h_min -19
_diffrn_reflns_limit_k_max 9
_diffrn_reflns_limit_k_min -9
_diffrn_reflns_limit_l_max 10
_diffrn_reflns_limit_l_min -16
_diffrn_reflns_number 3023
_diffrn_reflns_theta_full 26.30
_diffrn_reflns_theta_max 26.30
_diffrn_reflns_theta_min 3.31
_exptl_absorpt_coefficient_mu 10.705
_exptl_absorpt_correction_T_max 1.00000
_exptl_absorpt_correction_T_min 0.47314
_exptl_absorpt_correction_type multi-scan
_exptl_absorpt_process_details
;
CrysAlisPro 1.171.38.46 (Rigaku Oxford Diffraction, 2015)
Empirical absorption correction using spherical harmonics,
implemented in SCALE3 ABSPACK scaling algorithm.
;
_exptl_crystal_colour green
_exptl_crystal_density_diffrn 2.760
_exptl_crystal_density_method 'not measured'
_exptl_crystal_description parallelepiped
_exptl_crystal_F_000 1148
_exptl_crystal_preparation 'Magnetic properties'
_exptl_crystal_size_max 0.25
_exptl_crystal_size_mid 0.15
_exptl_crystal_size_min 0.10
_refine_diff_density_max 0.559
_refine_diff_density_min -0.944
_refine_diff_density_rms 0.186
_refine_ls_extinction_method none
_refine_ls_goodness_of_fit_ref 1.036
_refine_ls_hydrogen_treatment constra
_refine_ls_matrix_type full
_refine_ls_number_parameters 79
_refine_ls_number_reflns 1538
_refine_ls_number_restraints 0
_refine_ls_restrained_S_all 1.036
_refine_ls_R_factor_all 0.0396
_refine_ls_R_factor_gt 0.0320
_refine_ls_shift/su_max 0.000
_refine_ls_shift/su_mean 0.000
_refine_ls_structure_factor_coef Fsqd
_refine_ls_weighting_details
'calc w=1/[\s^2^(Fo^2^)+(0.0370P)^2^+0.0000P] where P=(Fo^2^+2Fc^2^)/3'
_refine_ls_weighting_scheme calc
_refine_ls_wR_factor_gt 0.0706
_refine_ls_wR_factor_ref 0.0745
_reflns_number_gt 1314
_reflns_number_total 1538
_reflns_threshold_expression >2sigma(I)
_cod_data_source_file d0dt04071a2.cif
_cod_data_source_block exp_2198
_cod_depositor_comments
'Adding full bibliography for 7706719--7706724.cif.'
_cod_original_cell_volume 1524.46(15)
_cod_database_code 7706719
loop_
_symmetry_equiv_pos_as_xyz
'x, y, z'
'-x, y, -z+1/2'
'x+1/2, y+1/2, z'
'-x+1/2, y+1/2, -z+1/2'
'-x, -y, -z'
'x, -y, z-1/2'
'-x+1/2, -y+1/2, -z'
'x+1/2, -y+1/2, z-1/2'
loop_
_atom_site_label
_atom_site_type_symbol
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_U_iso_or_equiv
_atom_site_adp_type
_atom_site_occupancy
_atom_site_symmetry_multiplicity
_atom_site_calc_flag
_atom_site_refinement_flags
_atom_site_disorder_assembly
_atom_site_disorder_group
I1 I 0.14259(3) 0.80733(5) 0.69013(3) 0.04124(15) Uani 1 1 d . . .
Cu1 Cu 0.2500 0.7500 0.5000 0.0245(2) Uani 1 2 d S . .
Br1 Br 0.12243(3) 0.85448(7) 0.35677(4) 0.03650(17) Uani 1 1 d . . .
N1 N 0.1739(2) 0.5694(5) 0.5299(3) 0.0258(9) Uani 1 1 d . . .
C5 C 0.1653(3) 0.4250(7) 0.4732(4) 0.0348(12) Uani 1 1 d . . .
H5A H 0.1923 0.4176 0.4187 0.042 Uiso 1 1 calc R . .
C1 C 0.1332(3) 0.5791(6) 0.6066(4) 0.0285(11) Uani 1 1 d . . .
C3 C 0.0789(3) 0.2999(6) 0.5723(5) 0.0406(14) Uani 1 1 d . . .
H3A H 0.0480 0.2081 0.5878 0.049 Uiso 1 1 calc R . .
C4 C 0.1188(4) 0.2894(7) 0.4918(5) 0.0418(14) Uani 1 1 d . . .
H4A H 0.1143 0.1919 0.4509 0.050 Uiso 1 1 calc R . .
C2 C 0.0848(3) 0.4465(7) 0.6299(4) 0.0392(13) Uani 1 1 d . . .
H2A H 0.0568 0.4566 0.6834 0.047 Uiso 1 1 calc R . .
loop_
_atom_site_aniso_label
_atom_site_aniso_U_11
_atom_site_aniso_U_22
_atom_site_aniso_U_33
_atom_site_aniso_U_23
_atom_site_aniso_U_13
_atom_site_aniso_U_12
I1 0.0547(3) 0.0377(2) 0.0355(2) -0.00672(17) 0.02011(19) 0.00020(16)
Cu1 0.0290(4) 0.0223(4) 0.0244(4) -0.0004(4) 0.0114(3) -0.0059(3)
Br1 0.0352(3) 0.0372(3) 0.0336(3) 0.0069(2) 0.0056(2) -0.0030(2)
N1 0.028(2) 0.026(2) 0.024(2) 0.0038(18) 0.0090(17) -0.0047(17)
C5 0.041(3) 0.032(3) 0.035(3) -0.004(3) 0.017(2) -0.003(2)
C1 0.032(3) 0.028(3) 0.025(2) 0.001(2) 0.008(2) -0.002(2)
C3 0.034(3) 0.026(3) 0.060(4) 0.014(3) 0.012(3) -0.007(2)
C4 0.040(3) 0.027(3) 0.055(4) -0.007(3) 0.010(3) -0.008(2)
C2 0.039(3) 0.042(3) 0.042(3) 0.010(3) 0.020(2) -0.001(3)
loop_
_atom_type_symbol
_atom_type_description
_atom_type_scat_dispersion_real
_atom_type_scat_dispersion_imag
_atom_type_scat_source
C C 0.0033 0.0016 'International Tables Vol C Tables 4.2.6.8 and 6.1.1.4'
H H 0.0000 0.0000 'International Tables Vol C Tables 4.2.6.8 and 6.1.1.4'
N N 0.0061 0.0033 'International Tables Vol C Tables 4.2.6.8 and 6.1.1.4'
Cu Cu 0.3201 1.2651 'International Tables Vol C Tables 4.2.6.8 and 6.1.1.4'
Br Br -0.2901 2.4595 'International Tables Vol C Tables 4.2.6.8 and 6.1.1.4'
I I -0.4742 1.8119 'International Tables Vol C Tables 4.2.6.8 and 6.1.1.4'
loop_
_geom_angle_atom_site_label_1
_geom_angle_atom_site_label_2
_geom_angle_atom_site_label_3
_geom_angle
_geom_angle_site_symmetry_1
_geom_angle_site_symmetry_3
_geom_angle_publ_flag
N1 Cu1 N1 180.0 7_566 . ?
N1 Cu1 Br1 90.10(11) 7_566 7_566 ?
N1 Cu1 Br1 89.91(11) . 7_566 ?
N1 Cu1 Br1 89.90(11) 7_566 . ?
N1 Cu1 Br1 90.09(11) . . ?
Br1 Cu1 Br1 180.0 7_566 . ?
C1 N1 C5 117.7(4) . . ?
C1 N1 Cu1 123.7(3) . . ?
C5 N1 Cu1 118.5(3) . . ?
N1 C5 C4 123.2(5) . . ?
N1 C5 H5A 118.4 . . ?
C4 C5 H5A 118.4 . . ?
N1 C1 C2 122.3(5) . . ?
N1 C1 I1 117.4(3) . . ?
C2 C1 I1 120.2(4) . . ?
C2 C3 C4 119.6(5) . . ?
C2 C3 H3A 120.2 . . ?
C4 C3 H3A 120.2 . . ?
C5 C4 C3 118.5(5) . . ?
C5 C4 H4A 120.8 . . ?
C3 C4 H4A 120.8 . . ?
C3 C2 C1 118.6(5) . . ?
C3 C2 H2A 120.7 . . ?
C1 C2 H2A 120.7 . . ?
loop_
_geom_bond_atom_site_label_1
_geom_bond_atom_site_label_2
_geom_bond_distance
_geom_bond_site_symmetry_2
_geom_bond_publ_flag
I1 C1 2.097(5) . ?
Cu1 N1 1.976(4) 7_566 ?
Cu1 N1 1.976(4) . ?
Cu1 Br1 2.4036(5) 7_566 ?
Cu1 Br1 2.4036(5) . ?
N1 C1 1.336(5) . ?
N1 C5 1.349(6) . ?
C5 C4 1.361(7) . ?
C5 H5A 0.9300 . ?
C1 C2 1.384(7) . ?
C3 C2 1.373(8) . ?
C3 C4 1.374(7) . ?
C3 H3A 0.9300 . ?
C4 H4A 0.9300 . ?
C2 H2A 0.9300 . ?
loop_
_geom_torsion_atom_site_label_1
_geom_torsion_atom_site_label_2
_geom_torsion_atom_site_label_3
_geom_torsion_atom_site_label_4
_geom_torsion
_geom_torsion_site_symmetry_1
_geom_torsion_site_symmetry_2
_geom_torsion_site_symmetry_3
_geom_torsion_site_symmetry_4
_geom_torsion_publ_flag
N1 Cu1 N1 C1 -112(100) 7_566 . . . ?
Br1 Cu1 N1 C1 84.2(4) 7_566 . . . ?
Br1 Cu1 N1 C1 -95.8(4) . . . . ?
N1 Cu1 N1 C5 71(100) 7_566 . . . ?
Br1 Cu1 N1 C5 -92.9(3) 7_566 . . . ?
Br1 Cu1 N1 C5 87.1(3) . . . . ?
C1 N1 C5 C4 -1.2(7) . . . . ?
Cu1 N1 C5 C4 176.1(4) . . . . ?
C5 N1 C1 C2 1.0(7) . . . . ?
Cu1 N1 C1 C2 -176.1(4) . . . . ?
C5 N1 C1 I1 -177.6(3) . . . . ?
Cu1 N1 C1 I1 5.3(5) . . . . ?
N1 C5 C4 C3 -0.1(8) . . . . ?
C2 C3 C4 C5 1.5(8) . . . . ?
C4 C3 C2 C1 -1.7(8) . . . . ?
N1 C1 C2 C3 0.4(8) . . . . ?
I1 C1 C2 C3 179.0(4) . . . . ?
4 changes: 4 additions & 0 deletions examples/parse_geometry/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[deps]
CrystalInfoFramework = "6007d9b0-c6b2-11e8-0510-1d10e825f3f1"
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
33 changes: 33 additions & 0 deletions examples/parse_geometry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Parsing CIF geometry

The file `parse_geometry.jl` defines the function `cif_geometry(path)` that
reads a geometry from a CIF file and returns

- A list of element symbol, e.g. `:C` for a carbon atom, in
a format that is compatible with the `PeriodicTable.jl` and `Mendeleeiev.jl` packages to look up properties of the elements.
- A `3 x n_atoms` array of the position.
The array elements are `Measurement`s of `Unitful` quantities,
therefore both the uncertainty given in the CIF file
and the units are carried with the geometry.
The uncertainties and units can be dropped using, respectively,
`Measurements.value.(geometry)` and `ustrip.(geometry)`.

To use the file directly,
make the `examples/parse_geometry/` folder the working
directory (usually using the `cd` terminal command).

The example requires the `Measurements`, `Unitful` and `CrystalInfoFramework`
packages.
You can either install them manually
(by typing `] add Measurements Unitful CrystalInforFramework` in julia REPL)
or use the example environment
(by starting julia as `julia --project`
while being in the `examples/parse_geometry/` folder
and then typing `] instantiate` in julia REPL).

To run as a command line program from the folder, type `julia --project parse_geometry.jl <filename>`,
where `<filename>` is a CIF file. If `<filename>` is missing, the supplied example
file from the COD is used.

To run interactively from the folder, type `julia --project`, then at the prompt `include("parse_geometry.jl")`,
then `cif_geometry(<path>)`.
52 changes: 52 additions & 0 deletions examples/parse_geometry/parse_geometry.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using CrystalInfoFramework
using Measurements
using Unitful

parse_cif_value(x) = measurement(x)

function cif_geometry(file)
cif = only(Cif(file))[2]

atoms = Symbol.(cif["_atom_site_type_symbol"])
fract_x = parse_cif_value.(cif["_atom_site_fract_x"])
fract_y = parse_cif_value.(cif["_atom_site_fract_y"])
fract_z = parse_cif_value.(cif["_atom_site_fract_z"])
fract = permutedims(hcat(fract_x, fract_y, fract_z))

a, b, c = map(["a", "b", "c"]) do dim
return parse_cif_value(only(cif["_cell_length_$dim"])) * u"Å"
end

α, β, γ = map(["alpha", "beta", "gamma"]) do angle
return parse_cif_value(only(cif["_cell_angle_$angle"])) * u"°"
end

# Transformation matrix according to
# https://chemistry.stackexchange.com/questions/136836/converting-fractional-coordinates-into-cartesian-coordinates-for-crystallography
n2 = (cos(α) - cos(γ)*cos(β)) / sin(γ)

M = [
a 0u"Å" 0u"Å" ;
b*cos(γ) b*sin(γ) 0u"Å" ;
c*cos(β) c*n2 c*sqrt(sin(β)^2 - n2^2)
]

return atoms, M' * fract
end


if abspath(PROGRAM_FILE) == @__FILE__
if length(ARGS) == 0

# Some data from the Crystallography Open Database (COD), ID 7706719
file = "7706719.cif"
else
file = first(a)
end

atoms, geometry = cif_geometry(file)
println("Atoms from $file")
println(atoms)
println("\n Geometry:")
println(geometry)
end

0 comments on commit 7ba4a04

Please sign in to comment.