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

[FBMN] Filtering MGF based on quant file #695

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ def main():
shutil.copyfile(input_mgf, args.output_mgf)
mzmine2_formatter.convert_to_feature_csv(args.quantification_table, args.quantification_table_reformatted)

# Checking that the MGF input has only the features that we included in the quantification table
try:
all_features_df = pd.read_csv(args.quantification_table_reformatted, sep=",")
all_features_list = list(all_features_df["row ID"])

import ming_spectrum_library
spectrum_collection = ming_spectrum_library.SpectrumCollection()
spectrum_collection.load_from_file(args.output_mgf)

all_spectra = spectrum_collection.spectrum_list
filtered_spectra = []
for spectum in all_spectra:
if spectrum is None:
continue

if int(spectrum.scan) in all_features_list:
filtered_spectra.append(spectrum)

spectrum_collection.spectrum_list = filtered_spectra
spectrum_collection.save_to_mgf(args.output_mgf, renumber_scans=False)
except:
pass

elif args.toolname == "OPENMS":
print("OPENMS")

Expand Down