Alignment¶
Implements an alignment between two sequences or trees.
-
class
edist.alignment.
Alignment
¶ Models a list of tuples. Note that, by convention, an alignment between sequences only permits tuples in lexicographically ascending order, i.e. an alignment of nothing to 0, 0 to 1, and 1 to 2, should be stored in that order and not as [(1, 2), (0, 1), (-1, 0)], for example. The same holds for tree alignments, with the additional requirement that aligned indices must respect the structure of the tree, i.e. if i is aligned to j and i2 to j2, then i can only be a parent of i2 if j is a parent of j2 (and vice versa).
-
append_tuple
(left, right, op=None)¶ Appends a new tuple to the current Alignment.
Parameters: - left (int) – the left index.
- right (int) – the right index.
- op (str (default = None)) – a name for the underlying edit operation.
-
cost
(x, y, deltas)¶ Computes the cost of this trace. This is equivalent to the sum of the cost of all tuples in this trace.
Parameters: - x (list) – A symbol list for the left indices.
- y (list) – A symbol list for the right indices.
- deltas (function or dictionary) – The cost function delta mapping pairs of elements to replacement/deletion/insertion costs OR A map which contains for any operation name such a function.
Returns: cost – The cost assigned by deltas to this Alignment.
Return type: float
-
render
(x, y, deltas=None)¶ Represents this trace as a string, showing the left and right indices in addition to the respective labels in x and y, and in addition to the tuple cost. This is equivalent as to calling ‘render’ on all tuples in this trace and joining the resulting strings with newlines.
Parameters: - x (list) – A symbol list for the left indices.
- y (list) – A symbol list for the right indices.
- deltas (function or dictionary (default = None)) – The cost function delta mapping pairs of elements to replacement/deletion/insertion costs OR A map which contains for any operation name such a function. If provided, the cost for any operation is rendered as well.
Returns: repr – A string representing this Alignment.
Return type: str
-
-
class
edist.alignment.
Tuple
(name, left, right)¶ Models a single alignment entry with an edit operation name, a left index, and a right index.
-
_name
¶ The name of the corresponding edit operation.
Type: str
-
_left
¶ The index of the aligned object on the left or -1 if no such object exists.
Type: int
-
_right
¶ The index of the aligned object on the right or -1 if no such object exists.
Type: int
-
cost
(x, y, deltas)¶ Computes the cost of the current edit tuple.
Parameters: - x (list) – A symbol list for the left indices.
- y (list) – A symbol list for the right indices.
- deltas (function or dictionary) – The cost function delta mapping pairs of elements to replacement/deletion/insertion costs OR A map which contains for any operation name such a function.
Returns: cost – The cost assigned by deltas to this tuple.
Return type: float
-
render
(x, y, deltas=None)¶ Represents an tuple as a string, showing the left and right indices in addition to the respective labels in x and y, and in addition to the tuple cost.
Parameters: - x (list) – A symbol list for the left indices.
- y (list) – A symbol list for the right indices.
- deltas (function or dictionary (default = None)) – The cost function delta mapping pairs of elements to replacement/deletion/insertion costs OR A map which contains for any operation name such a function. If provided, the cost for any operation is rendered as well.
Returns: repr – A string representing this tuple.
Return type: str
-