Skip to content

GNPS2 Task Spectra with a "+" do not resolve #216

@Michael-C-Strobel

Description

@Michael-C-Strobel

Target USI:
mzspec:GNPS2:TASK-4d6b9bd8158b4f4eadfac04ea31c3aaa-nf_output/search/query_spectra/D0 - SM+ - 5.mzML:scan:1
Example Request

Resolver requests:
https://gnps2.org/spectrumpeaks?format=json&usi=mzspec:GNPS2:TASK-4d6b9bd8158b4f4eadfac04ea31c3aaa-nf_output/search/query_spectra/D0%20-%20SM+%20-%205.mzML:scan:1

Resolver should request:
https://gnps2.org/spectrumpeaks?format=json&usi=mzspec:GNPS2:TASK-4d6b9bd8158b4f4eadfac04ea31c3aaa-nf_output/search/query_spectra/D0%20-%20SM%2B%20-%205.mzML:scan:1
(+ -> %2B)

File path in USI should be escaped here, but we should probable create a general "escape USI" function:

f"{gnps2server_url}/spectrumpeaks?format=json&usi={usi}"

Here is some messy code to achieve this:

from urllib.parse import quote

portion_prior_to_task = usi.split("TASK-", 1)[0]
task_id_and_beyond = usi.split("TASK-", 1)[1]
task_id_and_path = task_id_and_beyond.split(':scan:', 1)[0]
task_id_and_path = quote(task_id_and_path)
scan = task_id_and_beyond.split(':scan:', 1)[1]
quoted_usi = f"{portion_prior_to_task}TASK-{task_id_and_path}:scan:{scan}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions