Skip to content

Instantly share code, notes, and snippets.

@rajarshi
Created January 14, 2022 21:55
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/3357906414d57689513714b85f810629 to your computer and use it in GitHub Desktop.
Save rajarshi/3357906414d57689513714b85f810629 to your computer and use it in GitHub Desktop.
library(rcdk)
library(fingerprint)
query_smi <- "CCCCCCCC"
hmdb <- load.molecules("smpdb_structures/compounds-1.sdf")
junk <- lapply(hmdb, function(x) set.title(x, get.property(x, "DATABASE_ID")))
query_fp <- get.fingerprint(parse.smiles(query_smi)[[1]])
hmdb_fp <- lapply(hmdb, get.fingerprint)
sm <- fp.sim.matrix(hmdb_fp, list(query_fp))
rownames(sm) <- sapply(hmdb, get.property, "DATABASE_ID")
sm[ which.max(sm[,1]), ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment