ms2pip.spectrum_output
Write spectrum files from MS²PIP prediction results.
Examples
The simplest way to write MS²PIP predictions to a file is to use the write_spectra()
function:
>>> from ms2pip import predict_single, write_spectra
>>> results = [predict_single("ACDE/2")]
>>> write_spectra("/path/to/output/filename", results, "mgf")
Specific writer classes can also be used directly. Writer classes should be used in a context manager to ensure the file is properly closed after writing. The following example writes MS²PIP predictions to a TSV file:
>>> from ms2pip import predict_single
>>> results = [predict_single("ACDE/2")]
>>> with TSV("output.tsv") as writer:
... writer.write(results)
Results can be written to the same file sequentially:
>>> results_2 = [predict_single("PEPTIDEK/2")]
>>> with TSV("output.tsv", write_mode="a") as writer:
... writer.write(results)
... writer.write(results_2)
Results can be written to an existing file using the append mode:
>>> with TSV("output.tsv", write_mode="a") as writer:
... writer.write(results_2)
- ms2pip.spectrum_output.write_spectra(filename, processing_results, file_format='tsv', write_mode='w')[source]
Write MS2PIP processing results to a supported spectrum file format.
- Parameters:
filename (str | Path) – Output filename without file extension.
processing_results (List[ProcessingResult]) – List of
ms2pip.result.ProcessingResultobjects.file_format (str) – File format to write. See
FILE_FORMATSfor available formats.write_mode (str) – Write mode for file. Default is
w(write). Usea(append) to add to existing file.
- class ms2pip.spectrum_output.TSV(filename, write_mode='w')[source]
Bases:
_WriterWrite TSV files from MS2PIP processing results.
- write(processing_results)[source]
Write multiple processing results to file.
- Parameters:
processing_results (List[ProcessingResult]) –
- class ms2pip.spectrum_output.MSP(filename, write_mode='w')[source]
Bases:
_WriterWrite MSP files from MS2PIP processing results.
- write(results)[source]
Write multiple processing results to file.
- Parameters:
results (List[ProcessingResult]) –
- class ms2pip.spectrum_output.MGF(filename, write_mode='w')[source]
Bases:
_WriterWrite MGF files from MS2PIP processing results.
See http://www.matrixscience.com/help/data_file_help.html for documentation on the MGF format.
- write(results)[source]
Write multiple processing results to file.
- Parameters:
results (List[ProcessingResult]) –
- class ms2pip.spectrum_output.Spectronaut(filename, write_mode='w')[source]
Bases:
_WriterWrite Spectronaut files from MS2PIP processing results.
- write(processing_results)[source]
Write multiple processing results to file.
- Parameters:
processing_results (List[ProcessingResult]) –
- class ms2pip.spectrum_output.Bibliospec(filename, write_mode='w')[source]
Bases:
_WriterWrite Bibliospec SSL and MS2 files from MS2PIP processing results.
Bibliospec SSL and MS2 files are also compatible with Skyline. See https://skyline.ms/wiki/home/software/BiblioSpec/page.view?name=BiblioSpec%20input%20and%20output%20file%20formats for documentation on the Bibliospec file formats.
- write(processing_results)[source]
Write multiple processing results to file.
- Parameters:
processing_results (List[ProcessingResult]) –
- class ms2pip.spectrum_output.DLIB(filename, write_mode='w')[source]
Bases:
_WriterWrite DLIB files from MS2PIP processing results.
See EncyclopeDIA File Formats for documentation on the DLIB format.
- write(processing_results)[source]
Write MS2PIP predictions to a DLIB SQLite file.
- Parameters:
processing_results (List[ProcessingResult]) –