SpectraTutorials icon indicating copy to clipboard operation
SpectraTutorials copied to clipboard

Export options other than mgf?

Open gmhhope opened this issue 4 years ago • 6 comments

What options for the export function in Spectra other than .mgf?

Thanks, Minghao

gmhhope avatar Apr 26 '21 02:04 gmhhope

This depends on the MsBackend you're using. With the MsBackendMzR it is possible to export to mzML or mzXML files, with the MsBackendMgf to mgf files and with MsBackendMassbank to massbank txt files. Additional export options might be implemented if needed (I usually implement them if I need them myself).

jorainer avatar Apr 26 '21 06:04 jorainer

This depends on the MsBackend you're using. With the MsBackendMzR it is possible to export to mzML or mzXML files, with the MsBackendMgf to mgf files and with MsBackendMassbank to massbank txt files. Additional export options might be implemented if needed (I usually implement them if I need them myself).

Thanks! That is actually very nice. I need to have ".json" format for our python application. If that can be implemented, it will be great! Well, I will do some research to parse those formats to ".json" but if you have some insightful hint will be great as well if you don't want to engage with something like 'MSbackendJson" 😄

gmhhope avatar Apr 26 '21 13:04 gmhhope

I've never worked with json yet, but I know that there are packages in R that allow to parse json files. Would be great if you could work on a backend for your type of data! Maybe you can use the MsBackendMassbank as template? the repo is https://github.com/rformassspectrometry/MsBackendMassbank and the file to check is the MsBackendMassbank.R.

jorainer avatar Apr 27 '21 05:04 jorainer

It will be honored to contribute. I will come back to you soon! Thanks!

Best, Minghao

gmhhope avatar Apr 27 '21 16:04 gmhhope

I've never worked with json yet, but I know that there are packages in R that allow to parse json files. Would be great if you could work on a backend for your type of data! Maybe you can use the MsBackendMassbank as template? the repo is https://github.com/rformassspectrometry/MsBackendMassbank and the file to check is the MsBackendMassbank.R.

I just found out MoNA database is stored in Json. Did you ever work on that yet? Maybe that can be a better template to work with from my end. We may have our own database soon but the format will probably align with MoNA?

BTW, I also looked into the MsBackendMassbank.R. Unfortunately, I am not very familiar with developer-level R scripts. I just need to export that to JSON format like this:

class Spectrum(Peak):
    '''
    Spectrum provides data points as measured on the instrument, 
    to support the concept of Peak.
    This can be MS level 1, 2 or n.
    
    templated on MONA JSON
            {"instrument": "",
            "precursor type": "M+H[1+]",
            "precursor m/z": 169,
            "collision energy": "30V",
            "score": 5.5,
            "spectrum": "59.000:0.615142 72.600:0.031546 74.600:0.015773 78.900:0.086751 85.200:1.490536 150.500:0.055205 166.000:0.055205 167.200:100.000000",
            },
            {},
            {}
    '''

    ms_level = 2
    precursor_ion = ''
    precursor_ion_mz = 0

    list_mz = []
    list_intensity = []
    retention_time = 0 

Please provides me any feedback if you can!

Thanks, Minghao Gong

gmhhope avatar May 05 '21 12:05 gmhhope

I think we added support to import MoNa data in CompoundDb - I just don't remember if we also support importing spectra data or just the compound information...

jorainer avatar May 05 '21 13:05 jorainer