Ejemplo n.º 1
0
def test_count_g_a_change():
    """
    """
    in_file = "data_c_t_change.fasta"
    ref_seq = get_ref(in_file)
    cg_posits = get_cg_posits_in_ref(ref_seq)
    num_c_t_change_in_reads = count_c_t_change(in_file, cg_posits)
    num_g_a_change_in_reads = count_g_a_change(in_file, cg_posits)
    assert num_c_t_change_in_reads == 4
    assert num_g_a_change_in_reads == 0

    in_file = "data_g_a_change.fasta"
    ref_seq = get_ref(in_file)
    cg_posits = get_cg_posits_in_ref(ref_seq)
    num_c_t_change_in_reads = count_c_t_change(in_file, cg_posits)
    num_g_a_change_in_reads = count_g_a_change(in_file, cg_posits)
    assert num_c_t_change_in_reads == 0
    assert num_g_a_change_in_reads == 4

    in_file = "data_cg_ta_change.fasta"
    ref_seq = get_ref(in_file)
    cg_posits = get_cg_posits_in_ref(ref_seq)
    num_c_t_change_in_reads = count_c_t_change(in_file, cg_posits)
    num_g_a_change_in_reads = count_g_a_change(in_file, cg_posits)
    assert num_c_t_change_in_reads == 4
    assert num_g_a_change_in_reads == 4
Ejemplo n.º 2
0
def test_count_total_c_and_g_in_reads():
    """
    """
    in_file = "data_c_pos.fasta"
    ref_seq = get_ref(in_file)
    ref_name = get_ref_name(in_file)
    cg_posits = get_cg_posits_in_ref(ref_seq)
    num_reads_in_file = get_num_of_reads_in_file(in_file)
    num_c_in_ref, num_g_in_ref = count_num_of_c_and_g_in_ref(cg_posits)
    total_num_c_in_reads, total_num_g_in_reads = count_total_c_and_g_in_reads(
        ref_name, cg_posits, in_file)
    assert total_num_c_in_reads == 12
    assert total_num_g_in_reads == 0

    in_file = "data_g_pos.fasta"
    ref_seq = get_ref(in_file)
    ref_name = get_ref_name(in_file)
    cg_posits = get_cg_posits_in_ref(ref_seq)
    num_reads_in_file = get_num_of_reads_in_file(in_file)
    num_c_in_ref, num_g_in_ref = count_num_of_c_and_g_in_ref(cg_posits)
    total_num_c_in_reads, total_num_g_in_reads = count_total_c_and_g_in_reads(
        ref_name, cg_posits, in_file)
    assert total_num_c_in_reads == 0
    assert total_num_g_in_reads == 12

    in_file = "data_cg_pos.fasta"
    ref_seq = get_ref(in_file)
    ref_name = get_ref_name(in_file)
    cg_posits = get_cg_posits_in_ref(ref_seq)
    num_reads_in_file = get_num_of_reads_in_file(in_file)
    num_c_in_ref, num_g_in_ref = count_num_of_c_and_g_in_ref(cg_posits)
    total_num_c_in_reads, total_num_g_in_reads = count_total_c_and_g_in_reads(
        ref_name, cg_posits, in_file)
    assert total_num_c_in_reads == 12
    assert total_num_g_in_reads == 12
Ejemplo n.º 3
0
def test_get_cg_positions():
    """
    """

    ref_seq = get_ref("data_cg_pos.fasta")

    d = get_cg_posits_in_ref(ref_seq)

    assert d["C_pos"][0] == 0
    assert d["C_pos"][1] == 2
    assert d["C_pos"][2] == 4
    assert d["C_pos"][3] == 6
    assert d["G_pos"][0] == 1
    assert d["G_pos"][1] == 3
    assert d["G_pos"][2] == 5
    assert d["G_pos"][3] == 7
    
    




    

   
    
Ejemplo n.º 4
0
def test_calculate_total_percent_c_t_g_a_change_10_15_15():
    """
    """
    test_percent_files = [
        "data_ct_10_ga_10.fasta", "data_ct_20_ga_10.fasta",
        "data_ct_10_ga_20.fasta", "data_ct_1_ga_10.fasta"
    ]
    results = [10, 15, 15, 5.5]
    counter = 0
    for file in test_percent_files:
        in_file = file  #
        ref_seq = get_ref(in_file)
        ref_name = get_ref_name(in_file)
        cg_posits = get_cg_posits_in_ref(ref_seq)

        num_reads_in_file = get_num_of_reads_in_file(in_file)
        num_c_in_ref, num_g_in_ref = count_num_of_c_and_g_in_ref(cg_posits)
        total_num_c_in_reads, total_num_g_in_reads = count_total_c_and_g_in_reads(
            ref_name, cg_posits, in_file)
        num_c_t_change_in_reads = count_c_t_change(in_file, cg_posits)
        num_g_a_change_in_reads = count_g_a_change(in_file, cg_posits)

        percent_c_t_change = calculate_percent_c_t_change(
            num_c_t_change_in_reads, total_num_c_in_reads, num_c_in_ref)
        percent_g_a_change = calculate_percent_g_a_change(
            num_g_a_change_in_reads, total_num_g_in_reads, num_g_in_ref)

        c_t_and_g_a_change_percent = calculate_c_t_and_g_a_change_percent(
            total_num_c_in_reads, total_num_g_in_reads,
            num_c_t_change_in_reads, num_g_a_change_in_reads)
        assert c_t_and_g_a_change_percent == results[counter]
        counter += 1
Ejemplo n.º 5
0
def test_calculate_percent_c_t_change():
    """
    """
    in_file = "data_c_t_10_percent_change.fasta"  #
    ref_seq = get_ref(in_file)
    ref_name = get_ref_name(in_file)
    cg_posits = get_cg_posits_in_ref(ref_seq)

    num_reads_in_file = get_num_of_reads_in_file(in_file)
    num_c_in_ref, num_g_in_ref = count_num_of_c_and_g_in_ref(cg_posits)
    total_num_c_in_reads, total_num_g_in_reads = count_total_c_and_g_in_reads(
        ref_name, cg_posits, in_file)

    num_c_t_change_in_reads = count_c_t_change(in_file, cg_posits)
    num_g_a_change_in_reads = count_g_a_change(in_file, cg_posits)

    percent_c_t_change = calculate_percent_c_t_change(num_c_t_change_in_reads,
                                                      total_num_c_in_reads,
                                                      num_c_in_ref)
    percent_g_a_change = calculate_percent_g_a_change(num_g_a_change_in_reads,
                                                      total_num_g_in_reads,
                                                      num_g_in_ref)

    assert percent_c_t_change == 10
    assert percent_g_a_change == "no G in reference"
Ejemplo n.º 6
0
def test_count_num_of_c_and_g_in_ref():
    """
    """
    in_file = "data_c_pos.fasta"
    ref_seq = get_ref(in_file)
    cg_posits = get_cg_posits_in_ref(ref_seq)
    num_c_in_ref, num_g_in_ref = count_num_of_c_and_g_in_ref(cg_posits)
    assert num_c_in_ref == 4
    assert num_g_in_ref == 0

    in_file = "data_g_pos.fasta"
    ref_seq = get_ref(in_file)
    cg_posits = get_cg_posits_in_ref(ref_seq)
    num_c_in_ref, num_g_in_ref = count_num_of_c_and_g_in_ref(cg_posits)
    assert num_c_in_ref == 0
    assert num_g_in_ref == 4

    in_file = "data_cg_pos.fasta"
    ref_seq = get_ref(in_file)
    cg_posits = get_cg_posits_in_ref(ref_seq)
    num_c_in_ref, num_g_in_ref = count_num_of_c_and_g_in_ref(cg_posits)
    assert num_c_in_ref == 4
    assert num_g_in_ref == 4