2.2 Read MzML File - PRIDE-Utilities/ms-data-core-api GitHub Wiki
Example of Reading and mzML file:
MzMLControllerImpl mzMLController = new MzMLControllerImpl(inputFile);
/** Retrieve the file metadata including contacts File Description, etc**/
ExperimentMetaData metada = mzMLController.getExperimentMetaData();
/** Retrieve the Sample information **/
List<Sample> samples = mzMLController.getSamples();
/** Retrieve the List of Softwares used to generate the file**/
List<Software> softwares = mzMLController.getSoftwares();
/** Retrieve Dta Processing steps **/
List<DataProcessing> dataProcessings = mzMLController.getDataProcessings();
/** Retrieve all the MS sptra **/
List<Comparable> ids = new ArrayList<Comparable>(mzMLController.getSpectrumIds());
for(Comparable id: ids){
Spectrum spectrum = mzMLController.getSpectrumById(id);
/** Print number of Peaks **/
int numberOfPeaks = spectrum.getMassIntensityMap().length;
System.out.println(numberOfPeaks);
}
/** Retrieve all the Chromatograms **/
ids = new ArrayList<Comparable>(mzMLController.getChromatogramIds());
for(Comparable id: ids){
Chromatogram chromatogram = mzMLController.getChromatogramById("id");
/** Print number of Peaks **/
int numberOfPeaks = chromatogram.getTimeArray().getDoubleArray().length;
System.out.println(numberOfPeaks);
}
``