classmethod IntervalMetadata.concat(interval_metadata)[source]

Concatenate an iterable of IntervalMetadata objects.

State: Experimental as of 0.5.1.

It concatenates the multiple IntervalMetadata objects into one coordinate space. The order of the objects in the input iterable matters. The coordinate of the second InterableMetadata will be shifted up with the length of the first IntervalMetadata object.

This function is useful when you concatenate multiple sequences.

Parameters:interval_metadata (Iterable (IntervalMetadata)) – The interval metadata to concatenate.
Returns:Concatenated interval metadata.
Return type:IntervalMetadata


>>> from skbio.metadata import IntervalMetadata

Create two IntervalMetadata objects:

>>> im1 = IntervalMetadata(3)
>>> _ = im1.add([(0, 2)], [(True, False)], {'gene': 'sagA'})
>>> im2 = IntervalMetadata(4)
>>> _ = im2.add([(1, 4)], [(True, True)], {'gene': 'sagB'})

Concatenate them into a single coordinate space. The second IntervalMetadata’s interval features are all shifted up. The resulting IntervalMetadata’s upper bound is the sum of upper bounds of concatenated objects:

>>> im = IntervalMetadata.concat([im1, im2])
>>> im   # doctest: +ELLIPSIS
2 interval features
Interval(interval_metadata=<...>, bounds=[(0, 2)], fuzzy=[(True, False)], metadata={'gene': 'sagA'})
Interval(interval_metadata=<...>, bounds=[(4, 7)], fuzzy=[(True, True)], metadata={'gene': 'sagB'})
>>> im.upper_bound