Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrian Schreyer aschreyer

View GitHub Profile
@aschreyer
aschreyer / gist:982860
Created May 20, 2011
Credoscript example
View gist:982860
In [ 1]: from credo.credoscript import *
# Fetch a structure from a database with the corresponding adaptor
In [ 2]: s = StructureAdaptor().fetch_by_pdb('3CS9')
# Database columns are mapped as attributes
In [ 3]: s.title
Out[ 3]: 'Human ABL kinase in complex with nilotinib'
# Relationships with other entities are mapped as attributes as well
@aschreyer
aschreyer / openeye-enumerate-tautomers.sql
Created May 20, 2011
Introduction to the OpenEye PostgreSQL cartridge
View openeye-enumerate-tautomers.sql
SELECT openeye.enumerate_tautomers('O=C1NN=Cc2cocc12');
enumerate_tautomers
---------------------------------------
'{O=c1[nH]ncc2c1coc2,Oc1nncc2c1coc2}'
(1 row)
@aschreyer
aschreyer / array-intersection.sql
Created May 20, 2011
Examples of the Eigen PostgreSQL extension
View array-intersection.sql
SELECT '{1,2,3,4,5}'::arrayxi & '{5,4,3,2,1}'::arrayxi;
?column?
---------------
'{0,0,3,0,0}'
(1 row)
Time: 0.290 ms
@aschreyer
aschreyer / epinephrines.sql
Created May 24, 2011
Stereochemistry functions in the PostgreSQL OpenEye cartridge
View epinephrines.sql
SELECT canonical_smiles, openeye.has_undef_stereo(canonical_smiles)
FROM chembl.compound_structures s
JOIN chembl.chembl_id_lookup i
ON s.molregno = i.entity_id AND i.entity_type = 'COMPOUND'
WHERE i.chembl_id = 'CHEMBL287587' OR i.chembl_id = 'CHEMBL1437';
canonical_smiles | has_undef_stereo
----------------------------+-----------------------
'NC[C@H](O)c1ccc(O)c(O)c1' | f
@aschreyer
aschreyer / fuzcav-calpha.sql
Created Jun 1, 2011
Binding site similarity search in CREDO using the FuzCav algorithm
View fuzcav-calpha.sql
SELECT s.pdb, l.ligand_name, s.title, sq.similarity
FROM (
WITH query AS (SELECT calphafp FROM credo.ligand_fuzcav WHERE ligand_id = 3919)
SELECT f.ligand_id, arrayxi_fuzcavsim_global(query.calphafp, f.calphafp) AS similarity
FROM credo.ligand_fuzcav f, query
WHERE arrayxi_fuzcavsim_global(query.calphafp, f.calphafp) > 0.17
) sq,
credo.ligands l, credo.biomolecules b, credo.structures s
WHERE sq.ligand_id = l.ligand_id
AND l.biomolecule_id = b.biomolecule_id
@aschreyer
aschreyer / vector3d-angle.sql
Created Jun 1, 2011
Eigen Vector3D PostgreSQL extension
View vector3d-angle.sql
SELECT degrees('(3,0,0)'::vector3d @ '(5,5,0)'::vector3d) AS angle;
angle
-------
45
(1 row)
@aschreyer
aschreyer / credo-restful-example.py
Created Jun 1, 2011
Implementation of RESTful web services for CREDO
View credo-restful-example.py
import json
from urllib import urlopen
# GET A CHEMICAL COMPONENT
response = urlopen('http://0.0.0.0:8000/credo/rest/chemcomps/sti').read()
# PARSE JSON INTO PYTHON DICTIONARY
sti = json.loads(response)
# COLUMN DATA/ATTRIBUTES ARE CONVERTED TO DICTIONARY KEYS
@aschreyer
aschreyer / credo-contrib-chemresolver.py
Created Jun 1, 2011
Implementing the Chemical Identifier Resolver
View credo-contrib-chemresolver.py
from credo.credoscript import *
from credo.contrib.chemidresolver import *
ca = ChemCompAdaptor()
rsvr = ChemIdResolver()
# GET THE SDF FILE OF LAPATINIB WITH 3D COORDINATES
molstring = rsvr.get_structure('lapatinib','sdf', get3d=True)
# GET THE USR MOMENTS FOR THE STRUCTURE
@aschreyer
aschreyer / credo-rdkit.py
Created Jun 1, 2011
RDKit integration in CREDO
View credo-rdkit.py
from credo.credoscript import *
ca = ChemCompAdaptor()
# GET IMATINIB
sti = ca.fetch_by_het_id('STI')
# GET ALL SIMILAR CHEMICAL COMPONENTS USING CIRCULAR FINGERPRINTS
ca.fetch_all_by_sim(sti.ism, fp='circular')
@aschreyer
aschreyer / sql-lingo.sql
Created Jun 13, 2011
Using the PostgreSQL pg_trgm extension for chemical similarity searching
View sql-lingo.sql
SELECT molregno, s.ism, similarity(s.ism, 'C[NH+](C)CC[C@H](CSc1ccccc1)Nc2ccc(cc2[N+](=O)[O-])S(=O)(=O)NC(=O)c3ccc(cc3)N4CC[NH+](CC4)Cc5ccccc5c6ccc(cc6)Cl') As sim
FROM chembl.compound_smiles s
WHERE s.ism % 'C[NH+](C)CC[C@H](CSc1ccccc1)Nc2ccc(cc2[N+](=O)[O-])S(=O)(=O)NC(=O)c3ccc(cc3)N4CC[NH+](CC4)Cc5ccccc5c6ccc(cc6)Cl'
ORDER BY s.ism <-> 'C[NH+](C)CC[C@H](CSc1ccccc1)Nc2ccc(cc2[N+](=O)[O-])S(=O)(=O)NC(=O)c3ccc(cc3)N4CC[NH+](CC4)Cc5ccccc5c6ccc(cc6)Cl'
LIMIT 20;
You can’t perform that action at this time.