dasi.utils

Functions

bisect_between(a, low, high)

Returns the start (inclusive) and end (exclusive) indices for a sorted array using a key function.

bisect_slice_between(a, keys, low, high)

Slice the iterable using inclusive bisection.

group_by(arr, key)

Group a list by some key.

log_metadata([key, class_attribute, …])

wrapper for logging method run times for a class.

log_times([key, class_attribute])

wrapper for logging method run times for a class.

perfect_subject(data)

Determine whether a blast result consumes the entire subject.

sort_with_keys(a, key)

Sort an iterable, returning both the sorted array and the sorted keys.

Utilities (dasi.utils)

This module provide various utility functions.

Utility modules

npdf

NumpyDataFrame.

region

sequence_design

Networkx utilities

Specialized networkx algorithms for path and cycle finding.

algorithsm

exceptions

shortest_path

utils

Functions

bisect_between

bisect_slice_between

perfect_subject

prep_df

sort_with_keys

dasi.utils.bisect_between(a, low, high)[source]

Returns the start (inclusive) and end (exclusive) indices for a sorted array using a key function.

Parameters
  • a (Iterable) – sorted array (does not check)

  • low (Any) – low key

  • high (Any) – high key

Return type

Tuple[int, int]

Returns

tuple of start (inclusive) and end (exclusive) indices

dasi.utils.bisect_slice_between(a, keys, low, high)[source]

Slice the iterable using inclusive bisection. Assumes both the iterable and keys are sorted. Bisect at specified low and high.

Parameters
  • a (Iterable) – pre-sorted iterable to slice

  • keys (Iterable) – pre-sorted keys to bisect

  • low (Any) – low key

  • high (Any) – high key

Return type

Iterable

Returns

sliced iterable

dasi.utils.group_by(arr, key)[source]

Group a list by some key.

dasi.utils.log_metadata(key=None, class_attribute='_method_trace', additional_metadata=None)[source]

wrapper for logging method run times for a class.

dasi.utils.log_times(key=None, class_attribute='_method_trace')[source]

wrapper for logging method run times for a class.

dasi.utils.perfect_subject(data)[source]

Determine whether a blast result consumes the entire subject.

dasi.utils.sort_with_keys(a, key)[source]

Sort an iterable, returning both the sorted array and the sorted keys.

Parameters
  • a (Iterable[Any]) – the iterable

  • key (Callable) – key function to use for sorting

Return type

Tuple[List, List]

Returns