# skbio.core.sequence.NucleotideSequence.fraction_diff¶

NucleotideSequence.fraction_diff(other)[source]

Return fraction of positions that differ relative to other

Parameters: other : BiologicalSequence The BiologicalSequence to compare against. float The fraction of positions that differ between self and other. skbio.core.exception.BiologicalSequenceError If len(self) != len(other).

See also

distance, fraction_same, scipy.spatial.distance.hamming

Notes

Computed as the Hamming distance between self and other. This is available in addition to distance in case the distance method is updated to use something other than scipy.spatial.distance.hamming as the default distance metric. So, if you specifically want the fraction of positions that differ, you should use this function instead of distance to ensure backward compatibility.

Examples

>>> from skbio.core.sequence import BiologicalSequence
>>> s = BiologicalSequence('GGUC')
>>> t = BiologicalSequence('AGUC')
>>> s.fraction_diff(t)
0.25