From 930a50aa09f220c64415183754829e48b487157e Mon Sep 17 00:00:00 2001 From: Elmar Zander Date: Tue, 1 Oct 2024 14:48:12 +0200 Subject: [PATCH] Fixed path problems probably causing errors under windows --- tests/conftest.py | 29 ++++++++--------------------- tests/system_tests/test_rollup.py | 16 +++++----------- 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f6bd71a..4734b24 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -254,9 +254,7 @@ def psms_dataset(psm_df_1000): def psms_ondisk(): """A small OnDiskPsmDataset""" filename = Path("data", "scope2_FP97AA.pin") - df_spectra = pd.read_csv( - filename, sep="\t", usecols=["ScanNr", "ExpMass", "Label"] - ) + df_spectra = pd.read_csv(filename, sep="\t", usecols=["ScanNr", "ExpMass", "Label"]) with open(filename) as perc: columns = perc.readline().rstrip().split("\t") psms = OnDiskPsmDataset( @@ -308,7 +306,7 @@ def psms_ondisk(): @pytest.fixture def psms_ondisk_from_parquet(): """A small OnDiskPsmDataset""" - filename = Path("data/10k_psms_test.parquet") + filename = Path("data") / "10k_psms_test.parquet" df_spectra = pq.read_table( filename, columns=["ScanNr", "ExpMass", "Label"] ).to_pandas() @@ -451,9 +449,7 @@ def targets_decoys_psms_scored(tmp_path): scores = scores[idx] label = label[idx] qval = tdc(scores, label) - pep = getQvaluesFromScores( - target_scores, decoy_scores, includeDecoys=True - )[1] + pep = getQvaluesFromScores(target_scores, decoy_scores, includeDecoys=True)[1] peptides = np.hstack([np.arange(1, n + 1), np.arange(1, n + 1)]) peptides.sort() df = pd.DataFrame( @@ -468,19 +464,13 @@ def targets_decoys_psms_scored(tmp_path): ], ) df["proteinIds"] = "dummy" - df[df["Label"] == 1].drop("Label", axis=1).to_csv( - psms_t, sep="\t", index=False - ) - df[df["Label"] == -1].drop("Label", axis=1).to_csv( - psms_d, sep="\t", index=False - ) + df[df["Label"] == 1].drop("Label", axis=1).to_csv(psms_t, sep="\t", index=False) + df[df["Label"] == -1].drop("Label", axis=1).to_csv(psms_d, sep="\t", index=False) return [psms_t, psms_d] -def _make_fasta( - num_proteins, peptides, peptides_per_protein, random_state, prefix="" -): +def _make_fasta(num_proteins, peptides, peptides_per_protein, random_state, prefix=""): """Create a FASTA string from a set of peptides Parameters @@ -504,9 +494,7 @@ def _make_fasta( lines = [] for protein in range(num_proteins): lines.append(f">{prefix}sp|test|test_{protein}") - lines.append( - "".join(list(random_state.choice(peptides, peptides_per_protein))) - ) + lines.append("".join(list(random_state.choice(peptides, peptides_per_protein)))) return lines @@ -514,8 +502,7 @@ def _make_fasta( def _random_peptide(length, random_state): """Generate a random peptide""" return "".join( - list(random_state.choice(list("ACDEFGHILMNPQSTVWY"), length - 1)) - + ["K"] + list(random_state.choice(list("ACDEFGHILMNPQSTVWY"), length - 1)) + ["K"] ) diff --git a/tests/system_tests/test_rollup.py b/tests/system_tests/test_rollup.py index 3d05851..841391c 100644 --- a/tests/system_tests/test_rollup.py +++ b/tests/system_tests/test_rollup.py @@ -79,9 +79,7 @@ def test_extra_cols(tmp_path): """Test that two identical mokapot runs produce same results.""" extended_file = Path("data", "percolator-noSplit-extended-10000.tab") - non_extended_file = Path( - "data", "percolator-noSplit-non-extended-10000.tab" - ) + non_extended_file = Path("data", "percolator-noSplit-non-extended-10000.tab") params = [ ("--dest_dir", tmp_path), @@ -110,12 +108,8 @@ def test_extra_cols(tmp_path): df_run1_t_psms[df_run2_t_psms.columns], df_run2_t_psms ) - df_run1_t_peptides = pd.read_csv( - tmp_path / "run1.targets.peptides.csv", sep="\t" - ) - df_run2_t_peptides = pd.read_csv( - tmp_path / "run2.targets.peptides.csv", sep="\t" - ) + df_run1_t_peptides = pd.read_csv(tmp_path / "run1.targets.peptides.csv", sep="\t") + df_run2_t_peptides = pd.read_csv(tmp_path / "run2.targets.peptides.csv", sep="\t") pd.testing.assert_frame_equal( df_run1_t_peptides[df_run2_t_peptides.columns], df_run2_t_peptides ) @@ -124,7 +118,7 @@ def test_extra_cols(tmp_path): def test_deduplication(tmp_path): """Test that deduplication of psms works.""" path = tmp_path - file = "data/scope2_FP97AA.pin" + file = Path("data") / "scope2_FP97AA.pin" params = [ file, @@ -172,7 +166,7 @@ def test_deduplication(tmp_path): def test_streaming(tmp_path, percolator_extended_file_big): """Test that streaming of confidence assignments works.""" path = tmp_path - file = "data/scope2_FP97AA.pin" + file = Path("data") / "scope2_FP97AA.pin" base_params = [ file,