lgatto / MSnbase

Base Classes and Functions for Mass Spectrometry and Proteomics
http://lgatto.github.io/MSnbase/
123 stars 50 forks source link

error writeMgfData when using connections #505

Closed ricoderks closed 4 years ago

ricoderks commented 4 years ago

Hi,

I'am trying to use writeMgfData with a file connection. If I use this code:

con <- file(description = "test.mgf",
            open = "w")
writeMgfData(object = swath_spectrum[[1]],
             con = con)
close(con)

I get the following error: Error in file(description = con, open = "at") : invalid 'description' argument

And the full traceback:

Error in file(description = con, open = "at") : invalid 'description' argument
5. file(description = con, open = "at")
4. writeMgfDataFile(list(object), con = con, COM = COM, TITLE = TITLE, verbose = isMSnbaseVerbose())
3. .local(object, ...)
2. writeMgfData(object = swath_spectrum[[1]], con = con)
1. writeMgfData(object = swath_spectrum[[1]], con = con)

I'am also wondering why it says open = "at" while I specified open = "w"?

I would like to use connections, because later I would like to append more MSMS spectra to the same mgf ile.

Using R 3.6.3 and MSnbase 2.12.0.

Best regards, Rico

ricoderks commented 4 years ago

I just had a look at the code and I think I fixed it. I'll send a PR. I haven't done this that often so I hope I get it right.

lgatto commented 4 years ago

Thank you for the PR.