Exemplo n.º 1
0
def test_compute_cn(output_folder):
    if solver_available():
        main(args=[
            '-x',
            f'{output_folder}/results',
            '-i',
            f'{this_dir}/data/bbc/bulk',
            '-n2',
            '-p',
            '100',
            '-v',
            '3',
            '-u',
            '0.03',
            '-r',
            '6700',  # random seed
            '-j',
            '8',
            '-eD',
            '6',
            '-eT',
            '12',
            '-g',
            '0.35',
            '-l',
            '0.6'
        ])

        df1 = pd.read_csv(f'{output_folder}/results/best.bbc.ucn', sep='\t')
        df2 = pd.read_csv(f'{this_dir}/data/results/best.bbc.ucn', sep='\t')
        assert_frame_equal(df1, df2)
Exemplo n.º 2
0
def test_solve_command_gurobi(output_folder):
    old_value = config.compute_cn.solver
    config.compute_cn.solver = 'gurobi'

    main(args=[
        '-x',
        os.path.join(output_folder), '-i',
        os.path.join(this_dir, 'data/bulk'), '-n2', '-p', '400', '-v', '3',
        '-u', '0.03', '--mode', '1', '-r', '6700', '-j', '8', '-eD', '6',
        '-eT', '12', '-g', '0.35', '-l', '0.6'
    ])

    df1 = pd.read_csv(os.path.join(output_folder, 'best.bbc.ucn'), sep='\t')
    df2 = pd.read_csv(os.path.join(this_dir, 'data', 'best.bbc.ucn'), sep='\t')
    assert_frame_equal(df1, df2)

    config.compute_cn.solver = old_value
Exemplo n.º 3
0
def test_script(_, bams, output_folder):
    normal_bam, tumor_bams = bams

    binBAM(
        args=[
            '-N', normal_bam,
            '-T'
        ] + tumor_bams + [
            '-b', '50kb',
            '-st', config.paths.samtools,
            '-S', 'Normal', 'Tumor1', 'Tumor2', 'Tumor3',
            '-g', config.paths.reference,
            '-j', '12',
            '-q', '11',
            '-O', os.path.join(output_folder, 'bin/normal.1bed'),
            '-o', os.path.join(output_folder, 'bin/bulk.1bed'),
            '-v'
        ]
    )

    SNPCaller(
        args=[
            '-N', normal_bam,
            '-r', config.paths.reference,
            '-c', '290',    # min reads
            '-C', '300',  # max reads
            '-R', '',
            '-o', os.path.join(output_folder, 'snps'),
            '-st', config.paths.samtools,
            '-bt', config.paths.bcftools,
            '-j', '1'
        ]
    )

    deBAF(
        args=[
            '-bt', config.paths.bcftools,
            '-st', config.paths.samtools,
            '-N', normal_bam,
            '-T'
        ] + tumor_bams + [
            '-S', 'Normal', 'Tumor1', 'Tumor2', 'Tumor3',
            '-r', config.paths.reference,
            '-j', '12',
            '-q', '11',
            '-Q', '11',
            '-U', '11',
            '-c', '8',
            '-C', '300',
            '-O', os.path.join(output_folder, 'baf/normal.1bed'),
            '-o', os.path.join(output_folder, 'baf/bulk.1bed'),
            '-L', os.path.join(output_folder, 'snps', 'chr22.vcf.gz'),
            '-v'
        ]
    )

    _stdout = sys.stdout
    sys.stdout = StringIO()

    comBBo(args=[
        '-c', os.path.join(output_folder, 'bin/normal.1bed'),
        '-C', os.path.join(output_folder, 'bin/bulk.1bed'),
        '-B', os.path.join(output_folder, 'baf/bulk.1bed'),
        '-e', '12'
    ])

    out = sys.stdout.getvalue()
    sys.stdout.close()
    sys.stdout = _stdout

    with open(os.path.join(output_folder, 'bb/bulk.bb'), 'w') as f:
        f.write(out)

    cluBB(args=[
        os.path.join(output_folder, 'bb/bulk.bb'),
        '-o', os.path.join(output_folder, 'bbc/bulk.seg'),
        '-O', os.path.join(output_folder, 'bbc/bulk.bbc'),
        '-e', '22171',  # random seed
        '-tB', '0.04',
        '-tR', '0.15',
        '-d', '0.4'
    ])

    df1 = pd.read_csv(os.path.join(output_folder, 'bbc/bulk.seg'), sep='\t')
    df2 = pd.read_csv(os.path.join(this_dir, 'data', 'bulk.seg'), sep='\t')
    assert_frame_equal(df1, df2)

    BBot(args=[
        os.path.join(output_folder, 'bbc/bulk.bbc'),
        '--rundir', os.path.join(output_folder, 'plots')
    ])

    if os.getenv('GRB_LICENSE_FILE') is not None:
        main(args=[
            SOLVE,
            '-x', os.path.join(output_folder, 'results'),
            '-i', os.path.join(output_folder, 'bbc/bulk'),
            '-n2',
            '-p', '400',
            '-v', '3',
            '-u', '0.03',
            '-r', '6700',  # random seed
            '-j', '8',
            '-eD', '6',
            '-eT', '12',
            '-g', '0.35',
            '-l', '0.6'
        ])

        df1 = pd.read_csv(os.path.join(output_folder, 'results/best.bbc.ucn'), sep='\t')
        df2 = pd.read_csv(os.path.join(this_dir, 'data', 'best.bbc.ucn'), sep='\t')
        assert_frame_equal(df1, df2)

        BBeval(args=[
            os.path.join(output_folder, 'results/best.bbc.ucn'),
            '--rundir', os.path.join(output_folder, 'evaluation')
        ])