Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fragpipe params #408

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 49 additions & 19 deletions proteobench/io/params/fragger.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ def extract_params(file: BytesIO) -> ProteoBenchParameters:
msfragger_executable = ""

params.search_engine_version = msfragger_executable
params.enzyme = fragpipe_params.loc["msfragger.search_enzyme_name_1"]
enzyme = fragpipe_params.loc["msfragger.search_enzyme_name_1"]
if fragpipe_params.loc["msfragger.search_enzyme_name_2"] != "null":
enzyme += f"|{fragpipe_params.loc['msfragger.search_enzyme_name_2']}"
params.enzyme = enzyme
params.allowed_miscleavages = fragpipe_params.loc["msfragger.allowed_missed_cleavage_1"]
# TODO: Fragpipe reports "0.0" mass shift for each unmodified AA here, which is not useful and could be removed
params.fixed_mods = fragpipe_params.loc["msfragger.table.fix-mods"]
# TODO: Fragpipe reports a lot of default suggestions for variable mods and assigns them as 'false' here,
# which is not useful and could be removed, i.e. only retain true variable mods
params.variable_mods = fragpipe_params.loc["msfragger.table.var-mods"]
params.max_mods = fragpipe_params.loc["msfragger.max_variable_mods_per_peptide"]
params.min_peptide_length = fragpipe_params.loc["msfragger.digest_min_length"]
Expand All @@ -100,30 +106,54 @@ def extract_params(file: BytesIO) -> ProteoBenchParameters:
precursor_mass_units = "Da"
if int(fragpipe_params.loc["msfragger.precursor_mass_units"]):
precursor_mass_units = "ppm"
params.precursor_mass_tolerance = (
f'{fragpipe_params.loc["msfragger.precursor_true_tolerance"]} {precursor_mass_units}'
)
params.precursor_mass_tolerance = f'{fragpipe_params.loc["msfragger.precursor_mass_lower"]} {precursor_mass_units}|{fragpipe_params.loc["msfragger.precursor_mass_upper"]} {precursor_mass_units}'

fragment_mass_units = "Da"
if int(fragpipe_params.loc["msfragger.fragment_mass_units"]):
fragment_mass_units = "ppm"
params.fragment_mass_tolerance = f'{fragpipe_params.loc["msfragger.fragment_mass_tolerance"]} {fragment_mass_units}'
# ! ionquant is not necessarily fixed?
params.ident_fdr_protein = fragpipe_params.loc["ionquant.proteinfdr"]
params.ident_fdr_peptide = fragpipe_params.loc["ionquant.peptidefdr"]
params.ident_fdr_psm = fragpipe_params.loc["ionquant.ionfdr"]

for key in ["ident_fdr_protein", "ident_fdr_peptide", "ident_fdr_psm"]:
value = getattr(params, key)
try:
value = int(value) / 100
setattr(params, key, value)
except ValueError:
logging.warning(f"Could not convert {value} to int.")

params.min_precursor_charge = int(fragpipe_params.loc["msfragger.misc.fragger.precursor-charge-lo"])
params.max_precursor_charge = int(fragpipe_params.loc["msfragger.misc.fragger.precursor-charge-hi"])
params.enable_match_between_runs = bool(fragpipe_params.loc["ionquant.mbr"])
if fragpipe_params.loc["quantitation.run-label-free-quant"] == "true":
params.ident_fdr_protein = fragpipe_params.loc["ionquant.proteinfdr"]
params.ident_fdr_peptide = fragpipe_params.loc["ionquant.peptidefdr"]
params.ident_fdr_psm = fragpipe_params.loc["ionquant.ionfdr"]
elif fragpipe_params.loc["diann.run-dia-nn"] == "true":
params.ident_fdr_protein = fragpipe_params.loc["diann.q-value"]
params.ident_fdr_peptide = fragpipe_params.loc["diann.q-value"]
params.ident_fdr_psm = fragpipe_params.loc["diann.q-value"]

# I think this is incorrect? The values are stored as proportions in the fragpipe.workflow file? Commenting out for now
# for key in ["ident_fdr_protein", "ident_fdr_peptide", "ident_fdr_psm"]:
# value = getattr(params, key)
# try:
# value = int(value) / 100
# setattr(params, key, value)
# except ValueError:
# logging.warning(f"Could not convert {value} to int.")

if fragpipe_params.loc["msfragger.override_charge"] == "true":
params.min_precursor_charge = int(fragpipe_params.loc["msfragger.misc.fragger.precursor-charge-lo"])
params.max_precursor_charge = int(fragpipe_params.loc["msfragger.misc.fragger.precursor-charge-hi"])
else: # Fragpipe takes charge info from data, this is the default
params.min_precursor_charge = 1
params.max_precursor_charge = None
if fragpipe_params.loc["quantitation.run-label-free-quant"] == "true":
params.enable_match_between_runs = bool(fragpipe_params.loc["ionquant.mbr"])
elif fragpipe_params.loc["diann.run-dia-nn"] == "true":
diann_quant_dict = {
1: "Any LC (high accuracy)",
2: "Any LC (high precision)",
3: "Robust LC (high accuracy)",
4: "Robust LC (high precision)",
}
if "--reanalyse" in fragpipe_params.loc["diann.fragpipe.cmd-opts"]:
params.enable_match_between_runs = True
else:
params.enable_match_between_runs = False
params.quantification_method_DIANN = diann_quant_dict[int(fragpipe_params.loc["diann.quantification-strategy"])]
if fragpipe_params.loc["protein-prophet.run-protein-prophet"] == "true":
params.protein_inference = "ProteinProphet: {}".format(fragpipe_params.loc["protein-prophet.cmd-opts"])

return params


Expand Down
1 change: 1 addition & 0 deletions proteobench/modules/quant_base/quant_base_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, token: str = None, proteobench_repo_name: str = "", proteobot
"i2MassChroQ": extract_params_i2masschroq,
"DIA-NN": extract_params_diann,
"AlphaDIA": extract_params_alphadia,
"FragPipe (DIA-NN quant)": extract_params_fragger,
# "Spectronaut": extract_params_spectronaut
}

Expand Down
10 changes: 5 additions & 5 deletions test/params/fragpipe_extracted_params.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ software_version,21.0
search_engine,MSFragger
search_engine_version,4.0
ident_fdr_psm,0.01
ident_fdr_peptide,0.01
ident_fdr_protein,0.01
ident_fdr_peptide,1
ident_fdr_protein,1
enable_match_between_runs,True
precursor_mass_tolerance,20 ppm
precursor_mass_tolerance,-20 ppm|20 ppm
fragment_mass_tolerance,20 ppm
enzyme,stricttrypsin
allowed_miscleavages,2
Expand All @@ -17,9 +17,9 @@ fixed_mods,"0.0,C-Term Peptide,true,-1; 0.0,N-Term Peptide,true,-1; 0.0,C-Term P
variable_mods,"15.9949,M,true,3; 42.0106,[^,true,1; 79.96633,STY,false,3; -17.0265,nQnC,false,1; -18.0106,nE,false,1; 4.025107,K,false,2; 6.020129,R,false,2; 8.014199,K,false,2; 10.008269,R,false,2; 0.0,site_10,false,1; 0.0,site_11,false,1; 0.0,site_12,false,1; 0.0,site_13,false,1; 0.0,site_14,false,1; 0.0,site_15,false,1; 0.0,site_16,false,1"
max_mods,3
min_precursor_charge,1
max_precursor_charge,4
max_precursor_charge,
scan_window,
quantification_method_DIANN,
second_pass,
protein_inference,
protein_inference,ProteinProphet: --maxppmdiff 2000000
predictors_library,
12 changes: 6 additions & 6 deletions test/params/fragpipe_v22_extracted_params.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ software_version,22.0
search_engine,MSFragger
search_engine_version,
ident_fdr_psm,0.01
ident_fdr_peptide,0.01
ident_fdr_protein,0.01
ident_fdr_peptide,1
ident_fdr_protein,1
enable_match_between_runs,True
precursor_mass_tolerance,10 ppm
precursor_mass_tolerance,-20 ppm|20 ppm
fragment_mass_tolerance,0.02 Da
enzyme,stricttrypsin
allowed_miscleavages,2
Expand All @@ -17,9 +17,9 @@ fixed_mods,"0.0,C-Term Peptide,true,-1; 0.0,N-Term Peptide,true,-1; 0.0,C-Term P
variable_mods,"15.9949,M,true,3; 42.0106,[^,true,1; 79.96633,STY,false,3; -17.0265,nQnC,false,1; -18.0106,nE,false,1; 4.025107,K,false,2; 6.020129,R,false,2; 8.014199,K,false,2; 10.008269,R,false,2; 0.0,site_10,false,1; 0.0,site_11,false,1; 0.0,site_12,false,1; 0.0,site_13,false,1; 0.0,site_14,false,1; 0.0,site_15,false,1; 0.0,site_16,false,1"
max_mods,3
min_precursor_charge,1
max_precursor_charge,4
max_precursor_charge,
scan_window,
quantification_method_DIANN,
second_pass,
protein_inference,
predictors_library,
protein_inference,ProteinProphet: --maxppmdiff 2000000
predictors_library,
10 changes: 5 additions & 5 deletions test/params/fragpipe_win_paths_extracted_params.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ software_version,21.1
search_engine,MSFragger
search_engine_version,4.0
ident_fdr_psm,0.01
ident_fdr_peptide,0.01
ident_fdr_protein,0.01
ident_fdr_peptide,1
ident_fdr_protein,1
enable_match_between_runs,True
precursor_mass_tolerance,10 ppm
precursor_mass_tolerance,-20 ppm|20 ppm
fragment_mass_tolerance,0.02 Da
enzyme,stricttrypsin
allowed_miscleavages,2
Expand All @@ -17,9 +17,9 @@ fixed_mods,"0.0,C-Term Peptide,true,-1; 0.0,N-Term Peptide,true,-1; 0.0,C-Term P
variable_mods,"15.9949,M,true,3; 42.0106,[^,true,1; 79.96633,STY,false,3; -17.0265,nQnC,false,1; -18.0106,nE,false,1; 4.025107,K,false,2; 6.020129,R,false,2; 8.014199,K,false,2; 10.008269,R,false,2; 0.0,site_10,false,1; 0.0,site_11,false,1; 0.0,site_12,false,1; 0.0,site_13,false,1; 0.0,site_14,false,1; 0.0,site_15,false,1; 0.0,site_16,false,1"
max_mods,3
min_precursor_charge,1
max_precursor_charge,4
max_precursor_charge,
scan_window,
quantification_method_DIANN,
second_pass,
protein_inference,
protein_inference,ProteinProphet: --maxppmdiff 2000000
predictors_library,
Loading