Reading cifs

If you have a .cif file, use amd.CifReader to extract the crystals:

# create list of crystals in a .cif
crystals = list(amd.CifReader('file.cif'))

# Can also accept path to a directory, reading all files inside
crystals = list(amd.CifReader('path/to/folder'))

# loop over the reader and get AMDs (k=100) of crystals
amds = []
for p_set in amd.CifReader('file.cif'):
    amds.append(amd.AMD(p_set, 100))

The CifReader returns periodicset.PeriodicSet objects representing the crystals, which can be passed to amd.AMD() or amd.PDD() to calculate their invariants. The PeriodicSet has attributes .name, .motif, .cell, .types (atomic numbers), as well as .asymmetric_unit and .wyckoff_multiplicities for use in calculations. When the path is to a folder, it will also have an attribute .filename.

CifReader can accept other file formats, if you have csd-python-api installed. This should work if you pass reader='ccdc' to the reader, though formats other than .cif have not been tested.

Reading options

amd.io.CifReader accepts the following parameters (many shared by io.CSDReader):

amd.CifReader(
    'file.cif',                  # path to file or folder
    reader='ase',                # backend cif parser
    remove_hydrogens=False,      # remove Hydrogens
    disorder='skip',             # handling disorder
    heaviest_component=False,    # just keep the heaviest component in asym unit
    show_warnings=True           # silence warnings
)
  • reader controls the backend package used to parse the file. The default is ase; to use csd-python-api change to ccdc. The ccdc reader should be able to read any format accepted by ccdc.io.EntryReader, though only .cifs have been tested.

  • remove_hydrogens removes Hydrogen atoms from the structure.

  • disorder controls how disordered structures are handled. The default is to skip any crystal with disorder, since disorder conflicts with the periodic set model. To read disordered structures anyway, choose either ordered_sites to remove sites with disorder or all_sites include all sites regardless.

  • heaviest_component csd-python-api only. Removes all but the heaviest molecule in the asymmetric unit, intended for removing solvents.

  • show_warnings will not print warnings during reading if False, e.g. from disordered structures or crystals with missing data.

See the references io.CifReader or periodicset.PeriodicSet for more.