API

Python wrapper around the ThermoRawFileParser command line interface.

class pyrawr.ThermoRawFileParser(executable='thermorawfileparser', docker_image=None)

Wrapper around ThermoRawFileParser CLI.

Parameters
  • executable (str) – ThermoRawFileParser shell command. For example, thermorawfileparser or mono ThermoRawFileParser.exe.

  • docker_image (str, optional) – Docker image with ThermoRawFileParser. Requires the docker run CLI command.

version_requirement

ThermoRawFile semver version requirement.

Type

str

installed_version

Installed ThermoRawFileParser version.

Type

str

Examples

>>> from pyrawr import ThermoRawFileParser
>>> trfp = ThermoRawFileParser(
...     executable="thermorawfileparser",
...     docker_image="quay.io/biocontainers/thermorawfileparser:1.3.3--ha8f3691_1"
... )
>>> trfp.parse("OR4_110719_OB_PAR14_sSCX_fr10.raw")
>>> trfp.metadata("OR4_110719_OB_PAR14_sSCX_fr10.raw")
{'FileProperties': [{'accession': 'NCIT:C47922', 'cvLabel': 'NCIT' ... }]}
>>> trfp.query("OR4_110719_OB_PAR14_sSCX_fr10.raw", "508,680")
[{'mzs': [204.8467254638672,
262.4529113769531,
309.53961181640625,
...
>>> trfp.xic(
...     "OR4_110719_OB_PAR14_sSCX_fr10.raw",
...     [{"mz":488.5384, "tolerance":10, "tolerance_unit":"ppm"}],
... )
{'OutputMeta': {'base64': False, 'timeunit': 'minutes'},
'Content': [{'Meta': {'MzStart': 488.53351461600005,
    'MzEnd': 488.543285384,
    'RtStart': 0.007536666666666666,
    'RtEnd': 179.99577166666666},
'RetentionTimes': [0.007536666666666666,
    0.022771666666666666,
    0.036936666666666666,
    ...
parse(input_file, output_format=None, options=None)

Parse raw file to one of the supported output formats.

Parameters
  • input_file (str) – Path to input file.

  • output_format (str, optional) – Output format. One of mgf, mzml, indexed_mzml, parquet, or scan_info.

  • options (List) – List of other CLI options to pass to ThermoRawFileParser. See ThermoRawFileParser docs for more info.

metadata(input_file)

Get raw file metadata as Python dictionary.

Parameters

input_file (str) – Path to input file.

Returns

metadata – Dictionary containing raw file metadata.

Return type

dict

query(input_file, scans, options=None)

Retrieve specific spectra by scan number in ProXI format.

Parameters
  • input_file (str) – Path to input file.

  • scans (str) – Scan numbers, e.g. 1-5, 20, 25-30.

  • options (list) – List of other CLI options to pass to ThermoRawFileParser. See ThermoRawFileParser docs for more info.

Returns

spectra – List of spectra in ProXI format.

Return type

list

xic(input_file, query, base64=False)

Retrieve one or more chromatograms based on a query.

Parameters
  • input_file (str) – Path to input file.

  • query (list) – List of query dictionaries. See ThermoRawFileParser docs for more info.

  • base64 (boolean, optional) – Encode the content of the xic vectors as base 64.

Returns

xic – Dictionary containing XICs.

Return type

dict

exception pyrawr.ThermoRawFileParserError

General ThermoRawFileParser error.

exception pyrawr.ThermoRawFileParserInstallationError

Could not find ThermoRawFileParser CLI.

exception pyrawr.ThermoRawFileParserRunError

Error running ThermoRawFileParser.