def test_count_indels_single_del_from_tail():

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "2_dels_single_del_from_tail.fasta")
    cov = count_indels._get_coverage("2_dels_single_del_from_tail.fasta")
    total_dels = count_indels._count_dels("2_dels_single_del_from_tail.fasta",
                                          ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins("2_dels_single_del_from_tail.fasta",
                                        ref_seq, ref_seq_id, cov)

    assert total_dels[0][0] == 1
    assert total_dels[1][0] == 1
    assert total_dels[2][0] == 1
    assert total_dels[3][0] == 1
    assert total_dels[4][0] == 1
    assert total_dels[5][0] == 1
    assert total_dels[6][0] == 1
    assert total_dels[7][0] == 1
    assert total_dels[8][0] == 1
    assert total_dels[9][0] == 1

    assert total_ins[0] == []
    assert total_ins[1] == []
    assert total_ins[2] == []
    assert total_ins[3] == []
    assert total_ins[4] == []
    assert total_ins[5] == []
    assert total_ins[6] == []
    assert total_ins[7] == []
    assert total_ins[8] == []
    assert total_ins[9] == []
def test_count_indels_insertions_var_lens_ladder_forward():
    #ref_seq, total_dels, total_ins, cov = count_indels._count_indels("10_ins_ladder_forward.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "10_ins_ladder_forward.fasta")
    cov = count_indels._get_coverage("10_ins_ladder_forward.fasta")
    total_dels = count_indels._count_dels("10_ins_ladder_forward.fasta",
                                          ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins("10_ins_ladder_forward.fasta", ref_seq,
                                        ref_seq_id, cov)

    #assert total_ins[0][0] == 0
    assert total_ins[1][0] == 1
    assert total_ins[2][0] == 2
    assert total_ins[3][0] == 3
    assert total_ins[4][0] == 4
    assert total_ins[5][0] == 3

    # check if there's one insertion under each position
    assert len(total_ins[0]) == 0
    assert len(total_ins[1]) == 1
    assert len(total_ins[2]) == 1
    assert len(total_ins[3]) == 1
    assert len(total_ins[4]) == 1
    assert len(total_ins[5]) == 1

    assert total_dels[0] == []
    assert total_dels[1] == []
    assert total_dels[2] == []
    assert total_dels[3] == []
    assert total_dels[4] == []
    assert total_dels[5] == []
def test_count_indels_insertions_var_lens_ladder():
    #ref_seq, total_dels, total_ins, cov = count_indels._count_indels("11_ins_ladder.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq("11_ins_ladder.fasta")
    cov = count_indels._get_coverage("11_ins_ladder.fasta")
    total_dels = count_indels._count_dels("11_ins_ladder.fasta", ref_seq,
                                          ref_seq_id, cov)
    total_ins = count_indels._count_ins("11_ins_ladder.fasta", ref_seq,
                                        ref_seq_id, cov)

    assert total_ins[1][0] == 1
    assert total_ins[1][1] == 1
    assert total_ins[2][0] == 2
    assert total_ins[2][1] == 2
    assert total_ins[3][0] == 3
    assert total_ins[3][1] == 3
    assert total_ins[4][0] == 4
    assert total_ins[4][1] == 4
    assert total_ins[5][0] == 3

    assert len(total_ins[0]) == 0
    assert len(total_ins[1]) == 2
    assert len(total_ins[2]) == 2
    assert len(total_ins[3]) == 2
    assert len(total_ins[4]) == 2
    assert len(total_ins[5]) == 1

    assert total_dels[0] == []
    assert total_dels[1] == []
    assert total_dels[2] == []
    assert total_dels[3] == []
    assert total_dels[4] == []
    assert total_dels[5] == []
def test_create_plots_create_matrix_insertions_percent():
    #ref_seq, total_dels, total_ins, cov = crispr_count_indels._count_indels("16_ins_ladder_for_matrix.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "16_ins_ladder_for_matrix.fasta")
    cov = count_indels._get_coverage("16_ins_ladder_for_matrix.fasta")
    total_dels = count_indels._count_dels("16_ins_ladder_for_matrix.fasta",
                                          ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins("16_ins_ladder_for_matrix.fasta",
                                        ref_seq, ref_seq_id, cov)

    df_dels = count_indels._create_df(ref_seq, total_dels)
    df_ins = count_indels._create_df(ref_seq, total_ins)
    df_cov = count_indels._create_df_cov(cov)

    count_indels._save_df(df_dels, df_ins, df_cov,
                          "16_ins_ladder_for_matrix.fasta")

    insertion_matrix = create_matrices._create_matrix(
        "16_ins_ladder_for_matrix.xlsx", "insertions")

    insertion_matrix_percent = create_matrices._create_matrix_percent(
        "16_ins_ladder_for_matrix.xlsx", insertion_matrix, cov, "insertions")

    assert insertion_matrix_percent.iloc[3, 1] == 30
    assert insertion_matrix_percent.iloc[2, 2] == 20
    assert insertion_matrix_percent.iloc[1, 3] == 20
    assert insertion_matrix_percent.iloc[0, 4] == 20
    assert insertion_matrix_percent.iloc[1, 5] == 10

    # column 0
    assert insertion_matrix_percent.iloc[0, 0] == 0
    assert insertion_matrix_percent.iloc[1, 0] == 0
    assert insertion_matrix_percent.iloc[2, 0] == 0
    assert insertion_matrix_percent.iloc[3, 0] == 0

    # column 1
    assert insertion_matrix_percent.iloc[0, 1] == 0
    assert insertion_matrix_percent.iloc[1, 1] == 0
    assert insertion_matrix_percent.iloc[2, 1] == 0

    # column 2
    assert insertion_matrix_percent.iloc[0, 2] == 0
    assert insertion_matrix_percent.iloc[1, 2] == 0
    assert insertion_matrix_percent.iloc[3, 2] == 0

    # column 3
    assert insertion_matrix_percent.iloc[0, 3] == 0
    assert insertion_matrix_percent.iloc[2, 3] == 0
    assert insertion_matrix_percent.iloc[3, 3] == 0

    # column 4
    assert insertion_matrix_percent.iloc[1, 4] == 0
    assert insertion_matrix_percent.iloc[2, 4] == 0
    assert insertion_matrix_percent.iloc[3, 4] == 0

    return insertion_matrix_percent
def test_count_indels_hang_from_tail_various_len():

    #ref_seq, total_dels, total_ins, cov = count_indels._count_indels("6_dels_hanging_from_tail_var_len.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "6_dels_hanging_from_tail_var_len.fasta")
    cov = count_indels._get_coverage("6_dels_hanging_from_tail_var_len.fasta")
    total_dels = count_indels._count_dels(
        "6_dels_hanging_from_tail_var_len.fasta", ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins(
        "6_dels_hanging_from_tail_var_len.fasta", ref_seq, ref_seq_id, cov)

    #assert total_dels[0][0] == 10
    assert total_dels[1][0] == 9
    assert total_dels[2][0] == 8
    assert total_dels[3][0] == 7
    assert total_dels[4][0] == 6
    assert total_dels[5][0] == 5
    assert total_dels[6][0] == 4
    assert total_dels[7][0] == 3
    assert total_dels[8][0] == 2
    assert total_dels[9][0] == 1

    # only one del at each entry
    assert len(total_dels[0]) == 0
    assert len(total_dels[1]) == 1
    assert len(total_dels[2]) == 1
    assert len(total_dels[3]) == 1
    assert len(total_dels[4]) == 1
    assert len(total_dels[5]) == 1
    assert len(total_dels[6]) == 1
    assert len(total_dels[7]) == 1
    assert len(total_dels[8]) == 1
    assert len(total_dels[9]) == 1

    assert total_ins[0] == []
    assert total_ins[1] == []
    assert total_ins[2] == []
    assert total_ins[3] == []
    assert total_ins[4] == []
    assert total_ins[5] == []
    assert total_ins[6] == []
    assert total_ins[7] == []
    assert total_ins[8] == []
    assert total_ins[9] == []
def test_count_indels_del_ladder():

    #ref_seq, total_dels, total_ins, cov = count_indels._count_indels("7_dels_ladder.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq("7_dels_ladder.fasta")
    cov = count_indels._get_coverage("7_dels_ladder.fasta")
    total_dels = count_indels._count_dels("7_dels_ladder.fasta", ref_seq,
                                          ref_seq_id, cov)
    total_ins = count_indels._count_ins("7_dels_ladder.fasta", ref_seq,
                                        ref_seq_id, cov)

    assert total_dels[0][0] == 1
    assert total_dels[1][0] == 2
    assert total_dels[2][0] == 3
    assert total_dels[3][0] == 4
    assert total_dels[4][0] == 5
    assert total_dels[5][0] == 5
    assert total_dels[6][0] == 4
    assert total_dels[7][0] == 3
    assert total_dels[8][0] == 2
    assert total_dels[9][0] == 1

    # only one del at each entry
    assert len(total_dels[0]) == 1
    assert len(total_dels[1]) == 1
    assert len(total_dels[2]) == 1
    assert len(total_dels[3]) == 1
    assert len(total_dels[4]) == 1
    assert len(total_dels[5]) == 1
    assert len(total_dels[6]) == 1
    assert len(total_dels[7]) == 1
    assert len(total_dels[8]) == 1
    assert len(total_dels[9]) == 1

    assert total_ins[0] == []
    assert total_ins[1] == []
    assert total_ins[2] == []
    assert total_ins[3] == []
    assert total_ins[4] == []
    assert total_ins[5] == []
    assert total_ins[6] == []
    assert total_ins[7] == []
    assert total_ins[8] == []
    assert total_ins[9] == []
def test_count_indels_single_del_hang_at_head():

    #ref_seq, total_dels, total_ins, cov = count_indels._count_indels("3_dels_single_del_hang_at_head.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "3_dels_single_del_hang_at_head.fasta")
    cov = count_indels._get_coverage("3_dels_single_del_hang_at_head.fasta")
    total_dels = count_indels._count_dels(
        "3_dels_single_del_hang_at_head.fasta", ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins("3_dels_single_del_hang_at_head.fasta",
                                        ref_seq, ref_seq_id, cov)

    assert total_dels[0][0] == 1
    assert total_dels[0][1] == 1
    assert total_dels[0][2] == 1

    assert total_ins[0] == []
    assert total_ins[1] == []
    assert total_ins[2] == []
def test_count_indels_hang_from_head_various_len():

    #ref_seq, total_dels, total_ins, cov = count_indels._count_indels("5_dels_hanging_from_head_var_len.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "5_dels_hanging_from_head_var_len.fasta")
    cov = count_indels._get_coverage("5_dels_hanging_from_head_var_len.fasta")
    total_dels = count_indels._count_dels(
        "5_dels_hanging_from_head_var_len.fasta", ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins(
        "5_dels_hanging_from_head_var_len.fasta", ref_seq, ref_seq_id, cov)

    assert total_dels[0][0] == 1
    assert total_dels[0][1] == 2
    assert total_dels[0][2] == 3
    assert total_dels[0][3] == 4
    assert total_dels[0][4] == 5
    assert total_dels[0][5] == 6
    assert total_dels[0][6] == 7
    assert total_dels[0][7] == 8
    assert total_dels[0][8] == 9

    # all the other entries are empty
    assert total_dels[1] == []
    assert total_dels[2] == []
    assert total_dels[3] == []
    assert total_dels[4] == []
    assert total_dels[5] == []
    assert total_dels[6] == []
    assert total_dels[7] == []
    assert total_dels[8] == []
    assert total_dels[9] == []

    assert total_ins[0] == []
    assert total_ins[1] == []
    assert total_ins[2] == []
    assert total_ins[3] == []
    assert total_ins[4] == []
    assert total_ins[5] == []
    assert total_ins[6] == []
    assert total_ins[7] == []
    assert total_ins[8] == []
    assert total_ins[9] == []
def test_count_indels_single_insertions_from_tail():
    #ref_seq, total_dels, total_ins, cov = count_indels._count_indels("9_ins_single_ins_from_tail.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "9_ins_single_ins_from_tail.fasta")
    cov = count_indels._get_coverage("9_ins_single_ins_from_tail.fasta")
    total_dels = count_indels._count_dels("9_ins_single_ins_from_tail.fasta",
                                          ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins("9_ins_single_ins_from_tail.fasta",
                                        ref_seq, ref_seq_id, cov)

    assert total_ins[1][0] == 1
    assert total_ins[2][0] == 1
    assert total_ins[3][0] == 1
    assert total_ins[4][0] == 1
    assert total_ins[5][0] == 1
    assert total_ins[6][0] == 1
    assert total_ins[7][0] == 1
    assert total_ins[8][0] == 1
    assert total_ins[9][0] == 1

    assert len(total_ins[0]) == 0
    assert len(total_ins[1]) == 1
    assert len(total_ins[2]) == 1
    assert len(total_ins[3]) == 1
    assert len(total_ins[4]) == 1
    assert len(total_ins[5]) == 1
    assert len(total_ins[6]) == 1
    assert len(total_ins[7]) == 1
    assert len(total_ins[8]) == 1
    assert len(total_ins[9]) == 1

    assert total_dels[0] == []
    assert total_dels[1] == []
    assert total_dels[2] == []
    assert total_dels[3] == []
    assert total_dels[4] == []
    assert total_dels[5] == []
    assert total_dels[6] == []
    assert total_dels[7] == []
    assert total_dels[8] == []
    assert total_dels[9] == []
def test_count_indels_insertion_ladder_forward():
    """
    """
    #ref_seq, total_dels, total_ins, cov = count_indels._count_indels("10_ins_ladder_forward.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "10_ins_ladder_forward.fasta")
    cov = count_indels._get_coverage("10_ins_ladder_forward.fasta")
    total_dels = count_indels._count_dels("10_ins_ladder_forward.fasta",
                                          ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins("10_ins_ladder_forward.fasta", ref_seq,
                                        ref_seq_id, cov)

    df_dels = count_indels._create_df(ref_seq, total_dels)
    df_ins = count_indels._create_df(ref_seq, total_ins)
    df_cov = count_indels._create_df_cov(cov)

    assert df_ins[("A", 1)].isna().item() == True
    assert df_ins[("T", 2)].item() == 1
    assert df_ins[("G", 3)].item() == 2
    assert df_ins[("C", 4)].item() == 3
    assert df_ins[("A", 5)].item() == 4
    assert df_ins[("T", 6)].item() == 3

    assert df_dels.empty == True

    assert df_cov["coverage"].item() == 5

    return df_dels, df_ins, df_cov


#df_dels, df_ins, df_cov = test_count_indels_insertion_ladder_forward()

#print(df_ins)
#print(df_cov)

#df_dels, df_ins, df_cov  = test_count_indels_single_del_from_head()

#print(df_dels)
#print(df_ins)
#print(df_cov)
def test_count_indels_single_del_from_head():
    """single deletions over the whole ref_seq
    no insertions"""
    #ref_seq, total_dels, total_ins, cov = count_indels._count_indels("13_df_dels.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq("13_df_dels.fasta")
    cov = count_indels._get_coverage("13_df_dels.fasta")
    total_dels = count_indels._count_dels("13_df_dels.fasta", ref_seq,
                                          ref_seq_id, cov)
    total_ins = count_indels._count_ins("13_df_dels.fasta", ref_seq,
                                        ref_seq_id, cov)

    df_dels = count_indels._create_df(ref_seq, total_dels)
    df_ins = count_indels._create_df(ref_seq, total_ins)
    df_cov = count_indels._create_df_cov(cov)

    # we should use item() method to return Python scalar value
    # otherwise we'll get ValueError: The truth value of a Series is ambiguous.
    # to check up compare:
    # type(df_dels[("A", 1)].isna()) and type(df_dels[("A", 1)].isna().item())
    # the first we'll be pandas.core.series.Series, the second - bool

    assert df_dels[("T", 2)].item() == 1
    assert df_dels[("A", 5)].item() == 2

    assert df_dels[("A", 1)].isna().item() == True
    assert df_dels[("G", 3)].isna().item() == True
    assert df_dels[("C", 4)].isna().item() == True
    assert df_dels[("T", 6)].isna().item() == True
    assert df_dels[("G", 7)].isna().item() == True

    assert df_ins.empty == True

    assert df_cov["coverage"].item() == 1

    return df_dels, df_ins, df_cov
def test_count_indels_single_del_from_head():
    """single deletions over the whole ref_seq
    no insertions"""

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "1_dels_single_del_from_head.fasta")
    cov = count_indels._get_coverage("1_dels_single_del_from_head.fasta")
    total_dels = count_indels._count_dels("1_dels_single_del_from_head.fasta",
                                          ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins("1_dels_single_del_from_head.fasta",
                                        ref_seq, ref_seq_id, cov)

    assert len(ref_seq) == 10
    assert cov == 10

    assert total_dels[0][0] == 1
    assert total_dels[1][0] == 1
    assert total_dels[2][0] == 1
    assert total_dels[3][0] == 1
    assert total_dels[4][0] == 1
    assert total_dels[5][0] == 1
    assert total_dels[6][0] == 1
    assert total_dels[7][0] == 1
    assert total_dels[8][0] == 1
    assert total_dels[9][0] == 1

    assert total_ins[0] == []
    assert total_ins[1] == []
    assert total_ins[2] == []
    assert total_ins[3] == []
    assert total_ins[4] == []
    assert total_ins[5] == []
    assert total_ins[6] == []
    assert total_ins[7] == []
    assert total_ins[8] == []
    assert total_ins[9] == []
def test_create_plots_create_matrix_insertions_raw_count():
    """
    """
    #ref_seq, total_dels, total_ins, cov = crispr_count_indels._count_indels("16_ins_ladder_for_matrix.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "16_ins_ladder_for_matrix.fasta")
    cov = count_indels._get_coverage("16_ins_ladder_for_matrix.fasta")
    total_dels = count_indels._count_dels("16_ins_ladder_for_matrix.fasta",
                                          ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins("16_ins_ladder_for_matrix.fasta",
                                        ref_seq, ref_seq_id, cov)

    df_dels = count_indels._create_df(ref_seq, total_dels)
    df_ins = count_indels._create_df(ref_seq, total_ins)
    df_cov = count_indels._create_df_cov(cov)

    count_indels._save_df(df_dels, df_ins, df_cov,
                          "16_ins_ladder_for_matrix.fasta")

    insertion_matrix = create_matrices._create_matrix(
        "16_ins_ladder_for_matrix.xlsx", "insertions")
    try:
        deletions_matrix = create_matrices._create_matrix(
            "16_ins_ladder_for_matrix.xlsx", "insertions")
    except ValueError:
        print("no insertion matrix")

    assert insertion_matrix.iloc[3, 1] == 3
    assert insertion_matrix.iloc[2, 2] == 2
    assert insertion_matrix.iloc[1, 3] == 2
    assert insertion_matrix.iloc[0, 4] == 2
    assert insertion_matrix.iloc[1, 5] == 1

    # column 0
    assert insertion_matrix.iloc[0, 0] == 0
    assert insertion_matrix.iloc[1, 0] == 0
    assert insertion_matrix.iloc[2, 0] == 0
    assert insertion_matrix.iloc[3, 0] == 0

    # column 1
    assert insertion_matrix.iloc[0, 1] == 0
    assert insertion_matrix.iloc[1, 1] == 0
    assert insertion_matrix.iloc[2, 1] == 0

    # column 2
    assert insertion_matrix.iloc[0, 2] == 0
    assert insertion_matrix.iloc[1, 2] == 0
    assert insertion_matrix.iloc[3, 2] == 0

    # column 3
    assert insertion_matrix.iloc[0, 3] == 0
    assert insertion_matrix.iloc[2, 3] == 0
    assert insertion_matrix.iloc[3, 3] == 0

    # column 4
    assert insertion_matrix.iloc[1, 4] == 0
    assert insertion_matrix.iloc[2, 4] == 0
    assert insertion_matrix.iloc[3, 4] == 0

    return insertion_matrix
def test_create_plots_create_matrix_deletion_raw_count():
    """
    """
    #ref_seq, total_dels, total_ins, cov = crispr_count_indels._count_indels("15_dels_ladder_for_matrix.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "15_dels_ladder_for_matrix.fasta")
    cov = count_indels._get_coverage("15_dels_ladder_for_matrix.fasta")
    total_dels = count_indels._count_dels("15_dels_ladder_for_matrix.fasta",
                                          ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins("15_dels_ladder_for_matrix.fasta",
                                        ref_seq, ref_seq_id, cov)

    df_dels = count_indels._create_df(ref_seq, total_dels)
    df_ins = count_indels._create_df(ref_seq, total_ins)
    df_cov = count_indels._create_df_cov(cov)

    count_indels._save_df(df_dels, df_ins, df_cov,
                          "15_dels_ladder_for_matrix.fasta")

    deletion_matrix = create_matrices._create_matrix(
        "15_dels_ladder_for_matrix.xlsx", "deletions")
    try:
        insertion_matrix = create_matrices._create_matrix(
            "15_dels_ladder_for_matrix.xlsx", "insertions")
    except ValueError:
        print("no insertion matrix")

    # non empty values, counted indels
    assert deletion_matrix.iloc[4, 0] == 2
    assert deletion_matrix.iloc[3, 1] == 2
    assert deletion_matrix.iloc[2, 2] == 2
    assert deletion_matrix.iloc[1, 3] == 2
    assert deletion_matrix.iloc[0, 4] == 2
    assert deletion_matrix.iloc[0, 5] == 2
    assert deletion_matrix.iloc[1, 6] == 1
    assert deletion_matrix.iloc[2, 7] == 1
    assert deletion_matrix.iloc[3, 8] == 1
    assert deletion_matrix.iloc[4, 9] == 1

    # empty value, villed with 0
    #column 0
    assert deletion_matrix.iloc[0, 0] == 0
    assert deletion_matrix.iloc[1, 0] == 0
    assert deletion_matrix.iloc[2, 0] == 0
    assert deletion_matrix.iloc[3, 0] == 0

    #column 1
    assert deletion_matrix.iloc[0, 1] == 0
    assert deletion_matrix.iloc[1, 1] == 0
    assert deletion_matrix.iloc[2, 1] == 0
    assert deletion_matrix.iloc[4, 1] == 0

    #columns 2
    assert deletion_matrix.iloc[0, 2] == 0
    assert deletion_matrix.iloc[1, 2] == 0
    assert deletion_matrix.iloc[3, 2] == 0
    assert deletion_matrix.iloc[4, 2] == 0

    #columns 3
    assert deletion_matrix.iloc[0, 3] == 0
    assert deletion_matrix.iloc[2, 3] == 0
    assert deletion_matrix.iloc[3, 3] == 0
    assert deletion_matrix.iloc[4, 3] == 0

    #columns 4
    assert deletion_matrix.iloc[1, 4] == 0
    assert deletion_matrix.iloc[2, 4] == 0
    assert deletion_matrix.iloc[3, 4] == 0
    assert deletion_matrix.iloc[4, 4] == 0

    #columns 5
    assert deletion_matrix.iloc[1, 5] == 0
    assert deletion_matrix.iloc[2, 5] == 0
    assert deletion_matrix.iloc[3, 5] == 0
    assert deletion_matrix.iloc[4, 5] == 0

    #columns 6
    assert deletion_matrix.iloc[0, 6] == 0
    assert deletion_matrix.iloc[2, 6] == 0
    assert deletion_matrix.iloc[3, 6] == 0
    assert deletion_matrix.iloc[4, 6] == 0

    #columns 7
    assert deletion_matrix.iloc[0, 7] == 0
    assert deletion_matrix.iloc[1, 7] == 0
    assert deletion_matrix.iloc[3, 7] == 0
    assert deletion_matrix.iloc[4, 7] == 0

    #columns 8
    assert deletion_matrix.iloc[0, 8] == 0
    assert deletion_matrix.iloc[1, 8] == 0
    assert deletion_matrix.iloc[2, 8] == 0
    assert deletion_matrix.iloc[4, 8] == 0

    #columns 9
    assert deletion_matrix.iloc[0, 9] == 0
    assert deletion_matrix.iloc[1, 9] == 0
    assert deletion_matrix.iloc[2, 9] == 0
    assert deletion_matrix.iloc[3, 9] == 0

    return deletion_matrix
def test_create_plots_create_matrix_deletion_percent():
    #ref_seq, total_dels, total_ins, cov = crispr_count_indels._count_indels("15_dels_ladder_for_matrix.fasta")

    ref_seq, ref_seq_id = count_indels._get_ref_seq(
        "15_dels_ladder_for_matrix.fasta")
    cov = count_indels._get_coverage("15_dels_ladder_for_matrix.fasta")
    total_dels = count_indels._count_dels("15_dels_ladder_for_matrix.fasta",
                                          ref_seq, ref_seq_id, cov)
    total_ins = count_indels._count_ins("15_dels_ladder_for_matrix.fasta",
                                        ref_seq, ref_seq_id, cov)

    df_dels = count_indels._create_df(ref_seq, total_dels)
    df_ins = count_indels._create_df(ref_seq, total_ins)
    df_cov = count_indels._create_df_cov(cov)

    count_indels._save_df(df_dels, df_ins, df_cov,
                          "15_dels_ladder_for_matrix.fasta")

    deletion_matrix = create_matrices._create_matrix(
        "15_dels_ladder_for_matrix.xlsx", "deletions")

    perc_deletion_matrix = create_matrices._create_matrix_percent(
        "15_dels_ladder_for_matrix.xlsx", deletion_matrix, cov, "deletions")

    assert perc_deletion_matrix.iloc[4, 0] == 10
    assert perc_deletion_matrix.iloc[3, 1] == 10
    assert perc_deletion_matrix.iloc[2, 2] == 10
    assert perc_deletion_matrix.iloc[1, 3] == 10
    assert perc_deletion_matrix.iloc[0, 4] == 10
    assert perc_deletion_matrix.iloc[0, 5] == 10
    assert perc_deletion_matrix.iloc[1, 6] == 5
    assert perc_deletion_matrix.iloc[2, 7] == 5
    assert perc_deletion_matrix.iloc[3, 8] == 5
    assert perc_deletion_matrix.iloc[4, 9] == 5

    # empty value, villed with 0
    #column 0
    assert perc_deletion_matrix.iloc[0, 0] == 0
    assert perc_deletion_matrix.iloc[1, 0] == 0
    assert perc_deletion_matrix.iloc[2, 0] == 0
    assert perc_deletion_matrix.iloc[3, 0] == 0

    #column 1
    assert perc_deletion_matrix.iloc[0, 1] == 0
    assert perc_deletion_matrix.iloc[1, 1] == 0
    assert perc_deletion_matrix.iloc[2, 1] == 0
    assert perc_deletion_matrix.iloc[4, 1] == 0

    #columns 2
    assert perc_deletion_matrix.iloc[0, 2] == 0
    assert perc_deletion_matrix.iloc[1, 2] == 0
    assert perc_deletion_matrix.iloc[3, 2] == 0
    assert perc_deletion_matrix.iloc[4, 2] == 0

    #columns 3
    assert perc_deletion_matrix.iloc[0, 3] == 0
    assert perc_deletion_matrix.iloc[2, 3] == 0
    assert perc_deletion_matrix.iloc[3, 3] == 0
    assert perc_deletion_matrix.iloc[4, 3] == 0

    #columns 4
    assert perc_deletion_matrix.iloc[1, 4] == 0
    assert perc_deletion_matrix.iloc[2, 4] == 0
    assert perc_deletion_matrix.iloc[3, 4] == 0
    assert perc_deletion_matrix.iloc[4, 4] == 0

    #columns 5
    assert perc_deletion_matrix.iloc[1, 5] == 0
    assert perc_deletion_matrix.iloc[2, 5] == 0
    assert perc_deletion_matrix.iloc[3, 5] == 0
    assert perc_deletion_matrix.iloc[4, 5] == 0

    #columns 6
    assert perc_deletion_matrix.iloc[0, 6] == 0
    assert perc_deletion_matrix.iloc[2, 6] == 0
    assert perc_deletion_matrix.iloc[3, 6] == 0
    assert perc_deletion_matrix.iloc[4, 6] == 0

    #columns 7
    assert perc_deletion_matrix.iloc[0, 7] == 0
    assert perc_deletion_matrix.iloc[1, 7] == 0
    assert perc_deletion_matrix.iloc[3, 7] == 0
    assert perc_deletion_matrix.iloc[4, 7] == 0

    #columns 8
    assert perc_deletion_matrix.iloc[0, 8] == 0
    assert perc_deletion_matrix.iloc[1, 8] == 0
    assert perc_deletion_matrix.iloc[2, 8] == 0
    assert perc_deletion_matrix.iloc[4, 8] == 0

    #columns 9
    assert perc_deletion_matrix.iloc[0, 9] == 0
    assert perc_deletion_matrix.iloc[1, 9] == 0
    assert perc_deletion_matrix.iloc[2, 9] == 0
    assert perc_deletion_matrix.iloc[3, 9] == 0

    return perc_deletion_matrix