def main(args): print args dt_dao=dao_mongo(cls=Drugcard, db=args.db_name) query={} for k,v in grouper(2, args.query): query[k]=v print 'query: %s' % query targets=dt_dao.find(query, collection=args.collection) print '%s: %d results' % (query, len(targets)) for t in targets: print t
def main(args): print args path=args.path dt_dao=dao_mongo(cls=rdf.graph, db=args.db_name) query={'pred':'Pathway', 'obj':path} drugs=dt_dao.find(query, collection=args.collection) for d in drugs: query={'pred':'Drug(s)', 'sub':d.sub} targets=dt_dao.find(query, collection=args.collection) if len(targets)==0: continue print d s='' if len(targets)==1 else 's' print '%d target%s for %s' % (len(targets), s, d.sub) for t in targets: print t print
def main(args): ''' Do a gene (syn) -> target lookup in the mongo collection 'graph' ''' print args g_syn=args.gene dt_dao=dao_mongo(cls=rdf.graph, db=args.db_name) query={'pred':'Synonyms', 'obj':g_syn} drugs=dt_dao.find(query, collection=args.collection) # print '%s: %d results' % (query, len(drugs)) for d in drugs: print d query={'pred':'Drug(s)', 'sub':d.sub} # print query targets=dt_dao.find(query, collection=args.collection) print '%d targets for %s' % (len(targets), d.sub) for t in targets: print t print
def main(args): ''' print out stats for mongo db ''' print args dc_dao=dao_mongo(cls=Drugcard, db='nof1') drug_histo=Histogram() pw_histo=Histogram() gene_histo=Histogram() for dc in dc_dao.iter({'_cls':'drugcard.Drugcard'}): # print 'dc %s' % dc.id if not dc.Drug_Type: continue if not ('Approved' in dc.Drug_Type or 'Biotech' in dc.Drug_Type): continue try: drug_histo.add(dc.Generic_Name[0]) except IndexError: print "no Generic_Name for %s" % dc.id for pw in dc.Pathways: pw_histo.add(pw) for target in dc.targets: try: for pw in target.Pathway: pw_histo.add(pw) except AttributeError, e: print "no Pathway for pw id=%s" % target.ID try: for gene in target.Gene_Name: gene_histo.add(gene) except AttributeError, e: print "no Gene_Name for pw id=%s" % target.ID
def setUp(self): self.dc_dao=dao_mongo(cls=Drugcard, db='test_nof1') self.dc_dao.remove()