File: molform.R

package info (click to toggle)
r-cran-rcdk 3.8.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 888 kB
  • sloc: makefile: 14; sh: 13
file content (51 lines) | stat: -rw-r--r-- 1,940 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## -----------------------------------------------------------------------------
library(rcdk)
sp <- get.smiles.parser()
molecule <- parse.smiles('N')[[1]]
convert.implicit.to.explicit(molecule)
formula <- get.mol2formula(molecule,charge=0)

## -----------------------------------------------------------------------------
formula@mass
formula@charge
formula@string

## -----------------------------------------------------------------------------
formula@isotopes

## -----------------------------------------------------------------------------
formula <- set.charge.formula(formula, charge=1)

## -----------------------------------------------------------------------------
formula <- get.formula('NH4', charge = 1)
formula

## ----warn=FALSE---------------------------------------------------------------
mfSet <- generate.formula(18.03383, window=1,
    elements=list(c("C",0,50),c("H",0,50),c("N",0,50)),
    validation=FALSE)
mfSet

## -----------------------------------------------------------------------------
formula <- get.formula('NH4', charge = 0)
isvalid.formula(formula,rule=c("nitrogen","RDBE"))

## -----------------------------------------------------------------------------
formula <- get.formula('NH4', charge = 1)
isvalid.formula(formula,rule=c("nitrogen","RDBE"))

## ----warn=FALSE---------------------------------------------------------------
mit <- generate.formula.iter(100, charge=0, window=0.1,
                             elements=list(c("C",0,50), c("H",0,50), c("N",0,50)))
hit <- itertools::ihasNext(mit)
while (itertools::hasNext(hit)) 
    print(iterators::nextElem(hit))

## -----------------------------------------------------------------------------
formula <- get.formula('CHCl3', charge = 0)
isotopes <- get.isotopes.pattern(formula,minAbund=0.1)
isotopes

## -----------------------------------------------------------------------------
plot(isotopes, type="h", xlab="m/z", ylab="Intensity")