-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Rdkit cart substructure search #2055
base: main
Are you sure you want to change the base?
Changes from all commits
21cf4b6
341419b
33011db
e52370a
2643193
a957ac6
eee482a
4cb0a54
c27daa0
3b069bb
a54abd1
027895b
15c1f3f
2b23d03
2921577
df9b4fc
38a719d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# https://github.com/rvianello/docker-postgres-rdkit/blob/master/Dockerfile | ||
ARG postgres_image_version=16 # changed from 16.2 | ||
FROM docker.io/postgres:${postgres_image_version} AS builder | ||
ARG postgres_version=16 | ||
ARG boost_dev_version=1.74 | ||
ARG rdkit_git_url=https://github.com/rdkit/rdkit.git | ||
ARG rdkit_git_ref=Release_2024_03_1 | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -yq --no-install-recommends \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg \ | ||
lsb-release \ | ||
&& curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ | ||
&& echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -yq --no-install-recommends \ | ||
build-essential \ | ||
cmake \ | ||
git \ | ||
coreutils \ | ||
libboost-iostreams${boost_dev_version}-dev \ | ||
libboost-regex${boost_dev_version}-dev \ | ||
libboost-serialization${boost_dev_version}-dev \ | ||
libboost-system${boost_dev_version}-dev \ | ||
libeigen3-dev \ | ||
libfreetype6-dev \ | ||
postgresql-server-dev-${postgres_version} \ | ||
zlib1g-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir -p /opt/RDKit-build \ | ||
&& chown postgres:postgres /opt/RDKit-build | ||
|
||
USER postgres | ||
WORKDIR /opt/RDKit-build | ||
|
||
RUN git clone ${rdkit_git_url} | ||
WORKDIR /opt/RDKit-build/rdkit | ||
RUN git checkout ${rdkit_git_ref} | ||
|
||
RUN cmake \ | ||
-D RDK_BUILD_CAIRO_SUPPORT=OFF \ | ||
-D RDK_BUILD_INCHI_SUPPORT=ON \ | ||
-D RDK_BUILD_AVALON_SUPPORT=ON \ | ||
-D RDK_BUILD_PYTHON_WRAPPERS=OFF \ | ||
-D RDK_BUILD_DESCRIPTORS3D=OFF \ | ||
-D RDK_BUILD_FREESASA_SUPPORT=OFF \ | ||
-D RDK_BUILD_COORDGEN_SUPPORT=ON \ | ||
-D RDK_BUILD_MOLINTERCHANGE_SUPPORT=OFF \ | ||
-D RDK_BUILD_YAEHMOP_SUPPORT=OFF \ | ||
-D RDK_BUILD_STRUCTCHECKER_SUPPORT=OFF \ | ||
-D RDK_USE_URF=OFF \ | ||
-D RDK_BUILD_PGSQL=ON \ | ||
-D RDK_PGSQL_STATIC=ON \ | ||
-D PostgreSQL_CONFIG=pg_config \ | ||
-D PostgreSQL_INCLUDE_DIR=`pg_config --includedir` \ | ||
-D PostgreSQL_TYPE_INCLUDE_DIR=`pg_config --includedir-server` \ | ||
-D PostgreSQL_LIBRARY_DIR=`pg_config --libdir` \ | ||
-D RDK_INSTALL_INTREE=OFF \ | ||
-D CMAKE_INSTALL_PREFIX=/opt/RDKit \ | ||
-D CMAKE_BUILD_TYPE=Release \ | ||
. | ||
RUN make -j$(nproc) | ||
|
||
USER root | ||
WORKDIR /opt/RDKit-build/rdkit | ||
|
||
RUN make install | ||
RUN /bin/bash /opt/RDKit-build/rdkit/Code/PgSQL/rdkit/pgsql_install.sh | ||
|
||
USER postgres | ||
WORKDIR /opt/RDKit-build/rdkit | ||
|
||
RUN initdb -D /opt/RDKit-build/pgdata \ | ||
&& pg_ctl -D /opt/RDKit-build/pgdata -l /opt/RDKit-build/pgdata/log.txt start \ | ||
&& RDBASE="$PWD" LD_LIBRARY_PATH="$PWD/lib" ctest -j4 --output-on-failure \ | ||
&& pg_ctl -D /opt/RDKit-build/pgdata stop | ||
|
||
|
||
FROM docker.io/postgres:${postgres_image_version} | ||
ARG postgres_version=16 | ||
ARG boost_version=1.74.0 | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -yq --no-install-recommends \ | ||
libboost-iostreams${boost_version} \ | ||
libboost-regex${boost_version} \ | ||
libboost-serialization${boost_version} \ | ||
libboost-system${boost_version} \ | ||
libfreetype6 \ | ||
zlib1g \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=builder /usr/share/postgresql/${postgres_version}/extension/*rdkit* /usr/share/postgresql/${postgres_version}/extension/ | ||
COPY --from=builder /usr/lib/postgresql/${postgres_version}/lib/rdkit.so /usr/lib/postgresql/${postgres_version}/lib/rdkit.so | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ class SearchAPI < Grape::API | |
All Samples Reactions Wellplates Screens all samples reactions wellplates screens elements cell_lines by_ids advanced structure | ||
] | ||
optional :molfile, type: String | ||
optional :search_type, type: String, values: %w[similar sub] | ||
optional :search_type, type: String, values: %w[similar sub subRDKit] | ||
optional :tanimoto_threshold, type: Float | ||
optional :page_size, type: Integer | ||
optional :structure_search, type: Boolean | ||
|
@@ -97,10 +97,13 @@ def sample_structure_search(c_id = @c_id, not_permitted = @dl_s && @dl_s < 1) | |
|
||
# TODO: implement this: http://pubs.acs.org/doi/abs/10.1021/ci600358f | ||
scope = | ||
if params[:selection][:search_type] == 'similar' | ||
case params[:selection][:search_type] | ||
when 'similar' | ||
Sample.by_collection_id(c_id).search_by_fingerprint_sim(molfile, threshold) | ||
else | ||
when 'sub' | ||
Sample.by_collection_id(c_id).search_by_fingerprint_sub(molfile) | ||
when 'subRDKit' | ||
Sample.by_collection_id(c_id).search_by_rdkit_sub(molfile) | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed adding a fallback / default case for invalid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The search type has a whitelist: "optional :search_type, type: String, values: %w[similar sub subRDKit]" |
||
order_by_molecule(scope) | ||
end | ||
|
@@ -519,12 +522,11 @@ def elements_by_scope(scope, collection_id = @c_id) | |
end | ||
|
||
post do | ||
Usecases::Search::StructureSearch.new( | ||
collection_id: @c_id, | ||
params: params, | ||
user: current_user, | ||
detail_levels: @dl, | ||
).perform! | ||
samples = sample_structure_search | ||
JanCBrammer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
serialization_by_elements_and_page( | ||
elements_by_scope(samples), | ||
params[:page], | ||
) | ||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This switch case seems to be replicating the switch case under
usecases/search/structure_search.rb
. Why?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usecases/search/structure_search.rb removed