Beispiel #1
0
    def test_old_version(self):

        records = read_records(self.sample_stream, min_version=3)

        self.assertRaisesRegexp(
            IOError,
            'File version 1 is less than minimum version 3 in test_file.',
            records.next)
    def test_old_version(self):

        records = read_records(self.sample_stream, min_version=3)

        self.assertRaisesRegex(
            IOError,
            'File version 1 is less than minimum version 3 in test_file.',
            records.__next__)
Beispiel #3
0
    def test_load_multiple_records(self):
        self.sample_data[1] = 2  # record size
        self.pack_data()
        expected_records = ['AB', 'CD']

        records = list(read_records(self.sample_stream, min_version=1))

        self.assertEqual(expected_records, records)
    def test_load_multiple_records(self):
        self.sample_data[1] = 2  # record size
        self.pack_data()
        expected_records = [b'AB', b'CD']

        records = list(read_records(self.sample_stream, min_version=1))

        self.assertEqual(expected_records, records)
Beispiel #5
0
    def test_partial_record(self):
        self.sample_data[1] = 3
        self.pack_data()
        records = read_records(self.sample_stream, min_version=1)
        record1 = records.next()

        self.assertEqual('ABC', record1)
        self.assertRaisesRegexp(
            IOError, 'Partial record of length 1 found in test_file.',
            records.next)
    def test_partial_record(self):
        self.sample_data[1] = 3
        self.pack_data()
        records = read_records(self.sample_stream, min_version=1)
        record1 = next(records)

        self.assertEqual(b'ABC', record1)
        self.assertRaisesRegex(
            IOError,
            'Partial record of length 1 found in test_file.',
            records.__next__)
Beispiel #7
0
def read_tiles(data_file):
    """ Read a tile metrics data file.

    :param file data_file: an open file-like object. Needs to have a two-byte
    header with the file version and the length of each record, followed by the
    records.
    :return: an iterator over the records of data in the file. Each record is a
    dictionary with the following keys:
    - lane [uint16]
    - tile [uint16]
    - metric_code [uint16]
    - metric_value [float32]
    """
    PARSED_LENGTH = 10
    format_string = '<HHHf'
    for data in read_records(data_file, min_version=2):
        fields = unpack(format_string, data[:PARSED_LENGTH])
        yield dict(lane=fields[0],
                   tile=fields[1],
                   metric_code=fields[2],
                   metric_value=fields[3])
Beispiel #8
0
def read_quality(data_file):
    """ Read a quality metrics data file.

    :param file data_file: an open file-like object. Needs to have a two-byte
    header with the file version and the length of each record, followed by the
    records.
    :return: an iterator over the records of data in the file. Each record is a
    dictionary with the following keys:
    - lane [uint16]
    - tile [uint16]
    - cycle [uint16]
    - quality_bins [list of 50 uint32, representing quality 1 to 50]
    """
    PARSED_LENGTH = 206
    format_string = '<HHH' + 'L' * 50
    for data in read_records(data_file, min_version=4):
        fields = unpack(format_string, data[:PARSED_LENGTH])
        yield dict(lane=fields[0],
                   tile=fields[1],
                   cycle=fields[2],
                   quality_bins=fields[3:])
def read_quality(data_file):
    """ Read a quality metrics data file.

    :param file data_file: an open file-like object. Needs to have a two-byte
    header with the file version and the length of each record, followed by the
    records.
    :return: an iterator over the records of data in the file. Each record is a
    dictionary with the following keys:
    - lane [uint16]
    - tile [uint16]
    - cycle [uint16]
    - quality_bins [list of 50 uint32, representing quality 1 to 50]
    """
    PARSED_LENGTH = 206
    format_string = '<HHH' + 'L'*50
    for data in read_records(data_file, min_version=4):
        fields = unpack(format_string, data[:PARSED_LENGTH])
        yield dict(lane=fields[0],
                   tile=fields[1],
                   cycle=fields[2],
                   quality_bins=fields[3:])
Beispiel #10
0
def read_tiles(data_file):
    """ Read a tile metrics data file.

    :param file data_file: an open file-like object. Needs to have a two-byte
    header with the file version and the length of each record, followed by the
    records.
    :return: an iterator over the records of data in the file. Each record is a
    dictionary with the following keys:
    - lane [uint16]
    - tile [uint16]
    - metric_code [uint16]
    - metric_value [float32]
    """
    PARSED_LENGTH = 10
    format_string = '<HHHf'
    for data in read_records(data_file, min_version=2):
        fields = unpack(format_string, data[:PARSED_LENGTH])
        yield dict(lane=fields[0],
                   tile=fields[1],
                   metric_code=fields[2],
                   metric_value=fields[3])
Beispiel #11
0
    def test_load(self):
        expected_records = ['ABCD']

        records = list(read_records(self.sample_stream, min_version=1))

        self.assertEqual(expected_records, records)
    def test_load(self):
        expected_records = [b'ABCD']

        records = list(read_records(self.sample_stream, min_version=1))

        self.assertEqual(expected_records, records)