Class MgfFileUtils
java.lang.Object
com.compomics.util.experiment.io.mass_spectrometry.mgf.MgfFileUtils
public class MgfFileUtils extends Object
Utilities for the handling of mgf files.
- Author:
- Marc Vaudel
-
Field Summary
Fields Modifier and Type Field Description static String[]
EXTENSIONS
The file extension for mgf files. -
Constructor Summary
Constructors Constructor Description MgfFileUtils()
-
Method Summary
Modifier and Type Method Description static void
addMissingPrecursorCharges(File mgfFile, WaitingHandler waitingHandler)
Add missing precursor charges.static void
addMissingSpectrumTitles(File mgfFile, WaitingHandler waitingHandler)
Adds missing spectrum titles.static void
removeDuplicateSpectrumTitles(File mgfFile, WaitingHandler waitingHandler)
Removes duplicate spectrum titles (the first occurrence is kept).static void
removeZeroes(File mgfFile, WaitingHandler waitingHandler)
Removes zero intensity peaks.static void
renameDuplicateSpectrumTitles(File mgfFile, WaitingHandler waitingHandler)
Renames duplicate spectrum titles.static ArrayList<MgfIndex>
splitFile(File mgfFile, int nSpectra, WaitingHandler waitingHandler)
Splits an mgf file into smaller ones and returns the indexes of the generated files.
-
Field Details
-
EXTENSIONS
The file extension for mgf files.
-
-
Constructor Details
-
MgfFileUtils
public MgfFileUtils()
-
-
Method Details
-
removeDuplicateSpectrumTitles
public static void removeDuplicateSpectrumTitles(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, UnsupportedEncodingExceptionRemoves duplicate spectrum titles (the first occurrence is kept).- Parameters:
mgfFile
- the MGF file to validatewaitingHandler
- a waitingHandler showing the progress, can be null- Throws:
FileNotFoundException
- Exception thrown whenever the file is not foundIOException
- Exception thrown whenever an error occurs while reading the fileUnsupportedEncodingException
- if the decoding of a spectrum title fails
-
addMissingSpectrumTitles
public static void addMissingSpectrumTitles(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, UnsupportedEncodingExceptionAdds missing spectrum titles.- Parameters:
mgfFile
- the MGF file to fixwaitingHandler
- a waitingHandler showing the progress, can be null- Throws:
FileNotFoundException
- Exception thrown whenever the file is not foundIOException
- Exception thrown whenever an error occurs while reading the fileUnsupportedEncodingException
- if the decoding of a spectrum title fails
-
addMissingPrecursorCharges
public static void addMissingPrecursorCharges(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, UnsupportedEncodingExceptionAdd missing precursor charges.- Parameters:
mgfFile
- the MGF file to fixwaitingHandler
- a waitingHandler showing the progress, can be null- Throws:
FileNotFoundException
- Exception thrown whenever the file is not foundIOException
- Exception thrown whenever an error occurs while reading the fileUnsupportedEncodingException
- if the decoding of a spectrum title fails
-
removeZeroes
public static void removeZeroes(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, UnsupportedEncodingExceptionRemoves zero intensity peaks.- Parameters:
mgfFile
- the MGF file to fixwaitingHandler
- a waitingHandler showing the progress, can be null- Throws:
FileNotFoundException
- Exception thrown whenever the file is not foundIOException
- Exception thrown whenever an error occurs while reading the fileUnsupportedEncodingException
- if the decoding of a spectrum title fails
-
renameDuplicateSpectrumTitles
public static void renameDuplicateSpectrumTitles(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, UnsupportedEncodingExceptionRenames duplicate spectrum titles. Adds (2), (3) etc, behind the duplicate spectrum titles.- Parameters:
mgfFile
- the MGF file to validatewaitingHandler
- a waitingHandler showing the progress- Throws:
FileNotFoundException
- Exception thrown whenever the file is not foundIOException
- Exception thrown whenever an error occurs while reading the fileUnsupportedEncodingException
- if the decoding of a spectrum title fails
-
splitFile
public static ArrayList<MgfIndex> splitFile(File mgfFile, int nSpectra, WaitingHandler waitingHandler) throws FileNotFoundException, IOExceptionSplits an mgf file into smaller ones and returns the indexes of the generated files.- Parameters:
mgfFile
- the mgf file to splitnSpectra
- the number of spectra allowed in the smaller fileswaitingHandler
- the waitingHandler showing the progress- Returns:
- a list of indexes of the generated files
- Throws:
FileNotFoundException
- exception thrown whenever a file was not foundIOException
- exception thrown whenever a problem occurred while reading/writing a file
-