gpf.utils package

Submodules

gpf.utils.testing module

gpf.utils.testing.setup_t4c8_instance(root_path: Path, grr: GenomicResourceRepo | None = None) GPFInstance[source]

Setup a t4c8 based GPF instance for testing.

gpf.utils.variant_utils module

class gpf.utils.variant_utils.BitmaskEnumTranslator(*, main_enum_type: type[Enum], partition_by_enum_type: type[Enum])[source]

Bases: object

Encoder and decoder of two enums into a single value.

It has two enum types: the main and the partition by enum. For every enum value in the partition_by enum, a tuple of bits corresponding to the main enum will be added to the value. The amount of bits in the tuple will depend on how many bitwise values the main enum holds. The amount of tuples depends on the amount of bitwise values the partition by holds.

Enums provided to this class must have bitwise values, behavior with enums without bitwise values is undefined.

apply_mask(mask: int, main_enum_value: int, partition_by_enum: Enum) int[source]

Apply a mask filter over an existing mask and return the new mask.

gpf.utils.variant_utils.best2gt(best_state: ~numpy.ndarray, dtype: ~numpy.dtype[~typing.Any] | None | type[~typing.Any] | ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]] | str | tuple[~typing.Any, int] | tuple[~typing.Any, ~typing.SupportsIndex | ~collections.abc.Sequence[~typing.SupportsIndex]] | list[~typing.Any] | ~numpy._typing._dtype_like._DTypeDict | tuple[~typing.Any, ~typing.Any] = <class 'numpy.int8'>) ndarray[source]

Convert a best state array to a genotype array.

gpf.utils.variant_utils.fgt2str(family_genotypes: ndarray, sep: str = ';') str[source]

Convert a family genotype array to a string.

gpf.utils.variant_utils.get_interval_locus_ploidy(chrom: str, pos_start: int, pos_end: int, sex: Sex, genome: ReferenceGenome) int[source]
gpf.utils.variant_utils.get_locus_ploidy(chrom: str, pos: int, sex: Sex, genome: ReferenceGenome) int[source]

Return the number of ploidy at a given position in a chromosome.

gpf.utils.variant_utils.gt2str(gt: ndarray) str[source]

Convert a genotype array to a string.

gpf.utils.variant_utils.is_all_reference_genotype(gt: ndarray) bool[source]
gpf.utils.variant_utils.is_all_unknown_genotype(gt: ndarray) bool[source]
gpf.utils.variant_utils.is_reference_genotype(gt: ndarray) bool[source]
gpf.utils.variant_utils.is_unknown_genotype(gt: ndarray) bool[source]
gpf.utils.variant_utils.mat2str(mat: ndarray | list[list[int]], col_sep: str = '', row_sep: str = '/') str[source]

Construct sting representation of a matrix.

gpf.utils.variant_utils.reference_genotype(size: int) ndarray[source]
gpf.utils.variant_utils.str2fgt(fgt: str) ndarray[source]

Convert a string to a family genotype array.

gpf.utils.variant_utils.str2gt(genotypes: str, split: str = ', ', dtype: ~numpy.dtype[~typing.Any] | None | type[~typing.Any] | ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]] | str | tuple[~typing.Any, int] | tuple[~typing.Any, ~typing.SupportsIndex | ~collections.abc.Sequence[~typing.SupportsIndex]] | list[~typing.Any] | ~numpy._typing._dtype_like._DTypeDict | tuple[~typing.Any, ~typing.Any] = <class 'numpy.int8'>) ndarray[source]

Convert a string to a genotype array.

gpf.utils.variant_utils.str2lists(mat: str, col_sep: str = '', row_sep: str = '/') list[list[int]][source]

Convert a string into a numpy matrix.

gpf.utils.variant_utils.str2mat(mat: str, col_sep: str = '', row_sep: str = '/', dtype: ~numpy.dtype[~typing.Any] | None | type[~typing.Any] | ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]] | str | tuple[~typing.Any, int] | tuple[~typing.Any, ~typing.SupportsIndex | ~collections.abc.Sequence[~typing.SupportsIndex]] | list[~typing.Any] | ~numpy._typing._dtype_like._DTypeDict | tuple[~typing.Any, ~typing.Any] = <class 'numpy.int8'>) ndarray[source]

Convert a string into a numpy matrix.

gpf.utils.variant_utils.str2mat_adjust_colsep(mat: str) ndarray[source]

Convert a string into a numpy matrix.

Module contents