toMassbank {RMassBank} | R Documentation

## Write MassBank record into character array

### Description

Writes a MassBank record in list format to a text array.

### Usage

    toMassbank(mbdata)

### Arguments

`mbdata` | A MassBank record in list format.

### Details

The function is a general conversion tool for the MassBank format; i.e. the field names are not fixed. `mbdata` must be a named list, and the entries can be as follows:

- A single text line:

  `'CH\$EXACT_MASS' = '329.1023'`

  is written as

  `CH\$EXACT_MASS: 329.1023`

- A character array:

  `'CH\$NAME' = c('2-Aminobenzimidazole', '1H-Benzimidazol-2-amine')`

  is written as

  `CH\$NAME: 2-Aminobenzimidazole`

  `CH\$NAME: 1H-Benzimidazol-2-amine`

- A named list of strings:

  `'CH\$LINK' = list('CHEBI' = "27822", "KEGG" = "C10901")`

  is written as

  `CH\$LINK: CHEBI 27822`

  `CH\$LINK: KEGG C10901`

- A data frame (e.g. the peak table) is written as specified in the MassBank record format (Section 2.6.3): the column names are used as headers for the first line, all data rows are printed space-separated.

### Value

The result is a text array, which is ready to be written to the disk as a file.

### Note

The function iterates over the list item names. This means that duplicate entries in `mbdata` are (partially) discarded! The correct way to add them is by making a character array (as specified above): Instead of `'CH\$NAME' = 'bla', 'CH\$NAME' = 'blub'` specify `'CH\$NAME' = c('bla','blub')`.

### Author(s)

Michael Stravs

### References

MassBank record format: http://www.massbank.jp/manuals/MassBankRecord_en.pdf

### See Also

`compileRecord`, `mbWorkflow`

### Examples

    ## Not run:
    # Read just the compound info skeleton from the Internet for some compound ID
    id <- 35
    mbdata <- gatherData(id)
    #' # Export the mbdata blocks to line arrays
    # (there is no spectrum information, just the compound info...)
    mbtext <- toMassbank(mbdata)

    ## End(Not run)

[Package RMassBank version 3.0.0 Index]