cryspy-extract-struc

Last updated: October 16, 2026

cryspy-extract-struc Command

From v1.5.0, cryspy-extract-struc extracts structures from init_struc_data.pkl or opt_struc_data.pkl and saves them as CIF files. This command integrates CrySPY Utility’s extract_struc.py into CrySPY. It can also print structure information without writing files.

Usage and Options

cryspy-extract-struc infile [options]

The input file can be specified with a relative or absolute path. CIF files are saved in the directory where the command is run. Specify exactly one of -i, -a, or -t; these options cannot be combined.

Argument or optionDescription
infileA structure-data pickle file, such as init_struc_data.pkl or opt_struc_data.pkl. Gzip-compressed files are also supported.
-i INDEX [INDEX ...], --index INDEX [INDEX ...]Structure IDs to extract. Multiple IDs can be specified.
-a, --all_idExtract all structures in the input file.
-t TOP, --top TOPExtract the specified number of structures in ascending order of E_eV_atom in rslt_data.pkl.
-p, --printPrint structure information without writing CIF files.
-r, --rankUse with -t to prefix output filenames with the rank.
-s, --symmetrizedWrite CIF files with symmetry information.
--tolerance TOLERANCETolerance for symmetry detection with -s. The default is 0.01.
-h, --helpShow help.

Examples

Extracting by Structure ID

cryspy-extract-struc ./data/pkl_data/opt_struc_data.pkl -i 0 1

Structures with IDs 0 and 1 are saved as 0.cif and 1.cif in the current directory. Missing IDs are skipped with a warning.

cryspy-extract-struc ./data/pkl_data/opt_struc_data.pkl -i 0 1 -p

With -p, structure IDs and structure information are printed without creating CIF files.

Extracting the Lowest-Energy Structures

cryspy-extract-struc ./data/pkl_data/opt_struc_data.pkl -t 3

This extracts the three lowest-energy structures. rslt_data.pkl must be in the same directory as the input file. Output filenames are {ID}.cif.

Adding -r produces filenames of the form {rank}_{ID}.cif. Ranks start from 1.

cryspy-extract-struc ./data/pkl_data/opt_struc_data.pkl -t 3 -r

Extracting All Structures

cryspy-extract-struc ./data/pkl_data/init_struc_data.pkl -a

All initial structures are saved as {ID}.cif.

Writing Symmetry Information

cryspy-extract-struc ./data/pkl_data/opt_struc_data.pkl -i 0 1 -s --tolerance 0.01

With -s, output CIF files include symmetry information such as the space group. --tolerance is optional. Adding symmetry information may change the cell representation and the number of atoms.

Extracting from Gzip-Compressed Files

cryspy-extract-struc ./data/pkl_data/opt_struc_data.pkl.gz -i 0 1

Gzip-compressed structure data can be read directly without decompression. Options such as -a, -t, -p, and -s can be used in the same way. When using -t, place rslt_data.pkl in the same directory as the compressed input file.