skbio.alignment.TabularMSA.index

TabularMSA.index

Index containing labels along the sequence axis.

State: Experimental as of 0.4.1.

Returns:

pd.Index

Index containing sequence labels.

See also

reassign_index

Notes

This property can be set and deleted. Deleting the index will reset the index to the TabularMSA constructor’s default.

Examples

Create a TabularMSA object with sequences labeled by sequence identifier:

>>> from skbio import DNA, TabularMSA
>>> seqs = [DNA('ACG', metadata={'id': 'a'}),
...         DNA('AC-', metadata={'id': 'b'}),
...         DNA('AC-', metadata={'id': 'c'})]
>>> msa = TabularMSA(seqs, minter='id')

Retrieve index:

>>> msa.index
Index(['a', 'b', 'c'], dtype='object')

Set index:

>>> msa.index = ['seq1', 'seq2', 'seq3']
>>> msa.index
Index(['seq1', 'seq2', 'seq3'], dtype='object')

Deleting the index resets it to the TabularMSA constructor’s default:

>>> del msa.index
>>> msa.index
RangeIndex(start=0, stop=3, step=1)