mzx package

Submodules

mzx.cli module

mzx.cli.main()[source]

Module contents

exception mzx.RawFileConversionError[source]

Bases: Exception

exception mzx.WatersConvertException[source]

Bases: Exception

mzx.convert_raw_file(params: TConfig) str[source]

Convert the raw file to mzML format based on the vendor.

mzx.exclusion_string(x: int) str[source]

Return a string representing “all positive integers except x,” using “start-end” ranges. By convention, “N-” means “N through ∞.”

Examples:

exclude 5 → “1-4 6-” exclude 1 → “2-” exclude 2 → “1 3-” exclude 3 → “1-2 4-”

mzx.export_chromatograms(raw_dir, chrom_info)[source]

Extract and export all chromatogram channels from a Waters .raw directory to CSV.

Output files are written to the parent directory of the .raw folder, named {raw_name}_{channel_name}.csv.

Args:

raw_dir: Path to the Waters .raw directory. chrom_info: Channel metadata from get_chromatogram_info().

Returns:

List of output CSV file paths.

mzx.extract_tic_from_mzml(mzml_path, output_csv=None)[source]

Extract the Total Ion Current (TIC) from an mzML file and write to CSV.

Parses each spectrum element for scan start time and total ion current. Times are converted from minutes to seconds.

Args:

mzml_path: Path to the mzML file. output_csv: Output CSV path. Defaults to {mzml_base}_TIC.csv.

Returns:

Path to the output CSV file.

mzx.format_function_number(s)[source]
mzx.get_chromatogram_info(raw_dir)[source]

Locate and parse _CHROMS.INF from a Waters .raw directory.

Args:

raw_dir: Path to the Waters .raw directory.

Returns:

List of chromatogram channel metadata from parse_chroinf.

mzx.modify_waters_scan_header(line)[source]

Modify the Waters scan header line.

mzx.msconvert(params)[source]

Converts the given file to the mzML format using the msconvert tool.

mzx.parse_chrodat(path)[source]

Parse a Waters _CHRO*.DAT binary file.

Each sample is 8 bytes: two little-endian 32-bit floats (time, intensity). Data starts at offset 0x80.

Args:

path: Path to the _CHRO*.DAT file.

Returns:

Tuple of (times, intensities) as lists of floats, or None if empty.

mzx.parse_chroinf(path)[source]

Parse a Waters _CHROMS.INF file.

Reads channel metadata (name and unit) for each analog data file.

Args:

path: Path to the _CHROMS.INF file.

Returns:

List of [name, unit] pairs for each chromatogram channel.

mzx.process_waters_scan_headers(file_path)[source]

Process the Waters scan headers in the given file.

mzx.run_cmd(cmd)[source]

Run a command and return the output.

mzx.waters_convert(params: TConfig) str[source]

Convert Waters raw file to mzML format.

mzx.write_chrom_csv(filename, times, intensities)[source]

Write chromatogram data to a CSV file.

Args:

filename: Output CSV file path. times: List of time values. intensities: List of intensity values.