CDK-R / cdkr

Integrating R and the CDK
https://cdk-r.github.io/cdkr/
42 stars 27 forks source link

Isotope labels for get.isotope.pattern #151

Open gjgfml opened 4 months ago

gjgfml commented 4 months ago

Hi, I'm using the rCDK package and I'm getting the isotope pattern for a given molecular formula, but they have no labels as to what combination of isotopes each line belongs to. Is there a way to get labels generated along side each isotopologue, their mass and respective abundance.

Hope you can help G

zachcp commented 3 months ago

library(rcdk)

formula <- get.formula("CCCCl")
get.isotopes.pattern(formula = formula, minAbund = 0.001)

#         mass      abund
# [1,] 70.96885 1.00000000
# [2,] 71.97221 0.03244718
# [3,] 72.96590 0.31995776
# [4,] 73.96926 0.01038173

get.isotopes.pattern(formula = formula, minAbund = 0.1)

#          mass     abund
# [1,] 70.96885 1.0000000
# [2,] 72.96590 0.3199578

Okay. I see what you mean. It will need some experimentation. Here's a version of the get.isotope.patterns internal code the might help you get started.Note; if you can do it in CDK you can do it in rCDK.


library(rcdk)

formula  <- get.formula("CCCCl")
minAbund <- 0.1

isoGen <- .jnew("org/openscience/cdk/formula/IsotopePatternGenerator",
                as.double(minAbund));

isoPattern <- isoGen$getIsotopes(formula@objectJ)

numIP <- isoPattern$getNumberOfIsotopes()

for (i in numIP) {
  isoContainer <- isoPattern$getIsotope(as.integer(i-1))
  print(isoContainer$getMass())
  print(isoContainer$getIntensity())
}