dae.variants package
Subpackages
- dae.variants.tests package
- Submodules
- dae.variants.tests.test_allele module
- dae.variants.tests.test_attributes_utils module
- dae.variants.tests.test_best_state module
- dae.variants.tests.test_inheritance_checks module
- dae.variants.tests.test_keep_pedigree_order module
- dae.variants.tests.test_roles module
- dae.variants.tests.test_sex module
- dae.variants.tests.test_summary_allele module
- dae.variants.tests.test_variant_details module
- dae.variants.tests.test_variant_to_records module
- dae.variants.tests.test_variant_type module
- dae.variants.tests.test_vcf2cshl_variant_format module
- dae.variants.tests.test_zygosity module
- Module contents
Submodules
dae.variants.attributes module
- class dae.variants.attributes.GeneticModel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
- X = 4
- X_broken = 5
- autosomal = 1
- autosomal_broken = 2
- pseudo_autosomal = 3
- class dae.variants.attributes.Inheritance(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enumerator for variant inheritance type.
- denovo = 4
- static from_name(name: str) Inheritance [source]
- static from_value(value: int) Inheritance [source]
- mendelian = 2
- missing = 128
- omission = 16
- other = 64
- possible_denovo = 8
- possible_omission = 32
- reference = 1
- unknown = 256
- class dae.variants.attributes.Role(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enumerator for a person’s role in a pedigree.
- child = 512
- dad = 32
- property display_name: str
- static from_name(name: str | int | None) Role [source]
Construct and return a Role from it’s string representation.
- half_sibling = 4096
- maternal_aunt = 65536
- maternal_cousin = 1048576
- maternal_grandfather = 2
- maternal_grandmother = 1
- maternal_half_sibling = 1024
- maternal_uncle = 131072
- mom = 16
- parent = 64
- paternal_aunt = 262144
- paternal_cousin = 2097152
- paternal_grandfather = 8
- paternal_grandmother = 4
- paternal_half_sibling = 2048
- paternal_uncle = 524288
- prb = 128
- sib = 256
- spouse = 16777216
- step_dad = 8388608
- step_mom = 4194304
- unknown = 33554432
- class dae.variants.attributes.Sex(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enumerator for a person’s sex.
- F = 2
- M = 1
- U = 4
- female = 2
- male = 1
- unspecified = 4
- class dae.variants.attributes.Status(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enumerator for a person’s status.
- affected = 2
- static from_name(name: int | str | None) Status [source]
Construct and return person status from string.
- unaffected = 1
- unspecified = 4
- class dae.variants.attributes.TransmissionType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
- denovo = 2
- transmitted = 1
- unknown = 0
- class dae.variants.attributes.Zygosity(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enumerance for allele zygosity.
- heterozygous = 2
- homozygous = 1
- undefined = 0
- dae.variants.attributes.bitmask2inheritance(bitmask: int) set[Inheritance] [source]
Convert a bitmask to set of inheritance.
dae.variants.core module
- class dae.variants.core.Allele(chrom: str, pos: int, pos_end: int | None = None, ref: str | None = None, alt: str | None = None, allele_type: Type | None = None)[source]
Bases:
object
Class representing alleles.
- TYPE_DISPLAY_NAME: ClassVar[dict[str, str]] = {'complex': 'comp', 'large_deletion': 'cnv-', 'large_insertion': 'cnv+', 'small_deletion': 'del', 'small_insertion': 'ins', 'substitution': 'sub'}
- class Type(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enumerator for allele type.
- cnv = 48
- complex = 8
- indel = 14
- large_deletion = 16
- large_duplication = 32
- position = 0
- small_deletion = 4
- small_insertion = 2
- substitution = 1
- tandem_repeat = 64
- tandem_repeat_del = 68
- tandem_repeat_ins = 66
- property alternative: str | None
- property chrom: str
- property chromosome: str
- property end_position: int | None
- get_annotatable() Annotatable [source]
Return an annotatable version of the allele.
- property position: int
- property reference: str | None
dae.variants.family_variant module
- class dae.variants.family_variant.FamilyAllele(summary_allele: SummaryAllele, family: Family, genotype: ndarray | None, best_state: ndarray | None, genetic_model: GeneticModel | None = None, inheritance_in_members: list[Inheritance] | None = None)[source]
Bases:
SummaryAllele
,FamilyDelegate
Class representing an allele in a family.
- property allele_in_members: list[str | None]
- property allele_index: int
- property alternative: str | None
- property attributes: dict[str, Any]
- property best_st: ndarray
Deprecated since version Replace: best_st with best_state
- property best_state: ndarray
Return the best state of the variant.
- classmethod calc_inheritance_trio(parent_1: ndarray, parent_2: ndarray, child: ndarray, allele_index: int) Inheritance [source]
Calculate the inheritance type of a trio family.
- Parameters:
parent_1 – genotype of the first parent (pair of allele indexes).
parent_2 – genotype of the second parent.
child – genotype of the child.
- Returns:
inheritance type as
variants.attributes.Inheritance
of the trio family.
- static check_denovo_trio(parent_1: ndarray, parent_2: ndarray, child: ndarray, allele_index: int) bool [source]
Check if the inheritance type for a trio family is denovo.
- Parameters:
parent_1 – genotype of the first parent (pair of allele indexes).
parent_2 – genotype of the second parent.
child – genotype of the child.
- Returns:
True, when the inheritance is mendelian.
- static check_mendelian_trio(parent_1: ndarray, parent_2: ndarray, child: ndarray, allele_index: int) bool [source]
Check if the inheritance type for a trio family is mendelian.
- Parameters:
parent_1 – genotype of the first parent (pair of allele indexes).
parent_2 – genotype of the second parent.
child – genotype of the child.
- Returns:
True, when the inheritance is mendelian.
- static check_omission_trio(parent_1: ndarray, parent_2: ndarray, child: ndarray, allele_index: int) bool [source]
Check if the inheritance type for a trio family is omission.
- Parameters:
parent_1 – genotype of the first parent (pair of allele indexes).
parent_2 – genotype of the second parent.
child – genotype of the child.
- Returns:
True, when the inheritance is mendelian.
- property chrom: str
- property chromosome: str
- property details: VariantDetails
Build and return CSHL allele details.
- property effects: AlleleEffects | None
Build and return allele effect.
- property end_position: int | None
- property family_attributes: dict[str, Any]
- property family_index: int | None
- property genetic_model: GeneticModel | None
- property genotype: ndarray
Return the genotype of the family.
- get_attribute(item: str, default_val: Any = None) Any [source]
Return list of values from additional attributes matching given key.
looks up values matching key item in additional attributes passed on creation of the variant.
- has_attribute(item: str) bool [source]
Check if the additional variant attributes contain a given key.
- property inheritance_in_members: list[Inheritance]
Return list of family member inheritance.
- property position: int
- property reference: str | None
- summary_allele: SummaryAllele
summary allele that corresponds to this allele in family variant
- property summary_attributes: dict[str, Any]
- property summary_index: int
- property transmission_type: TransmissionType
- property variant_in_members: list[str | None]
Return set of affected by this variant family members’ IDs.
- property variant_in_members_fpid: list[tuple[str, str]]
Return list of person with the variant.
- property variant_in_roles: list[Role | None]
Return list of roles that have affected by this variant members.
Returns None if none found.
- property variant_in_sexes: list[Sex | None]
Return list of sexes that are affected by this variant in family.
- property variant_in_statuses: list[Status | None]
Return list of statuses (or ‘None’) of the members with variant.
- property zygosity_in_roles: int
- property zygosity_in_sexes: int
- property zygosity_in_status: int
- class dae.variants.family_variant.FamilyDelegate(family: Family)[source]
Bases:
object
Delegate for handling families.
- property family_id: str
Return the family ID.
- property members_fpids: list[tuple[str, str]]
Return list of family members IDs.
- property members_ids: list[str]
Return list of family members IDs.
- class dae.variants.family_variant.FamilyVariant(summary_variant: SummaryVariant, family: Family, genotype: ndarray | None, best_state: ndarray | None, inheritance_in_members: dict[int, list[Inheritance]] | None = None)[source]
Bases:
SummaryVariant
,FamilyDelegate
Class representing a variant in a family.
- property allele_count: int
- property allele_indexes: list[int]
- property alleles: list[SummaryAllele]
- property best_st
Deprecated since version Replace: usage of best_st with best_state
- property best_state: ndarray
Return best state of the variant.
- static calc_alleles(gt: ndarray) list[int] [source]
Return allele indexes that are relevant for the given genotype.
- Parameters:
gt – genotype as np.array.
- Returns:
list of all allele indexes present into genotype passed.
- static calc_alt_alleles(gt: ndarray) list[int] [source]
Return relevant for the given genotype alternative allele indexes.
- Parameters:
gt – genotype as np.array.
- Returns:
list of all alternative allele indexes present into genotype passed.
- property chrom: str
- property chromosome: str
- property end_position: int | None
- property family_allele_indexes: list[int]
- property family_alleles: list[FamilyAllele]
- property family_alt_alleles: list[FamilyAllele]
- property family_best_state: ndarray
- property family_genotype: list[list[int]]
Return family genotype using family variant indexes.
- property family_index: int | None
- property fvuid: str
Construct and return the family variant unique identifier.
- property genetic_model: GeneticModel
- property genotype: list[list[int]]
Return genotype using summary variant allele indexes.
- property position: int
- property reference: str | None
- property summary_index: int
- property variant_in_members: set[str]
Return list of members with the variant.
- property zygosity_in_roles: int
Calculate and cache zygosity based on alternative alleles.
- property zygosity_in_sexes: int
Calculate and cache zygosity based on alternative alleles.
- property zygosity_in_status: int
Calculate and cache zygosity based on alternative alleles.
dae.variants.variant module
Classes and helper function to represent variants.
- class dae.variants.variant.SummaryAllele(chromosome: str, position: int, reference: str | None, alternative: str | None = None, end_position: int | None = None, summary_index: int = -1, allele_index: int = 0, transmission_type: TransmissionType = TransmissionType.transmitted, allele_type: Type | None = None, attributes: dict[str, Any] | None = None, effect: str | None = None)[source]
Bases:
Allele
Class to represents a single allele for given position.
- property allele_index: int
- property attributes: dict[str, Any]
- static create_reference_allele(allele: SummaryAllele) SummaryAllele [source]
Given an allele creates the corresponding reference allele.
- property cshl_location: str
Return CSHL location (chrom:position) of an allele.
- property cshl_position: int | None
Return CSHL position of an allele.
- property cshl_variant: str | None
- property cshl_variant_full: str
- property details: VariantDetails
Build and return CSHL allele details.
- property effect_gene_symbols: list[str]
- property effect_genes: list[EffectGene]
- property effect_types: list[str]
- property effects: AlleleEffects | None
Build and return allele effect.
- property frequency: float | None
- get_attribute(item: str, default_val: Any = None) Any [source]
Return attribute value.
Looks up values matching key item in additional attributes passed on creation of the variant.
- property is_reference_allele: bool
- property summary_index: int
- property transmission_type: TransmissionType
- property worst_effect: str | None
- class dae.variants.variant.SummaryVariant(alleles: list[SummaryAllele])[source]
Bases:
object
Represents summary variant.
- property allele_count: int
- property alleles: list[SummaryAllele]
- property alt_alleles: list[SummaryAllele]
Return list of all alternative alleles of the variant.
- property alternative: str | None
- property attributes: list[dict[str, Any]]
- property chrom: str
- property chromosome: str
- property cshl_location: list[str]
- property cshl_variant: list[str | None]
- property cshl_variant_full: list[str | None]
- property details: list[VariantDetails]
Return list of ‘VariantDetails’ for each allele.
- property effect_gene_symbols: list[str]
- property effect_types: list[str]
- property effects: list[AlleleEffects]
Return list of allele effects.
- property end_position: int | None
- property frequencies: list[float | None]
Return list of allele frequencies.
- property location: str
Return summary variant location.
- property matched_alleles: list[SummaryAllele]
- property matched_alleles_indexes: list[int]
- property matched_gene_effects: set[EffectGene]
- property position: int
- property ref_allele: SummaryAllele
Return the reference allele of the variant.
- property reference: str | None
- property summary_index: int
- property svuid: str
Build and return summary variant ‘unique’ ID.
- property transmission_type: TransmissionType
- property variant_types: set[Any]
Return set of allele types.
- class dae.variants.variant.SummaryVariantFactory[source]
Bases:
object
Factory for summary variants.
- static summary_allele_from_record(record: dict[str, Any], transmission_type: TransmissionType | None = None, attr_filter: set[str] | None = None) SummaryAllele [source]
Build a summary allele from a dictionary (record).
- static summary_variant_from_records(records: list[dict[str, Any]], transmission_type: TransmissionType | None = None, attr_filter: set[str] | None = None) SummaryVariant [source]
Build summary variant from a list of dictionaries (records).
- static summary_variant_from_vcf(vcf_variant: VariantRecord, summary_index: int, transmission_type: TransmissionType) SummaryVariant [source]
Build sumamry variant from a pysam VCF record.
- class dae.variants.variant.VariantDesc(variant_type: Type, position: int, end_position: int | None = None, ref: str | None = None, alt: str | None = None, length: int | None = None, tr_ref: int | None = None, tr_alt: int | None = None, tr_unit: str | None = None)[source]
Bases:
object
Variant description.
- static combine(variant_descs: list[VariantDesc]) list[str] [source]
Combine multiple variant description into list of descriptions.
- class dae.variants.variant.VariantDetails(chrom: str, variant_desc: VariantDesc)[source]
Bases:
object
Represents CSHL variant details.
- static from_cnv(variant: SummaryAllele) VariantDetails [source]
Build variant details from a CNV variant.
- static from_vcf(chrom: str, position: int, reference: str, alternative: str) VariantDetails [source]
Build variant details from a VCF variant.
- dae.variants.variant.allele_type_from_cshl_variant(variant: str) Type [source]
Return allele type from a CSHL variant type.
- dae.variants.variant.allele_type_from_name(name: str) Type [source]
Return allele type from an allele type name.
- dae.variants.variant.cshl_format(pos: int, ref: str, alt: str, trimmer: ~collections.abc.Callable[[int, str, str], tuple[int, str, str]] = <function trim_str_left_right>) VariantDesc [source]
Build a description for an CSHL allele.
- dae.variants.variant.tandem_repeat(ref: str, alt: str, min_mono_reference: int = 8) tuple[str | None, int | None, int | None] [source]
Check if an allele is a tandem repeat and builds it.
- dae.variants.variant.vcf2cshl(pos: int, ref: str, alt: str, trimmer: ~collections.abc.Callable[[int, str, str], tuple[int, str, str]] = <function trim_str_right_left>) VariantDesc [source]
Build a description for an VCF allele.