def get_object_genotype(id, **args): obj = scigraph.bioobject(id, 'Genotype') obj.phenotype_associations = search_associations( subject=id, object_category='phenotype', **args)['associations'] obj.disease_associations = search_associations(subject=id, object_category='disease', **args)['associations'] obj.gene_associations = search_associations(subject=id, object_category='gene', **args)['associations'] return (obj)
def get(self, id): """ Returns phenotypes associated with disease """ return search_associations('disease', 'phenotype', None, id, **core_parser.parse_args())
def get(self): """ Returns list of matching associations """ args = parser.parse_args() return search_associations(**args)
def get(self, object): """ Returns list of matching associations """ args = parser.parse_args() return search_associations(object=object, **args)
def get(self, id): """ TODO Returns expression events for a gene """ return search_associations('gene', 'anatomy', None, id, **core_parser.parse_args())
def get_counts(entities=[], object_category=None, **kwargs): """ given a set of entities (genes, diseases, etc) returns the number of entities associated with each descriptor in a given category """ results = search_associations(subjects=entities, subject_direct=True, rows=0, facet_fields=[M.IS_DEFINED_BY, M.SUBJECT_TAXON, M.SUBJECT_CATEGORY], object_category=object_category, facet_mincount=3, # TODO facet_limit=-1, json_facet={ 'categories':{ 'limit':-1, 'type': 'terms', 'field' : M.OBJECT_CLOSURE, 'facet' : { 'uniq_subject': "unique(subject)" } } }, **kwargs) buckets = results['facets']['categories']['buckets'] cmap = {} for bucket in buckets: cmap[bucket['val']] = bucket['uniq_subject'] return (cmap, results)
def get(self, subject_category='gene', object_category='gene'): """ Returns list of matching associations """ args = parser.parse_args() return search_associations(subject_category, object_category, **args)
def get(self, id): """ Returns genes associated with a variant """ # TODO: invert return search_associations('variant', 'gene', None, id, **core_parser.parse_args())
def get(self, id): """ Returns diseases associated with a genotype """ # TODO: invert return search_associations('genotype', 'disease', None, id, **core_parser.parse_args())
def get_object_gene(id, **args): obj = scigraph.bioobject(id, 'Gene') obj.phenotype_associations = search_associations( subject=id, object_category='phenotype', **args)['associations'] obj.homology_associations = search_associations(subject=id, rel=homol_rel, object_category='gene', **args)['associations'] obj.disease_associations = search_associations(subject=id, object_category='disease', **args)['associations'] obj.genotype_associations = search_associations(subject=id, invert_subject_object=True, object_category='genotype', **args)['associations'] return (obj)
def get(self, id): """ Returns phenotypes associated with gene """ args = core_parser.parse_args() print(args) return search_associations('gene', 'phenotype', None, id, **core_parser.parse_args())
def get(self, id): """ TODO Returns expression events for a gene """ # TODO: we don't store this directly # could be retrieved by getting all associations and then extracting pubs return search_associations('gene', 'publication', None, id, **core_parser.parse_args())
def get(self, id): """ Returns genotypes-genotype associations. Genotypes may be related to one another according to the GENO model """ # TODO: invert return search_associations('genotype', 'genotype', None, id, **core_parser.parse_args())
def get_background(objects, taxon, object_category, **kwargs): results = search_associations(objects=objects, subject_taxon=taxon, object_category=object_category, rows=0, facet_fields=[M.SUBJECT], facet_mincount=3, # TODO facet_limit=-1, **kwargs) return results['facet_counts'][M.SUBJECT].keys()
def get(self, id): """ Returns genes associated with a disease """ args = core_parser.parse_args() return search_associations('disease', 'gene', None, id, invert_subject_object=True, **core_parser.parse_args())
def get(self, subject, object): """ Returns associations connecting two entities Given two entities (e.g. a particular gene and a particular disease), if these two entities are connected (directly or indirectly), then return the association objects describing the connection. """ args = parser.parse_args() return search_associations(object=object, **args)
def get(self, subject_category, object_category): """ All relations used plus count of associations """ args = parser.parse_args() return search_associations(rows=0, subject_category=subject_category, object_category=object_category, facet_fields=[M.RELATION, M.RELATION_LABEL], **args)
def term_matrix(idlist, subject_category, taxon, **kwargs): """ Intersection between annotated objects P1 not(P1) F1 0 5 not(F1) 6 0 """ results = search_associations(objects=idlist, subject_taxon=taxon, subject_category=subject_category, select_fields=[M.SUBJECT, M.OBJECT_CLOSURE], facet_fields=[], rows=-1, include_raw=True, **kwargs) docs = results['raw'].docs subjects_per_term = {} smap = {} for d in docs: smap[d[M.SUBJECT]] = 1 for c in d[M.OBJECT_CLOSURE]: if c in idlist: if c not in subjects_per_term: subjects_per_term[c] = [] subjects_per_term[c].append(d[M.SUBJECT]) pop_n = len(smap.keys()) cells = [] for cx in idlist: csubjs = set(subjects_per_term[cx]) for dx in idlist: dsubjs = set(subjects_per_term[dx]) a = len(csubjs.intersection(dsubjs)) b = len(csubjs) - a c = len(dsubjs) - a d = pop_n - len(dsubjs) - b ctable = [[a, b], [c, d]] _, p_under = sp.stats.fisher_exact(ctable, 'less') _, p_over = sp.stats.fisher_exact(ctable, 'greater') cells.append({ 'c': cx, 'd': dx, 'nc': len(csubjs), 'nd': len(dsubjs), 'n': a, 'p_l': p_under, 'p_g': p_over }) return cells
def get_object_closure(subject, object_category=None, **kwargs): """ Find all terms used to annotate subject plus ancestors """ results = search_associations(subject=subject, object_category=object_category, select_fields=[], facet_fields=[M.OBJECT_CLOSURE], facet_limit=-1, rows=0, **kwargs) return set(results['facet_counts'][M.OBJECT_CLOSURE].keys())
def get(self, id, taxon): """ Same as `/disease/<id>/models` but constrain models by taxon """ # TODO: invert return search_associations('disease', 'model', None, id, invert_subject_object=True, object_taxon=taxon, **core_parser.parse_args())
def get(self): """ Relation usage count for all subj x obj category combinations, showing label """ args = parser.parse_args() return search_associations(rows=0, facet_fields=[M.RELATION_LABEL], facet_pivot_fields=[ M.SUBJECT_CATEGORY, M.OBJECT_CATEGORY, M.RELATION_LABEL ], **args)
def get(self): """ All relations used plus count of associations """ args = parser.parse_args() return search_associations(rows=0, facet_fields=[M.RELATION], facet_pivot_fields=[ M.SUBJECT_CATEGORY, M.OBJECT_CATEGORY, M.RELATION ], **args)
def get(self, id): """ Returns function associations for a gene. Note: currently this is implemented as a query to the GO solr instance. A smaller set of identifiers may be supported: - ZFIN e.g. ZFIN:ZDB-GENE-050417-357 - MGI e.g. MGI:1342287 - Use UniProt for human (TODO: map this) """ return search_associations('gene', 'function', None, id, **core_parser.parse_args())
def get(self): """ Returns homology associations for a given input set of genes """ args = parser.parse_args() M = GolrFields() rel = 'RO:0002434' # TODO; allow other types results = search_associations( subjects=args.get('subject'), select_fields=[M.SUBJECT, M.RELATION, M.OBJECT], use_compact_associations=True, relation=rel, rows=MAX_ROWS, facet_fields=[], **args) return results
def get(self): """ Summary statistics for objects associated """ args = parser.parse_args() M = GolrFields() results = search_associations( subjects=args.get('subject'), rows=0, facet_fields=[M.OBJECT_CLOSURE, M.IS_DEFINED_BY], facet_limit=-1, **args) print("RESULTS=" + str(results)) obj_count_dict = results['facet_counts'][M.OBJECT_CLOSURE] del results['facet_counts'][M.OBJECT_CLOSURE] return {'results': obj_count_dict, 'facets': results['facet_counts']}
def get(self): """ Returns compact associations for a given input set """ args = parser.parse_args() M = GolrFields() #results = search_associations(subjects=args.get('subject'), # rows=0, # pivot_subject_object=True, # facet_fields=[], # facet_limit=-1, # **args) results = search_associations( subjects=args.get('subject'), select_fields=[M.SUBJECT, M.RELATION, M.OBJECT], use_compact_associations=True, rows=MAX_ROWS, facet_fields=[], **args) return results
def get(self, id): """Returns associations to models of the disease In the association object returned, the subject will be the disease, and the object will be the model. The model may be a gene or genetic element. If the query disease is a general class, the association subject may be to a specific disease. In some cases the association will be *direct*, for example if a paper asserts a genotype is a model of a disease. In other cases, the association will be *indirect*, for example, chaining over orthology. In these cases the chain will be reflected in the *evidence graph* * TODO: provide hook into owlsim for dynamic computation of models by similarity """ return search_associations('disease', 'model', None, id, invert_subject_object=True, **core_parser.parse_args())
def get(self, id): """ Returns homologs for a gene """ return search_associations('gene', 'gene', homol_rel, id, **core_parser.parse_args())
def get(self, id): """ Returns associations between a lit entity and a genotype """ return search_associations('literature', 'genotype', None, id, **core_parser.parse_args())
def get(self, id): """ Returns interactions for a gene """ return search_associations('gene', 'gene', 'RO:0002434', id, **core_parser.parse_args())