Last active
September 19, 2022 14:34
-
-
Save sneumann/959a6d205ea4ac73eaf1393da0ec0673 to your computer and use it in GitHub Desktop.
Install and benchmark a number of
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("microbenchmark") | |
install.packages("plyr") | |
install.packages("rcdk") | |
install.packages("OrgMassSpecR") | |
install.packages("CHNOSZ") | |
BiocManager::install("Rdisop") | |
BiocManager::install("MetaboCoreUtils") | |
BiocManager::install("ChemmineR") | |
BiocManager::install("ChemmineOB") | |
BiocManager::install("enviPat") | |
## These require loading the packages explicitly | |
library(plyr) | |
library(CHNOSZ) | |
library(enviPat) | |
library(MetaboCoreUtils) | |
library(rcdk) | |
library(ChemmineR) | |
library(ChemmineOB) | |
library(OrgMassSpecR) | |
library(Rdisop) | |
## enviPat | |
data(isotopes) | |
benchmark <- microbenchmark::microbenchmark( | |
MetaboCoreUtils = MetaboCoreUtils::calculateMass("C2H6O"), | |
rcdk = rcdk::get.formula("C2H6O", charge = 0)@mass, | |
Rdisop = Rdisop::getMolecule("C2H6O")$exactmass, | |
ChemmineR = ChemmineR::exactMassOB(ChemmineR::smiles2sdf("CCO")), | |
OrgMassSpecR = OrgMassSpecR::MonoisotopicMass(formula = OrgMassSpecR::ListFormula("C2H6O)"), charge = 0), | |
CHNOSZ = CHNOSZ::mass("C2H6O"), | |
enviPat = enviPat::isopattern(isotopes, "C2H6O", charge=FALSE, verbose=FALSE)[[1]][1,1] | |
, times=1000L) | |
masses <- c( | |
MetaboCoreUtils=MetaboCoreUtils::calculateMass("C2H6O"), | |
rcdk=rcdk::get.formula("C2H6O", charge = 0)@mass, | |
Rdisop=Rdisop::getMolecule("C2H6O")$exactmass, | |
ChemmineR=ChemmineR::exactMassOB(ChemmineR::smiles2sdf("CCO")), | |
OrgMassSpecR=OrgMassSpecR::MonoisotopicMass(formula = OrgMassSpecR::ListFormula("C2H6O)"), charge = 0), | |
CHNOSZ=CHNOSZ::mass("C2H6O"), | |
enviPat=enviPat::isopattern(isotopes, "C2H6O", charge=FALSE, verbose=FALSE)[[1]][1,1] | |
) | |
options(digits=10) | |
t(t(sort(masses))) | |
summary(benchmark)[order(summary(benchmark)[,"median"]) , ] | |
clipr::write_clip(as.data.frame(summary(benchmark)[order(summary(benchmark)[,"median"]) , ] )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated code with some improvements to RCDK: https://gist.github.com/zachcp/ac410b900d67264ffb8061d2b8fa45bf