mafreitas / tdf2mzml

Other
25 stars 14 forks source link

UnboundLocalError: local variable 'base_peak_mz' referenced before assignment #6

Closed andzajan closed 3 years ago

andzajan commented 3 years ago

Hi, I have tried converting TimsTof Pro file to the mzML and I am getting error below. I am using Windows 10 machine with Cona environmnet. Docker image doesn't work on Windows OS because git converts line endiings from Unix format to the M$ Windows. I can try running Docker image from linux on the same file later in the week.

Error message:

C:\Users\Andris\tdf2mzml (main -> origin)
(base) λ python tdf2mzml.py -i input.d\ -o test.mzML
INFO:root:transforming TDF to mzML file: input.d\
INFO:root:41568 Total Frames.
INFO:root:60267 Total Spectra.
INFO:root:15479 MS1 Frames.
INFO:root:44788 MS2 Merged Scans.
INFO:root:writting to mzML file: test.mzML
INFO:root:sha1_checksum function took 0.151 s
INFO:root:sha1_checksum function took 3.610 s
INFO:root:Processing 60267 Spectra.
INFO:root:Reading, Merging and Formating Frames for mzML
Traceback (most recent call last):
  File "tdf2mzml.py", line 977, in <module>
    main()
  File "tdf2mzml.py", line 972, in main
    write_mzml(args)
  File "tdf2mzml.py", line 60, in wrap
    ret = f(*args)
  File "tdf2mzml.py", line 850, in write_mzml
    write_precursor_frame(mzml_data_struct)
  File "tdf2mzml.py", line 631, in write_precursor_frame
    {"base peak m/z": base_peak_mz, 'unit_name': 'm/z'}
UnboundLocalError: local variable 'base_peak_mz' referenced before assignment

Conda environment and pip packages:

C:\Users\Andris\tdf2mzml (main -> origin)
(base) λ conda list
# packages in environment at C:\Users\Andris\miniconda3:
#
# Name                    Version                   Build  Channel
brotlipy                  0.7.0           py38h2bbff1b_1003
ca-certificates           2020.10.14                    0
certifi                   2020.6.20          pyhd3eb1b0_3
cffi                      1.14.3           py38hcd4344a_2
chardet                   3.0.4           py38haa95532_1003
conda                     4.9.2            py38haa95532_0
conda-package-handling    1.7.2            py38h76e460a_0
console_shortcut          0.1.1                         4
cryptography              3.2.1            py38hcd4344a_1
cycler                    0.10.0                   pypi_0    pypi
greenlet                  1.0.0                    pypi_0    pypi
idna                      2.10                       py_0
kiwisolver                1.3.1                    pypi_0    pypi
lxml                      4.6.3                    pypi_0    pypi
matplotlib                3.3.4                    pypi_0    pypi
menuinst                  1.4.16           py38he774522_1
numpy                     1.20.1                   pypi_0    pypi
openssl                   1.1.1h               he774522_0
pandas                    1.2.3                    pypi_0    pypi
pillow                    8.1.2                    pypi_0    pypi
pip                       20.2.4           py38haa95532_0
powershell_shortcut       0.0.1                         3
psims                     0.1.34                   pypi_0    pypi
pycosat                   0.6.3            py38h2bbff1b_0
pycparser                 2.20                       py_2
pyopenssl                 19.1.0             pyhd3eb1b0_1
pyparsing                 2.4.7                    pypi_0    pypi
pysocks                   1.7.1            py38haa95532_0
python                    3.8.5                h5fd99cc_1
python-dateutil           2.8.1                    pypi_0    pypi
pytz                      2021.1                   pypi_0    pypi
pywin32                   227              py38he774522_1
requests                  2.24.0                     py_0
ruamel_yaml               0.15.87          py38he774522_1
setuptools                50.3.1           py38haa95532_1
six                       1.15.0           py38haa95532_0
sqlalchemy                1.4.2                    pypi_0    pypi
sqlite                    3.33.0               h2a8f88b_0
tqdm                      4.51.0             pyhd3eb1b0_0
urllib3                   1.25.11                    py_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_3
wheel                     0.35.1             pyhd3eb1b0_0
win_inet_pton             1.1.0            py38haa95532_0
wincertstore              0.2                      py38_0
yaml                      0.2.5                he774522_0
zlib                      1.2.11               h62dcd97_4

C:\Users\Andris\tdf2mzml (main -> origin)
(base) λ pip list
Package                Version
---------------------- -------------------
brotlipy               0.7.0
certifi                2020.6.20
cffi                   1.14.3
chardet                3.0.4
conda                  4.9.2
conda-package-handling 1.7.2
cryptography           3.2.1
cycler                 0.10.0
greenlet               1.0.0
idna                   2.10
kiwisolver             1.3.1
lxml                   4.6.3
matplotlib             3.3.4
menuinst               1.4.16
numpy                  1.20.1
pandas                 1.2.3
Pillow                 8.1.2
pip                    20.2.4
psims                  0.1.34
pycosat                0.6.3
pycparser              2.20
pyOpenSSL              19.1.0
pyparsing              2.4.7
PySocks                1.7.1
python-dateutil        2.8.1
pytz                   2021.1
pywin32                227
requests               2.24.0
ruamel-yaml            0.15.87
setuptools             50.3.1.post20201107
six                    1.15.0
SQLAlchemy             1.4.2
tqdm                   4.51.0
urllib3                1.25.11
wheel                  0.35.1
win-inet-pton          1.1.0
wincertstore           0.2

C:\Users\Andris\tdf2mzml (main -> origin)
mafreitas commented 3 years ago

We have not encountered this error. To troubleshoot can you share the file?

mafreitas commented 3 years ago

I looked at the input file. I don't the data are TDF 2.0. This script was designed for processing TDF 2.0 generated by the timsTOF instrument. Have you tried using proteowizard?

mafreitas commented 3 years ago

Actually I spoke to soon I am testing a fix now. There was a bug in the code checking for empty scans.

andzajan commented 3 years ago

Great, data are in TDF 3.3 format, from TimsTOF pro with PASEF. Proteowizard does work, but takes very long, so I am investigating what is around.

mafreitas commented 3 years ago

I just pushed the fix to the main branch. There were many missing scans at the beginning that trigged the crash. Please let me know if you have any other issues.

andzajan commented 3 years ago

Thank you, it is working now. We intentionally don't record any data during the first 15 minutes of the run.