def test_yield_fast5_reads_set_versus_list_equality(self):
        f5_read_gen_by_id_set = yield_fast5_reads(self.fast5_path,
                                                  recursive=False,
                                                  read_ids=self.read_id_set)

        f5_read_gen_by_id_list = yield_fast5_reads(self.fast5_path,
                                                   recursive=False,
                                                   read_ids=self.read_id_list)

        # Consume the generators into sets
        ids_by_set = set(rid for rid, _ in f5_read_gen_by_id_set)
        ids_by_list = set(rid for rid, _ in f5_read_gen_by_id_list)
        self.assertTrue(ids_by_list == ids_by_set,
                        'Ids differ when using read_id list versus set')
 def test_yield_fast5_reads_with_garbage_set(self):
     f5_read_gen = yield_fast5_reads(self.fast5_path,
                                     recursive=False,
                                     read_ids={'_g4rbag£_'})
     f5_reads = list(f5_read_gen)
     self.assertTrue(
         len(f5_reads) == 0, "Garbage read_ids returned non-zero reads")
    def test_yield_fast5_reads_with_empty_set(self):
        f5_read_gen = yield_fast5_reads(self.fast5_path,
                                        recursive=False,
                                        read_ids=set([]))

        self.assertTrue(
            len(list(f5_read_gen)) != 0,
            "Empty read_ids resulted in zero returned reads")
    def test_yield_fast5_reads_with_list(self):
        f5_read_gen = yield_fast5_reads(self.fast5_path,
                                        recursive=False,
                                        read_ids=self.read_id_set)
        f5_reads = list(f5_read_gen)
        self.assertTrue(len(f5_reads) == len(self.read_id_list))

        for read_id, read_data in f5_reads:
            self.assertTrue(read_id in self.read_id_set,
                            "A read_id is not a member of read_id_list")
            self.assertTrue(isinstance(read_data, Fast5Read),
                            "Return is not Fast5Read instance")
 def test_yield_fast5_reads_from_dir(self):
     f5_read_gen = yield_fast5_reads(test_data, recursive=False)
     read_id, read_data = next(f5_read_gen)
     self.assertTrue(read_id is not None, "read_id is None")
     self.assertTrue(isinstance(read_data, Fast5Read),
                     "Return is not Fast5Read instance")
 def test_yield_fast5_reads_type_error(self):
     with self.assertRaisesRegex(TypeError, 'read_ids'):
         f5_read_gen = yield_fast5_reads(self.fast5_path,
                                         recursive=False,
                                         read_ids=int(1))
         next(f5_read_gen)