コード例 #1
0
def test_one_matrix():
    outfile = NamedTemporaryFile(suffix='.hdf5', delete=False)
    outfile.close()
    args = "--matrices {} --referencePoints {} --backgroundModel {} --range {} {} -o {} -t {}".format(
        ROOT + 'FL-E13-5_chr1.cool',
        ROOT + 'referencePoints_chicViewpoint.bed', ROOT + 'background.txt',
        200000, 200000, outfile.name, 1).split()
    chicViewpoint.main(args)

    interactionFileH5Object = h5py.File(outfile.name, 'r')
    assert 'FL-E13-5_chr1' in interactionFileH5Object
    assert len(interactionFileH5Object) == 1

    assert 'genes' in interactionFileH5Object['FL-E13-5_chr1']

    assert interactionFileH5Object.attrs['type'] == 'interactions'
    assert len(interactionFileH5Object.attrs['range']) == 2
    assert interactionFileH5Object.attrs['range'][0] == 200000
    assert interactionFileH5Object.attrs['range'][1] == 200000
    assert interactionFileH5Object.attrs['averageContactBin'] == 5
    assert interactionFileH5Object.attrs['fixateRange'] == 500000
    for chromosome in interactionFileH5Object['FL-E13-5_chr1']:
        assert len(interactionFileH5Object['FL-E13-5_chr1'][chromosome]) == 3
        for gene in interactionFileH5Object['FL-E13-5_chr1'][chromosome]:
            assert len(interactionFileH5Object['FL-E13-5_chr1'][chromosome]
                       [gene]) == 12
            for data in interactionFileH5Object['FL-E13-5_chr1'][chromosome][
                    gene]:
                assert data in [
                    'chromosome', 'end_list', 'gene', 'interaction_data_list',
                    'pvalue', 'raw', 'reference_point_end',
                    'reference_point_start', 'relative_position_list',
                    'start_list', 'sum_of_interactions', 'xfold'
                ]
コード例 #2
0
def test_one_matrix():
    outfile = NamedTemporaryFile(suffix='.bed', delete=False)
    output_folder = mkdtemp(prefix="output_")
    outfile.close()
    args = "--matrices {} --referencePoints {} --backgroundModel {} --range {} {} -o {}".format(
        ROOT + 'FL-E13-5_chr1.cool',
        ROOT + 'referencePoints_chicViewpoint.bed', ROOT + 'background.bed',
        200000, 200000, output_folder).split()
    chicViewpoint.main(args)

    assert are_files_equal(
        ROOT +
        "chicViewpoint/output_2/FL-E13-5_chr1_chr1_4487435_4487435_Sox17.bed",
        output_folder + '/FL-E13-5_chr1_chr1_4487435_4487435_Sox17.bed',
        skip=4)
    assert are_files_equal(
        ROOT +
        "chicViewpoint/output_2/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.bed",
        output_folder + '/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.bed',
        skip=4)
    assert are_files_equal(
        ROOT +
        "chicViewpoint/output_2/FL-E13-5_chr1_chr1_19093103_19093103_Tfap2d.bed",
        output_folder + '/FL-E13-5_chr1_chr1_19093103_19093103_Tfap2d.bed',
        skip=4)

    assert set(os.listdir(ROOT + "chicViewpoint/output_2/")) == set(
        os.listdir(output_folder))
コード例 #3
0
def test_two_matrices_writeFileName_crash():
    outfile = NamedTemporaryFile(suffix='.txt', delete=False)
    outfile_name_list = NamedTemporaryFile(suffix='.txt', delete=False)

    output_folder = mkdtemp(prefix="output_")
    outfile.close()
    args = "--matrices {} {} --referencePoints {} --backgroundModel {} --range {} {} -o {} -w {} -t {} --decimalPlaces {}".format(
        ROOT + 'FL-E13-5_chr1.cool', ROOT + 'MB-E10-5_chr1.cool',
        ROOT + 'referencePoints_chicViewpoint_crash.bed',
        ROOT + 'background.txt', 200000, 200000, output_folder,
        outfile_name_list.name, 1, 5).split()
    chicViewpoint.main(args)
    assert are_files_equal(ROOT + "chicViewpoint/fileNames_two_matrices.txt",
                           outfile_name_list.name)

    assert are_files_equal(
        ROOT +
        "chicViewpoint/output_3/FL-E13-5_chr1_chr1_4487435_4487435_Sox17.txt",
        output_folder + '/FL-E13-5_chr1_chr1_4487435_4487435_Sox17.txt',
        skip=4)
    assert are_files_equal(
        ROOT +
        "chicViewpoint/output_3/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.txt",
        output_folder + '/FL-E13-5_chr1_chr1_14300280_14300280_Eya1.txt',
        skip=4)
    assert are_files_equal(
        ROOT +
        "chicViewpoint/output_3/FL-E13-5_chr1_chr1_19093103_19093103_Tfap2d.txt",
        output_folder + '/FL-E13-5_chr1_chr1_19093103_19093103_Tfap2d.txt',
        skip=4)
    assert are_files_equal(
        ROOT +
        "chicViewpoint/output_3/MB-E10-5_chr1_chr1_4487435_4487435_Sox17.txt",
        output_folder + '/MB-E10-5_chr1_chr1_4487435_4487435_Sox17.txt',
        skip=4)
    assert are_files_equal(
        ROOT +
        "chicViewpoint/output_3/MB-E10-5_chr1_chr1_14300280_14300280_Eya1.txt",
        output_folder + '/MB-E10-5_chr1_chr1_14300280_14300280_Eya1.txt',
        skip=4)
    assert are_files_equal(
        ROOT +
        "chicViewpoint/output_3/MB-E10-5_chr1_chr1_19093103_19093103_Tfap2d.txt",
        output_folder + '/MB-E10-5_chr1_chr1_19093103_19093103_Tfap2d.txt',
        skip=4)

    assert set(os.listdir(ROOT + "chicViewpoint/output_3/")) == set(
        os.listdir(output_folder))