async def test_bowtie_mappings(tests_config, event_loop, chrom): event_loop.set_debug(True) pipeline = MappableRegionsPipeline(tests_config) bowtie = await pipeline.async_start_bowtie() reads_generator = pipeline.generate_reads([chrom], 100) writer = asyncio.Task( pipeline.async_write_reads_generator(bowtie.stdin, reads_generator)) infile = bowtie.stdout while True: line = await infile.readline() if not line: break line = line.decode() if line[0] == '@': # comment continue mapping = Mapping.parse_sam(line) if mapping.flag == 0: # print(mapping) chromosome, pos = mapping.name.split('.') assert int(pos) == mapping.start assert chrom == chromosome await writer
async def test_generate_reads(tests_config): pipeline = MappableRegionsPipeline(tests_config) generator = pipeline.generate_reads(['chr1'], 100) for num, rec in enumerate(generator): print(rec.id, len(rec)) if num >= 10: break generator.close()
def test_reads_generator(tests_config): pipeline = MappableRegionsPipeline(tests_config) reads_generator = pipeline.generate_reads(['chrM'], 100) # ouptut_writer = pipeline.mappable_regions_writer() count = 0 for _read in reads_generator: # print(read) count += 1 print(count) assert 16472 == count
async def test_async_mappings_generator(tests_config, event_loop): # Enable debugging event_loop.set_debug(True) pipeline = MappableRegionsPipeline(tests_config) bowtie = await pipeline.async_start_bowtie() reads_generator = pipeline.generate_reads(['chrM'], 100) writer = asyncio.Task( pipeline.async_write_reads_generator(bowtie.stdin, reads_generator)) async for mapping in pipeline.async_mappable_regions_generator( bowtie.stdout): print(mapping) await bowtie.wait() await writer