예제 #1
0
    def test_group_in_packets(self):
        'It groups an iterator in packets of items'
        packets = [packet for packet in  group_in_packets(range(4), 2)]
        assert packets == [[0, 1], [2, 3]]

        packets = [packet for packet in  group_in_packets(range(5), 2)]
        assert packets == [[0, 1], [2, 3], [4]]

        packets = [packet for packet in  group_in_packets([], 2)]
        assert packets == []
예제 #2
0
    def test_group_in_packets(self):
        'It groups an iterator in packets of items'
        packets = list(group_in_packets(range(4), 2))
        assert packets == [(0, 1), (2, 3)]

        packets = [packet for packet in  group_in_packets(range(5), 2)]
        assert packets == [(0, 1), (2, 3), (4,)]

        packets = list(group_in_packets_fill_last(range(5), 2))
        assert packets == [(0, 1), (2, 3), (4, None)]

        packets = list(group_in_packets([], 2))
        assert packets == []
예제 #3
0
파일: seqio.py 프로젝트: fangly/seq_crumbs
def _read_seqrecord_packets(fhands, size=get_setting('PACKET_SIZE'),
                           file_format=GUESS_FORMAT):
    '''It yields SeqRecords in packets of the given size.'''
    seqs = _read_seqrecords(fhands, file_format=file_format)
    return group_in_packets(seqs, size)
예제 #4
0
파일: seqio.py 프로젝트: fangly/seq_crumbs
def read_seq_packets(fhands, size=get_setting('PACKET_SIZE'), out_format=None,
                     file_format=GUESS_FORMAT, prefered_seq_classes=None):
    '''It yields SeqItems in packets of the given size.'''
    seqs = read_seqs(fhands, file_format, out_format=out_format,
                     prefered_seq_classes=prefered_seq_classes)
    return group_in_packets(seqs, size)
예제 #5
0
def _read_seqrecord_packets(fhands, size=get_setting('PACKET_SIZE')):
    '''It yields SeqRecords in packets of the given size.'''
    seqs = _read_seqrecords(fhands)
    return group_in_packets(seqs, size)
예제 #6
0
def read_seq_packets(fhands, size=PACKET_SIZE, file_format=GUESS_FORMAT):
    '''It yields SeqRecords in packets of the given size.'''

    seqs = read_seqrecords(fhands, file_format=file_format)
    return group_in_packets(seqs, size)
예제 #7
0
def group_in_filter_packets(items, items_per_packet):
    for packet in group_in_packets(items, items_per_packet):
        yield {PASSED: packet, FILTERED_OUT: []}
예제 #8
0
def _read_seqrecord_packets(fhands, size=get_setting('PACKET_SIZE')):
    '''It yields SeqRecords in packets of the given size.'''
    seqs = _read_seqrecords(fhands)
    return group_in_packets(seqs, size)
예제 #9
0
def read_seq_packets(fhands, size=get_setting('PACKET_SIZE'), out_format=None,
                     prefered_seq_classes=None):
    '''It yields SeqItems in packets of the given size.'''
    seqs = read_seqs(fhands, out_format=out_format,
                     prefered_seq_classes=prefered_seq_classes)
    return group_in_packets(seqs, size)
예제 #10
0
파일: seqio.py 프로젝트: fastq/seq_crumbs
def _itemize_fastq(fhand):
    'It returns the fhand divided in chunks, one per seq'
    blobs = group_in_packets(filter(_line_is_not_empty, fhand), 4)
    return (SeqItem(_get_name_from_lines(lines), lines) for lines in blobs)
예제 #11
0
def group_in_filter_packets(items, items_per_packet):
    for packet in group_in_packets(items, items_per_packet):
        yield {PASSED: packet, FILTERED_OUT: []}
예제 #12
0
def _read_seqrecord_packets(fhands,
                            size=get_setting('PACKET_SIZE'),
                            file_format=GUESS_FORMAT):
    '''It yields SeqRecords in packets of the given size.'''
    seqs = _read_seqrecords(fhands, file_format=file_format)
    return group_in_packets(seqs, size)