dae.variants_loaders.raw package

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.AnnotationDecorator(variants_loader: VariantsLoader)[source]

Bases: VariantsLoaderDecorator

Base class for annotators.

CLEAN_UP_COLUMNS = {'alternatives_data', 'best_state_data', 'effect_gene', 'effect_type', 'family_id', 'family_variant_index', 'frequency_data', 'genetic_model_data', 'genomic_scores_data', 'genotype_data', 'inheritance_data', 'variant_in_member', 'variant_inheritance', 'variant_roles', 'variant_sexes'}
SEP1 = '!'
SEP2 = '|'
SEP3 = ':'
static build_annotation_filename(filename: str) str[source]

Return the corresponding annotation file for filename.

static has_annotation_file(variants_filename: str) bool[source]
static save_annotation_file(variants_loader: AnnotationPipelineDecorator, filename: str, sep: str = '\t') None[source]

Save annotation file.

class dae.variants_loaders.raw.loader.AnnotationPipelineDecorator(variants_loader: VariantsLoader, annotation_pipeline: AnnotationPipeline)[source]

Bases: AnnotationDecorator

Annotate variants by processing them through an annotation pipeline.

property annotation_schema: list[dae.annotation.annotation_pipeline.AttributeInfo]
close() None[source]

Close resources used by the loader.

full_variants_iterator() Generator[tuple[dae.variants.variant.SummaryVariant, list[dae.variants.family_variant.FamilyVariant]], None, None][source]
class dae.variants_loaders.raw.loader.ArgumentType(value)[source]

Bases: Enum

An enumeration.

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, 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.EffectAnnotationDecorator(variants_loader: VariantsLoader, effect_annotator: AnnotationPipeline)[source]

Bases: AnnotationDecorator

Annotate variants with an effect.

close() None[source]

Close resources used by the loader.

full_variants_iterator() Generator[tuple[dae.variants.variant.SummaryVariant, list[dae.variants.family_variant.FamilyVariant]], None, None][source]
class dae.variants_loaders.raw.loader.FamiliesGenotypes[source]

Bases: ABC

A base class for family genotypes.

abstract family_genotype_iterator() Generator[tuple[dae.pedigrees.family.Family, numpy.ndarray, Optional[numpy.ndarray]], None, None][source]
class dae.variants_loaders.raw.loader.StoredAnnotationDecorator(variants_loader: VariantsGenotypesLoader, annotation_filename: str)[source]

Bases: AnnotationDecorator

Annotate variant using a stored annotator.

static decorate(variants_loader: VariantsGenotypesLoader, source_filename: str) VariantsLoader[source]

Wrap variants_loader into a StoredAnnotationDecorator.

full_variants_iterator() Generator[tuple[dae.variants.variant.SummaryVariant, list[dae.variants.family_variant.FamilyVariant]], 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[str] | 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[dae.variants.variant.SummaryVariant, list[dae.variants.family_variant.FamilyVariant]], None, None][source]
reset_regions(regions: str | list[str] | 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[dae.annotation.annotation_pipeline.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[dae.variants.variant.SummaryVariant, list[dae.variants.family_variant.FamilyVariant]], None, None][source]
get_attribute(key: str) Any[source]
reset_regions(regions: str | list[str] | 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[dae.annotation.annotation_pipeline.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