MassBank / RMassBank

Playground for experiments on the official http://bioconductor.org/packages/devel/bioc/html/RMassBank.html
Other
12 stars 15 forks source link

accessionBuilder: collision in condition_hash #337

Closed tsufz closed 1 year ago

tsufz commented 1 year ago

Hi, I tried the accession generation using the accessionBuilder. Unfortuntely, the condition_hash creates collisions. As it does not include the ion, there is a collision if the precursor type is not included in the accessionBuilder. As we want to avoid semantics in the accession, I suggest upgrading the hash with additional information such as the precursor_type.

Yours, Tobias

tsufz commented 1 year ago

@meowcat, I tried something in buildRecord.R#396ff

  variables$mode_hash <- substr(toupper(adduct$hash), 1, .adductHashSize)
  # a "MS condition hash" merging instrument type, ionization, collision and CE
  # AC$INSTRUMENT_TYPE: LC-ESI-ITFT
  # AC$MASS_SPECTROMETRY: MS_TYPE MS2
  # AC$MASS_SPECTROMETRY: ION_MODE POSITIVE
  # AC$MASS_SPECTROMETRY: IONIZATION ESI
  # AC$MASS_SPECTROMETRY: FRAGMENTATION_MODE HCD
  # AC$MASS_SPECTROMETRY: COLLISION_ENERGY 15 % (nominal)
  # AC$MASS_SPECTROMETRY: RESOLUTION 15000
  variables$polarity <- function(digits=1) substr(variables$metadata$ION_MODE, 1, digits)
  variables$condition <- glue_data(
    variables$metadata,
    "{INSTRUMENT_TYPE}${MS_TYPE}${ION_MODE}${IONIZATION}${FRAGMENTATION_MODE}${COLLISION_ENERGY}${mode_hash}")

But I get

INFO [2023-07-25 19:05:14] mbWorkflow: Step 3. Data reformatting
INFO [2023-07-25 19:05:14] mbWorkflow: Step 4. Spectra compilation
INFO [2023-07-25 19:05:14] Compiling: Bisoprolol
Error in eval(parse(text = text, keep.source = FALSE), envir) :
object 'FRAGMENTATION_MODE' not found

Any clue, why FM is not found?

meowcat commented 1 year ago

I wouldn't know since this is not something that changed? But my suggestion to fix the collision issue (thanks for noticing!) would be:

variables$metadata <- c(
    spectrum@info$`AC$MASS_SPECTROMETRY`,
    spectrum@info$`CH$LINK`
    spectrum@info$`MS$FOCUSED_ION`
  )
// [...]
  variables$condition <- glue_data(
    variables$metadata,
    "{INSTRUMENT_TYPE}${MS_TYPE}${ION_MODE}${IONIZATION}${FRAGMENTATION_MODE}${COLLISION_ENERGY}${PRECURSOR_TYPE}")
meowcat commented 1 year ago

Merge #344 into your branch while working on this; variables$metadata now has much more data to access.

meowcat commented 1 year ago

Hm but adding mode_hash should also have been a viable option. Why it doesn't work, i can't tell from here...

tsufz commented 1 year ago

@meowcat enhanced documentation, now works.