Class MgfFileUtils
java.lang.Object
com.compomics.util.experiment.io.mass_spectrometry.mgf.MgfFileUtils
Utilities for the handling of mgf files.
- Author:
- Marc Vaudel, Harald Barsnes
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddMissingPrecursorCharges(File mgfFile, WaitingHandler waitingHandler) Add missing precursor charges.static voidaddMissingSpectrumTitles(File mgfFile, WaitingHandler waitingHandler) Adds missing spectrum titles.static voidremoveDuplicateSpectrumTitles(File mgfFile, WaitingHandler waitingHandler) Removes duplicate spectrum titles (the first occurrence is kept).static voidremoveZeroes(File mgfFile, WaitingHandler waitingHandler) Removes zero intensity peaks.static voidrenameDuplicateSpectrumTitles(File mgfFile, WaitingHandler waitingHandler) Renames duplicate spectrum titles.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, UnsupportedEncodingException Removes 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, UnsupportedEncodingException Adds 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, UnsupportedEncodingException Add 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, UnsupportedEncodingException Removes 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, UnsupportedEncodingException Renames 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, IOException Splits 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
-