Skip to content

Commit

Permalink
Merge pull request #855 from Mailaender/mzml-default-array-length
Browse files Browse the repository at this point in the history
Set required mzML defaultArrayLength
  • Loading branch information
eselmeister authored Dec 18, 2021
2 parents 76ead2b + 216b026 commit ec1007e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,41 @@ public void writeChromatogram(File file, IChromatogramMSD chromatogram, IProgres
float[] retentionTimes = new float[scans];
int i = 0;
for(IScan scan : chromatogram.getScans()) {
SpectrumType spectrum = new SpectrumType();
spectrum.setId("scan=" + scan.getScanNumber());
spectrum.setIndex(BigInteger.valueOf((scan.getScanNumber() - 1)));
// TIC
totalSignals[i] = scan.getTotalSignal();
retentionTimes[i] = scan.getRetentionTime();
i++;
//
// full spectra
IScanMSD scanMSD = (IScanMSD)scan;
//
CVParamType cvParamTotalIonCurrent = new CVParamType();
cvParamTotalIonCurrent.setAccession("MS:1000285");
cvParamTotalIonCurrent.setName("total ion current");
cvParamTotalIonCurrent.setUnitAccession("MS:1000131");
cvParamTotalIonCurrent.setUnitName("number of detector counts");
cvParamTotalIonCurrent.setValue(String.valueOf(scanMSD.getTotalSignal()));
spectrum.getCvParam().add(cvParamTotalIonCurrent);
//
CVParamType cvParamBasePeak = new CVParamType();
cvParamBasePeak.setAccession("MS:1000504");
cvParamBasePeak.setName("base peak m/z");
cvParamBasePeak.setUnitAccession("MS:1000040");
cvParamBasePeak.setUnitName("m/z");
cvParamBasePeak.setValue(String.valueOf(scanMSD.getBasePeak()));
spectrum.getCvParam().add(cvParamBasePeak);
//
CVParamType cvParamBasePeakIntensity = new CVParamType();
cvParamBasePeakIntensity.setAccession("MS:1000505");
cvParamBasePeakIntensity.setName("base peak intensity");
cvParamBasePeakIntensity.setUnitAccession("MS:1000131");
cvParamBasePeakIntensity.setUnitName("number of detector counts");
cvParamBasePeakIntensity.setValue(String.valueOf(scanMSD.getBasePeakAbundance()));
spectrum.getCvParam().add(cvParamBasePeakIntensity);
//
List<IIon> ionList = scanMSD.getIons();
double[] ions = new double[ionList.size()];
float[] abundances = new float[ionList.size()];
Expand Down Expand Up @@ -112,28 +141,35 @@ public void writeChromatogram(File file, IChromatogramMSD chromatogram, IProgres
ScanListType scanList = new ScanListType();
scanList.getScan().add(scanType);
//
SpectrumType spectrum = new SpectrumType();
spectrum.setId("scan=" + scan.getScanNumber());
spectrum.setIndex(BigInteger.valueOf((scan.getScanNumber() - 1)));
spectrum.setScanList(scanList);
spectrum.setBinaryDataArrayList(binaryDataArrayList);
IVendorMassSpectrum massSpectrum = (IVendorMassSpectrum)scanMSD;
CVParamType cvParamType = new CVParamType();
if(massSpectrum.getMassSpectrometer() == 1) {
cvParamType.setAccession("MS:1000579");
cvParamType.setName("MS1 spectrum");
} else {
cvParamType.setAccession("MS:1000580");
cvParamType.setName("MSn spectrum");
}
spectrum.getCvParam().add(cvParamType);
CVParamType cvParamLevel = new CVParamType();
cvParamLevel.setAccession("MS:1000511");
cvParamLevel.setName("ms level");
cvParamLevel.setValue(String.valueOf(massSpectrum.getMassSpectrometer()));
spectrum.getCvParam().add(cvParamLevel);
if(massSpectrum.getMassSpectrumType() == 0) {
CVParamType cvParamType = new CVParamType();
cvParamType.setAccession("MS:1000127");
cvParamType.setName("centroid spectrum");
spectrum.getCvParam().add(cvParamType);
CVParamType cvSpectrumType = new CVParamType();
cvSpectrumType.setAccession("MS:1000127");
cvSpectrumType.setName("centroid spectrum");
spectrum.getCvParam().add(cvSpectrumType);
} else if(massSpectrum.getMassSpectrumType() == 1) {
CVParamType cvParamType = new CVParamType();
cvParamType.setAccession("MS:1000128");
cvParamType.setName("profile spectrum");
spectrum.getCvParam().add(cvParamType);
CVParamType cvSpectrumType = new CVParamType();
cvSpectrumType.setAccession("MS:1000128");
cvSpectrumType.setName("profile spectrum");
spectrum.getCvParam().add(cvSpectrumType);
}
spectrum.setDefaultArrayLength(ions.length);
spectrumList.getSpectrum().add(spectrum);
}
run.setSpectrumList(spectrumList);
Expand All @@ -157,6 +193,7 @@ public void writeChromatogram(File file, IChromatogramMSD chromatogram, IProgres
binaryDataArrayList.getBinaryDataArray().add(retentionTimesBinaryDataArrayType);
//
ChromatogramType tic = new ChromatogramType();
tic.setDefaultArrayLength(totalSignals.length);
tic.setBinaryDataArrayList(binaryDataArrayList);
chromatogramList.getChromatogram().add(tic);
run.setChromatogramList(chromatogramList);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -205,7 +205,7 @@ public static Shell getShell(Widget widget) {
public static Shell getShell() {

if(Display.getCurrent() == null) {
logger.error("Try to access shell outside of UI-Thread!");
logger.error("Tried to access shell outside of UI thread!");
Thread.dumpStack();
return null;
}
Expand Down

0 comments on commit ec1007e

Please sign in to comment.