dae.effect_annotation package

Subpackages

Submodules

dae.effect_annotation.annotation_effects module

dae.effect_annotation.annotation_effects.get_effect_types(types=True, groups=False)[source]

Produce collection of effect types.

dae.effect_annotation.annotation_effects.get_effect_types_set(effect_types)[source]

Split comma separated list of effect types.

dae.effect_annotation.annotation_request module

class dae.effect_annotation.annotation_request.BaseAnnotationRequest(reference_genome: ReferenceGenome, code: NuclearCode, promoter_len: int, variant: Variant, transcript_model: TranscriptModel)[source]

Bases: ABC

Effect annotation request description.

cds_regions() list[BedRegion][source]
cod2aa(codon: str) str[source]

Translate codon to amino acid.

get_coding_left(pos: int, length: int, index: int) str[source]

Return coding sequence to the left of a position.

get_coding_region_for_pos(pos: int) int | None[source]

Find conding region for a position.

get_coding_right(pos: int, length: int, index: int) str[source]

Construct conding sequence to the right of a position.

get_codons_left(pos: int, length: int) str[source]
get_codons_right(pos: int, length: int) str[source]

Return coding sequence to the right of a position.

get_exonic_distance(start: int, end: int) int[source]

Calculate exonic distance.

get_exonic_length() int[source]
get_exonic_position() int[source]
static get_nucleotides_count_to_full_codon(length: int) int[source]
abstract get_protein_position() tuple[int, int][source]
get_protein_position_for_pos(position: int) int | None[source]
has_utr3_region() bool[source]
has_utr5_region() bool[source]
is_start_codon_affected() bool[source]
is_stop_codon_affected() bool[source]
class dae.effect_annotation.annotation_request.NegativeStrandAnnotationRequest(reference_genome: ReferenceGenome, code: NuclearCode, promoter_len: int, variant: Variant, transcript_model: TranscriptModel)[source]

Bases: BaseAnnotationRequest

Effect annotation request on the negative strand.

cod2aa(codon: str) str[source]

Translate codon to amino acid.

static complement(sequence: str) str[source]

Build the complementary sequence for a sequence of nucleotides.

get_amino_acids() tuple[list[str], list[str]][source]

Construct the list of amino acids.

get_codons() tuple[str, str][source]

Get list of codons.

get_frame(pos: int, index: int) int[source]

Return the frame of the annotation request.

get_protein_length() int[source]
get_protein_position() tuple[int, int][source]

Calculate the protein position.

has_utr3_region() bool[source]
has_utr5_region() bool[source]
in_start_codons(codon: str) bool[source]

Check if request belongs to the start codon.

is_start_codon_affected() bool[source]
is_stop_codon_affected() bool[source]
class dae.effect_annotation.annotation_request.PositiveStrandAnnotationRequest(reference_genome: ReferenceGenome, code: NuclearCode, promoter_len: int, variant: Variant, transcript_model: TranscriptModel)[source]

Bases: BaseAnnotationRequest

Effect annotation request on the positive strand.

get_amino_acids() tuple[list[str], list[str]][source]

Construct the list of amino acids.

get_codons() tuple[str, str][source]

Get list of codons.

get_frame(pos: int, index: int) int[source]

Return the frame of the annotation request.

get_protein_length() int[source]
get_protein_position() tuple[int, int][source]

Calculate protein position.

in_start_codons(codon: str) bool[source]

Check if request belongs to the start codon.

dae.effect_annotation.annotator module

class dae.effect_annotation.annotator.AnnotationRequestFactory[source]

Bases: object

Factory for annotation requests.

static create_annotation_request(annotator: EffectAnnotator, variant: Variant, transcript_model: TranscriptModel) PositiveStrandAnnotationRequest | NegativeStrandAnnotationRequest[source]

Create an annotation request.

class dae.effect_annotation.annotator.EffectAnnotator(reference_genome: ~dae.genomic_resources.reference_genome.ReferenceGenome, gene_models: ~dae.genomic_resources.gene_models.gene_models.GeneModels, code: ~dae.effect_annotation.gene_codes.NuclearCode = <dae.effect_annotation.gene_codes.NuclearCode object>, promoter_len: int = 0)[source]

Bases: object

Predicts variant effect.

annotate(variant: Variant) list[AnnotationEffect][source]

Annotate effects for a variant.

annotate_allele(chrom: str, pos: int, ref: str, alt: str, length: int | None = None, seq: str | None = None, variant_type: str | None = None) list[AnnotationEffect][source]

Annotate effects for a variant.

annotate_cnv(chrom: str, pos_start: int, pos_end: int, variant_type: Type) list[AnnotationEffect][source]

Annotate a CNV variant.

annotate_region(chrom: str, pos_start: int, pos_end: int, effect_type: str = 'unknown') list[AnnotationEffect][source]

Annotate a region or position.

static annotate_variant(gm: GeneModels, reference_genome: ReferenceGenome, chrom: str | None = None, position: int | None = None, location: str | None = None, variant: str | None = None, ref: str | None = None, alt: str | None = None, length: int | None = None, seq: str | None = None, variant_type: Type | None = None, promoter_len: int = 0) list[AnnotationEffect][source]

Build effect annotator and annotate a variant.

do_annotate_variant(chrom: str | None = None, pos: int | None = None, location: str | None = None, variant: str | None = None, ref: str | None = None, alt: str | None = None, length: int | None = None, seq: str | None = None, variant_type: Type | None = None) list[AnnotationEffect][source]

Annotate effects for a variant.

get_effect_for_transcript(variant: Variant, transcript_model: TranscriptModel) AnnotationEffect | None[source]

Calculate effect for a given transcript.

dae.effect_annotation.cli module

class dae.effect_annotation.cli.AnnotationAttributes(args)[source]

Bases: object

ALL_ATTRIBUTE_IDXS = {'effect_details': 2, 'gene_effects': 1, 'worst_effect': 0}
get_out_attributes() List[str][source]
get_source_attributes() List[str][source]
get_values(effect) List[str][source]
static set_argument(parser: ArgumentParser, default_columns: str = 'worst_effect,gene_effects,effect_details')[source]
class dae.effect_annotation.cli.EffectAnnotatorBuilder(args)[source]

Bases: object

build_effect_annotator()[source]
get_gene_models() GeneModels[source]
get_genomic_context() GenomicContext[source]
get_grr() GenomicResourceRepo[source]
get_refernce_genome() ReferenceGenome[source]
static set_arguments(parser: ArgumentParser) None[source]
class dae.effect_annotation.cli.VariantColumnInputFile(args)[source]

Bases: object

close() None[source]
get_header() List[str][source]
get_lines() Iterator[Tuple[List[str], Dict[str, str]]][source]
static set_argument(parser: ArgumentParser)[source]
variant_columns = ['chrom', 'pos', 'location', 'variant', 'ref', 'alt']
class dae.effect_annotation.cli.VariantColumnOutputFile(args)[source]

Bases: object

close() None[source]
static set_argument(parser: ArgumentParser)[source]
write_columns(columns) None[source]
dae.effect_annotation.cli.cli_columns()[source]
dae.effect_annotation.cli.cli_vcf()[source]

dae.effect_annotation.effect module

Classes and helpers for variant annotation effects.

class dae.effect_annotation.effect.AlleleEffects(worst_effect: str, gene_effects: list[EffectGene], effect_transcripts: dict[str, EffectTranscript])[source]

Bases: object

Class for allele effect used in alleles.

classmethod from_effects(effects: list[AnnotationEffect]) AlleleEffects[source]

Build allele effects from list of annotation effect.

classmethod from_simplified_effects(effect_type: str, effect_genes: list[tuple[str, str]], transcripts: list[tuple[str, str]]) AlleleEffects | None[source]

Build allele effects from simplified effects.

static from_string(data: str | None) AlleleEffects | None[source]

Build allele effect from string.

property types: list[str]
property worst: str
class dae.effect_annotation.effect.AnnotationEffect(effect_name: str)[source]

Bases: object

Class to represent variant effect.

SEVERITY: ClassVar[dict[str, int]] = {"3'UTR": 11, "3'UTR-intron": 6, "5'UTR": 10, "5'UTR-intron": 7, 'CDS': 15, 'CNV+': 35, 'CNV-': 35, 'all': 24, 'coding_unknown': 13, 'frame-shift': 22, 'intergenic': 2, 'intron': 9, 'missense': 17, 'no-frame-shift': 16, 'no-frame-shift-newStop': 20, 'no-mutation': 1, 'noEnd': 18, 'noStart': 19, 'non-coding': 8, 'non-coding-intron': 4, 'nonsense': 21, 'promoter': 5, 'regulatory': 12, 'splice-site': 23, 'synonymous': 14, 'tRNA:ANTICODON': 30, 'unknown': 3}
create_effect_details() str[source]

Build effect details.

classmethod effect_severity(effect: AnnotationEffect) int[source]
classmethod effects_description(effects: list[AnnotationEffect]) tuple[str, str, str][source]

Build effects description.

Condider deprecating this.

classmethod gene_effects(effects: list[AnnotationEffect]) list[list[str]][source]

Build parallel lists of genes and effects in that genes.

Consider deprecating this.

classmethod lgd_gene_effects(effects: list[AnnotationEffect]) list[list[str]][source]

Filter and return a mapping of gene to effects by the LGD group.

classmethod simplify_effects(effects: list[AnnotationEffect]) tuple[str, list[tuple[str, str]], list[tuple[str, str | None, str | None, str]]][source]

Simplify effects.

Consider deprecating this.

classmethod sort_effects(effects: list[AnnotationEffect]) list[AnnotationEffect][source]
classmethod transcript_effects(effects: list[AnnotationEffect]) tuple[list[str], list[str | None], list[str | None], list[str]][source]

Build parallel lists of transcripts, genes, effects and details.

Consider deprecating this.

classmethod worst_effect(effects: list[AnnotationEffect]) str[source]
class dae.effect_annotation.effect.EffectFactory[source]

Bases: object

Factory class for build annotation effects.

classmethod create_effect(effect_name: str) AnnotationEffect[source]
classmethod create_effect_with_aa_change(effect_name: str, request: PositiveStrandAnnotationRequest | NegativeStrandAnnotationRequest) AnnotationEffect[source]

Create effect with amino acid change.

classmethod create_effect_with_prot_length(effect_name: str, request: PositiveStrandAnnotationRequest | NegativeStrandAnnotationRequest) AnnotationEffect[source]
classmethod create_effect_with_prot_pos(effect_name: str, request: PositiveStrandAnnotationRequest | NegativeStrandAnnotationRequest) AnnotationEffect[source]

Create effect with protein change position.

classmethod create_effect_with_request(effect_name: str, request: PositiveStrandAnnotationRequest | NegativeStrandAnnotationRequest) AnnotationEffect[source]

Create effect with annotation request.

classmethod create_effect_with_tm(effect_name: str, transcript_model: TranscriptModel) AnnotationEffect[source]

Create effect with transcript model.

classmethod create_intronic_effect(effect_type: str, request: PositiveStrandAnnotationRequest | NegativeStrandAnnotationRequest, start: int, end: int, index: int) AnnotationEffect[source]

Create intronic effect.

classmethod create_intronic_non_coding_effect(effect_type: str, request: PositiveStrandAnnotationRequest | NegativeStrandAnnotationRequest, start: int, end: int, index: int) AnnotationEffect[source]

Create intronic non coding effect.

class dae.effect_annotation.effect.EffectGene(symbol: str | None = None, effect: str | None = None)[source]

Bases: object

Combine gene and effect and that gene.

classmethod from_gene_effects(gene_effects: list[tuple[str, str]]) list[EffectGene][source]

Build effect gene objects from list of gene, effect tuples.

static from_string(data: str) EffectGene | None[source]

Deserialize effect gene.

classmethod from_tuple(gene_effect: tuple[str, str]) EffectGene[source]
class dae.effect_annotation.effect.EffectTranscript(transcript_id: str, gene: str | None = None, effect: str | None = None, details: str | None = None)[source]

Bases: object

Defines effect transcript.

classmethod from_effect_transcripts(effect_transcripts: list[tuple[str, str]]) dict[str, EffectTranscript][source]

Build effect transcripts.

static from_string(data: str) EffectTranscript | None[source]

Deserialize effect transcript/details.

classmethod from_tuple(transcript_tuple: tuple[str, str | None, str | None, str]) EffectTranscript[source]
class dae.effect_annotation.effect.EffectTypesMixin[source]

Bases: object

Helper function to work with variant effects.

EFFECT_GROUPS: ClassVar[dict[str, list[str]]] = {'CNV': ['CNV+', 'CNV-'], 'LGDs': ['frame-shift', 'nonsense', 'splice-site', 'no-frame-shift-newStop'], 'UTRs': ["3'UTR", "5'UTR", "3'UTR-intron", "5'UTR-intron"], 'coding': ['nonsense', 'frame-shift', 'splice-site', 'no-frame-shift-newStop', 'missense', 'no-frame-shift', 'noStart', 'noEnd', 'synonymous'], 'noncoding': ['non coding', 'intron', 'intergenic', "3'UTR", "5'UTR"], 'nonsynonymous': ['nonsense', 'frame-shift', 'splice-site', 'no-frame-shift-newStop', 'missense', 'no-frame-shift', 'noStart', 'noEnd']}
EFFECT_TYPES: ClassVar[list[str]] = ["3'UTR", "3'UTR-intron", "5'UTR", "5'UTR-intron", 'frame-shift', 'intergenic', 'intron', 'missense', 'no-frame-shift', 'no-frame-shift-newStop', 'noEnd', 'noStart', 'non-coding', 'non-coding-intron', 'nonsense', 'splice-site', 'synonymous', 'CDS', 'CNV+', 'CNV-']
EFFECT_TYPES_MAPPING: ClassVar[dict[str, list[str]]] = {"3'-UTR": ["3'UTR", "3'UTR-intron"], "5'-UTR": ["5'UTR", "5'UTR-intron"], 'CNV': ['CNV'], 'CNV+': ['CNV+'], 'CNV-': ['CNV-'], 'Frame-shift': ['frame-shift'], 'Intergenic': ['intergenic'], 'Intron': ['intron', 'non-coding-intron'], 'Missense': ['missense'], 'No-frame-shift': ['no-frame-shift'], 'No-frame-shift-newStop': ['no-frame-shift-newStop'], 'Non coding': ['non-coding'], 'Nonsense': ['nonsense'], 'Nonsynonymous': ['nonsynonymous'], 'Splice-site': ['splice-site'], 'Synonymous': ['synonymous'], 'noEnd': ['noEnd'], 'noStart': ['noStart']}
EFFECT_TYPES_UI_NAMING: ClassVar[dict[str, str]] = {'frame-shift': 'Frame-shift', 'intron': 'Intron', 'missense': 'Missense', 'no-frame-shift': 'No-frame-shift', 'no-frame-shift-newStop': 'No-frame-shift-newStop', 'non-coding': 'Non coding', 'non-coding-intron': 'Intron', 'nonsense': 'Nonsense', 'splice-site': 'Splice-site', 'synonymous': 'Synonymous'}
classmethod build_effect_types(effect_types: str | Iterable[str], *, safe: bool = True) list[str][source]

Build list of effect types.

classmethod build_effect_types_groups(effect_types: list[str]) list[str][source]

Expand effect groups into effect types.

classmethod build_effect_types_list(effect_types: list[str]) list[str][source]

Fix naming of effect types coming from the UI.

classmethod build_effect_types_naming(effect_types: str | Iterable[str], *, safe: bool = True) list[str][source]

Build list of effect types appropriate for the UI.

classmethod get_effect_types(*, safe: bool = True, **kwargs: Any) list[str] | None[source]

Process effect types from kwargs.

dae.effect_annotation.effect.expand_effect_types(effect_groups: str | Iterable[str] | Iterable[Iterable[str]]) list[str][source]

Expand effect type groups into list of effect types.

dae.effect_annotation.effect.gd2str(eff: AlleleEffects) str[source]
dae.effect_annotation.effect.ge2str(eff: AlleleEffects) str[source]
dae.effect_annotation.effect.gene_effect_get_genes(gene_effects: AlleleEffects | None) str[source]

Return comma separted list of genes.

dae.effect_annotation.effect.gene_effect_get_genes_worst(gene_effects: AlleleEffects | None) str[source]

Return comma separted list of genes.

dae.effect_annotation.effect.gene_effect_get_worst_effect(gene_effects: AlleleEffects | None) str[source]

dae.effect_annotation.gene_codes module

class dae.effect_annotation.gene_codes.NuclearCode[source]

Bases: object

Defines codon to amino acid translation codes.

CodonsAa = {'Ala': ['GCG', 'GCA', 'GCT', 'GCC'], 'Arg': ['AGG', 'AGA', 'CGG', 'CGA', 'CGT', 'CGC'], 'Asn': ['AAT', 'AAC'], 'Asp': ['GAT', 'GAC'], 'Cys': ['TGT', 'TGC'], 'End': ['TAG', 'TAA', 'TGA'], 'Gln': ['CAG', 'CAA'], 'Glu': ['GAG', 'GAA'], 'Gly': ['GGG', 'GGA', 'GGT', 'GGC'], 'His': ['CAT', 'CAC'], 'Ile': ['ATA', 'ATT', 'ATC'], 'Leu': ['TTG', 'TTA', 'CTG', 'CTA', 'CTT', 'CTC'], 'Lys': ['AAG', 'AAA'], 'Met': ['ATG'], 'Phe': ['TTT', 'TTC'], 'Pro': ['CCG', 'CCA', 'CCT', 'CCC'], 'Ser': ['AGT', 'AGC', 'TCG', 'TCA', 'TCT', 'TCC'], 'Thr': ['ACG', 'ACA', 'ACT', 'ACC'], 'Trp': ['TGG'], 'Tyr': ['TAT', 'TAC'], 'Val': ['GTG', 'GTA', 'GTT', 'GTC']}
CodonsAaKeys = ['Gly', 'Glu', 'Asp', 'Val', 'Ala', 'Arg', 'Ser', 'Lys', 'Asn', 'Met', 'Ile', 'Thr', 'Trp', 'End', 'Cys', 'Tyr', 'Leu', 'Phe', 'Gln', 'His', 'Pro']
startCodons = ['ATG']
stopCodons = ['TAG', 'TAA', 'TGA']

dae.effect_annotation.variant module

class dae.effect_annotation.variant.Variant(chrom=None, position=None, loc=None, var=None, ref=None, alt=None, length=None, seq=None, variant_type=None)[source]

Bases: object

Provides variant defintion used in effect annotator.

set_position(chromosome, position, loc)[source]

Set variant position.

set_ref_alt(var, ref, alt, _length, seq, _typ)[source]

Set variant reference and alternative.

set_ref_alt_from_variant(var)[source]

Set reference and alternative from CSHL variant.

trim_equal_ref_alt_parts()[source]

Trim reference and alternative.

Module contents