Skip to content

Instantly share code, notes, and snippets.

@rajarshi
Created June 19, 2010 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajarshi/445252 to your computer and use it in GitHub Desktop.
Save rajarshi/445252 to your computer and use it in GitHub Desktop.
library(rcdk)
## Compare methods to convert Java BitSet -> R vector
mol <- parse.smiles("O=C(OC)C(c1ccccc1)C2NCCCC2")
fp <- .jnew('org/openscience/cdk/fingerprint/Fingerprinter',
as.integer(1024),
as.integer(6))
bitset <- .jcall(fp, "Ljava/util/BitSet;", "getFingerprint", mol)
system.time(
sapply(1:100, function(i) {
bitset <- .jcall(bitset, "S", "toString")
s <- gsub('[{}]','', bitset)
s <- as.numeric(strsplit(s, split=',')[[1]])-1
}))
system.time(
sapply(1:100, function(i) {
nbit <- 1024
bitvals <- sapply(1:nbit, function(x) {
.jcall(bitset, "Z", "get", as.integer(x-1))
})
bitvals <- which(bitvals)-1
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment