Skip to content

Commit

Permalink
Merge pull request #17582 from muon-spectroscopy-computational-projec…
Browse files Browse the repository at this point in the history
…t/33_fix_cif_sniff_23.2

[23.2] Account for newlines in CIF Datatype sniffer
  • Loading branch information
nsoranzo authored Mar 4, 2024
2 parents 73d5032 + c095ec6 commit de1bb85
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/galaxy/datatypes/molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,9 @@ def sniff_prefix(self, file_prefix: FilePrefix) -> bool:
>>> fname = get_test_fname('1.star')
>>> CIF().sniff(fname)
False
>>> fname = get_test_fname('LaMnO3.cif')
>>> CIF().sniff(fname)
True
"""

# check for optional CIF version marker '#\#CIF_<version>' at start of file
Expand All @@ -1019,7 +1022,7 @@ def sniff_prefix(self, file_prefix: FilePrefix) -> bool:
# first non-comment line must begin with 'data_'
# and '_atom_site_fract_(x|y|z)' must be specified somewhere in the file
for line in file_prefix.line_iterator():
if not line:
if not line.rstrip():
continue
elif line[0] == "#": # comment so skip
continue
Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy/datatypes/sniff.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ def guess_ext(fname_or_file_prefix: Union[str, "FilePrefix"], sniff_order, is_bi
>>> fname = get_test_fname('Si.cif')
>>> guess_ext(fname, sniff_order)
'cif'
>>> fname = get_test_fname('LaMnO3.cif')
>>> guess_ext(fname, sniff_order)
'cif'
>>> fname = get_test_fname('Si.xyz')
>>> guess_ext(fname, sniff_order)
'xyz'
Expand Down
66 changes: 66 additions & 0 deletions lib/galaxy/datatypes/test/LaMnO3.cif
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#######################################################################
#
# This file contains crystal structure data downloaded from the
# Cambridge Structural Database (CSD) hosted by the Cambridge
# Crystallographic Data Centre (CCDC) in cooperation with FIZ Karlsruhe.
#
# Please note that these data are only for research purposes or private use.
# For detailed information please see under Terms & Conditions.
# Full information about CCDC and FIZ Karlsruhe data access policies and
# citation guidelines are available at http://www.ccdc.cam.ac.uk/access/V1
#
# Audit and citation data items may have been added by FIZ Karlsruhe.
# Please retain this information to preserve the provenance of
# this file and to allow appropriate attribution of the data.
#
#######################################################################

data_150259-ICSD
_database_code_depnum_ccdc_archive 'CCDC 1667441'
loop_
_citation_id
_citation_doi
_citation_year
1 10.1006/jssc.2001.9440 2002
_audit_update_record
;
2018-02-27 deposited with the CCDC. 2024-01-08 downloaded from the CCDC.
;
_database_code_ICSD 150259
_chemical_name_systematic 'Lanthanum Manganate'
_chemical_formula_sum 'La1 Mn1 O3'
_cell_length_a 5.486
_cell_length_b 7.761
_cell_length_c 5.487
_cell_angle_alpha 90
_cell_angle_beta 90
_cell_angle_gamma 90.01
_cell_volume 233.62
_cell_formula_units_Z 4
_symmetry_space_group_name_H-M 'I 1 1 2/b'
_symmetry_Int_Tables_number 15
_symmetry_cell_setting monoclinic
_refine_ls_R_factor_all 0.03
loop_
_symmetry_equiv_pos_site_id
_symmetry_equiv_pos_as_xyz
1 '-x, -y+1/2, z'
2 'x, y+1/2, -z'
3 '-x, -y, -z'
4 'x, y, z'
5 '-x+1/2, -y, z+1/2'
6 'x+1/2, y, -z+1/2'
7 '-x+1/2, -y+1/2, -z+1/2'
8 '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
La1 La3+ 0 0.25 0.5052
Mn1 Mn3+ 0 0 0
O1 O2- 0 0.25 0.0015
O2 O2- 0.2682 0.0015 0.2427

#End of data_150259-ICSD

0 comments on commit de1bb85

Please sign in to comment.