pybedtools.bedtool.BedTool.with_attrs

BedTool.with_attrs(*args, **kwargs)[source]

Helper method for adding attributes in the middle of a pipeline.

Given arbitrary keyword arguments, turns the keys and values into attributes. Useful for labeling BedTools at creation time.

Example usage:

>>> # add a "label" attribute to each BedTool
>>> a = pybedtools.example_bedtool('a.bed')                                   .with_attrs(label='transcription factor 1')
>>> b = pybedtools.example_bedtool('b.bed')                                   .with_attrs(label='transcription factor 2')
>>> for i in [a, b]:
...     print('{0} features for {1}'.format(i.count(), i.label))
4 features for transcription factor 1
2 features for transcription factor 2