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 == []
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 == []
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)
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)
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)
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)
def group_in_filter_packets(items, items_per_packet): for packet in group_in_packets(items, items_per_packet): yield {PASSED: packet, FILTERED_OUT: []}
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)
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)