Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrian Schreyer aschreyer

View GitHub Profile
View USRCAT-ZINC-screen.sql
WITH conformer AS
(
SELECT openeye.omega('CC1=CC(=C(N1C2=CC(=CC(=C2)C(F)(F)F)C(F)(F)F)C)/C=C\3/C(=O)N=C(S3)NC4=CC=CC=C4') as oeb
),
query AS
(
SELECT openeye.usrcat(oeb) AS usr_moments
FROM conformer
),
screen AS
@aschreyer
aschreyer / credo-rest-usrcat.py
Created Feb 26, 2013
USRCAT search with one of the OSDD Malaria compounds, OSM-S-35. The SMILES strings were obtained by using chemicalize.org on the relevant OSDD blog post. Two stereoisomers were found for OSM-S-35 and a conformer generated for each with OpenEye's OMEGA toolkit.
View credo-rest-usrcat.py
import requests
headers = {'accept': 'application/json'}
files = {'file': open('/home/adrian/Dropbox/OSM-S-35-I.sdf')}
response = requests.post('http://marid.bioc.cam.ac.uk/credo/chemcomps/sim/usr/',
headers=headers, files=files, params={'usrcat':'t', 'limit':25})
View sample.cif
loop_
_pdbx_struct_oper_list.id
_pdbx_struct_oper_list.type
_pdbx_struct_oper_list.name
_pdbx_struct_oper_list.symmetry_operation
_pdbx_struct_oper_list.matrix[1][1]
_pdbx_struct_oper_list.matrix[1][2]
_pdbx_struct_oper_list.matrix[1][3]
_pdbx_struct_oper_list.vector[1]
_pdbx_struct_oper_list.matrix[2][1]
@aschreyer
aschreyer / pgopeneye-benchmark.sql
Last active Dec 12, 2015
PostgreSQL OpenEye cartridge benchmark based on ChEMBL15.
View pgopeneye-benchmark.sql
-- set search_path = public, openeye;
DO $$
DECLARE
molregno integer;
fp oefp;
BEGIN
FOR molregno, fp IN SELECT cfp.molregno, cfp.circular_fp
FROM chembl.compound_oefps cfp
ORDER BY random() LIMIT 100
View fetch-all-descendants.py
@paginate
def fetch_all_descendants(self, fragment_id, *expr, **kwargs):
"""
Returns all the descending fragments of the fragment with the given
fragment_id using an recursive SQL query.
"""
# query part that will be used in both parts of the recursive query
query = Fragment.query.with_entities(Fragment.fragment_id)
query = query.join(FragmentHierarchy, FragmentHierarchy.child_id==Fragment.fragment_id)
@aschreyer
aschreyer / chemcomprdmol-hybrid-method.py
Last active Dec 12, 2015
More credoscript examples to show the implementation of SQLAlchemy.
View chemcomprdmol-hybrid-method.py
@hybrid_method
@requires.rdkit
def contains(self, smiles):
return self.rdmol.HasSubstructMatch(MolFromSmiles(str(smiles)))
@contains.expression
def contains(self, smiles):
return self.rdmol.op('OPERATOR(rdkit.@>)')(smiles)
View credimus-urllib2.py
import urllib2
import json
headers = {'Accept' : 'application/json'}
req = urllib2.Request('http://marid.bioc.cam.ac.uk/credo/chemcomps/001', headers=headers)
resp = urllib2.urlopen(req)
jsondata = json.load(resp)
# output
{u'data': [7464,
@aschreyer
aschreyer / openeye-multimcs-chembl-threshold.sql
Created Nov 12, 2012
The multimcs() function in the PostgreSQL OpenEye cartridge
View openeye-multimcs-chembl-threshold.sql
SELECT assay_id,
count(DISTINCT molregno) AS compounds,
openeye.multimcs(array_agg(ism), threshold:=0.8) AS mcs
FROM chembl.target_dictionary
JOIN chembl.assay2target USING(tid)
JOIN chembl.activities a USING(assay_id)
JOIN chembl.compound_smiles cs USING(molregno)
WHERE protein_accession = 'P53779'
GROUP BY assay_id
HAVING count(DISTINCT molregno) >= 5
@aschreyer
aschreyer / unichem-fdw-query.sql
Created Nov 2, 2012
UniChem PostgreSQL Foreign Data Wrapper
View unichem-fdw-query.sql
SELECT *
FROM credo.unichem_pdb_to_kegg
LIMIT 10;
het_id compound_id
------ -----------
LQZ C07073
HC4 C00811
DC5 C14355
POD C10874
@aschreyer
aschreyer / usrcat-query.sql
Created Sep 10, 2012
Example USRCAT query demonstrating the use of the cube extension
View usrcat-query.sql
-- 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 (
You can’t perform that action at this time.