Skip to content

Instantly share code, notes, and snippets.

@aschreyer
Created May 20, 2011 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aschreyer/982860 to your computer and use it in GitHub Desktop.
Save aschreyer/982860 to your computer and use it in GitHub Desktop.
Credoscript example
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
In [ 4]: s.Biomolecules
Out[ 4]:
{1: <Biomolecule(1)>,
2: <Biomolecule(2)>,
3: <Biomolecule(3)>,
4: <Biomolecule(4)>}
# Shortcuts are supported
In [ 5]: s[1]['A'][253]['CA']
Out[ 5]: <Atom(CA )>
# Get the ligands of the first assembly of 3CS9
In [ 6]: s[1].Ligands
Out[ 6]: [<Ligand(A 600 NIL)>]
In [ 7]: l = s[1].Ligands[0]
# Get the conformation-independent information
In [ 8]: l.Components[0].ChemComp
Out[ 8]: <ChemComp(NIL)>
In [ 9]: nil = l.Components[0].ChemComp
# Molecular properties (here: isomeric SMILES)
In [10]: nil.ism
Out[10]:
'Cc1ccc(cc1Nc2nccc(n2)c3cccnc3)C(=O)Nc4cc(cc(c4)n5cc(nc5)C)C(F)(F)F'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment