skbio.alignment.TabularMSA.positional_metadata

TabularMSA.positional_metadata

pd.DataFrame containing metadata along an axis.

State: Stable as of 0.4.0.

Notes

This property can be set and deleted. When setting new positional metadata, a shallow copy is made and the pd.DataFrame index is set to pd.RangeIndex(start=0, stop=axis_len, step=1).

Examples

Note

scikit-bio objects with positional metadata share a common interface for accessing and manipulating their positional metadata. The following examples use scikit-bio’s DNA class to demonstrate positional metadata behavior. These examples apply to all other scikit-bio objects storing positional metadata.

Create a DNA sequence with positional metadata:

>>> from skbio import DNA
>>> seq = DNA(
...     'ACGT',
...     positional_metadata={'quality': [3, 3, 20, 11],
...                          'exons': [True, True, False, True]})
>>> seq
DNA
-----------------------------
Positional metadata:
    'exons': <dtype: bool>
    'quality': <dtype: int64>
Stats:
    length: 4
    has gaps: False
    has degenerates: False
    has definites: True
    GC-content: 50.00%
-----------------------------
0 ACGT

Retrieve positional metadata:

>>> seq.positional_metadata
   exons  quality
0   True        3
1   True        3
2  False       20
3   True       11

Update positional metadata:

>>> seq.positional_metadata['gaps'] = seq.gaps()
>>> seq.positional_metadata
   exons  quality   gaps
0   True        3  False
1   True        3  False
2  False       20  False
3   True       11  False

Set positional metadata:

>>> seq.positional_metadata = {'degenerates': seq.degenerates()}
>>> seq.positional_metadata
  degenerates
0       False
1       False
2       False
3       False

Delete positional metadata:

>>> seq.has_positional_metadata()
True
>>> del seq.positional_metadata
>>> seq.positional_metadata
Empty DataFrame
Columns: []
Index: [0, 1, 2, 3]
>>> seq.has_positional_metadata()
False