Skip to content

Commit

Permalink
fix: correclty use inflate and not deflate
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed Dec 2, 2024
1 parent 25fa073 commit baa1a4e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 10 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# History of formats

https://dx.doi.org/10.1074/mcp.R110.000133

- mzData was developed by HUPO-PSI
- http://psidev.info/index.php?qnode/80#mzdata
- https://doi.org/10.1002/pmic.200300588
- mzXML was developed at the Institute for Systems Biology
- mzML: new unified output format started in 2006

mzML - 4 goals:

- creation of a simple format
- elimination of alternate ways to encode the same information
- support for all the features of both mzXML and mzData
- validation through implementation prior to release.

![mzml](images/mzml.png)

cv = Controlled Volabulatry

# mzData

[![NPM version][npm-image]][npm-url]
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
"testEnvironment": "node"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"@babel/plugin-transform-modules-commonjs": "^7.24.1",
"@types/jest": "^29.5.12",
"cheminfo-build": "^1.2.0",
"eslint": "^8.57.0",
"eslint-config-cheminfo": "^9.2.0",
"jest": "^29.7.0",
"prettier": "^3.2.5",
"rollup": "^4.12.0"
"rollup": "^4.17.2"
},
"dependencies": {
"arraybuffer-xml-parser": "^0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export default {
input: 'src/index.js',
output: {
format: 'cjs',
file: 'lib/index.js'
file: 'lib/index.js',
}
};
2 changes: 2 additions & 0 deletions src/mzml/parseMzML.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { processSpectrumList } from './processSpectrumList';

const decoder = new TextDecoder();

// https://www.psidev.info/mzml
// CV = Controlled vocabulary
export function parseMzML(arrayBuffer) {
const result = {
metadata: {},
Expand Down
4 changes: 2 additions & 2 deletions src/mzml/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { decode } from 'base64-arraybuffer';
import pako from 'pako';
import { inflate } from 'pako';

export function decoder(base64Encoded, options = {}) {
const { compressionAlgorithm } = options;
let decoded;
switch (compressionAlgorithm) {
case 'zlib':
decoded = pako.deflate(decode(base64Encoded));
decoded = inflate(decode(base64Encoded));
break;
case undefined:
case '':
Expand Down
4 changes: 2 additions & 2 deletions src/mzxml/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { decode } from 'base64-arraybuffer';
import pako from 'pako';
import { inflate } from 'pako';

export function decoder(base64Encoded, options = {}) {
const { compressionAlgorithm } = options;
let decoded;
switch (compressionAlgorithm) {
case 'zlib':
decoded = pako.deflate(decode(base64Encoded));
decoded = inflate(decode(base64Encoded));
break;
case undefined:
case '':
Expand Down
6 changes: 3 additions & 3 deletions src/util/decodeBase64.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pako from 'pako';
import { inflate } from 'pako';
import { decode } from 'uint8-base64';

export function decodeBase64(base64, options = {}) {
Expand Down Expand Up @@ -28,13 +28,13 @@ export function decodeBase64(base64, options = {}) {
let uint8Array = decode(base64);
switch (compression.toLowerCase()) {
case 'zlib':
uint8Array = pako.inflate(uint8Array);
uint8Array = inflate(uint8Array);
break;
case '':
case 'none':
break;
default:
throw new Error(`Unknow compression algorithm: ${compression}`);
throw new Error(`Unknown compression algorithm: ${compression}`);
}

switch (endian.toLowerCase()) {
Expand Down

0 comments on commit baa1a4e

Please sign in to comment.