def fix_cif(cif):
    f = open(cif, 'r')
    alllines = f.readlines()
    f.close()
    for (i, line) in enumerate(alllines):
        if ('IT_coordinate_system_code' in line):
            fields = line.split()
            alllines[i] = '_symmetry_space_group_setting {0} \n'.format(fields[(- 1)])
        if (('_atom_site_type_symbol' in line) and ('_atom_site_label' in alllines[(i + 1)])):
            (alllines[i], alllines[(i + 1)]) = (alllines[(i + 1)], alllines[i])
    file_name = cif.rstrip('.cif')
    temp_file = '{0}/{1}_temp.cif'.format(filepath, file_name.split('/')[(- 1)])
    f = open(temp_file, 'w')
    f.writelines(alllines)
    f.close()
    atoms = read(temp_file)
    os.remove(temp_file)
    return (atoms, alllines)
def fix_cif(cif):
    f = open(cif, 'r')
    alllines = f.readlines()
    f.close()
    for (i, line) in enumerate(alllines):
        if ('IT_coordinate_system_code' in line):
            fields = line.split()
            alllines[i] = '_symmetry_space_group_setting {0} \n'.format(fields[(- 1)])
        if (('_atom_site_type_symbol' in line) and ('_atom_site_label' in alllines[(i + 1)])):
            (alllines[i], alllines[(i + 1)]) = (alllines[(i + 1)], alllines[i])
    file_name = cif.rstrip('.cif')
    temp_file = '{0}/{1}_temp.cif'.format(filepath, file_name.split('/')[(- 1)])
    f = open(temp_file, 'w')
    f.writelines(alllines)
    f.close()
    atoms = read(temp_file)
    os.remove(temp_file)
    return (atoms, alllines)