Skip to content

Commit

Permalink
Added logfile for mokapot
Browse files Browse the repository at this point in the history
  • Loading branch information
victorgiurcoiu committed Jul 25, 2023
1 parent a241348 commit 6c86879
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions oktoberfest/re_score.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import multiprocessing
import subprocess
from pathlib import Path
from typing import List, Optional, Union
Expand Down Expand Up @@ -272,14 +273,24 @@ def rescore(self, search_type: str = "rescore", test_fdr: float = 0.01, train_fd
subprocess.run(cmd, shell=True, check=True)
elif fdr_estimation_method == "mokapot":
logger.info("Starting mokapot rescoring")
mokapot_logger = logging.getLogger("mokapot")
mokapot_logger.setLevel(logging.INFO)
file_handler = logging.FileHandler(log_file)
file_handler.setLevel(logging.INFO)
log_formatter = logging.Formatter("%(levelname)s: %(message)s")
file_handler.setFormatter(log_formatter)
mokapot_logger.addHandler(file_handler)
np.random.seed(123)
file_path = perc_path / f"{search_type}.tab"
df = pd.read_csv(file_path, sep="\t")
df = df.rename(columns={"Protein": "Proteins"})
df.to_csv(file_path, sep="\t")
psms = mokapot.read_pin(file_path)
num_cores = multiprocessing.cpu_count()
logger.info(f"Running mokapot on {num_cores} cores")
results, models = mokapot.brew(psms, test_fdr=test_fdr)
results.to_txt(dest_dir=perc_path, file_root=f"{search_type}", decoys=True)
logger.info(f"Number of PSMs used for training: {len(psms)}")
else:
raise ValueError(
f"Unknown fdr estimation method: {fdr_estimation_method}. Choose between mokapot and percolator."
Expand Down

0 comments on commit 6c86879

Please sign in to comment.