resistance.tpt
resistance.tpt
Strain-aware TB preventive therapy (TPT).
TPTRx extends the base tbsim.TPTTx product so that sterilization is applied per strain: only strains susceptible to every drug in the TPT regimen are cleared; resistant strains remain and may then progress to disease and transmit (the spec’s “TPT clears a susceptible strain → resistant strain goes on to progress/transmit” dynamic). An agent moves to CLEARED only once all carried strains are removed.
Suppression (the base product’s rr_* progression-protection branch) is likewise applied per strain: the protection an agent receives is scaled by the fraction of its carried strains the regimen actually covers, so a surviving resistant strain is not shielded from progressing (spec §TPT: efficacy “varies by regimen and resistance/strain” — the same resistance-unmasking dynamic, via the progression channel rather than clearance).
TPT drug pressure can also select resistance among agents for whom TPT was ineffective (neither cleared nor protected): a susceptible carried strain mutates to its resistant counterpart with probability p_tpt_acq[drug] × a per-TB-state RR (spec: highest for ASYMPTOMATIC/SYMPTOMATIC, low-medium for NON_INFECTIOUS, very low for INFECTION).
Wrap TPTRx in any TPT delivery (e.g. tbsim.TPTSimple(product=TPTRx(...))); set the product’s p_sterilize > 0 so the strain-aware sterilization path is exercised.
Classes
| Name | Description |
|---|---|
| TPTRx | Strain-aware TPT product. See module docstring for the mechanism. |
TPTRx
resistance.tpt.TPTRx(
strains,
regimen_drugs=None,
p_tpt_acq=None,
acq_state_rr=None,
pars=None,
**kwargs,
)Strain-aware TPT product. See module docstring for the mechanism.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| strains | Strains | the strain registry (e.g. tb.strains). |
required |
| regimen_drugs | list | drugs in the TPT regimen (default: all drugs in strains). A strain is cleared by sterilization only if susceptible to every regimen drug. |
None |
| p_tpt_acq | dict | per-drug {drug: prob} of a susceptible strain acquiring resistance under TPT drug pressure (replacement). Default none (off). Each carried drug-susceptible strain rolls independently, so multiple strains may acquire resistance under one course. |
None |
| acq_state_rr | dict | per-TB-state multiplier on p_tpt_acq. Default follows the spec: INFECTION 0.05, NON_INFECTIOUS 0.5, ASYMPTOMATIC 1.0, SYMPTOMATIC 1.0. |
None |
| pars, **kwargs | forwarded to :class:tbsim.TPTTx (efficacy, p_sterilize, durations, …). |
required |
Methods
| Name | Description |
|---|---|
| apply_protection | Scale TPT progression-protection by the fraction of an agent’s carried strains the regimen covers. |
apply_protection
resistance.tpt.TPTRx.apply_protection()Scale TPT progression-protection by the fraction of an agent’s carried strains the regimen covers.
Base :class:tbsim.TPTTx protects a suppressed agent as a whole, multiplying rr_activation / rr_clearance / rr_death by the sampled modifiers. For a mixed infection that over-protects any surviving resistant strain, muting the spec’s resistance-unmasking dynamic (§TPT: efficacy varies by regimen and resistance/strain). Here each modifier is blended toward 1 (no effect) by the uncovered fraction: with coverage weight w an agent carrying only regimen-resistant strains (w = 0) gets no protection, an all-susceptible agent (w = 1) gets full protection, and mixed infections get partial protection. w is recomputed each step from the agent’s current strains, so it tracks strain changes (bottleneck, de-novo acquisition).