ISA-tools / mzml2isa

Parser to get meta information from mzML file and parse relevant information to a ISA-Tab structure
GNU General Public License v3.0
12 stars 6 forks source link

Uninformative stacktrace from extract_assay_parameters() #51

Open sneumann opened 2 months ago

sneumann commented 2 months ago

Hi, for some mzML from a Bruker microTOFq converted with msconvert I am getting an exception when running mzml2isa -i test -o /tmp/MTBLS4823/ -s MTBLS4823 with mzml2isa version 1.1.1

Traceback (most recent call last):
  File "/home/sneumann/.local/bin/mzml2isa", line 8, in <module>
    sys.exit(main())
  File "/home/sneumann/.local/lib/python3.10/site-packages/mzml2isa/parsing.py", line 251, in main
    convert(
  File "/home/sneumann/.local/lib/python3.10/site-packages/mzml2isa/parsing.py", line 129, in convert
    metalist = list(map(_parse_file, files_iter))
  File "/home/sneumann/.local/lib/python3.10/site-packages/mzml2isa/utils.py", line 122, in new_func
    return func(*args)
  File "/home/sneumann/.local/lib/python3.10/site-packages/mzml2isa/parsing.py", line 56, in _parse_file
    return parser(filesystem, path).metadata
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/sneumann/.local/lib/python3.10/site-packages/mzml2isa/mzml.py", line 1264, in metadata
    self._extract_assay_parameters(meta)
  File "/home/sneumann/.local/lib/python3.10/site-packages/mzml2isa/mzml.py", line 964, in _extract_assay_parameters
    for element in self._find_xpath(self._XPATHS[location]):
  File "/home/sneumann/.local/lib/python3.10/site-packages/mzml2isa/mzml.py", line 857, in _find_xpath
    ns = self.namespaces
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/sneumann/.local/lib/python3.10/site-packages/mzml2isa/mzml.py", line 803, in namespaces
    root = self.tree.getroot()
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/sneumann/.local/lib/python3.10/site-packages/mzml2isa/mzml.py", line 795, in tree
    return etree.parse(self.fs.getsyspath(self.path))
  File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 1222, in parse
    tree.parse(source, parser)
  File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 580, in parse
    self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: no element found: line 56013, column 0

=> This is because the mzML ended prematurely, because the Bruker *.d also aborted prematurely during the run, the mzML ends with :

            </binaryDataArray>
          </binaryDataArrayList>
        </spectrum>

So the only fix would be to xml lint the files prior to proper parsing. Feel free to close this issue right away. Yours, Steffen