def main(args): print args # dump ttd targets and drugs: ttd_targets=Target.objects.filter(src='ttd') print 'ttd: %d targets' % len(ttd_targets) # dump drugbank targets db_targets=Target.objects.filter(src='db') print 'db: %d targets\n' % len(db_targets) # list shared targets in various ways shared('name') shared('gene_sym') shared('uniprot_id') # Look up Sam genes: genelist=readgenes(args.samgenes_fn) SamGenesWithUniprot(genelist, uniprot2gene(args.uniprot_gene_fn)) SamGenes(genelist) # Look up tripNeg genes: genelist=readgenes(args.tripnegs_fn) g2s=gene2synonyms(args.gene2syn_fn) tripNegAll(genelist, g2s)
def main(args): print args genelist=readgenes(args.tripnegs_fn) print '%d trip-neg genes' % len(genelist) g2s=gene2synonyms(args.gene2syn_fn) def get_targets(gene_sym): genes=[gene_sym] try: genes.extend(g2s.g2s[gene_sym]) except KeyError: pass targets=[] syms=[] for gene in genes: ts=Target.objects.filter(gene_sym=gene) if len(ts)>0: targets.extend(ts) syms.append(gene) return targets,syms for gene in genelist: targets=get_targets(gene)[0] if len(targets)>0: print 'gene %s: %d targets' % (gene, len(targets)) for target in targets: drugs=target.drugs.all() print ' target: %s (%d drugs)' % (target, len(drugs)) for drug in drugs: print ' drug: %s' % drug print
def main(args): print args # clear dbs: if False: dao_og=dao_django(cls=OncotatorGene) dao_og.remove({}) dao_op=dao_django(cls=UniprotProtein) dao_op.remove({}) genes=readgenes(args.in_fn) base_url=args.base_url stats={'n_genes':0, 'n_prots':0} for gn in genes: try: gene=OncotatorGene.objects.get(name=gn) print '%s: already loaded' % gn continue except OncotatorGene.DoesNotExist: pass url=base_url+gn res=requests.get(url) if res.status_code != 200: print '%s: error/nothing found' % gn continue print gn dct=json.loads(res.content) # for k,v in dct.items(): # print '%s: %s' % (k,v) gene=OncotatorGene(name=gn, full_name=dct['full_name'], chr=dct['chr'], location=dct['location'], start=dct['start'], end=dct['end'], strand=dct['strand']) gene.save() stats['n_genes']+=1 prot_accs=[dct['uniprot_accession']] try: prot_accs.extend(dct['alt_uniprot_accessions']) except KeyError: pass for acc in prot_accs: prot=UniprotProtein(id=acc, gene=gene) prot.save() stats['n_prots']+=1 print dump(stats)