Skip to content

Commit

Permalink
clean up test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
danlu1 committed Mar 13, 2024
1 parent c678cc3 commit ccea136
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion genie_registry/maf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _check_tsa1_tsa2(df):
and not df.query("REFERENCE_ALLELE == TUMOR_SEQ_ALLELE2").empty
):
error = (
"maf: Contains instances where values in REFERENCE_ALLELE match values in TUMOR_SEQ_ALLELE2. "
f"{error}maf: Contains instances where values in REFERENCE_ALLELE match values in TUMOR_SEQ_ALLELE2. "
"This is invalid. Please correct.\n"
)
row_index = df.query("REFERENCE_ALLELE == TUMOR_SEQ_ALLELE2").index.values
Expand Down
36 changes: 16 additions & 20 deletions tests/test_maf.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,26 +241,6 @@ def test_error__check_allele_col():
assert warning == ""


def test_invalid__check_ref_tsa1_tsa2():
"""Test the scenario in which maf file has TSA1 and TSA2 and fails"""
df = pd.DataFrame(
dict(
REFERENCE_ALLELE=["A", "A", "A"],
TUMOR_SEQ_ALLELE1=["B", "B", "B"],
TUMOR_SEQ_ALLELE2=["A", "C", "C"],
)
)
error = genie_registry.maf._check_tsa1_tsa2(df)
assert error == (
"maf: Contains both "
"TUMOR_SEQ_ALLELE1 and TUMOR_SEQ_ALLELE2 columns. "
"All values in TUMOR_SEQ_ALLELE1 must match all values in "
"REFERENCE_ALLELE or all values in TUMOR_SEQ_ALLELE2.\n"
"REFERENCE_ALLELE should not equal to TUMOR_SEQ_ALLELE2. "
"Please check row: 1.\n"
)


@pytest.mark.parametrize(
"test_df,expected_error",
[
Expand Down Expand Up @@ -335,6 +315,21 @@ def test_invalid__check_ref_tsa1_tsa2():
),
"",
),
(
pd.DataFrame(
dict(
REFERENCE_ALLELE=["A", "A", "A"],
TUMOR_SEQ_ALLELE1=["B", "B", "B"],
TUMOR_SEQ_ALLELE2=["A", "C", "C"],
)
),
"maf: Contains both "
"TUMOR_SEQ_ALLELE1 and TUMOR_SEQ_ALLELE2 columns. "
"All values in TUMOR_SEQ_ALLELE1 must match all values in "
"REFERENCE_ALLELE or all values in TUMOR_SEQ_ALLELE2.\n"
"maf: Contains instances where values in REFERENCE_ALLELE match values in TUMOR_SEQ_ALLELE2. "
"This is invalid. Please correct.\n",
),
],
ids=[
"matching_tsa1_tsa2",
Expand All @@ -344,6 +339,7 @@ def test_invalid__check_ref_tsa1_tsa2():
"identical_ref_tsa2_missing_tsa1",
"valid_ref_tsa2_missing_tsa1",
"missing_tsa2_ref",
"invalid_tsa1_identical_ref_tsa2",
],
)
def test__check_tsa1_tsa2(test_df, expected_error):
Expand Down

0 comments on commit ccea136

Please sign in to comment.