dae.variants_loaders.raw package

Subpackages

Submodules

dae.variants_loaders.raw.flexible_variant_loader module

dae.variants_loaders.raw.flexible_variant_loader.adjust_chrom_prefix(add_chrom_prefix: str | None = None, del_chrom_prefix: str | None = None) Callable[[Dict[str, Any]], Dict[str, Any]][source]

Return a function that adds/removes a prefix to/from chrom names.

dae.variants_loaders.raw.flexible_variant_loader.flexible_variant_loader(infile: TextIO, in_header: List[str], line_splitter: Callable, transformers: Sequence[Callable[[Dict[str, Any]], Dict[str, Any]]], filters: Sequence[Callable[[Dict[str, Any]], bool]]) Generator[Dict[str, Any], None, None][source]

Split,transform and filter each line from infile.

dae.variants_loaders.raw.flexible_variant_loader.location_variant_to_vcf_transformer(genome: ReferenceGenome) Callable[[Dict[str, Any]], Dict[str, Any]][source]

Return a function extracting chrom,pos,ref,alt from a vcf variant.

dae.variants_loaders.raw.flexible_variant_loader.variant_to_variant_type() Callable[[Dict[str, Any]], Dict[str, Any]][source]

Return a function extracting the variant type from a vcf variant.

dae.variants_loaders.raw.loader module

Base classes and helpers for variant loaders.

class dae.variants_loaders.raw.loader.ArgumentType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

ARGUMENT = 1
OPTION = 2
class dae.variants_loaders.raw.loader.CLIArgument(argument_name: str, *, has_value: bool = True, default_value: int | str | bool | None = None, destination: str | None = None, help_text: str | None = None, action: str | None = None, value_type: type[str] | None = None, metavar: str | None = None, nargs: str | None = None, raw: bool = False)[source]

Bases: object

Defines class for handling CLI arguments in variant loaders.

This class handles the logic for CLI argument operations such as parsing arguments, transforming to dict, transforming a parsed argument back to a CLI argument and adding itself to an existing ArgumentParser. Construction closely mirrors the ArgumentParser argument format.

add_to_parser(parser: ArgumentParser) None[source]

Add this argument to argsparser.

build_option(params: dict[str, str], *, use_defaults: bool = False) str | None[source]

Build an option.

parse_cli_argument(argv: Namespace, *, use_defaults: bool = False) None[source]

Parse the command line argument from the argv object.

Args:

argv (argparse.Namespace): The command line arguments. use_defaults (bool, optional): Whether to use default values

if the argument is None. Defaults to False.

class dae.variants_loaders.raw.loader.CLILoader(params: dict[str, Any] | None = None)[source]

Bases: ABC

Base class for loader classes that require cli arguments.

build_arguments_dict() dict[str, str | bool][source]

Build a dictionary with the argument destinations as keys.

classmethod build_cli_arguments(params: dict) str[source]

Return a string with cli arguments.

classmethod cli_arguments(parser: ArgumentParser, *, options_only: bool = False) None[source]

Add command-line arguments specific for the CLILoader class.

Args:
parser (argparse.ArgumentParser): The ArgumentParser object to

add the arguments to.

options_only (bool, optional): If True, only adds options (not arguments) to the parser. Defaults to False.

classmethod cli_defaults() dict[str, Any][source]

Build a dictionary with default values for CLI arguments.

classmethod parse_cli_arguments(argv: Namespace, *, use_defaults: bool = False) tuple[list[str], dict[str, Any]][source]

Parse cli arguments.

class dae.variants_loaders.raw.loader.FamiliesGenotypes[source]

Bases: ABC

A base class for family genotypes.

abstract family_genotype_iterator() Generator[tuple[Family, ndarray, ndarray | None], None, None][source]
class dae.variants_loaders.raw.loader.VariantsGenotypesLoader(families: FamiliesData, filenames: str | list[str], genome: ReferenceGenome, transmission_type: TransmissionType = TransmissionType.transmitted, regions: list[Region] | None = None, *, expect_genotype: bool = True, expect_best_state: bool = False, params: dict[str, Any] | None = None)[source]

Bases: VariantsLoader

Base class for variants loaders.

Calculate missing best states and adds a genetic model value to the family variant and its alleles.

full_variants_iterator() Generator[tuple[SummaryVariant, list[FamilyVariant]], None, None][source]
reset_regions(regions: list[Region] | Sequence[Region | None] | None) None[source]
class dae.variants_loaders.raw.loader.VariantsLoader(families: FamiliesData, filenames: str | list[str], genome: ReferenceGenome, transmission_type: TransmissionType = TransmissionType.transmitted, params: dict[str, Any] | None = None, attributes: dict[str, Any] | None = None)[source]

Bases: CLILoader

Base class for all variant loaders.

property annotation_schema: list[AttributeInfo] | None
abstract property chromosomes: list[str]

Return list of all chromosomes.

abstract close() None[source]

Close resources used by the loader.

family_variants_iterator() Generator[FamilyVariant, None, None][source]
abstract full_variants_iterator() Generator[tuple[SummaryVariant, list[FamilyVariant]], None, None][source]
get_attribute(key: str) Any[source]
reset_regions(regions: list[Region] | Sequence[Region | None] | None) None[source]
set_attribute(key: str, value: Any) None[source]
property variants_filenames: list[str]
class dae.variants_loaders.raw.loader.VariantsLoaderDecorator(variants_loader: VariantsLoader)[source]

Bases: VariantsLoader

Base class for wrapping and decoring a variant loader.

property annotation_schema: list[AttributeInfo] | None
build_arguments_dict() dict[source]

Build a dictionary with the argument destinations as keys.

classmethod build_cli_arguments(params: dict) str[source]

Return a string with cli arguments.

property chromosomes: list[str]

Return list of all chromosomes.

classmethod cli_arguments(parser: ArgumentParser, *, options_only: bool = False) None[source]

Add command-line arguments specific for the CLILoader class.

Args:
parser (argparse.ArgumentParser): The ArgumentParser object to

add the arguments to.

options_only (bool, optional): If True, only adds options (not arguments) to the parser. Defaults to False.

classmethod cli_defaults() dict[str, Any][source]

Build a dictionary with default values for CLI arguments.

close() None[source]

Close resources used by the loader.

get_attribute(key: str) Any[source]

Module contents