Skip to content

Instantly share code, notes, and snippets.

@aschreyer
Created September 10, 2012 10:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aschreyer/3690246 to your computer and use it in GitHub Desktop.
Save aschreyer/3690246 to your computer and use it in GitHub Desktop.
Example USRCAT query demonstrating the use of the cube extension
-- select a query molecule
WITH query AS
(
SELECT *
FROM dude.usr_moments_fnta
WHERE category = 'ACTIVE' AND mol_idx = 1 AND conformer = 0
)
-- run the virtual screen with the given query
SELECT category, mol_idx, MAX(sq.similarity) as similarity
FROM (
SELECT t.category,
t.mol_idx,
arrayxd_usrcatsim(t.usr_moments, query.usr_moments, 1.0, 1.0, 1.0, 1.0, 1.0) as similarity -- function from pgeigen extension
FROM dude.usr_moments_fnta t, query
WHERE t.usr_space <@ cube_enlarge(query.usr_space, 1.5, 12) -- cube index
) sq
GROUP BY category, sq.mol_idx
ORDER BY 3 DESC
LIMIT 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment