GrammaredSequence.
distance
(other, metric=None)[source]¶Compute the distance to another sequence.
State: Experimental as of 0.4.0.
Parameters: | other : str, Sequence, or 1D np.ndarray (np.uint8 or ‘|S1’)
metric : function, optional
|
---|---|
Returns: | float
|
Raises: | TypeError
|
See also
skbio.sequence.distance
, fraction_diff
, fraction_same
Examples
>>> from skbio import Sequence
>>> s = Sequence('GGUC')
>>> t = Sequence('AGUC')
Compute Hamming distance (the default metric):
>>> s.distance(t)
0.25
Use a custom metric:
>>> def custom_metric(s1, s2): return 0.42
>>> s.distance(t, custom_metric)
0.42