Reading cifs¶
If you have a .cif file, use amd.CifReader to extract the crystals:
# list of crystals in a .cif
crystals = list(amd.CifReader('file.cif'))
# also accepts a directory, reading all cifs inside
crystals = list(amd.CifReader('path/to/folder'))
# loop over the reader and get AMDs (k=100) of crystals
amds = [amd.AMD(c, 100) for c in amd.CifReader('file.cif')]
The CifReader yields 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 asym_unit and weights for use in AMD/PDD calculations.
CSD Python API only: CifReader can accept other file formats when passed reader='ccdc'.
Reading options¶
CifReader accepts the following parameters (many shared with amd.CSDReader):
amd.CifReader(
'file.cif', # path to file/folder
reader='gemmi', # backend cif parser
remove_hydrogens=False, # remove Hydrogens
disorder='skip', # how to handle disorder
heaviest_component=False, # keep only heaviest molecule (CSD Python API only)
molecular_centres=False, # take molecular centres as the motif (CSD Python API only)
show_warnings=True, # silence warnings
verbose=False # print number of items processed
)
reader(defaultgemmi) controls the backend package used to parse the file. Acceptsgemmi,pycodcif,pymatgen,aseandccdc(if these packages are installed). The ccdc reader can read formats accepted byccdc.io.EntryReader.remove_hydrogens(defaultFalse) removes Hydrogen atoms from the structure.disorder(defaultskip) controls how disordered structures are handled. The default skips any crystal with disorder, since disorder conflicts somewhat with the periodic set model. Alternatively,ordered_sitesremoves atoms with disorder andall_sitesincludes all atoms regardless.heaviest_component(csd-python-apionly, defaultFalse) removes all but the heaviest connected molecule in the asymmetric unit, intended for removing solvents.molecular_centres(csd-python-apionly, defaultFalse) uses molecular centres of mass instead of atoms as the motif of the periodic set.show_warnings(defaultTrue) chooses whether to print warnings during reading, e.g. from disordered structures or crystals with missing data.verbose(defaultFalse) prints a progress bar showing the number of items read so far.
See the references amd.io.CifReader or amd.periodicset.PeriodicSet for more.