Skip to content

Commit

Permalink
Fixed path problems probably causing errors under windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ezander committed Oct 1, 2024
1 parent 11967f7 commit 930a50a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 32 deletions.
29 changes: 8 additions & 21 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -504,18 +494,15 @@ 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


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"]
)


Expand Down
16 changes: 5 additions & 11 deletions tests/system_tests/test_rollup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
)
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 930a50a

Please sign in to comment.