Example #1
0
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
Example #2
0
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