Skip to content

Can not read cif file download from Crystallography Open Database without GUI #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GKNB opened this issue Apr 29, 2025 · 4 comments
Open
Assignees
Labels
APS Bug or need identified/requested by APS user/staff In progress this is being addressed but is not complete

Comments

@GKNB
Copy link

GKNB commented Apr 29, 2025

Here I want to report (possibly) a bug where the latest GSAS-II can not read cif file downloaded from Crystallography Open Database (http://www.crystallography.net/cod/cif) on Polaris ALCF machine. (for example, http://www.crystallography.net/cod/cif/1/00/14/1001460.cif). Detail is the minimal requirement to reproduce this problem. Since it is running on Polaris, we don't want to use GUI and want to fully work with cmd.

I first install gsas-ii with the following command:

g2="https://github.com/AdvancedPhotonSource/GSAS-II-buildtools/releases/download/v1.0.1/gsas2main-Latest-Linux-x86_64.sh"
curl -L "$g2" > /tmp/g2.sh; bash /tmp/g2.sh -b -p /lus/eagle/projects/RECUP/twang/g2full_04282025

I got the following outputs:

PREFIX=/lus/eagle/projects/RECUP/twang/g2full_04282025
Unpacking payload ...
entry_point.py:256: DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.
entry_point.py:256: DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.

Installing base environment...

Preparing transaction: ...working... done
Executing transaction: ...working... 


done
entry_point.py:256: DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.
Finish up GSAS-II installation
launching bootstrap process
GSAS-II installer completed
installation finished.
WARNING:
    You currently have a PYTHONPATH environment variable set. This may cause
    unexpected behavior when running the Python interpreter in gsas2main.
    For best results, please verify that your PYTHONPATH only points to
    directories of packages that are compatible with the Python interpreter
    in gsas2main: /lus/eagle/projects/RECUP/twang/g2full_04282025

Then I notice there is a script in the installation directory, RunGSASII.sh, which says:

source /lus/eagle/projects/RECUP/twang/g2full_04282025/bin/activate
/lus/eagle/projects/RECUP/twang/g2full_04282025/bin/python3.13 /lus/eagle/projects/RECUP/twang/g2full_04282025/GSAS-II/GSASII/G2.py $*

and the content of /lus/eagle/projects/RECUP/twang/g2full_04282025/GSAS-II/GSASII/G2.py is basically adding the installation directory to the python path, so I did the following:

# Source the python environment
source /lus/eagle/projects/RECUP/twang/g2full_04282025/bin/activate

python -c "import sys, os; sys.path.insert(0, '/lus/eagle/projects/RECUP/twang/g2full_04282025/GSAS-II'); from GSASII import GSASIIscriptable as g2sc; gpx=g2sc.G2Project(newgpx = '/lus/eagle/projects/RECUP/twang/testbed/gsas_temp/FB.gpx'); phase0=gpx.add_phase('/lus/eagle/projects/RECUP/twang/testbed/gsas_temp/1001460.cif')"

Where '/lus/eagle/projects/RECUP/twang/testbed/gsas_temp/1001460.cif' is downloaded from Crystallography Open Database. Then I got the following error message:

N.B. Configuration file /home/twang3/.GSASII/config.ini does not exist
Error importing config.py file
 No module named 'config'
0 values read from /home/twang3/.GSASII/config.ini
======================================================================
Module pyspg in '/lus/eagle/projects/RECUP/twang/g2full_04282025/GSAS-II/GSASII-bin/linux_64_p3.13_n2.2' could not be loaded
error msg: /lib64/libm.so.6: version `GLIBC_2.38' not found (required by /lus/eagle/projects/RECUP/twang/g2full_04282025/GSAS-II/GSASII-bin/linux_64_p3.13_n2.2/pyspg.cpython-313-x86_64-linux-gnu.so)
======================================================================
*** ERROR: Unable to find GSAS-II binaries. Much of GSAS-II cannot function
binary load error: pyspg not found
pypowder is not available - profile calcs. not allowed
pydiffax is not available for this platform
pypowder is not available - profile calcs. not allowed
validator:  True
Warning: CIF Reader failed to read /lus/eagle/projects/RECUP/twang/testbed/gsas_temp/1001460.cif
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import sys, os; sys.path.insert(0, '/lus/eagle/projects/RECUP/twang/g2full_04282025/GSAS-II'); from GSASII import GSASIIscriptable as g2sc; gpx=g2sc.G2Project(newgpx = '/lus/eagle/projects/RECUP/twang/testbed/gsas_temp/FB.gpx'); phase0=gpx.add_phase('/lus/eagle/projects/RECUP/twang/testbed/gsas_temp/1001460.cif')
                                                                                                                                                                                                                                                ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lus/eagle/projects/RECUP/twang/g2full_04282025/GSAS-II/GSASII/GSASIIscriptable.py", line 1350, in add_phase
    phasereaders = import_generic(phasefile, Readers['Phase'],
                                      fmthint=fmthint, URL=URL)
  File "/lus/eagle/projects/RECUP/twang/g2full_04282025/GSAS-II/GSASII/GSASIIscriptable.py", line 503, in import_generic
    raise G2ImportException(f"No reader could read file: {filename}")
GSASII.GSASIIscriptable.G2ImportException: No reader could read file: /lus/eagle/projects/RECUP/twang/testbed/gsas_temp/1001460.cif

Since it first report error on not finding config module, I also did pip install config inside this environment and rerun that python command, but I still get the same error.

Meanwhile, as mentioned in https://github.com/AdvancedPhotonSource/GSAS-II/issues/165, gsas-ii is supposed to use PyCIFRW to read cif file, so I also did the following to test if PyCIFRW could read the cif file correctly:

source /lus/eagle/projects/RECUP/twang/g2full_04282025/bin/activate
python -c "from CifFile import ReadCif; cf = ReadCif('/lus/eagle/projects/RECUP/twang/testbed/gsas_temp/1001460.cif'); print(cf)"

and then I can get good result, part of the output is shown below:

Writing 1001460, <CifFile.StarFile.StarBlock object at 0x7fbb253ffcb0>
All blocks output.

##########################################################################
#               Crystallographic Information Format file
#               Produced by PyCifRW module
#
#  This is a CIF file.  CIF has been adopted by the International
#  Union of Crystallography as the standard for data archiving and
#  transmission.
#
#  For information on this file format, follow the CIF links at
#  http://www.iucr.org
##########################################################################

data_1001460

loop_
  _publ_author_name
         'Licheron, M'       
         'Gervais, F'        
         'Coutures, J'       
         'Choisnet, J' 
_publ_section_title      
<......................skip to save space......................>
loop_
  _atom_type_symbol
  _atom_type_oxidation_number
         Ba2+      2.000     
         Bi3+      3.000     
         Bi5+      5.000     
         O2-       -2.000

and you can see PyCIFRW can read that cif correctly.

So the question I want to ask is, is there any way I can solve this issue? Thanks!

@GKNB
Copy link
Author

GKNB commented Apr 29, 2025

Quick updates: I find the following gsas-ii library to work:

https://github.com/AdvancedPhotonSource/GSAS-II-buildtools/releases/download/v1.0.1/gsas2full-5786-Linux-x86_64.sh

The detailed command I used is as follows:

g2="https://github.com/AdvancedPhotonSource/GSAS-II-buildtools/releases/download/v1.0.1/gsas2full-5786-Linux-x86_64.sh"
curl -L "$g2" > /tmp/g2.sh; bash /tmp/g2.sh -b -p /lus/eagle/projects/RECUP/twang/g2full_04292025

source /lus/eagle/projects/RECUP/twang/g2full_04292025/bin/activate
python -c "import sys, os; sys.path.insert(0, '/lus/eagle/projects/RECUP/twang/g2full_04292025/GSAS-II/GSASII'); import GSASIIscriptable as g2sc; gpx=g2sc.G2Project(newgpx = '/lus/eagle/projects/RECUP/twang/testbed/gsas_temp/FB.gpx'); phase0=gpx.add_phase('/lus/eagle/projects/RECUP/twang/testbed/gsas_temp/1001460.cif')"

and it can read the cif successfully. Thanks!

@briantoby
Copy link
Collaborator

The gsas2full installer provides Python 3.11, a retired branch of GSAS-II (master), but does have much older compiled binaries which seem to be able to run on more Linux systems. I'd rather you do not rely on older software.

The gsas2main installer uses the current branch. I'd like to have that work for you.

I suspect that the reason the CIF is not reading is that the binaries we ship with gsas2main are apparently not compatible with the version of glibc on your machine. The CIF reader needs to look up the space group information for your CIF, and I suspect that this is where the reader is failing. I did test your CIF with the latest GSAS-II on my Mac and it read fine, but failed when I removed the binaries.

You can run meson to build binaries locally (see https://advancedphotonsource.github.io/GSAS-II-tutorials/compile.html) or you can see if the redhat set works for you (install this: https://github.com/AdvancedPhotonSource/GSAS-II-buildtools/releases/download/v1.0.1/gsas2main-rhel-Latest-Linux-x86_64.sh).

@briantoby briantoby self-assigned this Apr 30, 2025
@briantoby briantoby added APS Bug or need identified/requested by APS user/staff In progress this is being addressed but is not complete labels Apr 30, 2025
@briantoby
Copy link
Collaborator

Another choice would be to use the gitcompile script (not yet documented). The basic steps for use of that:

  1. install Python along with GSAS-II's needed packages (in your case you can use the one in /lus/eagle/projects/RECUP/twang/g2full_04292025 via /lus/eagle/projects/RECUP/twang/g2full_04292025/bin/activate), but you will need to use conda install meson cython` to add tools needed for building. I assume gcc & gfortran are already available.
  2. Download the gitcompile.py file into the location where you want GSAS-II to be installed. The install location will be a subdirectory named GSAS-II under the location where the gitcompile is installed.
  3. run the script: `python /gitcompile.py'. This should download and compile GSAS-II.

@briantoby
Copy link
Collaborator

following up: is this resolved or do you need some help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APS Bug or need identified/requested by APS user/staff In progress this is being addressed but is not complete
Projects
None yet
Development

No branches or pull requests

2 participants