skbio.alignment.TabularMSA.append

TabularMSA.append(sequence, minter=None, index=None)[source]

Append a sequence to the MSA without recomputing alignment.

State: Experimental as of 0.4.1.

Parameters:

sequence : IUPACSequence

Sequence to be appended. Must match the dtype of the MSA and the number of positions in the MSA.

minter : callable or metadata key, optional

Used to create an index label for the sequence being appended. If callable, it generates a label directly. Otherwise it’s treated as a key into the sequence metadata. Note that minter cannot be combined with index.

index : object, optional

Index label to use for the appended sequence. Note that index cannot be combined with minter.

Raises:

ValueError

If both minter and index are provided.

ValueError

If neither minter nor index are provided and the MSA has a non-default index.

TypeError

If the sequence object isn’t an IUPACSequence.

TypeError

If the type of the sequence does not match the dtype of the MSA.

ValueError

If the length of the sequence does not match the number of positions in the MSA.

Notes

If neither minter nor index are provided and this MSA has default index labels, the new index label will be auto-incremented.

The MSA is not automatically re-aligned when a sequence is appended. Therefore, this operation is not necessarily meaningful on its own.

Examples

>>> from skbio import DNA, TabularMSA
>>> msa = TabularMSA([DNA('ACGT')])
>>> msa
TabularMSA[DNA]
---------------------
Stats:
    sequence count: 1
    position count: 4
---------------------
ACGT
>>> msa.append(DNA('AG-T'))
>>> msa
TabularMSA[DNA]
---------------------
Stats:
    sequence count: 2
    position count: 4
---------------------
ACGT
AG-T

Auto-incrementing index labels:

>>> msa.index
Int64Index([0, 1], dtype='int64')
>>> msa.append(DNA('ACGA'))
>>> msa.index
Int64Index([0, 1, 2], dtype='int64')