Selector#

class biotite.sequence.align.Selector(permutation: Permutation | None = None)[source]#

Bases: Generic[S]

Abstract base class for all k-mer subset selectors.

A selector reduces the number of k-mers obtained from a sequence by choosing a representative subset, while still ensuring that the same k-mers are selected from similar sequences. The criterion for selecting a k-mer depends on the concrete subclass.

Parameters:
permutationPermutation

If set, the k-mer order is permuted, i.e. the selection is based on the ordering of the sort keys from Permutation.permute(), instead of the standard order of the KmerAlphabet.

Attributes:
permutationPermutation

The permutation.

abstractmethod select(sequence, alphabet_check=True)#

Obtain all overlapping k-mers from a sequence and select a subset of them.

Parameters:
sequenceSequence

The sequence to select the k-mers from. Must be compatible with the selector’s k-mer alphabet.

alphabet_checkbool, optional

If set to false, the compatibility between the alphabet of the sequence and the alphabet of the selector is not checked to gain additional performance.

Returns:
indicesndarray, dtype=np.uint32

The sequence indices where the selected k-mers start.

kmersndarray, dtype=np.int64

The corresponding k-mer codes of the selected k-mers.

abstractmethod select_from_kmers(kmers)#

Select a subset of the given k-mers.

Parameters:
kmersndarray, dtype=np.int64

The k-mer codes to select a subset from.

Returns:
indicesndarray, dtype=np.uint32

The indices in the input k-mer array of the selected k-mers.

kmersndarray, dtype=np.int64

The corresponding k-mer codes of the selected k-mers.