rainbow.waters.masslynx

Methods for parsing Waters Masslynx files.

Functions

calc_frac(keyfrac_bits, num_bits)

Decodes fractional values from keyfrac_bits.

calibrate(mzs, calib_nums)

Calibrates mzs using calib_nums.

parse_analog(path[, requested_files])

Finds and parses analog data from a Waters .raw directory.

parse_chrodat(path, name[, units])

Parses a Waters _CHRO .DAT file.

parse_chroinf(path)

Parses a Waters _CHROMS.INF file.

parse_compound_names(path)

parse_funcdat2(path, pair_counts[, prec, calib])

Parses a Waters _FUNC .DAT file with the 2-bytes format.

parse_funcdat4(path, pair_counts[, prec, calib])

Parses a Waters _FUNC .DAT file with the 4-bytes format.

parse_funcdat6(path, pair_counts[, prec, calib])

Parses a Waters _FUNC .DAT file with the 6-bytes format.

parse_funcdat8(path, pair_counts[, prec, calib])

Parses a Waters _FUNC .DAT file with the 8-bytes format.

parse_funcidx(path)

Parses a Waters _FUNC .IDX file.

parse_funcinf(path)

Parses a Waters _FUNCTNS.INF file.

parse_funcinf_q3(path)

Parses a Waters _FUNCTNS.INF file for Q3 transitions

parse_function(path[, prec, polarity, calib])

Parses data for a Waters function.

parse_metadata(path)

Parses metadata from a Waters .raw directory.

parse_spectrum(path[, prec, requested_files])

Finds and parses Waters UV and MS spectra from a .raw directory.

parse_spectrum(path, prec=0, requested_files=None)[source]

Finds and parses Waters UV and MS spectra from a .raw directory.

IMPORTANT: The HRMS data format is not supported. It can be differentiated from low resolution MS data using the _extern.inf or _FUNC .IDX files.

Parameters:
  • path (str) – Path to the .raw directory.

  • prec (int, optional) – Number of decimals to round ylabels.

  • requested_files (list, optional) – List of filenames to parse.

Returns:

List with a DataFile for each parsed spectrum.

parse_function(path, prec=0, polarity=None, calib=None)[source]

Parses data for a Waters function.

Each function corresponds to a MS or UV spectrum. The data is extracted from numbered _FUNC .IDX and _FUNC .DAT files.

IMPORTANT: There are multiple data formats for Waters spectra that are differentiated by the number of bytes used to store each data pair. This program only supports the 2, 6, and 8 byte formats.

Parameters:
  • path (str) – Path to the _FUNC .DAT file.

  • prec (int, optional) – Number of decimals to round ylabels.

  • polarity (str, optional) – Polarity of the spectrum.

  • calib (list, optional) – Float calibration values of the spectrum.

Returns:

DataFile with MS or UV spectrum data.

parse_funcidx(path)[source]

Parses a Waters _FUNC .IDX file.

Learn more about this file format here.

Parameters:

path (str) – Path to the _FUNC .IDX file.

Returns:

1D numpy array with retention times. 1D numpy array with the number of data pairs at each time. Integer representing the file format of the corresponding _FUNC .DAT file.

parse_funcdat2(path, pair_counts, prec=0, calib=None)[source]

Parses a Waters _FUNC .DAT file with the 2-bytes format.

This format contains MS data.

Learn more about this file format here.

Parameters:
  • path (str) – Path to the _FUNC .DAT file.

  • pair_counts (np.ndarray) – 1D array with the number of data pairs at each retention time.

  • prec (int, optional) – Number of decimals to round ylabels.

  • calib (list, optional) – Float calibration values of the spectrum.

Returns:

1D numpy array with ylabels. 2D numpy array with data values where the rows correspond to retention times and the columns correspond to ylabels.

parse_funcdat4(path, pair_counts, prec=0, calib=None)[source]

Parses a Waters _FUNC .DAT file with the 4-bytes format.

This format may contain MS or UV data.

Learn more about this file format here.

Parameters:
  • path (str) – Path to the Waters _FUNC .DAT file.

  • pair_counts (np.ndarray) – 1D array with the number of data pairs at each retention time.

  • prec (int, optional) – Number of decimals to round ylabels.

  • calib (list, optional) – Float calibration values of the spectrum.

Returns:

1D numpy array with ylabels. 2D numpy array with data values where the rows correspond to retention times and the columns correspond to ylabels.

parse_funcinf(path)[source]

Parses a Waters _FUNCTNS.INF file.

This file contains mz values for the 2-byte format.

Learn more about this file format here.

Parameters:

path (str) – Path to the _FUNCTNS.INF file.

Returns:

2D numpy array of mz values where the rows correspond to functions.

parse_funcdat6(path, pair_counts, prec=0, calib=None)[source]

Parses a Waters _FUNC .DAT file with the 6-bytes format.

This format may contain MS or UV data.

Learn more about this file format here.

Parameters:
  • path (str) – Path to the Waters _FUNC .DAT file.

  • pair_counts (np.ndarray) – 1D array with the number of data pairs at each retention time.

  • prec (int, optional) – Number of decimals to round ylabels.

  • calib (list, optional) – Float calibration values of the spectrum.

Returns:

1D numpy array with ylabels. 2D numpy array with data values where the rows correspond to retention times and the columns correspond to ylabels.

parse_funcdat8(path, pair_counts, prec=0, calib=None)[source]

Parses a Waters _FUNC .DAT file with the 8-bytes format.

This format contains MS data.

Learn more about this file format here.

Parameters:
  • path (str) – Path to the _FUNC .DAT file.

  • pair_counts (np.ndarray) – 1D array with the number of data pairs at each retention time.

  • prec (int, optional) – Number of decimals to round ylabels.

  • calib (list, optional) – Float calibration values of the spectrum.

Returns:

1D numpy array with ylabels. 2D numpy array with data values where the rows correspond to retention times and the columns correspond to ylabels.

calibrate(mzs, calib_nums)[source]

Calibrates mzs using calib_nums.

Computes the formula c1 * mz^0 + c2 * mz^1 + c3 * mz^2 for each mz where c1, c2, and c3 are the calibration values.

Parameters:
  • mzs (np.ndarray) – 1D array with uncalibrated mz values.

  • calib_nums (list) – Float calibration values.

Returns:

1D numpy array with calibrated mz values.

calc_frac(keyfrac_bits, num_bits)[source]

Decodes fractional values from keyfrac_bits.

This method skips the costly computation of decoding a Waters fraction by manipulating the bits into the standard double-precision floating point format.

Parameters:
  • keyfrac_bits (np.ndarray) – Bits representing a fractional value.

  • num_bits (np.ndarray) – Bitlength of each fractional value. This number is greater than the actual bitlength of the corresponding value in keyfrac_bits when there are unseen zero bits padding the head.

Returns:

1D numpy array with fractional values.

parse_analog(path, requested_files=None)[source]

Finds and parses analog data from a Waters .raw directory.

Parameters:
  • path (str) – Path to the .raw directory.

  • requested_files (list, optional) – List of filenames to parse.

Returns:

List of DataFiles that contain analog data.

parse_chroinf(path)[source]

Parses a Waters _CHROMS.INF file.

Retrieves the name and unit for each analog data file.

Parameters:

path (str) – Path to the _CHROMS.INF file.

Returns:

List of string lists that contain the name and unit (if it exists) of the data in each analog file.

parse_chrodat(path, name, units=None)[source]

Parses a Waters _CHRO .DAT file.

These files may contain data for CAD, ELSD, or UV channels. They may also contain other miscellaneous data like system pressure.

IMPORTANT: MassLynx classifies these files as “analog” data, but a DataDirectory will not treat CAD, ELSD, or UV channels as analog. Instead, those channels will be mapped to their detector.

Learn more about this file format here.

Parameters:
  • path (str) – Path to the _CHRO .DAT file.

  • name (str) – Name of the analog data.

  • units (str, optional) – Units of the analog data.

Returns:

DataFile with analog data, if the file can be parsed. Otherwise, None.

parse_metadata(path)[source]

Parses metadata from a Waters .raw directory.

Specifically, the date and vial position are extracted from _HEADER.txt.

Parameters:

path (str) – Path to the .raw directory.

Returns:

Dictionary with directory metadata.

parse_compound_names(path)[source]
parse_funcinf_q3(path)[source]

Parses a Waters _FUNCTNS.INF file for Q3 transitions

This file contains mz values for the 2-byte format.

Learn more about this file format here.

Parameters:

path (str) – Path to the _FUNCTNS.INF file.

Returns:

2D numpy array of mz values where the rows correspond to functions.