Question: How to merge mgf files?
0
gravatar for I0110
18 months ago by
I0110120
United States
I0110120 wrote:

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

proteomics • 614 views
ADD COMMENTlink modified 17 months ago by mobiusklein160 • written 18 months ago by I0110120
0
gravatar for mobiusklein
17 months ago by
mobiusklein160
United States
mobiusklein160 wrote:

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 COMMENTlink written 17 months ago by mobiusklein160
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 919 users visited in the last hour