skbio.alignment.AlignPath.to_bits#
- AlignPath.to_bits(expand=True)[source]#
Unpack the alignment path into an array of bits.
Changed in version 0.6.4: The default behavior now returns positions.
- Parameters:
- expandbool, optional
If True (default), each column in the returned array represents a position in the original alignment. If False, each column represents a segment in the alignment path.
Added in version 0.6.4.
- Returns:
- ndarray of (0, 1) of shape (n_sequences, n_positions or n_segments)
Array of zeros (character) and ones (gap) which represent the alignment.
Examples
>>> from skbio import DNA, TabularMSA >>> from skbio.alignment import AlignPath >>> seqs = [ ... DNA('CGTCGTGC'), ... DNA('CA--GT-C'), ... DNA('CGTCGT-T') ... ] >>> msa = TabularMSA(seqs) >>> path = AlignPath.from_tabular(msa)
Return a bit array representing positions:
>>> path.to_bits() array([[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0]], dtype=uint8)
Return a bit array representing segments:
>>> path.to_bits(expand=False) array([[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 1, 0]], dtype=uint8)