dae.variants package

Submodules

dae.variants.attributes module

class dae.variants.attributes.GeneticModel(value)[source]

Bases: Enum

An enumeration.

X = 4
X_broken = 5
autosomal = 1
autosomal_broken = 2
pseudo_autosomal = 3
class dae.variants.attributes.Inheritance(value)[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)[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.

static from_value(val: int) Role[source]
half_sibling = 4096
maternal_aunt = 65536
maternal_cousin = 1048576
maternal_grandfather = 2
maternal_grandmother = 1
maternal_half_sibling = 1024
maternal_uncle = 131072
mom = 16
static not_role(value: int) int[source]
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
static to_name(value: int) str[source]
static to_value(name: str | int | None) int[source]
unknown = 0
class dae.variants.attributes.Sex(value)[source]

Bases: Enum

Enumerator for a person’s sex.

F = 2
M = 1
U = 0
female = 2
static from_name(name: str | int | None) Sex[source]

Construct and return person Sex from string.

static from_value(val: int) Sex[source]
male = 1
short() str[source]
static to_name(value: int) str[source]
static to_value(name: str | int | None) int[source]
unspecified = 0
class dae.variants.attributes.Status(value)[source]

Bases: Enum

Enumerator for a person’s status.

affected = 2
static from_name(name: str | int | None) Status[source]

Construct and return person status from string.

static from_value(val: int) Status[source]
short() str[source]
static to_name(value: int) str[source]
static to_value(name: str | int | None) int[source]
unaffected = 1
unspecified = 0
class dae.variants.attributes.TransmissionType(value)[source]

Bases: IntEnum

An enumeration.

denovo = 2
transmitted = 1
unknown = 0
dae.variants.attributes.bitmask2inheritance(bitmask: int) set[dae.variants.attributes.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 = {'complex': 'comp', 'large_deletion': 'cnv-', 'large_insertion': 'cnv+', 'small_deletion': 'del', 'small_insertion': 'ins', 'substitution': 'sub'}
class Type(value)[source]

Bases: Enum

Enumerator for allele type.

cnv = 48
complex = 8
indel = 14
classmethod is_cnv(vt: Type) bool[source]
classmethod is_tr(vt: Type) bool[source]
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 allele_type: Type
property alternative: str | None
static build_cnv_allele(chrom: str, pos: int, pos_end: int, allele_type: Type) Allele[source]
static build_position_allele(chrom: str, pos: int) Allele[source]
static build_vcf_allele(chrom: str, pos: int, ref: str, alt: str) Allele[source]
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[dae.variants.attributes.Inheritance] | None = None)[source]

Bases: SummaryAllele, FamilyDelegate

Class representing an allele in a family.

property allele_in_members: list[str]
property allele_in_roles: list[Optional[dae.variants.attributes.Role]]
property allele_in_sexes: list[Optional[dae.variants.attributes.Sex]]
property allele_in_statuses: list[Optional[dae.variants.attributes.Status]]
property allele_index: int
property allele_type: Type
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 = 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.

gt_flatten() ndarray[source]

Return the family variant genotype flattened to a 1d array.

has_attribute(item: str) bool[source]

Check if the additional variant attributes contain a given key.

property inheritance_in_members: list[dae.variants.attributes.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
update_attributes(atts: dict[str, Any]) None[source]

Update additional attributes of the variant.

property variant_in_members: list[str]

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_members_objects: list[dae.pedigrees.family.Person]

Return list of person with the variant.

property variant_in_roles: list[Optional[dae.variants.attributes.Role]]

Return list of roles that have affected by this variant members.

Returns None if none found.

property variant_in_sexes: list[Optional[dae.variants.attributes.Sex]]

Return list of sexes that are affected by this variant in family.

property variant_in_statuses: list[Optional[dae.variants.attributes.Status]]

Return list of statuses (or ‘None’) of the members with variant.

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.

property members_in_order: list[dae.pedigrees.family.Person]

Return the members from the pedigree file in order.

Return list of the members of the family in the order specified from the pedigree file. Each element of the returned list is an object of type variants.family.Person.

class dae.variants.family_variant.FamilyVariant(summary_variant: SummaryVariant, family: Family, genotype: ndarray | None, best_state: ndarray | None, inheritance_in_members: dict[int, list[dae.variants.attributes.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[dae.variants.variant.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[dae.variants.family_variant.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
property genetic_model: GeneticModel
property genotype: list[list[int]]

Return genotype using summary variant allele indexes.

gt_flatten() ndarray[source]

Return genotype of the family variant flattened to a 1d array.

is_reference() bool[source]

Return True if all known alleles in the variant are reference.

is_unknown() bool[source]

Return True if all alleles in the variant are unknown.

property position: int
property reference: str | None
property summary_index: int
to_record() dict[str, Any][source]
property variant_in_members: set[str]

Return list of members with the variant.

dae.variants.family_variant.calculate_simple_best_state(genotype: ndarray, allele_count: int) ndarray[source]

Calculate and return the best state of a genotype.

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 = None) Any[source]

Return attribute value.

Looks up values matching key item in additional attributes passed on creation of the variant.

has_attribute(item: str) bool[source]

Check if an attribute item is available.

property is_reference_allele: bool
property summary_index: int
to_record() dict[str, Any][source]

Construct a record from an allele.

property transmission_type: TransmissionType
update_attributes(atts: dict[str, Any]) None[source]

Update allele attributes.

property variant_type: Type
property worst_effect: str | None
class dae.variants.variant.SummaryVariant(alleles: list[dae.variants.variant.SummaryAllele])[source]

Bases: object

Represents summary variant.

property allele_count: int
property alleles: list[dae.variants.variant.SummaryAllele]
property alt_alleles: list[dae.variants.variant.SummaryAllele]

Return list of all alternative alleles of the variant.

property alternative: str | None
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.

get_attribute(item: Any, default: Any | None = None) List[Any][source]
has_attribute(item: Any) bool[source]
property location: str

Return summary variant location.

property matched_alleles: list[dae.variants.variant.SummaryAllele]
property matched_alleles_indexes: list[int]
property matched_gene_effects: set[dae.effect_annotation.effect.EffectGene]
property position: int
property ref_allele: SummaryAllele

Return the reference allele of the variant.

property reference: str | None
set_matched_alleles(alleles_indexes: List[int]) None[source]
property summary_index: int
property svuid: str

Build and return summary variant ‘unique’ ID.

to_record() list[dict[str, Any]][source]
property transmission_type: TransmissionType
update_attributes(atts: Dict[str, Any]) None[source]
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_variant_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[dae.variants.variant.VariantDesc]) list[str][source]

Combine multiple variant description into list of descriptions.

to_cshl_full() str[source]

Convert variant description into CSHL full type description.

Includes tandem repeats descriptions.

to_cshl_short() str[source]

Convert variant description into CSHL short type description.

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: ~typing.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[Optional[str], Optional[int], Optional[int]][source]

Check if an allele is a tandem repeat and builds it.

dae.variants.variant.vcf2cshl(pos: int, ref: str, alt: str, trimmer: ~typing.Callable[[int, str, str], tuple[int, str, str]] = <function trim_str_right_left>) VariantDesc[source]

Build a description for an VCF allele.

Module contents