Genomics¶
The primary domain of IRIS. Models the complete lifecycle of genomic variant analysis: from raw variant calls through annotation and scoring to clinically classified variants ready for interpretation.
Entity Relationship Diagram¶
Overview¶
Central aggregate: VariantAnnotation¶
VariantAnnotation is the main output of the annotation pipeline. It holds
a core Variant together with everything derived from external sources:
- allele frequencies from one or more populations
- clinical classifications (ClinVar, ACMG, lab-specific)
- computational scores (CADD, pLI, LOEUF, splice, …)
- affected genes and per-transcript consequences
- ancestry annotations
- free-form
Metadatafor provenance
All collection fields default to empty tuples, so a partially annotated variant is valid at every stage of the pipeline. Annotations accumulate incrementally as each adapter enriches the object.
Entities¶
| Entity | Purpose |
|---|---|
Variant |
Core variant: type, CPRA/HGVS nomenclature, alleles, position |
VariantAnnotation |
Central aggregate — variant + all derived annotations |
Gene |
HGNC gene with optional chromosomal position |
GeneAnnotation |
Full gene knowledge: transcripts, scores, diseases, pathways |
Transcript |
Transcript structure: exons, UTRs, CDS intervals, MANE Select flag |
TranscriptVariant |
Variant effect on a specific transcript (SO terms, HGVS, codon change) |
Disease |
Genetic disease with MONDO/OMIM/Orphanet identifiers and HPO phenotypes |
ResolvedGeneRegion |
Output of resolve_gene_regions: gene + genomic regions + transcript used |
ResolvedGeneRegions |
Aggregate output: all resolved regions + unresolved symbols |
Value objects and enumerations (in objects.py)¶
Key value objects:
GenomicPosition— chromosome, start, end (1-based inclusive), strand. Supportsoverlaps(),contains(),distance_to().AlleleFrequency— allele frequency with population label, AC, AN, and homozygous count.ClinicalClassification— significance level (PATHOGENIC → BENIGN), source, and evidence rank.VariantScore— named computational score with type, value, tier, and metadata.GenotypingMetrics— call quality metrics (depth, call rate, dosage, phasing).VariantNomenclature— CPRA identifier and HGVS notations.GeneNomenclature— HGNC symbol set (backed byAliasSet) and cross-database IDs.GeneQuery— input specification forresolve_gene_regions: gene symbols, file path, transcript tag filter, inheritance mode filter, and disease name filter. Factory methods:from_file(),recessive(),dominant().
Key enumerations:
VariantType— SNV, MNV, INDEL, DUP, DEL, CNV, SV, VNTR, OTHER.ClinicalSignificance— 14 levels from PATHOGENIC to BENIGN withpathogenicity_rank.MendelianInheritance— composite flag (AD, AR, XLR, XLD, …) backed bySerializableFlag.Biotype— PROTEIN_CODING, NON_CODING, PSEUDOGENE, IMMUNE_RECEPTOR, TEC, OTHER.Zygosity— HOMOZYGOUS, HETEROZYGOUS, HEMIZYGOUS, UNKNOWN.CellOrigin— GERMLINE, SOMATIC, UNKNOWN.
Filters¶
filters.py defines composable boolean predicates for VariantAnnotation:
filt = AllOf(
MaxPopulationFrequency(0.01),
AnyOf(HasClinicalSignificance(PATHOGENIC), HighImpactConsequence()),
)
passing = [va for va in variants if filt(va)]
Boolean combinators (AllOf, AnyOf, Not) let you build arbitrarily complex
filter trees from simple leaf predicates. Every predicate is a callable that
accepts a VariantAnnotation and returns bool.
Domain services¶
Two domain services wrap pure logic and inject ports for operations that require external backends:
GenomicRangeService— pure range operations (overlap detection, sorting, normalization) plus delegated set operations via theRangeOperationsport (union, intersection, coverage, gap finding…).HpoService— ontology traversal and semantic similarity via theHpoOperationsport.
Ports (driven)¶
Ports are the domain's outward-facing contracts — abstract base classes that adapters implement. The domain never imports adapters directly.
| Port | Purpose |
|---|---|
VariantAnnotator |
Enrich a VariantAnnotation from an external source |
GeneAnnotator |
Enrich a GeneAnnotation from an external source |
RegionReader |
Read genomic intervals from a file or database |
RegionExporter |
Write genomic intervals to a file or stream |
GeneNomenclatureResolver |
Resolve symbols, aliases, and cross-database IDs |
RangeOperations |
Set-level operations on GenomicPosition collections |
HpoOperations |
HPO ontology traversal and semantic similarity |
GenotypeProcessor |
User-defined computation over a block of genotype data, called by ZarrVariantStore |
Coordinate convention¶
GenomicPosition uses 1-based inclusive coordinates throughout the domain.
Adapters are responsible for converting on input:
- BED files (0-based half-open) → converted in
BedRegionReader - pysam
.fetch()(0-based half-open) → add 1 to start before constructingGenomicPosition
Entities¶
iris.domain.genomics.entities
¶
Genomics domain entities: Disease, Gene, GeneAnnotation, Transcript, TranscriptStructure, TranscriptVariant, Variant, VariantAnnotation.
Disease
¶
A genetic disease with associated phenotypes, prevalence, and anatomical involvement.
nomenclature carries the canonical name and cross-database identifiers
(MONDO, OMIM, Orphanet). phenotypes lists the associated HPO terms.
prevalence may be a human-readable string (e.g. "1/10 000") or a
float, depending on the data source.
Gene
¶
A genomic gene with its nomenclature and chromosomal position.
Use from_symbol() for the common case of constructing from a bare
HGNC symbol. symbol and aliases are convenience properties that
delegate to the underlying GeneNomenclature.
from_symbol
classmethod
¶
Create a Gene using its symbol.
Transcript
¶
Lightweight transcript identity: nomenclature, biotype, and selection flags.
Carries only the information needed to identify a transcript and determine
its role (canonical, MANE Select). Structural data (exons, UTRs, CDS) lives
in :class:TranscriptStructure, which is held by :class:GeneAnnotation.
TranscriptStructure
¶
Full structural data for a transcript: position, exons, UTRs, and CDS.
Wraps a lightweight :class:Transcript with the genomic intervals needed
for positional annotation. Lives exclusively in :class:GeneAnnotation;
never embedded in :class:TranscriptVariant.
CDS intervals mirror GENCODE CDS features: one entry per coding exon.
Frame (0/½) is stored in GenomicPosition.markers[0] when available.
UTR type (5' vs 3') is encoded in GenomicPosition.name as "5UTR"
or "3UTR".
GeneAnnotation
¶
Full annotation for a gene including transcripts, scores, diseases, and pathways.
Aggregates all available knowledge about a gene: its canonical transcripts
(as :class:TranscriptStructure objects carrying full exon/CDS/UTR data),
dosage sensitivity assessments, associated diseases, pathway memberships,
expression data, and computational scores (e.g. pLI, LOEUF). All
collection fields default to empty tuples so partial annotations are valid.
primary_transcript
¶
Return the preferred transcript structure for this gene.
Selection priority: MANE Select > Ensembl canonical > first available.
Returns None if the gene has no annotated transcripts.
Example:
Source code in src/iris/domain/genomics/entities.py
TranscriptVariant
¶
The consequence of a variant on a specific transcript.
consequences is a tuple of Sequence Ontology terms (e.g.
"missense_variant") as returned by VEP or similar tools. HGVS
coding and protein notations, codon/amino-acid changes, and positional
fields (exon, intron, cDNA, CDS, protein) are populated when available.
Variant
¶
A genomic variant defined by its type, nomenclature, alleles, and position.
as_key
¶
Return (chrom, pos_1based, ref, alt) if all fields are present, else None.
Source code in src/iris/domain/genomics/entities.py
VariantAnnotation
¶
Full annotation for a variant including genes, frequencies, classifications, and scores.
Central aggregate of the genomics domain. Holds the core Variant
together with all data derived from external sources: allele frequencies
from one or more populations, clinical classifications (ClinVar, etc.),
computational scores (CADD, LoF, …), affected genes and transcript
consequences, ancestry annotations, and free-form metadata. All
collection fields default to empty tuples so partially annotated
variants are valid at every stage of the pipeline.
top_classification
property
¶
Return the classification with the highest pathogenicity rank, or None.
mane_consequence
property
¶
Return the TranscriptVariant for the MANE Select transcript, or None.
all_consequences
property
¶
Return all consequence terms across all transcripts, in order.
most_severe_consequence
property
¶
Return the most severe consequence term across all transcripts.
Severity follows the standard VEP/Ensembl SO ranking. Returns None if no transcripts are annotated.
is_pathogenic
property
¶
Return True if the top classification is Pathogenic or Likely Pathogenic.
af_for
¶
Return the AlleleFrequency for the given population label, or None.
score_for
¶
Return the first VariantScore with the given name, or None.
with_top_classification
¶
Return a copy retaining only the most pathogenic clinical classification.
A no-op when zero or one classifications are already present. Useful when normalising variants before serialisation or when downstream consumers expect at most one classification per variant (e.g. writing to a flat TSV or an Arrow schema with a single classification column).
The selection criterion is the same as :attr:top_classification:
the classification with the highest
:attr:~iris.domain.genomics.objects.ClinicalSignificance.pathogenicity_rank.
| RETURNS | DESCRIPTION |
|---|---|
VariantAnnotation
|
A new |
VariantAnnotation
|
|
VariantAnnotation
|
|
Example
Source code in src/iris/domain/genomics/entities.py
ResolvedGeneRegion
¶
A gene resolved to its genomic query regions, ready for variant extraction.
Produced by the resolve_gene_regions use case. Carries the full
GeneAnnotation alongside the actual regions that were used, so
downstream callers can inspect which transcript was chosen and why.
| ATTRIBUTE | DESCRIPTION |
|---|---|
gene |
Canonical Gene identity (nomenclature, Ensembl ID, position).
TYPE:
|
annotation |
Full GeneAnnotation from the repository — includes all
transcripts, diseases, scores, and metadata. Enables post-resolution
filtering (e.g.
TYPE:
|
regions |
Genomic positions to query for variants — typically the
exons of
TYPE:
|
transcript_used |
The TranscriptStructure whose exons were used as the base regions. None when the gene body was used as fallback.
TYPE:
|
resolution_method |
How the regions were derived:
TYPE:
|
ResolvedGeneRegions
¶
Aggregate output of the resolve_gene_regions use case.
Provides convenience methods to extract the flat list of regions or
the gene cache needed by downstream components like VepFlightAnnotator.
| ATTRIBUTE | DESCRIPTION |
|---|---|
resolved |
One
TYPE:
|
unresolved_symbols |
Gene symbols that could not be resolved to any annotation or genomic position. Callers should log or report these.
TYPE:
|
all_regions
¶
Return a flat list of all query regions across every resolved gene.
Suitable for passing directly to VariantExtractionPipeline.run().
Example:
Source code in src/iris/domain/genomics/entities.py
gene_cache
¶
Return a mapping of gene identifiers to Gene objects.
Seeds VepFlightAnnotator(gene_cache=...) so that VEP annotation
rows are matched to the same Gene instances used everywhere else in
the pipeline, preserving object identity across the full run.
Keys include the versioned Ensembl ID (e.g. "ENSG00000012048.23"),
the unversioned ID ("ENSG00000012048"), and the HGNC symbol
("BRCA1").
Source code in src/iris/domain/genomics/entities.py
Objects¶
iris.domain.genomics.objects
¶
Genomics domain value objects: enumerations, genomic positions, alleles, and nomenclatures.
Biotype
¶
Bases: Enum
Functional biotype classification of a gene or transcript.
CellOrigin
¶
Bases: Enum
Origin of the cell line from which a variant was detected.
ClinicalSignificance
¶
EvidenceRank
¶
Bases: IntEnum
Ordinal rank for the strength of evidence supporting a clinical assertion.
GeneDosageSensitivityType
¶
Bases: Enum
Type of gene dosage sensitivity.
GeneScoreType
¶
Bases: Enum
Category of a gene-level computational score.
GenotypingMetricType
¶
Bases: Enum
Type of genotyping quality metric recorded for a variant call.
InheritanceOrigin
¶
Bases: Enum
Inheritance origin of a variant in a proband.
MendelianInheritance
¶
Bases: SerializableFlag
A mode of inheritance of diseases traced back to variants in a single gene.
Supports composite modes via bitwise OR:
Example
is_x_linked
¶
Return True if any X-linked mode is active.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if XLR or XLD is set. |
is_recessive
¶
Return True if any recessive mode is active.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if AR or XLR is set. |
is_dominant
¶
Return True if any dominant mode is active.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if AD or XLD is set. |
to_list
¶
Return active primitive member names for Postgres TEXT[] storage.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Sorted list of primitive member names. |
Source code in src/iris/domain/generic/abstracts.py
to_str
¶
Return a pipe-separated string for VARCHAR storage.
| RETURNS | DESCRIPTION |
|---|---|
str
|
Pipe-separated primitive member names (e.g. 'AD|AR'). |
from_list
classmethod
¶
Reconstruct from a list of member names.
| PARAMETER | DESCRIPTION |
|---|---|
values
|
List of member names (e.g. ['AD', 'AR']).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SerializableFlag
|
Combined flag instance. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If any value is not a valid member name. |
Source code in src/iris/domain/generic/abstracts.py
from_str
classmethod
¶
Reconstruct from a pipe-separated string.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
Pipe-separated member names (e.g. 'AD|AR').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SerializableFlag
|
Combined flag instance. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If any part is not a valid member name. |
Source code in src/iris/domain/generic/abstracts.py
primitives
¶
Return active primitive (non-composite) members.
| RETURNS | DESCRIPTION |
|---|---|
list[Self]
|
List of primitive flag members. |
ScorePredictionRank
¶
Bases: IntEnum
Ordinal rank for the predicted effect tier of a computational score.
Strand
¶
Bases: Enum
Genomic strand orientation.
SuperPopulation
¶
Bases: Enum
Five-letter continental super-population codes used in population genetics databases.
VariantType
¶
Bases: Enum
Classification of a genetic variant by its structural type.
Covers the full spectrum from single-nucleotide changes to large structural rearrangements. Used throughout the domain to drive type-specific logic in filters, annotators, and exporters.
| ATTRIBUTE | DESCRIPTION |
|---|---|
SNV |
Single nucleotide variant — one base substituted for another
(e.g.
|
MNV |
Multi-nucleotide variant — two or more consecutive bases
substituted simultaneously (e.g.
|
INDEL |
Small insertion or deletion, typically under 50 bp. Includes pure insertions (ref shorter than alt), pure deletions (alt shorter than ref), and complex indels (both lengths differ and ref ≠ alt).
|
DUP |
Duplication — a segment of the genome is copied one or more
additional times. Represented in VCF as symbolic alleles such as
|
DEL |
Deletion — a segment of the genome is absent relative to the
reference. Represented as
|
CNV |
Copy number variation — gain or loss of a genomic segment without
specifying the precise breakpoints or mechanism. Broader than
:attr:
|
SV |
Structural variant — large-scale rearrangement (typically >50 bp) including inversions, translocations, and complex events not captured by the more specific types above.
|
VNTR |
Variable number tandem repeat — a locus where a short motif is repeated a variable number of times across individuals (e.g. microsatellites, minisatellites).
|
OTHER |
Catch-all for variant representations that do not fit any of the categories above (e.g. unknown symbolic alleles, malformed records).
|
Example
from_string
classmethod
¶
Parse a string into a VariantType, case-insensitive.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
String representation of the variant type. Matched against
member values after stripping whitespace and lowercasing
(e.g.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
VariantType
|
Matching VariantType member. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no member value matches the input string. |
Example
Source code in src/iris/domain/genomics/objects.py
from_alleles
classmethod
¶
Infer a VariantType from reference and alternate allele strings.
Applies rules in the following order:
- Symbolic ALT
<TOKEN>→ look up TOKEN in symbolic_map if provided; otherwise fall back to substring matching (DUP→ :attr:DUP,DEL→ :attr:DEL,CNV→ :attr:CNV); any other symbolic allele → :attr:SV. - Missing/spanning ALT (
"*"or"") → :attr:OTHER. len(ref) == 1andlen(alt) == 1→ :attr:SNV.len(ref) > 1andlen(alt) > 1and equal lengths → :attr:MNV.len(ref) != len(alt)→ :attr:INDEL.- Anything else → :attr:
OTHER.
| PARAMETER | DESCRIPTION |
|---|---|
ref
|
Reference allele string.
TYPE:
|
alt
|
Alternate allele string (may be symbolic, e.g.
TYPE:
|
symbolic_map
|
Optional mapping from symbolic ALT tokens (without
angle brackets) to :class:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Inferred
|
class:
TYPE:
|
Example
VariantType.from_alleles("A", "T")
# <VariantType.SNV: 'snv'>
VariantType.from_alleles("ATG", "A")
# <VariantType.INDEL: 'indel'>
VariantType.from_alleles("A", "<DUP>")
# <VariantType.DUP: 'duplication'>
VariantType.from_alleles("A", "<DUP>", symbolic_map={"DUP": VariantType.CNV})
# <VariantType.CNV: 'cnv'>
VariantType.from_alleles("A", "*")
# <VariantType.OTHER: 'other'>
Source code in src/iris/domain/genomics/objects.py
from_key
classmethod
¶
Infer a VariantType from a genomic key tuple (chrom, pos, ref, alt).
Delegates to :meth:from_alleles using ref and alt from the key.
Pass a symbolic_map via :meth:from_alleles directly when format-
specific symbolic allele mappings are needed (e.g. VCF readers).
| PARAMETER | DESCRIPTION |
|---|---|
key
|
Four-tuple
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
VariantType
|
Inferred VariantType. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If both ref and alt are empty strings. |
Example
Source code in src/iris/domain/genomics/objects.py
VariantScoreType
¶
Bases: Enum
Category of a variant-level computational score.
Zygosity
¶
Bases: Enum
Zygosity state of a variant in a specific sample.
| ATTRIBUTE | DESCRIPTION |
|---|---|
REF |
Homozygous reference — no alternate allele called.
|
HET |
Heterozygous — one reference and one alternate allele.
|
COM |
Compound heterozygous — two different alternate alleles on different haplotypes. Assigned by domain logic, not inferred from a single genotype call.
|
HOM |
Homozygous alternate — both alleles are the same alternate.
|
HEM |
Hemizygous — single allele (e.g. X-linked in males).
|
NUL |
Nullizygous — no copies of the locus present. Assigned by domain logic.
|
UNKNOWN |
Zygosity could not be determined.
|
from_gt
classmethod
¶
Infer zygosity from a genotype tuple of allele indices.
Handles pysam-style tuples (None for missing) and vcf2zarr-style
tuples (-1 for missing, -2 for polyploid fill). Returns
None when the genotype is unresolvable rather than guessing.
| PARAMETER | DESCRIPTION |
|---|---|
gt
|
Tuple of integer allele indices as returned by pysam
(
TYPE:
|
alt_idx
|
1-based index of the alternate allele to evaluate.
Defaults to
TYPE:
|
allow_negative
|
If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Zygosity | None
|
Inferred |
Zygosity | None
|
partially called, or unresolvable. |
Example
Source code in src/iris/domain/genomics/objects.py
from_string
classmethod
¶
Parse a zygosity string from any external source.
Recognizes VCF-style genotype strings ("0/1", "1|1"),
abbreviated labels ("HET", "HOM", "HEM"), full names
("heterozygous"): common software conventions.
Matching is case-insensitive and strips surrounding whitespace.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
Zygosity string from an external source.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Zygosity | None
|
Matching |
Example
Source code in src/iris/domain/genomics/objects.py
PositionRelation
¶
Bases: Enum
Spatial relationship between two GenomicPosition objects on the same assembly.
Allele
¶
Reference and alternate alleles with optional zygosity and inheritance origin.
alternate is a tuple to support multiallelic sites; single-alt
variants have a one-element tuple. zygosity and origin are
optional and populated when genotype information is available (e.g.
from a VCF with sample columns).
is_reference
property
¶
Return True if this allele represents the reference state (no alternate alleles).
genotype
¶
Return a string representation of the genotype.
For numeric notation, the separator is '|' when origin is known and phased (maternal or paternal), '/' otherwise. Maternal variants place the alternate allele on the left (maternal haplotype first): '1|0'. Paternal variants place it on the right: '0|1'.
For nucleotide notation, only SNVs are supported (single-base ref and alt). HOM returns the alternate repeated (e.g. 'TT'). HET returns ref+alt or alt+ref depending on origin.
| PARAMETER | DESCRIPTION |
|---|---|
as_nucleotides
|
If True, returns allele sequences (e.g. 'AT', 'TA'). Restricted to SNVs — raises ValueError for indels or multiallelic variants.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Genotype string. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If as_nucleotides=True and the allele is not a SNV.exit |
Example
# HET, nucleotides
Allele(reference="A", alternate=("T",), zygosity=Zygosity.HET).genotype(as_nucleotides=True) # snv only
# 'AT'
# HET, paternal --> alternate on right
Allele(reference="A", alternate=("T",), zygosity=Zygosity.HET, origin=InheritanceOrigin.PATERNAL).genotype()
# '0|1'
# HET, maternal --> alternate on left
Allele(reference="A", alternate=("T",), zygosity=Zygosity.HET, origin=InheritanceOrigin.MATERNAL).genotype()
# '1|0'
# HET, paternal, nucleotides
Allele(reference="A", alternate=("T",), zygosity=Zygosity.HET, origin=InheritanceOrigin.PATERNAL).genotype(
as_nucleotides=True
)
# 'AT'
# HET, maternal, nucleotides --> alt on left
Allele(reference="A", alternate=("T",), zygosity=Zygosity.HET, origin=InheritanceOrigin.MATERNAL).genotype(
as_nucleotides=True
)
# 'TA'
Source code in src/iris/domain/genomics/objects.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | |
AlleleFrequency
¶
GenotypeCount
¶
Raw genotype counts for one ALT allele across a sample cohort.
Counts assume diploid samples. Hemizygous loci (e.g. chrX in males) are not modelled separately: each called allele contributes to AN regardless of ploidy.
All derived statistics (AF, AN, AC, missingness) are computed properties so that downstream analyses only need to store this one object.
to_allele_frequency
¶
Convert to an AlleleFrequency domain object for use in VariantAnnotation.
Source code in src/iris/domain/genomics/objects.py
AncestryGroup
¶
Population and super-population labels for an ancestry group.
Both fields are optional to allow partial labelling (e.g. only a
super_population is known). Used as the grouping key inside
AncestryAnnotation.
AncestryAnnotation
¶
Variant annotation values for a specific ancestry group.
Aggregates the ancestry-level scores that accompany a variant in
population-scale resources (e.g. MCPS ancestry strata). Any numeric
field may be None when the resource does not report that metric
for the given group.
ChromosomeSet
¶
An ordered set of chromosome names with optional length map.
aliases is an AliasSet that stores canonical chromosome names
(e.g. "1", "X") and any alternative forms ("chr1").
lengths maps canonical names to base-pair sizes; construction
raises ValueError if a length key is not a recognized name.
resolve
¶
length_of
¶
normalize
classmethod
¶
Return the canonical chromosome name: strip 'chr' prefix, uppercase, M → MT.
This is a generic normalization independent of any particular ChromosomeSet instance — it does not consult aliases or lengths, only applies the standard UCSC-to-bare-name transformation.
| PARAMETER | DESCRIPTION |
|---|---|
chromosome
|
Raw chromosome name (e.g. 'chr1', 'chrX', 'chrM', '1').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Normalized chromosome name (e.g. '1', 'X', 'MT'). |
Source code in src/iris/domain/genomics/objects.py
ClinicalClassification
¶
Represents a clinical classification for a genetic variant.
Stores the ACMG/AMP significance tier (classification), optional
strength of evidence (evidence), supporting literature references,
and the originating database (source, e.g. "clinvar"). Multiple
classifications may be attached to a VariantAnnotation; use
top_classification to retrieve the most pathogenic one.
DiseaseNomenclature
¶
Canonical identifiers and aliases for a genetic disease.
names holds the primary display name and any synonyms via
AliasSet. Cross-references to MONDO, OMIM, and Orphanet are
stored as optional string identifiers and may be None when the
mapping is unavailable.
from_name
classmethod
¶
from_name(
name,
*,
normalize_function=None,
extra_ids=None,
mondo_id=None,
omim_id=None,
orphanet_id=None,
mesh_id=None,
icd10_id=None,
add_ids_as_aliases=True,
)
Build a DiseaseNomenclature from a primary name and optional database identifiers.
Source code in src/iris/domain/genomics/objects.py
GeneDosageSensitivity
¶
Dosage sensitivity assessment for a gene with evidence rank.
GeneFunction
¶
A functional description of a gene with supporting references.
GeneNomenclature
¶
Canonical symbol and cross-database identifiers for a gene.
symbols is an AliasSet whose primary entry is the HGNC-approved
symbol; alternative names and synonyms are stored as aliases. Ensembl,
HGNC, and RefSeq identifiers are optional and can be added via
from_symbol() with add_ids_as_aliases=True to make them
resolvable through the alias map.
from_symbol
classmethod
¶
from_symbol(
symbol,
*,
normalize_function=None,
extra_aliases=None,
ensembl_id=None,
hgnc_id=None,
refseq_id=None,
add_ids_as_aliases=True,
)
Build a GeneNomenclature from a primary symbol and optional database identifiers.
Source code in src/iris/domain/genomics/objects.py
from_list
classmethod
¶
Build multiple GeneNomenclature instances from a delimited string or iterable.
| PARAMETER | DESCRIPTION |
|---|---|
symbols
|
Either a delimited string (e.g. 'BRCA1, TP53, EGFR') or any iterable of symbol strings.
TYPE:
|
sep
|
Delimiter used to split the string. Ignored if symbols is already an iterable of strings. Defaults to ', '.
TYPE:
|
normalize_function
|
Optional normalization applied to each symbol before building the AliasSet. Passed through to from_symbol.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[GeneNomenclature, ...]
|
Tuple of GeneNomenclature instances, one per symbol, in input order. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If any symbol is empty after stripping. |
Example
Source code in src/iris/domain/genomics/objects.py
GeneScore
¶
A named computational score for a gene with an optional prediction tier.
GenomicPosition
¶
A genomic locus using 1-based inclusive coordinates on a named chromosome.
Both start and end are 1-based and inclusive (as in VCF and GFF).
Point variants have start == end; interval regions have
start < end. Consumers reading BED or pysam (0-based half-open)
must convert before constructing this object. The optional name
field carries a gene symbol or region label when the position was read
from a BED file.
coordinates_as_string
property
¶
Return a string representation of the genomic coordinates.
coordinates_as_tuple
property
¶
Return a tuple representation of the genomic coordinates.
from_cytoband
classmethod
¶
Parse cytoband-like strings such as '7q31.2', 'Xp22.31', or 'chr17p13.1'.
Coordinates are not inferred; the cytoband is stored as name.
Source code in src/iris/domain/genomics/objects.py
from_region
classmethod
¶
Parse region strings such as 'chr1:100-200', '1:100', or 'X:1,000-2,000'.
Source code in src/iris/domain/genomics/objects.py
from_bed
classmethod
¶
Build a GenomicPosition from 0-based half-open BED coordinates [start0, end0).
Source code in src/iris/domain/genomics/objects.py
from_tuple
classmethod
¶
Build a GenomicPosition from a 2- or 3-tuple of (chrom, start) or (chrom, start, end).
Coordinates are assumed 1-based inclusive.
Source code in src/iris/domain/genomics/objects.py
from_mapping
classmethod
¶
Build a GenomicPosition from a dict-like record with flexible key aliases.
Accepted aliases: chromosome: chromosome, chrom, chr, contig start: start, pos, position end: end, stop
Source code in src/iris/domain/genomics/objects.py
chromosome_only
classmethod
¶
Build a GenomicPosition referencing an entire chromosome with no start or end.
Source code in src/iris/domain/genomics/objects.py
overlaps
¶
Return True if this position overlaps with another.
A chromosome-level position (no start) is treated as spanning the whole chromosome. A point position (start only, no end) occupies a single base.
Source code in src/iris/domain/genomics/objects.py
contains
¶
Return True if this position fully contains another.
A chromosome-level position (no start) contains everything on that chromosome. No interval can contain a chromosome-level position.
Source code in src/iris/domain/genomics/objects.py
distance_to
¶
Return the distance in base pairs to another position, or None if not comparable.
Source code in src/iris/domain/genomics/objects.py
is_contained_in
¶
locate
¶
Return the spatial relationship of this position relative to another.
Source code in src/iris/domain/genomics/objects.py
GenotypingMetrics
¶
A named genotyping quality metric with an optional numeric value.
Phenotype
¶
A clinical phenotype with an optional HPO identifier.
TranscriptNomenclature
¶
Canonical name and cross-database identifiers for a transcript.
names is an AliasSet whose primary entry is the preferred
transcript identifier (e.g. an Ensembl or RefSeq accession). CCDS,
Ensembl, RefSeq, and UniProt identifiers are optional; the optional
gene back-reference links the transcript to its parent
GeneNomenclature.
from_name
classmethod
¶
from_name(
name,
*,
normalize_function=None,
extra_names=None,
ccds_id=None,
ensembl_id=None,
refseq_id=None,
uniprot_id=None,
gene=None,
add_ids_as_aliases=True,
)
Build a TranscriptNomenclature from a primary name and optional database identifiers.
Source code in src/iris/domain/genomics/objects.py
VariantNomenclature
¶
Canonical identifier and cross-database references for a variant.
The primary identifier (vid) follows the CPRA format
chrom:pos:ref:alt. ids is an AliasSet that also stores
dbSNP rs-IDs, ClinVar accessions, COSMIC identifiers, and HGVS genomic
notation when available. Use from_key() to construct from a raw
(chrom, pos, ref, alt) tuple.
from_key
classmethod
¶
from_key(
key,
*,
normalize_function=None,
extra_ids=None,
dbsnp_id=None,
clinvar_id=None,
cosmic_id=None,
hgvs_genomic=None,
add_ids_as_aliases=True,
)
Build a VariantNomenclature from genomic coordinates and optional database IDs.
Source code in src/iris/domain/genomics/objects.py
resolve
¶
VariantScore
¶
A named computational score for a variant with an optional prediction tier.
GeneEnrichment
¶
Statistical enrichment of a gene given a phenotype set.
Produced by a :class:~iris.domain.genomics.ports.driven.enrichment.PhenotypeEnrichmentModel
from a patient's HPO profile. p_value is the result of the statistical
test (hypergeometric by default); fold is the fold enrichment; count
is the number of overlapping annotated HPO terms supporting the gene.
is_significant
¶
Return True if the p-value is strictly below alpha.
| PARAMETER | DESCRIPTION |
|---|---|
alpha
|
Significance threshold. Defaults to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if |
Source code in src/iris/domain/genomics/objects.py
DiseaseEnrichment
¶
Statistical enrichment of an OMIM disease given a phenotype set.
Produced by a :class:~iris.domain.genomics.ports.driven.enrichment.PhenotypeEnrichmentModel
from a patient's HPO profile. p_value is the result of the statistical
test (hypergeometric by default); fold is the fold enrichment; count
is the number of overlapping annotated HPO terms supporting the disease.
is_significant
¶
Return True if the p-value is strictly below alpha.
| PARAMETER | DESCRIPTION |
|---|---|
alpha
|
Significance threshold. Defaults to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if |
Source code in src/iris/domain/genomics/objects.py
GeneQuery
¶
Specification of which genes to resolve, expressed in domain terms.
A GeneQuery lets callers express their intent in biological language
without tying the use case to a specific backend (file, database, API).
The resolve_gene_regions use case interprets the query and delegates
to the appropriate repository methods.
| ATTRIBUTE | DESCRIPTION |
|---|---|
symbols |
Explicit gene symbols to resolve (e.g.
TYPE:
|
symbols_file |
Path to a plain-text file with one gene symbol per line.
Lines starting with
TYPE:
|
transcript_tags |
Tags that the chosen transcript must carry in the
annotation source (e.g.
TYPE:
|
inheritance_modes |
Post-load filter — only include genes whose
TYPE:
|
disease_names |
Post-load filter — only include genes with at least one disease whose name or identifier matches any of these strings (case-insensitive substring match). Applied after loading.
TYPE:
|
Example:
# By explicit symbols:
GeneQuery(symbols=("BRCA1", "CFTR", "HEXA"))
# From a text file — one symbol per line:
GeneQuery.from_file(Path("recgenes.txt"))
# All autosomal recessive genes in the annotation:
GeneQuery.recessive()
# AR genes from a curated file:
GeneQuery.recessive(symbols_file=Path("panel.txt"))
from_file
classmethod
¶
Build a GeneQuery reading gene symbols from a text file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Plain-text file with one HGNC symbol per line.
Lines starting with
TYPE:
|
**kwargs
|
Additional keyword arguments forwarded to the constructor
(e.g.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
'GeneQuery'
|
GeneQuery with |
'GeneQuery'
|
|
Example:
Source code in src/iris/domain/genomics/objects.py
recessive
classmethod
¶
Build a GeneQuery filtering to autosomal recessive genes.
Post-load filter: only genes with at least one disease associated
with MendelianInheritance.AR will be included in the result.
| PARAMETER | DESCRIPTION |
|---|---|
**kwargs
|
Additional keyword arguments forwarded to the constructor
(e.g.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
'GeneQuery'
|
GeneQuery with |
Example:
# All AR genes in GENCODE:
GeneQuery.recessive()
# AR genes from a curated list:
GeneQuery.recessive(symbols_file=Path("panel.txt"))
Source code in src/iris/domain/genomics/objects.py
dominant
classmethod
¶
Build a GeneQuery filtering to autosomal dominant genes.
Post-load filter: only genes with at least one disease associated
with MendelianInheritance.AD will be included in the result.
| PARAMETER | DESCRIPTION |
|---|---|
**kwargs
|
Additional keyword arguments forwarded to the constructor.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
'GeneQuery'
|
GeneQuery with |
Source code in src/iris/domain/genomics/objects.py
Repositories¶
iris.domain.genomics.repositories
¶
Repository interfaces for the genomics domain.
GeneRepository
¶
Bases: Repository[Gene]
Read-only repository for Gene and GeneAnnotation entities.
TranscriptRepository
¶
Bases: Repository[TranscriptStructure]
Read-only repository for TranscriptStructure entities.
VariantRepository
¶
Bases: Repository[Variant]
Read-only repository for Variant and VariantAnnotation entities.
DiseaseRepository
¶
Bases: Repository[Disease]
Read-only repository for Disease entities.
Filters¶
iris.domain.genomics.filters
¶
Composable variant filters for genomic analysis pipelines.
VariantFilter
¶
Bases: ABC
Abstract base class for all variant filters.
AllOf
¶
Bases: VariantFilter
A composite filter that passes only when all constituent filters pass.
matches
¶
AnyOf
¶
Bases: VariantFilter
A composite filter that passes when at least one constituent filter passes.
matches
¶
Not
¶
MaxPopulationFrequency
¶
Bases: VariantFilter
Passes when the allele frequency is below max_af.
Variants absent from the database pass by default (absent_passes=True), since absence implies the variant is novel or ultra-rare.
matches
¶
Return True if the variant's population frequency is below max_af.
Source code in src/iris/domain/genomics/filters.py
HasClinicalSignificance
¶
Bases: VariantFilter
Passes when at least one classification matches the given set.
matches
¶
Return True if any classification matches the target significance set.
NoClinVar
¶
Bases: VariantFilter
Passes when the variant has no classification.
WithinRegion
¶
Bases: VariantFilter
Passes when the variant position overlaps the given genomic region.
Uses 1-based inclusive coordinates (same as GenomicPosition internally). If the region has no start/end, matches any variant on the same chromosome.
matches
¶
Return True if the variant overlaps the target genomic region.
Source code in src/iris/domain/genomics/filters.py
HighImpactConsequence
¶
Bases: VariantFilter
Passes when the most severe consequence belongs to the given set.
Defaults to HIGH_IMPACT_CONSEQUENCES (frameshift, stop, splice, etc.).
matches
¶
Return True if any transcript consequence belongs to the high-impact set.
all_of
¶
any_of
¶
apply
¶
Return the subset of variants that match the given filter.
Services¶
iris.domain.genomics.services
¶
Domain services for genomic operations.
Two services are provided:
- :class:
GenomicRangeService— pure domain logic and delegated backend operations for collections of :class:~iris.domain.genomics.objects.GenomicPosition. - :class:
HpoService— pure domain logic and delegated HPO operations for collections of :class:~iris.domain.genomics.objects.Phenotype.
Pure operations are implemented directly; complex or ontology-aware operations are delegated to an injected port.
GenomicRangeService
¶
Domain service for genomic range computations.
Separates pure domain logic from backend-specific operations. Pure methods operate directly on GenomicPosition objects using only the domain model. Complex methods delegate to the injected RangeOperations port.
| PARAMETER | DESCRIPTION |
|---|---|
ops
|
Concrete implementation of the RangeOperations port.
TYPE:
|
Example
Source code in src/iris/domain/genomics/services.py
overlapping
¶
Find all overlapping pairs between query and subject ranges.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
Query ranges.
TYPE:
|
subject
|
Subject ranges to test against.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[tuple[int, int]]
|
List of (query_index, subject_index) pairs where the ranges overlap. |
Source code in src/iris/domain/genomics/services.py
filter_overlapping
¶
Return query ranges that overlap at least one subject range.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
Ranges to filter.
TYPE:
|
subject
|
Ranges to test overlap against.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Subset of query ranges that overlap any range in subject. |
Source code in src/iris/domain/genomics/services.py
filter_by_chromosome
¶
Return ranges on a specific chromosome.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
chromosome
|
Chromosome name (normalized, e.g. '1', 'X', 'MT').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Ranges whose chromosome matches the given name. |
Source code in src/iris/domain/genomics/services.py
sort
¶
Sort ranges by chromosome, start, and end.
Chromosome order follows natural sort (1, 2, ..., 10, X, Y, MT).
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Sorted list of genomic ranges. |
Source code in src/iris/domain/genomics/services.py
merge_adjacent
¶
Merge overlapping or adjacent ranges on the same chromosome.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges. Need not be sorted.
TYPE:
|
max_gap
|
Maximum gap in bases between ranges to still merge. Default 0 merges only overlapping or book-ended ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Merged ranges sorted by chromosome and start position. |
Source code in src/iris/domain/genomics/services.py
total_length
¶
Compute total base pairs covered by all ranges (with overlaps counted once).
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Total number of unique base positions covered. |
Source code in src/iris/domain/genomics/services.py
by_chromosome
¶
Group ranges by chromosome.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, list[GenomicPosition]]
|
Dict mapping chromosome name to list of ranges on that chromosome. |
Source code in src/iris/domain/genomics/services.py
union
¶
Return the union of two sets of genomic ranges.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
First set of genomic ranges.
TYPE:
|
b
|
Second set of genomic ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Merged, non-overlapping ranges covering all positions in a or b. |
Source code in src/iris/domain/genomics/services.py
intersect
¶
Return ranges present in both a and b.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
First set of genomic ranges.
TYPE:
|
b
|
Second set of genomic ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Ranges representing the intersection of a and b. |
Source code in src/iris/domain/genomics/services.py
setdiff
¶
Return ranges in a not covered by b.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
Query ranges.
TYPE:
|
b
|
Ranges to subtract from a.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Ranges in a not overlapping any range in b. |
Source code in src/iris/domain/genomics/services.py
coverage
¶
Compute per-base coverage across all ranges.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Genomic ranges to compute coverage for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, list[int]]
|
Dict mapping chromosome name to a list of per-base coverage values. |
Source code in src/iris/domain/genomics/services.py
gaps
¶
Return gaps between ranges on each chromosome.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
genome
|
Optional chromosome lengths for boundary gaps.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Ranges representing uncovered regions. |
Source code in src/iris/domain/genomics/services.py
disjoin
¶
Split ranges into non-overlapping disjoint intervals.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges, possibly overlapping.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Maximal set of non-overlapping ranges. |
Source code in src/iris/domain/genomics/services.py
nearest
¶
Find the nearest subject range for each query range.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
Ranges to search for neighbors.
TYPE:
|
subject
|
Ranges to search within.
TYPE:
|
ignore_strand
|
If False, only consider same-strand ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int | None]
|
List of indices into subject. None if no neighbor found. |
Source code in src/iris/domain/genomics/services.py
precede
¶
Find the subject range immediately upstream of each query range.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
Ranges to search for upstream neighbors.
TYPE:
|
subject
|
Ranges to search within.
TYPE:
|
ignore_strand
|
If False, only consider same-strand ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int | None]
|
List of indices into subject. None if no upstream range found. |
Source code in src/iris/domain/genomics/services.py
follow
¶
Find the subject range immediately downstream of each query range.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
Ranges to search for downstream neighbors.
TYPE:
|
subject
|
Ranges to search within.
TYPE:
|
ignore_strand
|
If False, only consider same-strand ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int | None]
|
List of indices into subject. None if no downstream range found. |
Source code in src/iris/domain/genomics/services.py
flank
¶
Return flanking regions for each input range.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
width
|
Width of the flanking region in bases.
TYPE:
|
start
|
If True, flank the start; if False, flank the end.
TYPE:
|
both
|
If True, return flanks on both sides.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Flanking ranges. |
Source code in src/iris/domain/genomics/services.py
resize
¶
Resize ranges to a fixed width anchored at start, end, or center.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
width
|
Target width in bases.
TYPE:
|
fix
|
Anchor point — one of 'start', 'end', or 'center'.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Resized ranges. |
Source code in src/iris/domain/genomics/services.py
shift
¶
Shift all ranges by a fixed number of bases.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
shift
|
Bases to shift. Positive = downstream, negative = upstream.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Shifted ranges. |
Source code in src/iris/domain/genomics/services.py
HpoService
¶
Domain service for Human Phenotype Ontology operations.
Separates pure domain logic from backend-specific operations.
Pure methods operate directly on :class:~iris.domain.genomics.objects.Phenotype
objects without any external dependencies. Ontology-aware methods
delegate to the injected :class:~iris.domain.genomics.ports.driven.hpo_ops.HpoOperations
port.
| PARAMETER | DESCRIPTION |
|---|---|
ops
|
Concrete implementation of the HpoOperations port.
TYPE:
|
Example
Source code in src/iris/domain/genomics/services.py
with_id
¶
Return only phenotypes that carry an HPO identifier.
| PARAMETER | DESCRIPTION |
|---|---|
phenotypes
|
Input phenotypes, mixed with and without IDs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
Subset of phenotypes where |
Source code in src/iris/domain/genomics/services.py
without_id
¶
Return only phenotypes that lack an HPO identifier.
Useful for identifying phenotypes that still need to be mapped to an HPO term.
| PARAMETER | DESCRIPTION |
|---|---|
phenotypes
|
Input phenotypes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
Subset of phenotypes where |
Source code in src/iris/domain/genomics/services.py
by_id
¶
Index phenotypes by their HPO identifier.
Phenotypes without an hpo_id are silently excluded.
| PARAMETER | DESCRIPTION |
|---|---|
phenotypes
|
Input phenotypes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Phenotype]
|
Dict mapping |
dict[str, Phenotype]
|
When duplicates exist, the last occurrence wins. |
Source code in src/iris/domain/genomics/services.py
search
¶
Search HPO terms by name or synonym.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
Free-text query matched against term names and synonyms.
TYPE:
|
limit
|
Maximum number of results to return. Defaults to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
Matching phenotypes ordered by relevance, up to |
Source code in src/iris/domain/genomics/services.py
get
¶
Retrieve a single HPO term by its identifier.
| PARAMETER | DESCRIPTION |
|---|---|
hpo_id
|
HPO term identifier in
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Phenotype | None
|
The corresponding |
Source code in src/iris/domain/genomics/services.py
parents
¶
Return the direct parent terms of a phenotype.
| PARAMETER | DESCRIPTION |
|---|---|
phenotype
|
Source phenotype. Must be resolvable to an HPO term.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
Direct parent phenotypes (one level up in the hierarchy). |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/services.py
children
¶
Return the direct child terms of a phenotype.
| PARAMETER | DESCRIPTION |
|---|---|
phenotype
|
Source phenotype. Must be resolvable to an HPO term.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
Direct child phenotypes (one level down in the hierarchy). |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/services.py
ancestors
¶
Return all ancestor terms up to the ontology root.
| PARAMETER | DESCRIPTION |
|---|---|
phenotype
|
Source phenotype. Must be resolvable to an HPO term.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
All ancestor phenotypes, from closest parent to root. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/services.py
descendants
¶
Return all descendant terms below the given phenotype.
| PARAMETER | DESCRIPTION |
|---|---|
phenotype
|
Source phenotype. Must be resolvable to an HPO term.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
All descendant phenotypes reachable via child relationships. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/services.py
similarity
¶
Compute semantic similarity between two HPO terms.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
First phenotype.
TYPE:
|
b
|
Second phenotype.
TYPE:
|
kind
|
IC flavour — one of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
Similarity score in |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If either phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/services.py
set_similarity
¶
Compute semantic similarity between two sets of HPO terms.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
First phenotype set.
TYPE:
|
b
|
Second phenotype set.
TYPE:
|
kind
|
IC flavour — one of
TYPE:
|
combine
|
Aggregation strategy — one of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
Similarity score in |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If any phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/services.py
common_ancestors
¶
Return the common ancestors of two HPO terms.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
First phenotype.
TYPE:
|
b
|
Second phenotype.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
Phenotypes that are ancestors of both |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If either phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/services.py
Events¶
iris.domain.genomics.events
¶
Domain events for the genomics bounded context.
VariantAnnotated
¶
Emitted when a variant is successfully annotated.
VariantClassified
¶
Emitted when a variant receives a clinical significance classification.
GeneAnnotated
¶
Emitted when a gene is successfully annotated.
DiseaseAssociationRecorded
¶
Emitted when a gene-disease association is recorded.
Exceptions¶
iris.domain.genomics.exceptions
¶
Exceptions for the genomics domain.
GenomicsError
¶
Bases: Exception
Base exception for the genomics domain.
VariantNotFoundError
¶
Bases: GenomicsError
Raised when a variant cannot be found by the given identifier.
GeneNotFoundError
¶
Bases: GenomicsError
Raised when a gene cannot be found by the given identifier.
TranscriptNotFoundError
¶
Bases: GenomicsError
Raised when a transcript cannot be found by the given identifier.
DiseaseNotFoundError
¶
Bases: GenomicsError
Raised when a disease cannot be found by the given identifier.
InvalidGenomicPositionError
¶
Bases: GenomicsError
Raised when a genomic coordinate is malformed or out of range.
InvalidAlleleError
¶
Bases: GenomicsError
Raised when an allele string does not match the expected format.
AnnotationError
¶
Bases: GenomicsError
Raised when an annotation pipeline fails to produce a result.
AmbiguousIdentifierError
¶
Bases: GenomicsError
Raised when an identifier matches more than one entity.
Utils¶
iris.domain.genomics.utils
¶
Pure utility functions for the genomics domain.
These functions are stateless helpers used across the domain and adapters. They live here rather than in objects.py to keep that module focused on data modeling, and rather than in services.py to avoid conflating pure utilities with stateful domain services.
HUMAN_CHROMOSOMES
module-attribute
¶
HUMAN_CHROMOSOMES = ChromosomeSet(
aliases=AliasSet(
names=_HUMAN_CHROMOSOME_NAMES,
aliases=_human_chromosome_aliases(),
)
)
Canonical ChromosomeSet for the human genome (autosomes 1-22, X, Y, MT).
Built once at import time. Use resolve_human_chromosome() rather than HUMAN_CHROMOSOMES.resolve() directly when the input may carry an NCBI RefSeq version suffix (e.g. 'NC_000001.11') — the wrapper strips it first.
normalize_chromosome
¶
Return the canonical chromosome name: strip 'chr' prefix, uppercase, M → MT.
Thin wrapper around ChromosomeSet.normalize() kept for backwards compatibility with existing adapter imports.
| PARAMETER | DESCRIPTION |
|---|---|
chromosome
|
Raw chromosome name (e.g. 'chr1', 'chrX', 'chrM', '1').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Normalized chromosome name (e.g. '1', 'X', 'MT'). |
Source code in src/iris/domain/genomics/utils.py
resolve_chromosome
¶
Return the contig name as it appears in an index, or None if absent.
Tries the bare name first, then toggles the 'chr' prefix so that files indexed as 'chrX' work with bare names ('X') and vice-versa.
| PARAMETER | DESCRIPTION |
|---|---|
chrom
|
Normalized chromosome name (e.g. '1', 'X', 'MT').
TYPE:
|
contigs
|
Frozenset of contig names as they appear in the index.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
Matching contig name from the index, or None if not found. |
Source code in src/iris/domain/genomics/utils.py
chromosome_sort_key
¶
Return a sort key that orders chromosomes numerically then lexicographically.
Numeric chromosomes (1–22) sort before X, Y, MT, and any other names.
| PARAMETER | DESCRIPTION |
|---|---|
chrom
|
Normalized chromosome name (e.g. '1', 'X', 'MT').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, str]
|
Tuple of (numeric_order, name) for use as a sort key. |
Source code in src/iris/domain/genomics/utils.py
batched
¶
Yield ordered non-overlapping chunks from a sequence.
| PARAMETER | DESCRIPTION |
|---|---|
items
|
Input sequence.
TYPE:
|
size
|
Maximum chunk size.
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
Iterable[Sequence[_KT]]
|
Sequence slices preserving input order. |
Source code in src/iris/domain/genomics/utils.py
group_positions_by_chromosome_sorted
¶
Group positions by chromosome with chromosome-sort order.
Source code in src/iris/domain/genomics/utils.py
group_positions
¶
Partition positions into groups defined by key, preserving order within each group.
| PARAMETER | DESCRIPTION |
|---|---|
positions
|
List of genomic positions to group.
TYPE:
|
key
|
Function that extracts the grouping key from a position.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[_KT, list[GenomicPosition]]
|
Dict mapping each key value to the list of positions that produced it. |
Source code in src/iris/domain/genomics/utils.py
chrom_blocks
¶
Partition a chromosome into non-overlapping GenomicPosition blocks.
Coordinates are 1-based inclusive (GenomicPosition convention). The last block is clipped to length so no block extends past the chromosome end.
| PARAMETER | DESCRIPTION |
|---|---|
chrom
|
Normalized chromosome name (e.g.
TYPE:
|
length
|
Total chromosome length in bases.
TYPE:
|
block_size
|
Size of each block in bases (default 10 Mb).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Ordered list of GenomicPosition blocks. |
Example
Source code in src/iris/domain/genomics/utils.py
group_by_chromosome
¶
Partition positions by chromosome, preserving original order within each group.
| PARAMETER | DESCRIPTION |
|---|---|
positions
|
List of genomic positions to group.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, list[GenomicPosition]]
|
Dict mapping chromosome name to the positions on that chromosome. |
Source code in src/iris/domain/genomics/utils.py
resolve_human_chromosome
¶
Resolve any common human chromosome representation to its canonical name.
Handles UCSC ('chr1'), plain ('1'), and versioned NCBI RefSeq ('NC_000001.11') forms uniformly. This is the recommended replacement for normalize_chromosome() going forward — it additionally supports RefSeq accessions, which normalize_chromosome() never handled.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
Raw chromosome identifier from any source (VCF contig line, BAM/zarr metadata, user input).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Canonical name ('1'..'22', 'X', 'Y', 'MT'). |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If value does not match any known human chromosome name or alias. |
Example
Source code in src/iris/domain/genomics/utils.py
chromosome_set_from_contigs
¶
Build a ChromosomeSet from the literal contig names of an index file.
Unlike HUMAN_CHROMOSOMES, this does not assume canonical human naming — it takes whatever contig strings appear in a tabix/zarr index (which may use 'chr1', '1', or something else entirely) and builds aliases by toggling the 'chr' prefix, mirroring the old resolve_chromosome() logic. Use this when resolving against a specific file's contigs rather than a fixed catalog.
| PARAMETER | DESCRIPTION |
|---|---|
contigs
|
Contig names exactly as they appear in the file's index.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ChromosomeSet
|
ChromosomeSet whose canonical names are the literal contig strings, |
ChromosomeSet
|
with chr-prefix-toggled aliases for convenience. |
Source code in src/iris/domain/genomics/utils.py
Ports¶
Annotators¶
iris.domain.genomics.ports.driven.annotators
¶
Annotator port interfaces for the genomics domain.
Annotator
¶
Bases: ABC, Generic[T]
Abstract base class for annotation sources that enrich genomic entities.
VariantAnnotator
¶
Bases: Annotator[VariantAnnotation]
Abstract annotator that enriches VariantAnnotation objects.
annotate
abstractmethod
¶
Return new VariantAnnotation objects enriched with this source's data.
GeneAnnotator
¶
Bases: Annotator[GeneAnnotation]
Abstract annotator that enriches GeneAnnotation objects.
annotate
abstractmethod
¶
Return new GeneAnnotation objects enriched with this source's data.
Variant stores¶
iris.domain.genomics.ports.driven.variant_store
¶
VariantStore port interfaces for the genomics domain.
VariantStore
¶
Bases: ABC, Generic[T]
Abstract port for sources that deliver variants for a genomic region.
Symmetric to :class:~iris.domain.genomics.ports.driven.annotators.Annotator:
annotators enrich existing
:class:~iris.domain.genomics.entities.VariantAnnotation objects; stores
produce them from raw data sources (Zarr, VCF, tabix, …).
fetch
abstractmethod
¶
Return all variants whose positions fall within region.
| PARAMETER | DESCRIPTION |
|---|---|
region
|
1-based inclusive genomic window. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[T]
|
Possibly-empty list of variants within the region. |
Source code in src/iris/domain/genomics/ports/driven/variant_store.py
VariantAnnotationStore
¶
Bases: VariantStore[VariantAnnotation]
Abstract store that delivers VariantAnnotation objects per region.
Concrete implementations include Zarr cohort stores, tabix-indexed VCF files, or any other indexed variant source.
fetch
abstractmethod
¶
Return all variant annotations within region.
| PARAMETER | DESCRIPTION |
|---|---|
region
|
1-based inclusive genomic window.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[VariantAnnotation]
|
Possibly-empty list of |
list[VariantAnnotation]
|
class: |
Source code in src/iris/domain/genomics/ports/driven/variant_store.py
Exporters¶
iris.domain.genomics.ports.driven.exporters
¶
Region reader¶
iris.domain.genomics.ports.driven.region_reader
¶
Region exporter¶
iris.domain.genomics.ports.driven.region_exporter
¶
Gene nomenclature resolver¶
iris.domain.genomics.ports.driven.gene_nomenclature
¶
Port for resolving and enriching GeneNomenclature from external databases.
Defines the abstract interface that any gene nomenclature backend must implement. The domain uses this port to resolve symbols, aliases, and cross-references without depending on a specific database or API.
GeneNomenclatureResolver
¶
Bases: ABC
Abstract port for resolving gene nomenclature from external sources.
Implementations may be backed by local databases (PyHGNC), REST APIs (HGNC REST API), or other reference sources. All methods return GeneNomenclature objects enriched with the identifiers available in the underlying source.
resolve_symbol
abstractmethod
¶
Resolve a gene symbol to a canonical GeneNomenclature.
Searches both approved symbols and known aliases.
| PARAMETER | DESCRIPTION |
|---|---|
symbol
|
Gene symbol to resolve (e.g. 'BRCA1', 'TP53').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
GeneNomenclature | None
|
Canonical GeneNomenclature if found, None otherwise. |
Source code in src/iris/domain/genomics/ports/driven/gene_nomenclature.py
resolve_hgnc_id
abstractmethod
¶
Resolve a gene by its HGNC identifier.
| PARAMETER | DESCRIPTION |
|---|---|
hgnc_id
|
HGNC identifier string (e.g. 'HGNC:1100').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
GeneNomenclature | None
|
GeneNomenclature if found, None otherwise. |
Source code in src/iris/domain/genomics/ports/driven/gene_nomenclature.py
resolve_ensembl_id
abstractmethod
¶
Resolve a gene by its Ensembl gene identifier.
| PARAMETER | DESCRIPTION |
|---|---|
ensembl_id
|
Ensembl gene ID (e.g. 'ENSG00000012048').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
GeneNomenclature | None
|
GeneNomenclature if found, None otherwise. |
Source code in src/iris/domain/genomics/ports/driven/gene_nomenclature.py
resolve_refseq_id
abstractmethod
¶
Resolve a gene by its RefSeq accession.
| PARAMETER | DESCRIPTION |
|---|---|
refseq_id
|
RefSeq accession (e.g. 'NM_007294').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
GeneNomenclature | None
|
GeneNomenclature if found, None otherwise. |
Source code in src/iris/domain/genomics/ports/driven/gene_nomenclature.py
resolve_entrez_id
abstractmethod
¶
Resolve a gene by its NCBI Entrez gene ID.
| PARAMETER | DESCRIPTION |
|---|---|
entrez_id
|
NCBI Entrez gene identifier (e.g. 672).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
GeneNomenclature | None
|
GeneNomenclature if found, None otherwise. |
Source code in src/iris/domain/genomics/ports/driven/gene_nomenclature.py
search_by_name
abstractmethod
¶
Search genes by full or partial name.
Supports wildcard matching where the backend allows it. Use '%' as wildcard (e.g. 'breast cancer%').
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Full or partial gene name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GeneNomenclature]
|
List of matching GeneNomenclature objects, possibly empty. |
Source code in src/iris/domain/genomics/ports/driven/gene_nomenclature.py
aliases
abstractmethod
¶
Return all known alias symbols for a gene.
| PARAMETER | DESCRIPTION |
|---|---|
symbol
|
Approved gene symbol.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
List of alias symbols. Empty if gene not found or no aliases. |
Source code in src/iris/domain/genomics/ports/driven/gene_nomenclature.py
gene_family
abstractmethod
¶
Return the gene family names associated with a gene symbol.
| PARAMETER | DESCRIPTION |
|---|---|
symbol
|
Approved gene symbol.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
List of gene family names. Empty if none found. |
Source code in src/iris/domain/genomics/ports/driven/gene_nomenclature.py
orthologs
abstractmethod
¶
Return orthology predictions for a gene symbol.
| PARAMETER | DESCRIPTION |
|---|---|
symbol
|
Approved gene symbol.
TYPE:
|
species
|
Optional NCBI taxonomy ID to filter by species (e.g. 10090 for Mus musculus).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[dict[str, str]]
|
List of dicts with ortholog data. Each dict contains at minimum |
list[dict[str, str]]
|
'species', 'symbol', and 'ortholog_species_id'. |
Source code in src/iris/domain/genomics/ports/driven/gene_nomenclature.py
resolve_many
abstractmethod
¶
Resolve multiple gene symbols in a single operation.
More efficient than calling resolve_symbol in a loop when the backend supports batch queries.
| PARAMETER | DESCRIPTION |
|---|---|
symbols
|
Sequence of gene symbols to resolve.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, GeneNomenclature | None]
|
Dict mapping each input symbol to its GeneNomenclature, |
dict[str, GeneNomenclature | None]
|
or None if the symbol could not be resolved. |
Source code in src/iris/domain/genomics/ports/driven/gene_nomenclature.py
Range operations¶
iris.domain.genomics.ports.driven.range_ops
¶
Port for complex genomic range operations.
Defines the abstract interface that any range-computation backend must implement. The domain service uses this port; concrete adapters (BiocPy, bedtools, etc.) provide the implementation.
RangeOperations
¶
Bases: ABC
Abstract port for set-level and arithmetic operations on genomic ranges.
All coordinates follow the GenomicPosition convention: 1-based inclusive. Implementations are responsible for any coordinate conversion required by the underlying backend.
union
abstractmethod
¶
Return the union of two sets of genomic ranges.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
First set of genomic ranges.
TYPE:
|
b
|
Second set of genomic ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Merged, non-overlapping ranges covering all positions in a or b. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
intersect
abstractmethod
¶
Return ranges present in both a and b.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
First set of genomic ranges.
TYPE:
|
b
|
Second set of genomic ranges.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Ranges representing the intersection of a and b. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
setdiff
abstractmethod
¶
Return ranges in a that are not covered by b.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
Query ranges.
TYPE:
|
b
|
Ranges to subtract from a.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Ranges in a not overlapping any range in b. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
coverage
abstractmethod
¶
Compute per-base coverage across all ranges.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Genomic ranges to compute coverage for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, list[int]]
|
Dict mapping chromosome name to a list of per-base coverage values. |
dict[str, list[int]]
|
Index 0 corresponds to position 1 on that chromosome. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
gaps
abstractmethod
¶
Return the gaps between ranges on each chromosome.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
genome
|
Optional dict mapping chromosome name to its length. When provided, gaps at chromosome boundaries are included.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Ranges representing uncovered regions between the input ranges. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
disjoin
abstractmethod
¶
Split ranges into non-overlapping disjoint intervals.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges, possibly overlapping.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Maximal set of non-overlapping ranges derived from the input. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
nearest
abstractmethod
¶
Find the nearest subject range for each query range.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
Ranges to search for neighbors.
TYPE:
|
subject
|
Ranges to search within.
TYPE:
|
ignore_strand
|
If False, only consider ranges on the same strand.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int | None]
|
List of indices into subject (one per query). None if no neighbor found. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
precede
abstractmethod
¶
Find the subject range immediately upstream of each query range.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
Ranges to search for upstream neighbors.
TYPE:
|
subject
|
Ranges to search within.
TYPE:
|
ignore_strand
|
If False, only consider ranges on the same strand.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int | None]
|
List of indices into subject. None if no upstream range found. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
follow
abstractmethod
¶
Find the subject range immediately downstream of each query range.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
Ranges to search for downstream neighbors.
TYPE:
|
subject
|
Ranges to search within.
TYPE:
|
ignore_strand
|
If False, only consider ranges on the same strand.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int | None]
|
List of indices into subject. None if no downstream range found. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
flank
abstractmethod
¶
Return flanking regions for each input range.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
width
|
Width of the flanking region in bases.
TYPE:
|
start
|
If True, flank the start; if False, flank the end.
TYPE:
|
both
|
If True, return flanks on both sides (overrides start).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Flanking ranges, one per input range (or two per range if both=True). |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
resize
abstractmethod
¶
Resize ranges to a fixed width anchored at start, end, or center.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
width
|
Target width in bases.
TYPE:
|
fix
|
Anchor point — one of 'start', 'end', or 'center'.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Resized ranges with the same anchor point as the input. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
shift
abstractmethod
¶
Shift all ranges by a fixed number of bases.
| PARAMETER | DESCRIPTION |
|---|---|
ranges
|
Input genomic ranges.
TYPE:
|
shift
|
Number of bases to shift. Positive = downstream, negative = upstream.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[GenomicPosition]
|
Shifted ranges preserving width and strand. |
Source code in src/iris/domain/genomics/ports/driven/range_ops.py
HPO operations¶
iris.domain.genomics.ports.driven.hpo_ops
¶
Port for HPO (Human Phenotype Ontology) operations.
Defines the abstract interface that any HPO backend must implement. The domain service uses this port; concrete adapters (PyHPO, etc.) provide the implementation.
HpoOperations
¶
Bases: ABC
Abstract port for ontology-aware HPO operations.
All methods accept and return :class:~iris.domain.genomics.objects.Phenotype
domain objects. Implementations are responsible for resolving a
Phenotype to an HPO term (by hpo_id when available, by
name as a fallback) and for any library-specific initialization.
Valid kind values for similarity methods depend on the
information-content flavour used by the backend:
'omim'— OMIM disease-based IC (default)'gene'— gene-based IC'orpha'— Orphanet disease-based IC'decipher'— DECIPHER-based IC
Valid combine strategies for :meth:set_similarity:
'funSimAvg'— Schlicker et al. 2006 (default)'funSimMax'— Schlicker et al. 2006'BMA'— Best Match Average, Deng et al. 2015
search
abstractmethod
¶
Search HPO terms by name or synonym.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
Free-text query matched against term names and synonyms.
TYPE:
|
limit
|
Maximum number of results to return. Defaults to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
Matching phenotypes ordered by relevance, up to |
Source code in src/iris/domain/genomics/ports/driven/hpo_ops.py
get
abstractmethod
¶
Retrieve a single HPO term by its identifier.
| PARAMETER | DESCRIPTION |
|---|---|
hpo_id
|
HPO term identifier in
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Phenotype | None
|
The corresponding |
Source code in src/iris/domain/genomics/ports/driven/hpo_ops.py
parents
abstractmethod
¶
Return the direct parent terms of a phenotype.
| PARAMETER | DESCRIPTION |
|---|---|
phenotype
|
Source phenotype. Must be resolvable to an HPO term.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
Direct parent phenotypes (one level up in the hierarchy). |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/ports/driven/hpo_ops.py
children
abstractmethod
¶
Return the direct child terms of a phenotype.
| PARAMETER | DESCRIPTION |
|---|---|
phenotype
|
Source phenotype. Must be resolvable to an HPO term.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
Direct child phenotypes (one level down in the hierarchy). |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/ports/driven/hpo_ops.py
ancestors
abstractmethod
¶
Return all ancestor terms up to the ontology root.
| PARAMETER | DESCRIPTION |
|---|---|
phenotype
|
Source phenotype. Must be resolvable to an HPO term.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
All ancestor phenotypes, ordered from closest to root. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/ports/driven/hpo_ops.py
descendants
abstractmethod
¶
Return all descendant terms below the given phenotype.
| PARAMETER | DESCRIPTION |
|---|---|
phenotype
|
Source phenotype. Must be resolvable to an HPO term.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
All descendant phenotypes reachable via child relationships. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/ports/driven/hpo_ops.py
similarity
abstractmethod
¶
Compute semantic similarity between two HPO terms.
Uses information-content-based similarity (Lin by default via the backend's default method).
| PARAMETER | DESCRIPTION |
|---|---|
a
|
First phenotype.
TYPE:
|
b
|
Second phenotype.
TYPE:
|
kind
|
IC flavour to use — one of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
Similarity score in |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If either phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/ports/driven/hpo_ops.py
set_similarity
abstractmethod
¶
Compute semantic similarity between two sets of HPO terms.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
First phenotype set.
TYPE:
|
b
|
Second phenotype set.
TYPE:
|
kind
|
IC flavour — one of
TYPE:
|
combine
|
Aggregation strategy — one of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
Similarity score in |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If any phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/ports/driven/hpo_ops.py
common_ancestors
abstractmethod
¶
Return the common ancestors of two HPO terms.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
First phenotype.
TYPE:
|
b
|
Second phenotype.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Phenotype]
|
Phenotypes that are ancestors of both |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If either phenotype cannot be resolved to an HPO term. |
Source code in src/iris/domain/genomics/ports/driven/hpo_ops.py
Genotype processor¶
iris.domain.genomics.ports.driven.genotype_processor
¶
Port for user-defined genotype computation over variant blocks.
Defines the GenotypeProcessor protocol that ZarrVariantStore calls for each block of variants, enabling cohort-level statistics, stratified analyses, and regression models without subclassing the store.
GenotypeProcessor
¶
Bases: Protocol
Protocol for user-defined computation over a block of genotype data.
Implementations receive the raw genotype arrays for a block of variants
(all samples, one ALT allele at a time) and return a dict of computed
values to attach to each variant's metadata.
The processor is called **once per fetch block per ALT allele** with the
full sample dimension intact, enabling vectorised cohort-level statistics,
stratified allele frequencies, and regression models.
Contract:
- Input arrays have shape ``(n_variants, n_samples, ploidy)``.
- Output dict values must be either:
- arrays of shape ``(n_variants,)`` or ``(n_variants, k)``
- scalars (applied to all variants in the block)
- The processor must not mutate the input arrays.
- Missing calls are encoded as ``-1`` in ``gt`` and/or ``True``
in ``gt_mask``.
Example: