rainbow.agilent.masshunter

Methods for parsing Agilent Masshunter files.

Functions

parse_allfiles(path[, prec])

Finds and parses Agilent Masshunter data files.

parse_msdata(path[, prec])

Parses Masshunter MS data.

read_complextype(f, complextypes_dict, name)

Reads a "complex" type from f.

read_type(f, complextype_dict, name)

Reads a type from f.

parse_allfiles(path, prec=0)[source]

Finds and parses Agilent Masshunter data files. Currently, only HRMS data is supported. See the documentation on parse_msdata for info on the limitations.

If more file formats are added in the future, parsing should branch out from this method.

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

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

Returns:

List containing a DataFile for each parsed file.

parse_msdata(path, prec=0)[source]

Parses Masshunter MS data.

IMPORTANT: Masshunter MS data can be either stored in MSProfile.bin or MSPeak.bin. This method only supports parsing MSProfile.bin.

The following files are used (in order of listing):
  • MSTS.xml -> Number of retention times.

  • MSScan.xsd -> File structure of MSScan.bin.

  • MSScan.bin -> Offsets and compression info for MSProfile.bin.

  • MSMassCal.bin -> Calibration info for masses.

  • MSProfile.bin -> Actual data values.

Learn more about this file format here.

Parameters:
  • path (str) – Path to the AcqData subdirectory.

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

Returns:

DataFile containing Masshunter MS data.

read_complextype(f, complextypes_dict, name)[source]

Reads a “complex” type from f. Used only for MSScan.bin.

Mutually recurs with read_type.

Parameters:
  • f (_io.BufferedReader) – File opened in ‘rb’ mode.

  • complextypes_dict (dict) – Dictionary defining all “complex” types.

  • name (str) – Name of the “complex” type to parse.

Returns:

Dictionary mapping subtype names to values. If the subtype is “complex”, the value is a nested dictionary. Otherwise, the value is a number.

read_type(f, complextype_dict, name)[source]

Reads a type from f. Used only for MSScan.bin.

Mutually recurs with read_complextype.

Parameters:
  • f (_io.BufferedReader) – File opened in ‘rb’ mode.

  • complextypes_dict (dict) – Dictionary defining all “complex” types.

  • name (str) – Name of the type to parse.

Returns:

If the type is “simple”, a number value. If the type is “complex”, a dictionary mapping names to values.