Permalink
Browse files

separated individual mass related tests into individual functions

  • Loading branch information...
Rajarshi Guha
Rajarshi Guha committed Nov 13, 2018
1 parent 7df8c6d commit 68ddb0b89674b1a7e3fefd82b5ee2a1476ed374b
Showing with 23 additions and 22 deletions.
  1. +23 −22 rcdk/inst/unitTests/runit.mass.R
@@ -1,14 +1,7 @@
test.get.mass <- function() {
smiles <- c("CCNC1=NC(NC(C)C)=NC(Cl)=N1", # normal atrazine, DTXSID9020112
"[2H]N(CC)C1=NC(=NC(Cl)=N1)N([2H])C(C)C", #2H on implicit locations, DTXSID40892885
"[2H]C([2H])([2H])C([2H])([2H])NC1=NC(Cl)=NC(NC(C)C)=N1", #d5, DTXSID20486781
"CC[15NH]C1=NC(NC(C)C)=NC(Cl)=N1", #15N DTXSID40583908
"OC1=C(Br)C(Br)=C(Br)C(Br)=C1Br", #pentabromophenol, DTXSID9022079
"C[Se]CC[C@H](N)C(O)=O" # Selenium-L-methionine, DTXSID8046824
)
#atrzine
m <- parse.smiles(smiles[1])[[1]]
test.get.mass.atrazine <- function() {
m <- parse.smiles("CCNC1=NC(NC(C)C)=NC(Cl)=N1")[[1]] # normal atrazine, DTXSID9020112
f <- get.mol2formula(m)
# Dashboard ref mass: 215.093773, 215.69
#checkEquals(get.mass(m,type="total.exact"),215.0938, tolerance=1e-6) #currently NPE
#checkEquals(get.mass(m,type="natural.exact"),215.6835, tolerance=1e-6) #currently NPE
@@ -18,15 +11,18 @@ test.get.mass <- function() {
#fails with NPE right now
#checkEquals(get.exact.mass(m),get.mass(m,type="total.exact"), tolerance=1e-6)
#checkEquals(get.natural.mass(m),get.mass(m,type="natural.exact"), tolerance=1e-6)
###formula testing
checkEquals(get.mass(f,type="total.exact"),215.0938, tolerance=1e-6)
#checkEquals(get.mass(f,type="natural.exact"),215.6835, tolerance=1e-6) #currently returns wrong mass
checkEquals(get.mass(f,type="mass.number"),215, tolerance=1e-6) #215
checkEquals(get.mass(f,type="major.isotope"),215.0938, tolerance=1e-6) #215.0938
#checkEquals(get.mass(f,type="molecular.weight"),215.6835, tolerance=1e-6) #215.6835 # NPE
}
test.get.mass.deuterium.xchg <- function() {
m <- parse.smiles("[2H]N(CC)C1=NC(=NC(Cl)=N1)N([2H])C(C)C")[[1]] #2H on implicit locations, DTXSID40892885
#deuterium on exchangeable locations
m <- parse.smiles(smiles[2])[[1]]
# do.aromaticity(m)
# do.typing(m)
# do.isotopes(m)
@@ -42,9 +38,11 @@ test.get.mass <- function() {
#checkEquals(get.natural.mass(m),get.mass(m,type="natural.exact"), tolerance=1e-6)
#checkEquals(get.exact.mass(m),217.1063, tolerance=1e-6)
#checkEquals(get.natural.mass(m),215.6835) #this is wrong! It should be 217.7something
}
test.get.mass.deuterium.fixed <- function() {
m <- parse.smiles("[2H]C([2H])([2H])C([2H])([2H])NC1=NC(Cl)=NC(NC(C)C)=N1")[[1]] # #d5, DTXSID20486781
#deuterium on fixed locations
m <- parse.smiles(smiles[3])[[1]]
# Dashboard ref mass: 220.125157, 220.72
#checkEquals(get.mass(m,type="total.exact"),220.1252, tolerance=1e-6) #currently NPE
#checkEquals(get.mass(m,type="natural.exact"),215.6835, tolerance=1e-6) #currently NPE - have to check mass
@@ -56,9 +54,11 @@ test.get.mass <- function() {
#checkEquals(get.natural.mass(m),get.mass(m,type="natural.exact"), tolerance=1e-6)
#checkEquals(get.exact.mass(m),220.1252, tolerance=1e-6)
#checkEquals(get.natural.mass(m),215.6835) #this is wrong! It should be 220.7something
}
test.get.mass.atrazine15N <- function() {
m <- parse.smiles("CC[15NH]C1=NC(NC(C)C)=NC(Cl)=N1")[[1]] #15N DTXSID40583908
#15N-atrazine
m <- parse.smiles(smiles[4])[[1]]
# Dashboard ref mass: 216.090808, 216.68
#checkEquals(get.mass(m,type="total.exact"),216.0908, tolerance=1e-6) #currently NPE
#checkEquals(get.mass(m,type="natural.exact"),215.6835, tolerance=1e-6) #currently NPE - have to check mass
@@ -70,9 +70,11 @@ test.get.mass <- function() {
#checkEquals(get.natural.mass(m),get.mass(m,type="natural.exact"), tolerance=1e-6)
#checkEqualsNumeric(get.exact.mass(m),216.0908, tolerance=1e-6)
#checkEquals(get.natural.mass(m),215.6835) #this is wrong! It should be 216.68something
}
test.get.mass.pentabromophenol<- function() {
m <- parse.smiles("OC1=C(Br)C(Br)=C(Br)C(Br)=C1Br")[[1]] #pentabromophenol, DTXSID9022079
#pentabromophenol, DTXSID9022079 - tricky as lots of Br shifts pattern
m <- parse.smiles(smiles[5])[[1]]
# Dashboard ref mass: 483.59443, 488.593
#checkEquals(get.mass(m,type="total.exact"),483.5944, tolerance=1e-6) #currently NPE
#checkEquals(get.mass(m,type="natural.exact"),488.5894, tolerance=1e-6) #currently NPE - have to check mass
@@ -85,8 +87,9 @@ test.get.mass <- function() {
#checkEquals(get.exact.mass(m),483.5944, tolerance=1e-6)
#checkEquals(get.natural.mass(m),488.5894, tolerance=1e-6)
# Selenium-L-methionine, DTXSID8046824 - tricky as Se primary isotope not lowest mass
m <- parse.smiles(smiles[6])[[1]]
}
test.get.mass.selenium <- function() {
m <- parse.smiles("C[Se]CC[C@H](N)C(O)=O")[[1]] # Selenium-L-methionine, DTXSID8046824
# Dashboard ref mass: 196.995501, 196.119
#checkEquals(get.mass(m,type="total.exact"),196.9955, tolerance=1e-6) #currently NPE
#checkEquals(get.mass(m,type="natural.exact"),196.1059, tolerance=1e-6) #currently NPE - have to check mass
@@ -106,6 +109,4 @@ test.get.mass <- function() {
#checkEquals(get.mass(get.formula("C6H6"),type="molecular.weight"),78.114, tolerance=1e-6) #NPE
checkEquals(get.mass(get.formula("C6H6"),type="mass.number"),78, tolerance=1e-6)
checkEquals(get.mass(get.formula("C6H6"),type="major.isotope"),78.04695, tolerance=1e-6)
}

1 comment on commit 68ddb0b

@schymane

This comment has been minimized.

Contributor

schymane commented on 68ddb0b Nov 29, 2018

Thanks for separating this out ... one comment:

#formula checks on benzene

Looks like formula checks for benzene (or any C6H6) is still bundled into the test.get.mass.selenium?

Any progress/ideas on the cause of the NPEs?

Thanks for all the changes, in catch up mode as lots has happened (so sorry if I've missed something)!

Please sign in to comment.