Skip to content

Instantly share code, notes, and snippets.

@aschreyer
Created March 20, 2012 14:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aschreyer/2136435 to your computer and use it in GitHub Desktop.
Querying CIFStore with Python
for res in db.structures.find({"entry.id": "2P33"}, {'pdbx_entity_nonpoly.comp_id': 1}):
print res
{u'pdbx_entity_nonpoly': [{u'comp_id': u'J07'}, {u'comp_id': u'HOH'}], u'_id': u'2P33'}
from pymongo import Connection
connection = Connection('localhost', 27017)
db = connection.cifstore
db.structures.count()
79177
for res in db.structures.find({"pdbx_entity_nonpoly.comp_id":"STI"}, fields=["struct_ref.pdbx_db_accession"]):
print res
{u'_id': u'2OIQ', u'struct_ref': {}}
{u'_id': u'3HEC', u'struct_ref': {}}
{u'_id': u'1XBB', u'struct_ref': {}}
{u'_id': u'3FW1', u'struct_ref': {}}
{u'_id': u'2PL0', u'struct_ref': {}}
{u'_id': u'1OPJ', u'struct_ref': {}}
{u'_id': u'1T46', u'struct_ref': [{u'pdbx_db_accession': u'P10721'}, {u'pdbx_db_accession': u'4557695'}]}
{u'_id': u'1IEP', u'struct_ref': {u'pdbx_db_accession': u'P00520'}}
{u'_id': u'2HYY', u'struct_ref': {}}
{u'_id': u'3GVU', u'struct_ref': {}}
{u'_id': u'3K5V', u'struct_ref': {u'pdbx_db_accession': u'P00520'}}
{u'_id': u'3MS9', u'struct_ref': {u'pdbx_db_accession': u'P00520'}}
{u'_id': u'3MSS', u'struct_ref': {u'pdbx_db_accession': u'P00520'}}
{u'_id': u'3OEZ', u'struct_ref': {}}
{u'_id': u'3PYY', u'struct_ref': {}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment