RECETOX / galaxytools

Set of Galaxy tool wrappers developed at RECETOX
MIT License
13 stars 13 forks source link

matchms networking: fix compatability with newer matchms tools #435

Closed hechth closed 10 months ago

hechth commented 10 months ago

When running the networking on newer matchms output you get the following error:

Traceback (most recent call last):
  File "/opt/galaxy/shed_tools/toolshed.g2.bx.psu.edu/repos/recetox/matchms_networking/d8e937f335b8/matchms_networking/matchms_networking_wrapper.py", line 38, in <module>
    main(argv=sys.argv[1:])
  File "/opt/galaxy/shed_tools/toolshed.g2.bx.psu.edu/repos/recetox/matchms_networking/d8e937f335b8/matchms_networking/matchms_networking_wrapper.py", line 31, in main
    network.create_network(scores, args.score_name)
  File "/usr/local/tools/_conda/envs/__matchms@0.23.1/lib/python3.11/site-packages/matchms/networking/SimilarityNetwork.py", line 119, in create_network
    similars_idx, similars_scores = get_top_hits(scores, identifier_key=self.identifier_key,
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/tools/_conda/envs/__matchms@0.23.1/lib/python3.11/site-packages/matchms/networking/networking_functions.py", line 49, in get_top_hits
    r, _, v = scores.scores[:, i, score_name]
              ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/usr/local/tools/_conda/envs/__matchms@0.23.1/lib/python3.11/site-packages/sparsestack/StackedSparseArray.py", line 89, in __getitem__
    r, c, d = self._getitem_method(row, col, name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/tools/_conda/envs/__matchms@0.23.1/lib/python3.11/site-packages/sparsestack/StackedSparseArray.py", line 110, in _getitem_method
    return self.row[idx], self.col[idx], self._slicing_data(name, idx)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/tools/_conda/envs/__matchms@0.23.1/lib/python3.11/site-packages/sparsestack/StackedSparseArray.py", line 131, in _slicing_data
    return self.data[name][idx]
           ~~~~~~~~~^^^^^^
ValueError: no field of name CosineGreedy_score

This can be fixed by looking for the proper score name in the scores object and then passing that one.