dinopy.shaping module¶
This module contains functions to shape q-grams.
Note
The dinopy.processors.qgrams()
function that creates (shaped)
q-grams from a sequence is considered a processor and can be found
in the dinopy.processors
module.
- dinopy.shaping.apply_shape(qgram, shp)¶
Applies the given shape to the given q-gram. Calls
_apply_shape_array()
or_apply_shape_unicode()
, depending on the type of q-gram.- Parameters:
qgram (dtype) – A q-gram of any dtype.
shp (Shape) – see
dinopy.shape.Shape
- Returns:
A reduced q-gram. The result of applying
qgram_shape
toqgram
, e.g. applying#__##
toACGTA
results inATA
.- Return type:
dtype
- dinopy.shaping.windows(seq, qgram_shape)¶
Create all windows described by the shape from the seq.
Check the type of the input and invoke the right _windows_<type>
- Parameters:
seq (dtype) – A sequence of any dtype.
qgram_shape – see
dinopy.shape
- Yields:
dtype – An iterator over all gapped q-grams generated by applying
qgram_shape
to all q-grams of seq.- Raises:
TypeError – If seq is of an unsupported type. Supported types are: - bytes - bytearray - string / unicode - array
- dinopy.shaping.windows_list(seq, qgram_shape) list ¶
Check the type of the input and invoke the right _windows_<type> function to create all windows created by the given q-gram shape
- Parameters:
seq (dtype) – A sequence of any dtype.
qgram_shape – see
dinopy.shape
- Returns:
A list containing all gapped q-grams generated by applying
qgram_shape()
to all q-grams of seq.- Return type:
list
- Raises:
InvalidDtypeError – If the seq has an invalid dtype.