PageRenderTime 121ms CodeModel.GetById 88ms app.highlight 8ms RepoModel.GetById 12ms app.codeStats 1ms

/rcdk/inst/unitTests/runit.rcdk.R

http://github.com/rajarshi/cdkr
R | 143 lines | 110 code | 18 blank | 15 comment | 2 complexity | 0ef7d7c731872d3d424417d2f518fd50 MD5 | raw file
  1test.is.connected <- function()
  2{
  3  m <- parse.smiles('CCCC')[[1]]
  4  connected <- is.connected(m)
  5  checkTrue(connected)
  6  m <- parse.smiles('CCCC.CCCC')[[1]]  
  7  connected <- is.connected(m)
  8  checkTrue(!connected)  
  9}
 10
 11test.get.largest <- function() {
 12  m <- parse.smiles('CCCC')[[1]]
 13  l <- get.largest.component(m)
 14  checkEquals(length(get.atoms(l)), 4)
 15
 16  m <- parse.smiles('CCCC.CCCCCC.CC')[[1]]
 17  l <- get.largest.component(m)
 18  checkEquals(length(get.atoms(l)), 6)  
 19}
 20
 21test.atom.count <- function() {
 22  m <- parse.smiles("CCC")[[1]]
 23  natom <- get.atom.count(m)
 24  checkEquals(natom, 3)
 25
 26  convert.implicit.to.explicit(m)
 27  natom <- get.atom.count(m)
 28  checkEquals(natom, 11)  
 29}
 30
 31test.is.neutral <- function() {
 32  m <- parse.smiles("CCC")[[1]]
 33  checkTrue(is.neutral(m))
 34  m <- parse.smiles('[O-]CC')[[1]]
 35  checkTrue(!is.neutral(m))
 36}
 37
 38test.formula <- function() {
 39   formula_file <- system.file("molfiles/formulatest.mol", package = "rcdk")
 40   m <- load.molecules(formula_file)
 41   f1 <- get.mol2formula(m[[1]])
 42   checkEquals(f1@string, "C35H64N3O21P3S")
 43   m <- parse.smiles("C1(C(C(C(C(C1OP(=O)(O)OCC(COC(=O)CCCCCCCNC(=O)CCCCC2SCC3C2NC(=O)N3)OC(=O)CCCCCCC)O)OP(=O)(O)O)OP(=O)(O)O)O)O")[[1]]
 44   do.aromaticity(m)
 45   do.typing(m)
 46   do.isotopes(m)
 47   convert.implicit.to.explicit(m)
 48   f2 <- get.mol2formula(m)
 49   checkEquals(f2@string, "C35H64N3O21P3S")  
 50}
 51
 52test.desc.cats <- function() {
 53  cats <- get.desc.categories()
 54  print(cats)
 55  checkEquals(5, length(cats))
 56}
 57
 58test.desc.names <- function() {
 59  cats <- get.desc.categories()
 60  for (acat in cats) {
 61    dnames <- get.desc.names(acat)
 62    checkTrue(length(dnames) > 0)
 63  }
 64}
 65
 66test.desc.calc <- function() {
 67  dnames <- get.desc.names("topological")
 68  mols <- parse.smiles("c1ccccc1CCC")
 69  dvals <- eval.desc(mols, dnames[1])
 70  checkTrue(dvals[1,1] == 1)
 71}
 72
 73test.exact.natural.mass <- function() {
 74  smiles <- c("CCNC1=NC(NC(C)C)=NC(Cl)=N1", # normal atrazine, DTXSID9020112
 75              "[2H]N(CC)C1=NC(=NC(Cl)=N1)N([2H])C(C)C", #2H on implicit locations, DTXSID40892885
 76              "[2H]C([2H])([2H])C([2H])([2H])NC1=NC(Cl)=NC(NC(C)C)=N1", #d5, DTXSID20486781
 77              "CC[15NH]C1=NC(NC(C)C)=NC(Cl)=N1", #15N DTXSID40583908
 78              "OC1=C(Br)C(Br)=C(Br)C(Br)=C1Br", #pentabromophenol, DTXSID9022079
 79              "C[Se]CC[C@H](N)C(O)=O" # Selenium-L-methionine, DTXSID8046824
 80  ) 
 81  #atrzine
 82  m <- parse.smiles(smiles[1])[[1]]
 83  do.aromaticity(m)
 84  do.typing(m)
 85  do.isotopes(m)
 86  convert.implicit.to.explicit(m)
 87  # Dashboard ref mass: 215.093773, 215.69
 88  checkEquals(get.exact.mass(m),215.0938, tolerance=1e-6)
 89  checkEquals(get.natural.mass(m),215.6835, tolerance=1e-6)
 90  
 91  #deuterium on exchangeable locations
 92  m <- parse.smiles(smiles[2])[[1]]
 93  do.aromaticity(m)
 94  do.typing(m)
 95  do.isotopes(m)
 96  convert.implicit.to.explicit(m)
 97  # Dashboard ref mass: 217.106327, 217.7
 98  checkEquals(get.exact.mass(m),217.1063, tolerance=1e-6)
 99  #checkEquals(get.natural.mass(m),215.6835) #this is wrong! It should be 217.7something
100  
101  #deuterium on fixed locations
102  m <- parse.smiles(smiles[3])[[1]]
103  do.aromaticity(m)
104  do.typing(m)
105  do.isotopes(m)
106  convert.implicit.to.explicit(m)
107  # Dashboard ref mass: 220.125157, 220.72
108  checkEquals(get.exact.mass(m),220.1252, tolerance=1e-6)
109  #checkEquals(get.natural.mass(m),215.6835) #this is wrong! It should be 220.7something
110  
111  #15N-atrazine
112  m <- parse.smiles(smiles[4])[[1]]
113  do.aromaticity(m)
114  do.typing(m)
115  do.isotopes(m)
116  convert.implicit.to.explicit(m)
117  # Dashboard ref mass: 216.090808, 216.68
118  checkEqualsNumeric(get.exact.mass(m),216.0908, tolerance=1e-6)
119  #checkEquals(get.natural.mass(m),215.6835) #this is wrong! It should be 216.68something
120  
121  #pentabromophenol, DTXSID9022079 - tricky as lots of Br shifts pattern
122  m <- parse.smiles(smiles[5])[[1]]
123  do.aromaticity(m)
124  do.typing(m)
125  do.isotopes(m)
126  convert.implicit.to.explicit(m)
127  # Dashboard ref mass: 483.59443, 488.593
128  checkEquals(get.exact.mass(m),483.5944, tolerance=1e-6)
129  checkEquals(get.natural.mass(m),488.5894, tolerance=1e-6) 
130  
131  # Selenium-L-methionine, DTXSID8046824 - tricky as Se primary isotope not lowest mass
132  m <- parse.smiles(smiles[6])[[1]]
133  do.aromaticity(m)
134  do.typing(m)
135  do.isotopes(m)
136  convert.implicit.to.explicit(m)
137  # Dashboard ref mass: 196.995501, 196.119
138  checkEquals(get.exact.mass(m),196.9955, tolerance=1e-6)
139  checkEquals(get.natural.mass(m),196.1059, tolerance=1e-6) #quite a discrepancy in ref value
140  
141  
142}
143