rainbow.datasequence.DataSequence

class DataSequence(path, injections, metadata)[source]

Bases: object

Class representing a multi-injection sequence.

Where a DataDirectory is a single run (one injection), a DataSequence is the sequence of many runs: an ordered set of injections that share one instrument, one method, and (for Agilent) a sequence.acaml document. Each injection is itself a DataDirectory, so everything a single read supports still works per injection.

Parameters:
  • path (str) – Path of the sequence directory.

  • injections (list) – The DataDirectory objects, in acquisition order.

  • metadata (dict) – Sequence-level metadata. Depends on the vendor.

Attributes:
  • name (str) – Name of the sequence directory.

  • path (str) – Path of the sequence directory.

  • injections (list) – The DataDirectory objects, in acquisition order.

  • by_name (dict) – Maps each injection’s directory name to its DataDirectory. Lookups through get_injection, in and sequence[name] ignore case; this mapping keeps the names as the directories spell them.

  • metadata (dict) – Sequence-level metadata. Depends on the vendor.

get_injection(name)[source]

Returns an injection by its directory name.

Raises KeyError if the name is not in the sequence, naming the injections that are. Use name in sequence to ask without raising.

Parameters:

name (str) – Injection directory name (e.g. "008-...01.D").

get_info()[source]

Returns a string summary of the sequence.

to_asm(*, export_dad_cube=True, wavelengths=None, ions=None, decimal_places=None, technique=None, utc_offset=None)[source]

Returns an Allotrope Simple Model (ASM) document for this sequence.

The document carries one device system document for the sequence and one liquid- or gas-chromatography document per injection. If the sequence was read with peaks=True, each injection’s integrated peaks become its processed data. See rainbow.asm for the scope of the mapping.

A whole sequence bundles one document per injection, so it can be very large. export_dad_cube=False, a wavelengths subset, and decimal_places each shrink it; for export to disk prefer export_asm(), which streams.

Parameters:
  • export_dad_cube (bool, optional) – Include multi-wavelength DAD spectra as 3D UV spectrum cubes. On by default; the dominant size driver, so turning it off shrinks the output sharply.

  • wavelengths (float/list, optional) – Restrict the DAD spectrum cube to these wavelengths (nearest available, in nm); the default keeps every wavelength.

  • ions (float/list, optional) – m/z value(s) to extract from full-scan MS data, each exported as its own mass chromatogram. Single-ion (SIM) MS is always exported regardless of this argument.

  • decimal_places (int, optional) – Round emitted numeric values to this many decimal places. The default keeps full precision.

  • technique (str, optional) – Force the export technique, "GC" or "LC", overriding the method’s declaration and the FID-presence fallback.

  • utc_offset (str, optional) – UTC offset such as "-05:00" or "Z", stamped on timestamps the instrument recorded without one. An offset the source did record is never overridden.

Returns:

The ASM document.

Return type:

dict

export_asm(filename, *, export_dad_cube=True, wavelengths=None, ions=None, decimal_places=None, technique=None, utc_offset=None, indent=2, per_injection=False)[source]

Writes an Allotrope Simple Model (ASM) JSON document for this sequence.

The document is streamed to disk one injection at a time, so even a long sequence of large spectra never has to fit in memory at once.

With per_injection=True, filename is treated as a directory and each injection is written as its own standalone document (named for the injection), rather than one bundled file. This keeps a long diode-array sequence from producing a single multi-gigabyte file; the method then returns the list of paths written.

Parameters:
  • filename (str) – Output JSON file, or the output directory when per_injection is True.

  • export_dad_cube (bool, optional) – Include multi-wavelength DAD spectra as 3D UV spectrum cubes. On by default; turning it off shrinks the output sharply.

  • wavelengths (float/list, optional) – Restrict the DAD spectrum cube to these wavelengths (nearest available, in nm); the default keeps every wavelength.

  • ions (float/list, optional) – m/z value(s) to extract from full-scan MS data, each exported as its own mass chromatogram. Single-ion (SIM) MS is always exported regardless of this argument.

  • decimal_places (int, optional) – Round emitted numeric values to this many decimal places. The default keeps full precision.

  • technique (str, optional) – Force the export technique, "GC" or "LC", overriding the method’s declaration and the FID-presence fallback.

  • utc_offset (str, optional) – UTC offset such as "-05:00" or "Z", stamped on timestamps the instrument recorded without one. An offset the source did record is never overridden.

  • indent (int, optional) – Indentation for the output JSON.

  • per_injection (bool, optional) – Write one standalone document per injection into filename (a directory) instead of one bundled file. Returns the list of paths written.