RQC-HU / sum_dirac_dfcoef

This program summarizes the coefficients from DIRAC (http://diracprogram.org) output file that the .ANALYZE option and *PRIVEC and .VECPRI options in **ANALYZE section are used. (c.f. http://www.diracprogram.org/doc/release-23/manual/analyze/privec.html)
https://pypi.org/project/sum-dirac-dfcoef/
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Parsing issue in get_functions_info function #81

Closed kohei-noda-qcrg closed 8 months ago

kohei-noda-qcrg commented 8 months ago

molファイル(Hについて左に1つスペースが空いている)

DIAC

C   2
       1.    4
 H    -0.58016472   -1.08506272    0.00000000
 H    -0.57014631    0.42814547    0.87365150
 H    -0.59014631    0.42814547   -0.87365150
 H    -2.00681915   -0.07623954    0.00000000
LARGE BASIS STO-3G
       6.    1
C     -0.93681915   -0.07625272    0.00000000
LARGE BASIS STO-3G
FINISH

sum_dirac_dfcoef実行時のエラーとトレースバック

Traceback (most recent call last):
  File "/home/noda/.pyenv/versions/3.9.15/bin/sum_dirac_dfcoef", line 8, in <module>
    sys.exit(main())
  File "/home/noda/.pyenv/versions/3.9.15/lib/python3.9/site-packages/sum_dirac_dfcoef/sum_dirac_dfcoef.py", line 18, in main
    functions_info = get_functions_info(dirac_output)
  File "/home/noda/.pyenv/versions/3.9.15/lib/python3.9/site-packages/sum_dirac_dfcoef/functions_info.py", line 151, in get_functions_info
    func = read_func_info(words, line_str, component_func, symmetry)
  File "/home/noda/.pyenv/versions/3.9.15/lib/python3.9/site-packages/sum_dirac_dfcoef/functions_info.py", line 115, in read_func_info
    atom, subshell, gto_type = parse_plabel(plabel)
  File "/home/noda/.pyenv/versions/3.9.15/lib/python3.9/site-packages/sum_dirac_dfcoef/functions_info.py", line 101, in parse_plabel
    subshell = plabel[3].strip()  # e.g. "g" in "Cm g400"
IndexError: string index out of range

https://github.com/RQC-HU/sum_dirac_dfcoef/blob/5d262cfc9b484e59b1238f3c202553dfce95b12e/src/sum_dirac_dfcoef/functions_info.py#L113 上記コードで.stripしているため、Hの左のスペースが余分に1つ消えてしまい、それ以降のパース時のインデックスもズレてしまうため、IndexErrorが発生する

従って、stripしないことでインデックスがずれないようにしなければならない