_genomes
Parasite genome representation and replacement in serialized populations.
Genome
Represents a single parasite genome with barcode-to-DTK-dict conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
barcode
|
str
|
Nucleotide string (characters A/C/G/T). |
required |
allele_root_id
|
int
|
Root ID for allele tracking. Typically the individual's SUID or -999 for vectors. |
required |
Source code in emodpy_malaria/serialization/_genomes.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
from_dtk_dict(dtk_dict)
staticmethod
Construct a Genome from a DTK genome dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtk_dict
|
dict
|
A dict with |
required |
Returns:
| Type | Description |
|---|---|
Genome
|
Genome instance with matching barcode and hash codes. |
Source code in emodpy_malaria/serialization/_genomes.py
int_to_nucleotide(val)
staticmethod
Convert an integer encoding back to a nucleotide character.
Source code in emodpy_malaria/serialization/_genomes.py
nucleotide_to_int(ch)
staticmethod
Convert a single nucleotide character to its integer encoding.
Source code in emodpy_malaria/serialization/_genomes.py
to_dtk_dict()
Convert to DTK genome dict format (m_pInner structure).
Source code in emodpy_malaria/serialization/_genomes.py
to_dtk_map_entry()
Convert to DTK genome map entry format (key/value pair).
get_all_barcodes(ser_pop)
Extract all unique barcode strings from the population's genome map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ser_pop
|
SerializedPopulation
|
A loaded SerializedPopulation. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of unique barcode strings. |
Source code in emodpy_malaria/serialization/_genomes.py
get_infection_barcodes(ser_pop, *, node_index=None)
Extract barcode information for each infection in the population.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ser_pop
|
SerializedPopulation
|
A loaded SerializedPopulation. |
required |
node_index
|
int
|
If provided, inspect only this node. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of dicts with keys |
list[dict]
|
|
Source code in emodpy_malaria/serialization/_genomes.py
replace_genomes(ser_pop, next_barcode_fn)
Replace all parasite genomes in humans and vectors (in-place).
Clears the simulation-level ParasiteGenomeMap and rebuilds it with new
genomes generated by calling next_barcode_fn() for each infection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ser_pop
|
SerializedPopulation
|
A loaded SerializedPopulation. |
required |
next_barcode_fn
|
Callable[[], str]
|
Callable returning a barcode string each time it is called. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Total number of genomes replaced. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a generated barcode has a different length than the existing barcode at that position. |