[ase-users] Wrong atom number reading cif files

Gaël Donval G.Donval at bath.ac.uk
Thu Nov 23 15:11:04 CET 2017


Hi,

Please keep it on the list.

> Hi Gaël
> 
> 
> Thank you for your reply.
> 
> Yes, I knew that I could manually edit my file, but I wonder if there
> is the possibility to get rid of disorder automatically, since I have
> to work on a very large number of cif files and I can't edit each one
> of them.
> 
> 
> Up to now I am using a workaround deleting the lines you mentioned by
> using python "regex", but I wonder if there is a more "elegant" way.

Well, you can do it with ASE. It's not what I would call very elegant
code but it works well (and provides a useful, yet slightly suboptimal,
pattern to deal with CIFs in details):

    >>> from ase.io import read
    >>> from ase.io.cif import tags2atoms
    >>> full_struct = read("TIPS-pentacene.cif", store_tags=True)
    >>> tags = full_struct.info.copy()
    >>> is_valid_atom = [dg in ('.', 1) for dg in tags["_atom_site_disorder_group"]]
    >>> for tag in ('_atom_site_fract_x', '_atom_site_fract_y', '_atom_site_fract_z',
                    '_atom_site_type_symbol', '_atom_site_label'):
    >>>     if tag not in tags: continue
    >>>     tags[tag] = [el for is_ok, el in zip(is_valid_atom, tags[tag]) if is_ok]
    >>> struct = tags2atoms(tags)
    >>> print(struct.get_chemical_formula())
    C44H54Si2

(by the way, I don't know who wrote that reader but it is definitely
well-designed and very pleasing to tweak)

That should solve your problem.

Cheers,
Gaël

> 
> 
> Best regards,
> 
> Alessandro
> 
> ________________________________
> Da: ase-users-bounces at listserv.fysik.dtu.dk <ase-users-bounces at listse
> rv.fysik.dtu.dk> per conto di Gaël Donval via ase-users <ase-users at li
> stserv.fysik.dtu.dk>
> Inviato: giovedì 23 novembre 2017 11:43:43
> A: ase-users at listserv.fysik.dtu.dk
> Oggetto: Re: [ase-users] Wrong atom number reading cif files
> 
> Hi Alessandro,
> > Hello everyone.
> > 
> > 
> > I am a PhD student in chemistry at the University of Liverpool and
> > a
> > new user of ASE.
> > 
> > 
> > Unfortunately, I am having problems when I try to read the cif of
> > TIPS-pentacene (attached) that I downloaded from the Cambridge
> > Cristallographic Data Centre.
> > 
> > 
> > As you can see from the attached cif file, TIPS-pentacene has
> > chemical formula "C44 H54 Si2"
> > 
> > 
> > However when I use "atoms=ase.io.read(cif_file)", the actual
> > chemical
> > formula changes, as I checked by printing "atoms"
> 
> I am no CIF expert so someone might come after me and prove me wrong
> but it seems that your CIF provides atoms with partial occupancies to
> represent disorder while retaining a maximum number of symmetries.
> 
> If you don't care about disorder, you could edit the CIF file to
> remove
> the extra atoms (either manually or using a program that can do
> that).
> There are ways to make the overlapping atom check more strict (so
> that
> ASE would get rid of the copies), but this is not going to work here
> for a couple of hydrogens. You could also use ASE GUI, and manually
> select and delete copies (using backspace).
> 
> Basically just remove all the primed atomes (C20', etc.) and the D,
> E,
> F variants of hydrogen in the CIF file and it'll work with ASE.
> 
> Cheers,
> Gaël
> 
> > 
> > 
> > Atoms(symbols='C48H68Si2', pbc=True, cell=[[7.565, 0.0, 0.0],
> > [0.8598515049547191, 7.702152646463657, 0.0], [3.3793900993103994,
> > -0.1259731853643117, 16.49184884460357]])
> > 
> > Is it possible that it is due to the disorder in the cif file?
> > 
> > 
> > In any case, how can I avoid this problem and read (or get after
> > some
> > manipulations) only the atoms constituting the actual molecule? (I
> > don't care about the disorder since I only need a reasonable
> > structure to do some QM computations on it)
> > 
> > 
> > Thanks in advance.
> > 
> > 
> > Best regards,
> > 
> > Alessandro
> > 
> > 
> > _______________________________________________
> > ase-users mailing list
> > ase-users at listserv.fysik.dtu.dk
> > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
> 
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users



More information about the ase-users mailing list