datanator_rest_api.util package

Submodules

datanator_rest_api.util.paginator module

class datanator_rest_api.util.paginator.Paginator(count, docs)[source]

Bases: object

page(_from=0, size=10)[source]

Calculate page information.

Parameters
  • _from (int, optional) – Page starting from. Defaults to 0.

  • size (int, optional) – page size. Defaults to 10.

Returns

page info

Return type

(list)

datanator_rest_api.util.taxon_distance module

class datanator_rest_api.util.taxon_distance.TaxonDist(debugging=False)[source]

Bases: object

arrange_distance_objs(docs, target_species='homo sapiens', tax_field='taxon_name', org_format='tax_name')[source]

Arrange the distance object returned into arrays.

Parameters
  • docs (Iter) – Documents that need calculation of taxon_distance and rearranging.

  • target_species (str or int, optional) – User input for target species.

  • tax_field (str, optional) – Field containing taxon information in documents.

  • org_format (str, optional) – format of species identifier (tax_id or tax_name). Defaults to ‘tax_id’.

Returns

List of documents that have the taxon_distance objects.

Return type

(list of Obj)

get_dist_object(doc, queried_species, distance_obj, target_species, org_format='tax_id', tax_field='species_name', obj_name='taxon_distance')[source]

Return taxon_distance object for frontend.

Parameters
  • doc (Obj) – documents that need to be processed.

  • queried_species (deque) – already queried species.

  • distance_obj (Obj) – distance objects containing already queried species.

  • target_species (str or int) – target species.

  • org_format (str, optional) – format of species identifier (tax_id or tax_name). Defaults to ‘tax_id’.

  • tax_field (str, optional) – field containing taxon information in documents.

  • obj_name (str, optional) – name of the object containing taxon distance information.

Returns

(tuple of list, Obj, Obj)

Module contents