remove_terminal_gaps#

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

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 terminal gaps should be removed from.

Returns:
truncated_alignmentAlignment

A shallow copy of the input alignment with an truncated trace, that does not contain alignment columns with 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
>>> truncated_alignment = remove_terminal_gaps(alignment)
>>> print(truncated_alignment)
CTGATTC
CTG-TTC
CTGATTC