find_terminal_gaps#

biotite.sequence.align.find_terminal_gaps(alignment)[source]#

Find the slice indices that would remove terminal gaps from an alignment.

Terminal gaps are gaps that appear before all sequences start and after any sequence ends.

Parameters:
alignmentAlignment

The alignment, where the slice indices should be found in.

Returns:
start, stopint

Indices that point to the start and exclusive stop of the alignment columns without terminal gaps. When these indices are used as slice index for an alignment or trace, the index would remove terminal gaps.

Examples

>>> sequences = [
...     NucleotideSequence(seq_string) for seq_string in (
...         "AAAAACTGATTC",
...         "AAACTGTTCA",
...         "CTGATTCAAA"
...     )
... ]
>>> trace = np.transpose([
...     ( 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, -1, -1, -1),
...     (-1, -1,  0,  1,  2,  3,  4,  5, -1,  6,  7,  8,  9, -1, -1),
...     (-1, -1, -1, -1, -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9),
... ])
>>> alignment = Alignment(sequences, trace)
>>> print(alignment)
AAAAACTGATTC---
--AAACTG-TTCA--
-----CTGATTCAAA
>>> print(find_terminal_gaps(alignment))
(5, 12)