Skip to content

Commit

Permalink
(chore) reformatted tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jspaezp committed Sep 7, 2024
1 parent 1809edd commit 3214c24
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 57 deletions.
1 change: 0 additions & 1 deletion tests/system_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def test_basic_cli(tmp_path, scope_files):
assert targets_psms_df.iloc[0, 5] == "sp|P10809|CH60_HUMAN"



def test_cli_options(tmp_path, scope_files):
"""Test non-defaults"""
params = [
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_confidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_assign_confidence_parquet(psm_df_1000_parquet, tmp_path):
assign_confidence(
[copy.copy(psms_disk)],
prefixes=[None],
descs=None, # should default to [True] as in the first case
descs=None, # should default to [True] as in the first case
dest_dir=tmp_path,
max_workers=4,
eval_fdr=0.02,
Expand Down
54 changes: 28 additions & 26 deletions tests/unit_tests/test_parser_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,34 @@
def std_parquet(tmp_path):
"""Create a standard pin file"""
out_file = tmp_path / "std_pin.parquet"
df = pd.DataFrame([
{
"sPeCid": "DefaultDirection",
"LaBel": "0",
"pepTide": "-",
"sCore": "-",
"scanNR": "1",
"pRoteins": "-",
},
{
"sPeCid": "a",
"LaBel": "1",
"pepTide": "ABC",
"sCore": "5",
"scanNR": "2",
"pRoteins": "protein1",
},
{
"sPeCid": "b",
"LaBel": "-1",
"pepTide": "CBA",
"sCore": "10",
"scanNR": "3",
"pRoteins": "decoy_protein1",
},
])
df = pd.DataFrame(
[
{
"sPeCid": "DefaultDirection",
"LaBel": "0",
"pepTide": "-",
"sCore": "-",
"scanNR": "1",
"pRoteins": "-",
},
{
"sPeCid": "a",
"LaBel": "1",
"pepTide": "ABC",
"sCore": "5",
"scanNR": "2",
"pRoteins": "protein1",
},
{
"sPeCid": "b",
"LaBel": "-1",
"pepTide": "CBA",
"sCore": "10",
"scanNR": "3",
"pRoteins": "decoy_protein1",
},
]
)
df.to_parquet(out_file, index=False)
return out_file

Expand Down
50 changes: 30 additions & 20 deletions tests/unit_tests/test_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@
@pytest.fixture
def readers_to_merge():
# Prepare two dataframe readers
df1 = pd.DataFrame({
"foo": [1, 3, 4, 5, 8, 10],
"bar": [20, 6, 3, 2, 1, 0],
})
df2 = pd.DataFrame({
"foo": [2, 2, 6, 9, 11, 13, 15],
"bar": [18, 16, 13, 6, 5, 5, 0],
})
df1 = pd.DataFrame(
{
"foo": [1, 3, 4, 5, 8, 10],
"bar": [20, 6, 3, 2, 1, 0],
}
)
df2 = pd.DataFrame(
{
"foo": [2, 2, 6, 9, 11, 13, 15],
"bar": [18, 16, 13, 6, 5, 5, 0],
}
)
reader1 = DataFrameReader(df1)
reader2 = DataFrameReader(df2)
return [reader1, reader2]
Expand All @@ -31,14 +35,18 @@ def readers_to_merge():
@pytest.fixture
def readers_to_join():
# Prepare two dataframe readers
df1 = pd.DataFrame({
"foo": [1, 3, 4, 5, 8, 10],
"bar": [20, 6, 3, 2, 1, 0],
})
df2 = pd.DataFrame({
"baz": [11, 13, 14, 15, 18, 110],
"quux": [220, 26, 23, 22, 21, 20],
})
df1 = pd.DataFrame(
{
"foo": [1, 3, 4, 5, 8, 10],
"bar": [20, 6, 3, 2, 1, 0],
}
)
df2 = pd.DataFrame(
{
"baz": [11, 13, 14, 15, 18, 110],
"quux": [220, 26, 23, 22, 21, 20],
}
)
reader1 = DataFrameReader(df1)
reader2 = DataFrameReader(df2)
return [reader1, reader2]
Expand All @@ -51,10 +59,12 @@ def test_merged_tabular_data_reader(readers_to_merge):
)
pd.testing.assert_frame_equal(
reader.read(),
pd.DataFrame({
"foo": [1, 2, 2, 3, 4, 5, 6, 8, 9, 10, 11, 13, 15],
"bar": [20, 18, 16, 6, 3, 2, 13, 1, 6, 0, 5, 5, 0],
}),
pd.DataFrame(
{
"foo": [1, 2, 2, 3, 4, 5, 6, 8, 9, 10, 11, 13, 15],
"bar": [20, 18, 16, 6, 3, 2, 13, 1, 6, 0, 5, 5, 0],
}
),
)

# Check that chunked read works
Expand Down
20 changes: 11 additions & 9 deletions tests/unit_tests/test_writer_flashlfq.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ def test_basic(mock_conf, tmp_path):
"""Test that the basic output works"""
conf = mock_conf
df = pd.read_table(mokapot.to_flashlfq(conf, tmp_path / "test.txt"))
expected = pd.DataFrame({
"File Name": ["c.mzML"] * 2,
"Base Sequence": ["ABCDXYZ", "ABCDEFG"],
"Full Sequence": ["B.ABCD[+2.817]XYZ.A", "ABCDE(shcah8)FG"],
"Peptide Monoisotopic Mass": [1, 2],
"Scan Retention Time": [1.0, 2.0],
"Precursor Charge": [2, 3],
"Protein Accession": ["A|B|C; B|C|A", "A|B|C"],
})
expected = pd.DataFrame(
{
"File Name": ["c.mzML"] * 2,
"Base Sequence": ["ABCDXYZ", "ABCDEFG"],
"Full Sequence": ["B.ABCD[+2.817]XYZ.A", "ABCDE(shcah8)FG"],
"Peptide Monoisotopic Mass": [1, 2],
"Scan Retention Time": [1.0, 2.0],
"Precursor Charge": [2, 3],
"Protein Accession": ["A|B|C; B|C|A", "A|B|C"],
}
)

pd.testing.assert_frame_equal(df, expected)

Expand Down

0 comments on commit 3214c24

Please sign in to comment.