3.1.1.1. datanator_query_python.aggregate package

3.1.1.1.1. Submodules

3.1.1.1.2. datanator_query_python.aggregate.lookups module

Form aggregate lookup objects

class datanator_query_python.aggregate.lookups.Lookups[source]

Bases: object

complex_lookup(_from, let, pipeline, _as)[source]

Complex lookup object (lookups with let).

Parameters
  • _from (str) – collection to join.

  • let (Obj) – specifies variables to use in pipeline stages.

  • pipeline (list of Obj) – specifies the pipeline to run on the joined collection.

  • _as (str) – output array field.

simple_lookup(_from, local_field, foreign_field, _as)[source]

Simple look up operation (without let or pipeline).

Parameters
  • _from (str) – collection to join.

  • local_field (str) – field from input documents.

  • foreign_field (str) – field from the documents of the “_from” collection.

  • _as (str) – output array field.

Returns

(Obj)

3.1.1.1.3. datanator_query_python.aggregate.pipelines module

Various aggregation pipelines

class datanator_query_python.aggregate.pipelines.Pipeline[source]

Bases: object

aggregate_all_occurences(field, match=None, project_post={'count': 1}, group=None, unwind=None)[source]

Aggregate all occurences of values in field.

Parameters
  • field (str) – Name of the field.

  • match (Obj) – Filtering of unnecessary data.

  • project (Obj) – remove fields before matching.

  • group (Obj) – additional group parameters.

  • unwind (Obj) – Unwind operation if field of interest is in subdocuments.

Returns

(list)

aggregate_common_canon_ancestors(anchor, target, org_format='tax_id', intersect_name='anc_match')[source]

Get common canonical ancestors between two organisms.

Parameters
  • anchor (Obj) – document of anchor organism.

  • target (str or int) – target organism.

  • org_format (str, optional) – field used to identify organism (tax_id or tax_name).

  • intersect_name (str) – name for intersection array.

Returns

(list)

aggregate_field_count(field, projection={'parameter': 1}, match={'parameter.observed_name': 'Ki'}, unwind=None, group={'$group': {'count': {'$sum': 1}}})[source]

Aggregate number of occurences of a value in field.

Parameters
  • field (str) – field of interest.

  • projection (Obj) – Projection (prune unnecessary data in document).

  • match (Obj) – Further filtering of data that meet certain conditions.

Returns

(list)

aggregate_kegg_orthology(expr, projection={'_id': 0, 'gene_ortholog': 0})[source]

Aggregate kegg orthology information

Parameters
  • expr (Obj) – match expression.

  • projection (Obj, optional) – projection in pipeline.

Returns

(list)

aggregate_taxon_distance(match, local_field, _as, anchor, target, org_format='tax_id', intersect_name='anc_match')[source]

Aggrate canonical taxon distance information for frontend (avoiding iteration)

Parameters
  • match (Obj) – match object in pipeline.

  • local_field (str) – field from input documents.

  • _as (str) – output array.

  • anchor (Obj) – document of anchor organism.

  • target (str or int) – target organism.

  • org_format (str, optional) – field used to identify organism (tax_id or tax_name).

  • intersect_name (str) – name for intersection array.

Returns

(list)

aggregate_total_array_length(field)[source]

Aggregate the total length of an array field in collection. e.g. [{“field”: [0, 1]}, {“field”: [2]}]

Parameters

field (str) – Name of the field.

Returns

(list)

3.1.1.1.4. datanator_query_python.aggregate.tabu module

Tabulate taxonomic distribution of all observations across relevant collections. https://github.com/KarrLab/datanator_rest_api/issues/97

class datanator_query_python.aggregate.tabu.Tabu(MongoDB=None, db=None, username=None, password=None, authSource=None, readPreference=None, max_entries=inf, verbose=True)[source]

Bases: datanator_query_python.util.mongo_util.MongoUtil

taxon_dist(collection, field, match=None, unwind=None)[source]

Generalized version of uniprot_taxon_dist.

Parameters
  • collection (str) – name of collection.

  • field (str) – Field upon which aggregation will be done.

  • match (Obj) – Filtering of unnecessary data.

  • unwind (Obj) – Unwind operation if field of interest is in subdocuments.

Returns

(CommandCursor)

uniprot_taxon_dist()[source]

Tabulate uniprot collections taxonomic distribution.

Returns

(CommandCursor)

datanator_query_python.aggregate.tabu.main()[source]

3.1.1.1.5. Module contents