Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed mzML EncodedLength according to specification #844

Merged
merged 2 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.nio.FloatBuffer;
import java.util.zip.Deflater;

import javax.xml.bind.DatatypeConverter;

import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.v110.model.BinaryDataArrayType;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.v110.model.CVParamType;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.preferences.PreferenceSupplier;
Expand Down Expand Up @@ -69,16 +71,16 @@ private static BinaryDataArrayType createBinaryDataArray(ByteBuffer byteBuffer)
compresser.finish();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] readBuffer = new byte[1024];
int compressedDataLength = 0;
while(!compresser.finished()) {
int compressCount = compresser.deflate(readBuffer);
if(compressCount > 0) {
compressedDataLength += compressCount;
outputStream.write(readBuffer, 0, compressCount);
}
}
binaryDataArrayType.setEncodedLength(BigInteger.valueOf(compressedDataLength));
binaryDataArrayType.setBinary(outputStream.toByteArray());
byte[] outputByteArray = outputStream.toByteArray();
String characters = DatatypeConverter.printBase64Binary(outputByteArray);
binaryDataArrayType.setEncodedLength(BigInteger.valueOf(characters.length()));
binaryDataArrayType.setBinary(outputByteArray);
compresser.end();
} else {
binaryDataArrayType.setBinary(byteBuffer.array());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
Expand Down Expand Up @@ -62,6 +63,7 @@ public void writeChromatogram(File file, IChromatogramMSD chromatogram, IProgres
RunType run = new RunType();
SpectrumListType spectrumList = new SpectrumListType();
ChromatogramListType chromatogramList = new ChromatogramListType();
chromatogramList.setCount(BigInteger.valueOf(1));
//
int scans = chromatogram.getNumberOfScans();
float[] totalSignals = new float[scans];
Expand Down