def test_pin_parsing(std_pin): """Test pin parsing""" df = mokapot.read_pin(std_pin, to_df=True) assert df["LaBel"].dtype == "bool" assert len(df) == 2 assert len(df[df["LaBel"]]) == 1 assert len(df[df["LaBel"]]) == 1 dat = mokapot.read_pin(std_pin) pd.testing.assert_frame_equal(df.loc[:, ("sCore", )], dat.features)
def test_compare_to_percolator(): """Test that mokapot get almost the same answer as Percolator""" dat = mokapot.read_pin(os.path.join("data", "phospho_rep1.pin")) dat.add_proteins(os.path.join("data", "human_sp_td.fasta")) res, _ = mokapot.brew(dat) perc_path = os.path.join("data", "percolator.{l}.txt") perc_res = { l: mokapot.read_percolator(perc_path.format(l=l)) for l in ["psms", "peptides", "proteins"] } for level in ["psms", "peptides", "proteins"]: logging.info("Testing level: %s", level) if level != "proteins": perc = perc_res[level].rename(columns={ "PSMId": "SpecId", "peptide": "Peptide" }) else: perc = perc_res[level] res.proteins["ProteinId"] = res.proteins[ "mokapot protein group"].str.split(", ", expand=True)[0] merged = pd.merge(res.confidence_estimates[level], perc) assert merged["mokapot q-value"].corr(merged["q-value"]) > 0.99 assert (merged["mokapot PEP"].corr(merged["posterior_error_prob"]) > 0.99)
def test_compare_to_percolator(): """Test that mokapot get almost the same answer as Percolator""" dat = mokapot.read_pin(os.path.join("data", "phospho_rep1.pin")) res, _ = mokapot.brew(dat) perc_path = os.path.join("data", "percolator.{l}.txt") perc_res = { l: mokapot.parsers.read_percolator(perc_path.format(l=l)) for l in ["psms", "peptides"] } for level in ["psms", "peptides"]: logging.info("Testing level: %s", level) perc = perc_res[level].rename( columns={"PSMId": "SpecId", "peptide": "Peptide"} ) merged = pd.merge(res._confidence_estimates[level], perc) assert merged["mokapot q-value"].corr(merged["q-value"]) > 0.99 assert ( merged["mokapot PEP"].corr(merged["posterior_error_prob"]) > 0.99 )
def test_assign_confidence(): """Test that assign_confidence() methods run""" dset = mokapot.read_pin(EX_FILE) dset.assign_confidence()
def test_pin_wo_dir(): """Test a PIN file without a DefaultDirection line""" dat = mokapot.read_pin("data/scope2_FP97AA.pin")