Skip to content

Commit

Permalink
test: add noise to test data.
Browse files Browse the repository at this point in the history
  • Loading branch information
mo-sameh committed Sep 10, 2024
1 parent f775179 commit a8597e4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/unit_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def mock_precursor_df(
A mock precursor dataframe
"""

precursor_idx = np.arange(n_precursor)
precursor_mz = np.random.rand(n_precursor) * 2000 + 500
precursor_charge = np.random.choice([2, 3], size=n_precursor)

Expand All @@ -61,18 +60,18 @@ def mock_precursor_df(
for __ in range(6):
sequence += chr(np.random.randint(65, 91))
sequences.append(sequence)
return pd.DataFrame(

df = pd.DataFrame(
{
"precursor_idx": precursor_idx,
"decoy": decoy,
"mz_library": precursor_mz,
"rt_library": random_rt,
"mobility_library": random_mobility,
"mz_observed": precursor_mz,
"rt_observed": random_rt,
"mobility_observed": random_mobility,
"mz_calibrated": precursor_mz,
"rt_calibrated": random_rt,
"mz_observed": precursor_mz + np.random.rand(n_precursor) * 0.1,
"rt_observed": random_rt + np.random.rand(n_precursor) * 0.1,
"mobility_observed": random_mobility + np.random.rand(n_precursor) * 0.1,
"mz_calibrated": precursor_mz + np.random.rand(n_precursor) * 0.1,
"rt_calibrated": random_rt + np.random.rand(n_precursor) * 0.1,
"charge": precursor_charge,
"proteins": proteins,
"genes": genes,
Expand All @@ -85,6 +84,10 @@ def mock_precursor_df(
}
)

df = df.sample(frac=1).reset_index(drop=True)
df["precursor_idx"] = np.arange(len(df))
return df


def mock_fragment_df(n_fragments: int = 10, n_precursor: int = 20):
"""Create a mock fragment dataframe as it's found as the individual search outputs
Expand Down

0 comments on commit a8597e4

Please sign in to comment.