Exemplo n.º 1
0
def test_write_to_barcode_meta_csv():
    bam_file = utils.get_test_data('10x-example/possorted_genome_bam.bam')
    with utils.TempDirectory() as location:
        single_barcode_fastas = tenx.bam_to_temp_fasta(
            barcodes=None,
            barcode_renamer=None,
            delimiter="X",
            bam_file=bam_file,
            temp_folder=location)
        single_barcode_fastas = "," .join(
            itertools.chain(single_barcode_fastas))
        all_fastas_sorted = tenx.get_fastas_per_unique_barcodes(
            single_barcode_fastas)
        tenx.barcode_umi_seq_to_fasta(
            location,
            "X",
            True,
            0,
            location,
            all_fastas_sorted)
        csv = os.path.join(location, "meta.csv")
        tenx.write_to_barcode_meta_csv(location, csv)
        umi_counts = [6, 2, 6, 4, 15, 5, 2, 2]
        read_counts = [312, 36, 251, 194, 594, 153, 2, 68]
        for index, row in pd.read_csv(csv).iterrows():
            assert umi_counts[index] == row[tenx.UMI_COUNT]
            assert read_counts[index] == row[tenx.READ_COUNT]
Exemplo n.º 2
0
def test_barcode_umi_seq_to_fasta():
    bam_file = utils.get_test_data('10x-example/possorted_genome_bam.bam')
    with utils.TempDirectory() as location:
        single_barcode_fastas = tenx.bam_to_temp_fasta(
            barcodes=None,
            barcode_renamer=None,
            delimiter="X",
            bam_file=bam_file,
            temp_folder=location)
        single_barcode_fastas = "," .join(
            itertools.chain(single_barcode_fastas))
        all_fastas_sorted = tenx.get_fastas_per_unique_barcodes(
            single_barcode_fastas)
        tenx.barcode_umi_seq_to_fasta(
            location,
            "X",
            True,
            10,
            location,
            all_fastas_sorted)
        fastas = glob.glob(
            os.path.join(location, "*_bam2fasta.fasta"))
        assert len(fastas) == 1
        meta_txts = glob.glob(
            os.path.join(location, "*_meta.txt"))
        assert len(meta_txts) == 8
Exemplo n.º 3
0
def test_filtered_bam_to_umi_fasta():
    bam_file = utils.get_test_data(
        '10x-example/possorted_genome_bam_filtered.bam')
    fastas = tenx.bam_to_temp_fasta(barcodes=None,
                                    barcode_renamer=None,
                                    delimiter='X',
                                    bam_file=bam_file)
    assert len(list(fastas)) == 32
Exemplo n.º 4
0
def test_bam_to_temp_fasta():
    filename = utils.get_test_data('10x-example/barcodes.tsv')
    bam_file = utils.get_test_data('10x-example/possorted_genome_bam.bam')
    barcodes = tenx.read_barcodes_file(filename)

    fastas = tenx.bam_to_temp_fasta(barcodes=barcodes,
                                    barcode_renamer=None,
                                    delimiter="X",
                                    bam_file=bam_file)
    assert len(list(fastas)) == 8
Exemplo n.º 5
0
def test_get_fastas_per_unique_barcodes():
    filename = utils.get_test_data('10x-example/barcodes.tsv')
    renamer_filename = utils.get_test_data('10x-example/barcodes_renamer.tsv')
    bam_file = utils.get_test_data('10x-example/possorted_genome_bam.bam')
    barcodes = tenx.read_barcodes_file(filename)

    with utils.TempDirectory() as location:

        all_fastas = tenx.bam_to_temp_fasta(
            barcodes=barcodes,
            barcode_renamer=renamer_filename,
            delimiter="X",
            bam_file=bam_file,
            temp_folder=location)
        all_fastas = ",".join(itertools.chain(all_fastas))
        fastas_sorted = tenx.get_fastas_per_unique_barcodes(all_fastas)
        assert len(fastas_sorted) == 8