seqevolve¶
Simulation of nucleotide and amino acid sequences along a gene tree.
evolver
¶
Evolve sequences along a tree using models for substitutions, indels, and rate heterogeneity.
References
- Z. Yang. Computational molecular evolution. Oxford series in ecology and evolution. Oxford University Press, 2006. ISBN 978-0-19-856699-1 978-0-19-856702-8.
Evolver
¶
Class for evolving sequences along a tree.
Source code in asymmetree/seqevolve/evolver.py
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
__init__(subst_model: SubstModel, indel_model: IndelModel | None = None, het_model: HetModel | None = None, gillespie: str | bool = 'auto', **kwargs) -> None
¶
Constructor for the Evolver class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subst_model
|
SubstModel
|
Substitution model. |
required |
indel_model
|
IndelModel | None
|
Model for insertions and deletions. If not provided, no indels are simulated. |
None
|
het_model
|
HetModel | None
|
Model for substitution rate heterogeneity. If not provided, no rate heterogeneity is simulated. |
None
|
gillespie
|
str | bool
|
If True, the Gillespie algorithm is used instead of constructing the exchange probability matrix P via matrix diagonalization. The Gillespie algorithm may be faster if the rate heterogeneity is large. The default is 'auto', in which case the exchange probability matrix is used unless the heterogeneity model has more than one class or is sitewise, in which case the Gillespie algorithm is used. |
'auto'
|
Source code in asymmetree/seqevolve/evolver.py
evolve_along_tree(tree: Tree, start_length: int = 200, start_seq: str | None = None) -> dict[TreeNode, EvoSeq]
¶
Evolve sequence along a tree.
If start_seq is not supplied, then the sequence at the root is constructed randomly using
the stationary probabilities of the specified substitution model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tree
|
Tree
|
The tree along which sequences are simulated. |
required |
start_length
|
int
|
The length of the sequence at the root. The default is 200. This parameter
is ignored if |
200
|
start_seq
|
str | None
|
The start sequence for the root of the tree. The default is None, in which case a sequence is constructed at random. |
None
|
Returns:
| Type | Description |
|---|---|
dict[TreeNode, EvoSeq]
|
A dictionary containing the TreeNode instances in the tree as keys and the simulated
sequences as values (instances of type |
Source code in asymmetree/seqevolve/evolver.py
get_sequences(include_inner: bool = True) -> dict[TreeNode, str]
¶
Return the simulated sequence as strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_inner
|
bool
|
If True, the sequences of the inner nodes of the tree are also included. |
True
|
Returns:
| Type | Description |
|---|---|
dict[TreeNode, str]
|
A dictionary with the tree nodes as keys and the str sequence (without gaps) as values. |
Source code in asymmetree/seqevolve/evolver.py
write_sequences(file_path: str | Path, include_inner: bool = True) -> None
¶
Write the simulated sequences into a file in fasta format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | Path
|
The path and filename to the file into which the sequences shall be written. |
required |
include_inner
|
bool
|
If True, the sequences of the inner nodes of the tree are also written to the file. |
True
|
Source code in asymmetree/seqevolve/evolver.py
true_alignment(include_inner: bool = True, write_to: str | Path | None = None, alignment_format: str = 'phylip') -> dict[TreeNode, str]
¶
Construct the 'true' alignment of the simulated sequences.
The true alignment is constructed using the information about the history of substitutions and indels that is available for the simulated sequences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_inner
|
bool
|
If True, the alignment also contains the sequences of the inner nodes of the tree. |
True
|
write_to
|
str | Path | None
|
The path and filename to the file into which the alignment shall be written. The default is None, in which case nothing is written to a file. |
None
|
alignment_format
|
str
|
Format of the alignment that is written to a file. The default is 'phylip'. |
'phylip'
|
Returns:
| Type | Description |
|---|---|
dict[TreeNode, str]
|
A dictionary containing the TreeNode instances in the tree as keys and the str sequences as values that include the necessary gaps. |
Source code in asymmetree/seqevolve/evolver.py
evolving_sequence
¶
Data structure for evolving sequences.
The EvoSeq class represents a sequence that evolves along a tree. It is implemented as a doubly linked list, which allows for efficient insertions and deletions of sites, which are necessary to simulate indels. Each site in the sequence is represented by an EvoSeqNode, which contains information about the state of the site (whether it is inherited from the parent sequence, inserted, or part of the root sequence), its site ID, and its parent element in the case of inherited sites.
State
¶
EvoSeqNode
¶
Bases: DLListNode
Site in an evolving sequence.
Source code in asymmetree/seqevolve/evolving_sequence.py
__init__(value: int, status: State, site_id: int, prev_node: EvoSeqNode | None = None, next_node: EvoSeqNode | None = None, parent_el: EvoSeqNode | None = None, rate_class: int = 0, rate_factor: float = 1.0) -> None
¶
Constructor for the EvoSeqNode class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int
|
The character at the site represented as an integer (index in the alphabet) or None for gaps. |
required |
status
|
State
|
The state of the site (whether it is inherited from the parent sequence, inserted, or part of the root sequence). |
required |
site_id
|
int
|
The site ID, which is a unique identifier for the site across the entire tree. |
required |
prev_node
|
EvoSeqNode | None
|
The previous site in the sequence. |
None
|
next_node
|
EvoSeqNode | None
|
The next site in the sequence. |
None
|
Source code in asymmetree/seqevolve/evolving_sequence.py
EvoSeq
¶
Bases: DLList
Evolving sequence.
The EvoSeq class represents a sequence that evolves along a tree. It is implemented as a doubly linked list, which allows for efficient insertions and deletions of sites, which are necessary to simulate indels.
Source code in asymmetree/seqevolve/evolving_sequence.py
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
__init__() -> None
¶
__iter__()
¶
__next__()
¶
Raise an error if next is called on the EvoSeq object itself.
append(value: int | None, status: State, site_id: int, parent_el: EvoSeqNode | None = None, rate_class: int = 0, rate_factor: float = 1.0) -> EvoSeqNode
¶
Append a new site to the end of the evolving sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int | None
|
The character at the site represented as an integer (index in the alphabet) or None for gaps. |
required |
status
|
State
|
The state of the site (whether it is inherited from the parent sequence, inserted, or part of the root sequence). |
required |
site_id
|
int
|
The site ID, which is a unique identifier for the site across the entire tree. |
required |
parent_el
|
EvoSeqNode | None
|
The parent element in the case of inherited sites. |
None
|
rate_class
|
int
|
The rate class of the site. |
0
|
rate_factor
|
float
|
The rate factor of the site. |
1.0
|
Returns:
| Type | Description |
|---|---|
EvoSeqNode
|
The newly appended |
Source code in asymmetree/seqevolve/evolving_sequence.py
append_left(value: int | None, status: State, site_id: int, parent_el: EvoSeqNode | None = None, rate_class: int = 0, rate_factor: float = 1.0) -> EvoSeqNode
¶
Append a new site to the beginning of the evolving sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int | None
|
The character at the site represented as an integer (index in the alphabet) or None for gaps. |
required |
status
|
State
|
The state of the site (whether it is inherited from the parent sequence, inserted, or part of the root sequence). |
required |
site_id
|
int
|
The site ID, which is a unique identifier for the site across the entire tree. |
required |
parent_el
|
EvoSeqNode | None
|
The parent element in the case of inherited sites. |
None
|
rate_class
|
int
|
The rate class of the site. |
0
|
rate_factor
|
float
|
The rate factor of the site. |
1.0
|
Returns:
| Type | Description |
|---|---|
EvoSeqNode
|
The newly appended |
Source code in asymmetree/seqevolve/evolving_sequence.py
insert_right_of(element: EvoSeqNode, value: int | None, status: State, site_id: int, parent_el: EvoSeqNode | None = None, rate_class: int = 0, rate_factor: float = 1.0) -> EvoSeqNode
¶
Insert a new site to the right of the given element in the evolving sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
EvoSeqNode
|
The element to the left of the new site. |
required |
value
|
int | None
|
The character at the site represented as an integer (index in the alphabet) or None for gaps. |
required |
status
|
State
|
The state of the site (whether it is inherited from the parent sequence, inserted, or part of the root sequence). |
required |
site_id
|
int
|
The site ID, which is a unique identifier for the site across the entire tree. |
required |
parent_el
|
EvoSeqNode | None
|
The parent element in the case of inherited sites. |
None
|
rate_class
|
int
|
The rate class of the site. |
0
|
rate_factor
|
float
|
The rate factor of the site. |
1.0
|
Returns:
| Type | Description |
|---|---|
EvoSeqNode
|
The newly inserted |
Source code in asymmetree/seqevolve/evolving_sequence.py
clone() -> EvoSeq
¶
Clone the evolving sequence to create a child sequence from a parent sequence.
All sites in the child sequence are marked as inherited, and they reference the corresponding sites in the parent sequence.
Returns:
| Type | Description |
|---|---|
EvoSeq
|
A new |
Source code in asymmetree/seqevolve/evolving_sequence.py
element_pairs() -> Iterator[tuple[EvoSeqNode, EvoSeqNode]]
¶
Generator for subsequent element pairs.
Yields:
| Type | Description |
|---|---|
tuple[EvoSeqNode, EvoSeqNode]
|
Tuples of subsequent elements in the evolving sequence. |
Source code in asymmetree/seqevolve/evolving_sequence.py
count_status(status: State) -> int
¶
Count the number of sites with a given status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
State
|
The status to count. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The number of sites with the given status. |
Source code in asymmetree/seqevolve/evolving_sequence.py
EvoSeqIterator
¶
Bases: DLListIterator
Iterator class for evolving sequence.
Source code in asymmetree/seqevolve/evolving_sequence.py
__init__(evoseq: EvoSeq) -> None
¶
Constructor for the EvoSeqIterator class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evoseq
|
EvoSeq
|
The evolving sequence to iterate over. |
required |
__next__() -> EvoSeqNode
¶
Next site element in the evolving sequence.
Overrides the super class methods and returns the element instead of the value only.
Returns:
| Type | Description |
|---|---|
EvoSeqNode
|
The next |
Source code in asymmetree/seqevolve/evolving_sequence.py
substitution
¶
Substitution models for nucleotide and amino acid evolution.
The module contains the class SubstModel that can be used to represent a substitution model
for nucleotide or amino acid evolution. The class provides methods to compute the transition
probability matrix for a given time and to convert sequences between their str representation and a
list of indices.
For amino acid substitution models, some empirical models are available that can be loaded via the
EMPIRICAL_MODELS object. The values in the matrices and the equilibrium frequencies are
taken from [2].
References
- Z. Yang. Computational molecular evolution. Oxford series in ecology and evolution. Oxford University Press, 2006. ISBN 978-0-19-856699-1 978-0-19-856702-8.
- http://giphy.pasteur.fr/empirical-models-of-amino-acid-substitution/
SubstModel
¶
Substitution model for nucleotide or amino acid evolution.
Source code in asymmetree/seqevolve/substitution.py
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
__init__(model_type: str, model_name: str, **kwargs) -> None
¶
Constructor for the SubstModel class.
Some models require additional parameters, e.g. 'K80' requires the parameter 'kappa' and 'GTR' requires 'abcdef' and 'f', see documentation for details. For a custom model, the keyword parameter 'filename' has to be specified with a path to a custom model in paml format. All of these parameters are passed as keyword arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_type
|
str
|
Available options are 'n' for nucleotide and 'a' for amino acid sequences. |
required |
model_name
|
str
|
Available are e.g. 'JC69' (nuc./a.a.), 'K80' (nuc.), 'GTR' (nuc.), 'WAG' (a.a.), 'JTT' (a.a.), 'BLOSUM62' (a.a.), 'LG' (a.a.), and 'DAYHOFF' (a.a.). For the option 'CUSTOM', the keyword parameter 'filename' has to be specified with a path to a custom model in paml format. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an invalid model was specified. |
Source code in asymmetree/seqevolve/substitution.py
eigensystem()
¶
Compute the eigensystem of the rate matrix Q.
transition_prob_matrix(t: float) -> np.ndarray
¶
Calculate the transition probability matrix P(t).
The transition probability matrix P(t) is computed from the eigensystem of the rate matrix Q according to the formula P(t) = U x e^(Λ * t) x U^(-1) where U is the matrix of eigenvectors and Λ is the diagonal matrix of eigenvalues.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
The time / evolutionary distance for which to compute the transition probability matrix. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The transition probability matrix P(t) as a |
Source code in asymmetree/seqevolve/substitution.py
to_indices(sequence: str) -> list[int]
¶
Convert a sequence into a list of indices.
The letters in the sequence are converted to their corresponding indices in the alphabet of the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence
|
str
|
The sequence to be converted. |
required |
Returns:
| Type | Description |
|---|---|
list[int]
|
The list of indices corresponding to the letters in the sequence. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the sequence contains a letter that is not in the alphabet of the model. |
Source code in asymmetree/seqevolve/substitution.py
to_sequence(evoseq: EvoSeq) -> str
¶
Construct the str representation of a sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evoseq
|
EvoSeq
|
The sequence to be converted as an |
required |
Returns:
| Type | Description |
|---|---|
str
|
The nucleotide or amino acid sequence depending on the model. |
Source code in asymmetree/seqevolve/substitution.py
diagonalize(Q: np.ndarray, freqs: np.ndarray) -> tuple[np.ndarray, np.ndarray, np.ndarray]
¶
Diagonalize a matrix.
Diagonalize the rate matrix Q using the stationary frequencies freqs. If Q is symmetric, it is diagonalized directly. If Q is not symmetric but the model is time-reversible, it is first transformed to a symmetric matrix using the stationary frequencies and then diagonalized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q
|
ndarray
|
Rate matrix to be diagonalized. |
required |
freqs
|
ndarray
|
The stationary frequencies π corresponding to the rate matrix Q. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
A 1-dimensional array containing the eigenvalues. |
ndarray
|
A 2-dimensional array containing the eigenvectors as columns. The i-th column corresponds to the i-th eigenvalue. |
ndarray
|
A 2-dimensional array containing the inverse of the eigenvector matrix. |
Source code in asymmetree/seqevolve/substitution.py
heterogeneity
¶
Heterogeneity models for sequence evolution.
Not all sites in a sequence evolve at the same rate. This module provides a class for modeling rate heterogeneity across sites, which is a common feature of sequence evolution. The class supports rate heterogeneity based on a Gamma distribution ('+Gamma'-model) as well as invariant sites ('+I'-model), see [1].
References
- Z. Yang. Computational molecular evolution. Oxford series in ecology and evolution. Oxford University Press, 2006. ISBN 978-0-19-856699-1 978-0-19-856702-8.
HetModel
¶
Heterogeneity model.
Supports rate heterogeneity based on a Gamma distribution ('+Gamma'-model) as well as invariant sites ('+I'-model), see [1].
References: 1. Z. Yang. Computational molecular evolution. Oxford series in ecology and evolution. Oxford University Press, 2006. ISBN 978-0-19-856699-1 978-0-19-856702-8.
Source code in asymmetree/seqevolve/heterogeneity.py
21 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 134 | |
__init__(alpha: float, classes: int = 5, sitewise: bool = False, invariant: float = 0.0) -> None
¶
Constructor for the HetModel class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Parameter of the Gamma distribution (with mean 1) from which the rate factors are drawn. |
required |
classes
|
int
|
Number of classes such that sites in the same class share the same rate factor. |
5
|
sitewise
|
bool
|
If True, ignore the 'classes' attribute and treat each site as its own class. |
False
|
invariant
|
float
|
Expected proportion of invariant sites, i.e., sites where no mutations happen. |
0.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If alpha is not a float > 0.0, if classes is not an int > 0, or if invariant is not a float in [0.0, 1.0]. |
Source code in asymmetree/seqevolve/heterogeneity.py
assign(sequence: EvoSeq, exclude_inherited: bool = True) -> None
¶
Assign rate classes and rate factors to the sites of a sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence
|
EvoSeq
|
The sequence to which the rate classes and rate factors should be assigned. |
required |
exclude_inherited
|
bool
|
If True, do not assign new classes and rates to inherited sites, i.e., only if the sequence corresponds to the root of a tree along which is simulated or if new sites are added as a result of an insertion event. |
True
|
Source code in asymmetree/seqevolve/heterogeneity.py
indels
¶
Indel models for sequence evolution.
Indel events (insertions and deletions) are an important aspect of sequence evolution. This module provides a class for modeling indel events, which can be used to simulate sequence evolution along a tree. The class supports different distributions for the length of the indels.
References
- Z. Yang. Computational molecular evolution. Oxford series in ecology and evolution. Oxford University Press, 2006. ISBN 978-0-19-856699-1 978-0-19-856702-8.
- R. A. Cartwright. DNA assembly with gaps (Dawg): Simulating sequence evolution. In: Bioinformatics, 21(Suppl 3):iii31-iii38, November 2005. doi:10.1093/bioinformatics/bti1200.
IndelModel
¶
Indel model
Source code in asymmetree/seqevolve/indels.py
__init__(insertion_rate: float, deletion_rate: float, length_distr: tuple = ('zipf', 1.821), min_length: int = 1, max_length: int | None = None, **kwargs) -> None
¶
Constructor for the IndelModel class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
insertion_rate
|
float
|
Insertion rate w.r.t. units of evolutionary distance. |
required |
deletion_rate
|
float
|
Deletion rate w.r.t. units of evolutionary distance. |
required |
length_distr
|
tuple
|
Distribution of the length of the indels, see documentation for available options. The default is a Zipf distribution as observed for empirical data in [1]. |
('zipf', 1.821)
|
min_length
|
int
|
The minimal length of an indel, default is 1. |
1
|
max_length
|
int | None
|
The maximal length of an indel. The default is None in which case the distribution is not truncated (on the upper side). |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If insertion_rate or deletion_rate is negative. |
References
- M. S. Chang and S. A. Benner. Empirical Analysis of Protein Insertions and Deletions Determining Parameters for the Correct Placement of Gaps in Protein Sequence Alignments. In: Journal of Molecular Biology, 341(2):617-631, August 2004. doi:10.1016/j.jmb.2004.05.045.
Source code in asymmetree/seqevolve/indels.py
get_rates(seq_length: int) -> tuple[float, float]
¶
Return the current insertion and deletion rate.
Computes the current insertion and deletion rate according to the model and the length of the sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seq_length
|
int
|
The length of the sequence. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The total insertion rate for the given sequence length, see 1. |
float
|
The total deletion rate for the given sequence length, see 1. |
References
- R. A. Cartwright. DNA assembly with gaps (Dawg): Simulating sequence evolution. In: Bioinformatics, 21(Suppl 3):iii31-iii38, November 2005. doi:10.1093/bioinformatics/bti1200.
Source code in asymmetree/seqevolve/indels.py
draw_length() -> int
¶
alignment
¶
Module for constructing the true alignment of simulated sequences.
In the simulated sequences, the true history of substitutions and indels is known. This module uses this information to construct the true alignment of the sequences, which can for instance be used for evaluating the performance of alignment methods.
AlignmentBuilder
¶
Construction of the true alignment of simulated sequences.
Source code in asymmetree/seqevolve/alignment.py
__init__(tree: Tree, sequence_dict: dict[TreeNode, EvoSeq], alphabet: str, include_inner: bool = True) -> None
¶
Constructor for the AlignmentBuilder class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tree
|
Tree
|
The tree along which the sequences where simulated. |
required |
sequence_dict
|
dict[TreeNode, EvoSeq]
|
A dict containing the TreeNode instances in the tree as keys and the simulated sequences as values. |
required |
alphabet
|
str
|
The alphabet of the substitution model that was used. |
required |
include_inner
|
bool
|
If True, the alignment also contains the sequences of the inner nodes of the tree. |
True
|
Source code in asymmetree/seqevolve/alignment.py
build() -> dict[TreeNode, str]
¶
Build the true alignment.
Returns:
| Type | Description |
|---|---|
dict[TreeNode, str]
|
A |