Skip to main content

Writers and controlled vocabulary manager for PSI-MS's mzML and mzIdentML standards

Project description


Prototype work for a unified API for writing PSIMS standardized XML documents, currently just mzML and MzIdentML

See the Documenation for more information

mzML Minimal Example

from psims.mzml.writer import MzMLWriter

# Load the data to write
scans = get_scan_data()

with MzMLWriter(open("out.mzML", 'wb')) as out:
    # Add default controlled vocabularies
    # Open the run and spectrum list sections
        spectrum_count = len(scans) + sum([len(products) for _, products in scans])
        with out.spectrum_list(count=spectrum_count):
            for scan, products in scans:
                # Write Precursor scan
                    scan.mz_array, scan.intensity_array,
          , params=[
                        "MS1 Spectrum",
                        {"ms level": 1},
                        {"total ion current": sum(scan.intensity_array)}
                # Write MSn scans
                for prod in products:
                        prod.mz_array, prod.intensity_array,
              , params=[
                            "MSn Spectrum",
                            {"ms level": 2},
                            {"total ion current": sum(prod.intensity_array)}
                         # Include precursor information
                            "mz": prod.precursor_mz,
                            "intensity": prod.precursor_intensity,
                            "charge": prod.precursor_charge,
                            "scan_id": prod.precursor_scan_id


If you use psims in an academic project, please cite:

Klein, J. A., & Zaia, J. (2018). psims - A declarative writer for mzML and mzIdentML for Python. Molecular & Cellular Proteomics, mcp.RP118.001070.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for psims, version 0.1.28
Filename, size File type Python version Upload date Hashes
Filename, size psims-0.1.28.tar.gz (5.9 MB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page