Public Member Functions | Public Attributes

bbcflib::btrack::FeatureStream Class Reference

List of all members.

Public Member Functions

def __init__
def __iter__
def next

Public Attributes

 data
 fields

Detailed Description

Contains an iterator yielding features, and an extra fields attribute.
It can be constructed from either an iterator, a cursor, a list or a tuple.

Example::

    stream = FeatureStream([('chr',1,2),('chr',3,4)])
    stream = FeatureStream((('chr',1,2),('chr',3,4)))
    stream = FeatureStream(iter([('chr',1,2),('chr',3,4)]))

    def gen():
        for k in range(2):
            yield ('chr',2*k+1,2*k+2)

    stream = FeatureStream(gen())

Example of usage::

    >>> stream = FeatureStream([('chr',1,2),('chr',3,4)], fields=['chromosome','start','end'])
    >>> stream.next()
    ('chr', 1, 2)
    >>> stream.next()
    ('chr', 3, 4)
    >>> stream.data
    <listiterator object at 0x10183b650>

    >>> stream = FeatureStream([('chr',1,2),('chr',3,4)], fields=['chromosome','start','end'])
    >>> for s in stream: print s
    ('chr', 1, 2)
    ('chr', 3, 4)

.. attribute:: data

    An iterator, or cursor.

.. attribute:: fields

    The list of field names.

.. method:: __iter__()

    ``iter(self)`` returns self.data, which is an iterator itself.

.. method:: next()

    Iterating over the stream is iterating over its data.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions