How to merge mgf files?
1
0
Entering edit mode
5.7 years ago
I0110 ▴ 140

I was wondering if there is an easy way to merge mgf (mass-spec) files with Python and Bioconductor. Thanks!!!

Proteomics • 2.3k views
ADD COMMENT
0
Entering edit mode
5.7 years ago
mobiusklein ▴ 180

If none of the MGF files have parameters set at the top of the file, merging MGF files is as simple as concatenating two text files.

#!/usr/bin/python
with open("output.mgf", 'w') as fh:
   fh.write(open("a.mgf", 'r').read())
   fh.write("\n")
   fh.write(open("b.mgf", 'r').read())
   fh.write("\n")
   # or a for-loop if you have more than two files

If there are parameters at the top of both files, and they are not the same from file to file, and you don't care about preserving them, you can skip all the lines in each file before the first occurrence of BEGIN IONS. If you do care about preserving the top-level parameters, there isn't a standard way to merge files, in part because the meaning and interpretation of those parameters aren't standardized.

ADD COMMENT

Login before adding your answer.

Traffic: 2131 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6