File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Or check out an example:
1818- [ Embeddings] ( examples/openai/example.R ) with OpenAI
1919- [ Binary embeddings] ( examples/cohere/example.R ) with Cohere
2020- [ Sparse search] ( examples/sparse/example.R ) with Text Embeddings Inference
21+ - [ Molecular fingerprints] ( examples/fingerprint/example.R ) with ChemmineR
2122
2223## DBI
2324
Original file line number Diff line number Diff line change 1+ Package: example
2+ Version: 0.1.0
3+ Imports:
4+ ChemmineR,
5+ DBI,
6+ RPostgres
7+ Remotes:
8+ bioc::release/ChemmineR
Original file line number Diff line number Diff line change 1+ # good resource
2+ # https://www.bioconductor.org/packages/release/bioc/vignettes/ChemmineR/inst/doc/ChemmineR.html
3+
4+ library(ChemmineR )
5+ library(DBI )
6+
7+ db <- dbConnect(RPostgres :: Postgres(), dbname = " pgvector_example" )
8+
9+ invisible (dbExecute(db , " CREATE EXTENSION IF NOT EXISTS vector" ))
10+ invisible (dbExecute(db , " DROP TABLE IF EXISTS molecules" ))
11+ invisible (dbExecute(db , " CREATE TABLE molecules (id text PRIMARY KEY, fingerprint bit(1024))" ))
12+
13+ data(sdfsample )
14+ fpset <- desc2fp(sdf2ap(sdfsample ))
15+ molecules <- data.frame (id = sdfid(sdfsample ), fingerprint = as.character(fpset ))
16+ invisible (dbAppendTable(db , " molecules" , molecules ))
17+
18+ params <- list (molecules $ fingerprint [[1 ]])
19+ result <- dbGetQuery(db , " SELECT id FROM molecules ORDER BY fingerprint <%> $1 LIMIT 5" , params = params )
20+ print(result $ id )
You can’t perform that action at this time.
0 commit comments