Ejemplo n.º 1
0
def main(outdir, r1, r2, barcodes, no_trim, overwrite, prefix, max_mismatches):
    r"""
    Demultiplex a paired-end fastq file into several based on unique barcodes.

    The barcodes are sequences attached at the beginning of each read.
    By default, it trimms the barcodes off the demultiplexed reads,
    unless --no-trim is passed.

    The barcodes text file should be formatted to have 1 column with
    the barcodes, and an optional additional column to assign names to
    the demultiplexed result files.  the following structure:

        \b
        ATTCGT       A1
        ATATTC       A2
        TCGGAC       B1
        TCGAGG       B2
    """
    prefix = prefix if prefix.endswith('_') else f'{prefix}_'

    commands.demultiplex(
        barcodes_path=barcodes,
        max_mismatches=max_mismatches,
        no_trim=no_trim,
        prefix=prefix,
        output_dir=outdir,
        overwrite=overwrite,
        r1_path=r1,
        r2_path=r2,
    )
Ejemplo n.º 2
0
def test_prefix(tmpdir):
    params = {
        'barcodes_path': TEST_BARCODES,
        'max_mismatches': 1,
        'not_trim': True,
        'output_dir': tmpdir.strpath,
        'overwrite': True,
        'prefix': 'my_weird_prefix',
        'r1_path': TEST_R1,
        'r2_path': TEST_R2,
    }
    commands.demultiplex(*params.values())
    assert_output(**params)
Ejemplo n.º 3
0
def test_overwrite(tmpdir):
    params = {
        'barcodes_path': TEST_BARCODES,
        'max_mismatches': 1,
        'not_trim': False,
        'output_dir': tmpdir.strpath,
        'overwrite': True,
        'prefix': '',
        'r1_path': TEST_R1,
        'r2_path': TEST_R2,
    }
    commands.demultiplex(*params.values())
    commands.demultiplex(*params.values())

    params['overwrite'] = False
    with pytest.raises(click.UsageError) as excinfo:
        commands.demultiplex(*params.values())
    assert 'pass --overwrite as an option' in excinfo.value.message