Skip to content

Commit

Permalink
fix: update dependencies (#55)
Browse files Browse the repository at this point in the history
feat!: calculateForMF is now async and returns a Promise
feat: getPeaks will make a baseline correction before calculate the noise
chore!: remove support for Node.js 12

Co-authored-by: Luc Patiny <[email protected]>
  • Loading branch information
targos and lpatiny authored Mar 8, 2022
1 parent f1f5f06 commit c173e22
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 199 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lactame.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [published]

env:
NODE_VERSION: 14.x
NODE_VERSION: 16.x

jobs:
deploy:
Expand All @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- name: Get package name
run: echo "PACKAGE_NAME=$(jq .name package.json | tr -d '"')" >> $GITHUB_ENV
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
Expand Down
40 changes: 7 additions & 33 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,13 @@ name: Node.js CI

on:
push:
branches: master
branches:
- master
pull_request:

env:
NODE_VERSION: 14.x

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm install
- name: Run ESLint
run: npm run eslint
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test-coverage
- name: Send coverage report to Codecov
uses: codecov/codecov-action@v1
nodejs:
# Documentation: https://github.com/zakodium/workflows#nodejs-ci
uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1
with:
node-version-matrix: '[14, 16]'
37 changes: 8 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,12 @@ on:
branches:
- master

env:
NODE_VERSION: 14.x

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- name: Get package name
run: echo "PACKAGE_NAME=$(jq .name package.json | tr -d '"')" >> $GITHUB_ENV
- uses: GoogleCloudPlatform/release-please-action@v2
id: release
with:
token: ${{ secrets.BOT_TOKEN }}
release-type: node
package-name: ${{ env.PACKAGE_NAME }}
bump-minor-pre-major: Yes
- uses: actions/checkout@v2
# These if statements ensure that a publication only occurs when a new release is created
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }}
- run: npm install
if: ${{ steps.release.outputs.release_created }}
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_BOT_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
release:
# Documentation: https://github.com/zakodium/workflows#release
uses: zakodium/workflows/.github/workflows/release.yml@release-v1
with:
npm: true
secrets:
github-token: ${{ secrets.BOT_TOKEN }}
npm-token: ${{ secrets.NPM_BOT_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/typedoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
types: [published]

env:
NODE_VERSION: 14.x
NODE_VERSION: 16.x
ENTRY_FILE: 'chromatography.d.ts'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
Expand Down
5 changes: 0 additions & 5 deletions .ncurc

This file was deleted.

File renamed without changes.
54 changes: 26 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@
"build": "cheminfo-build --entry src/index.js --root Chromatography",
"eslint": "eslint src --cache",
"eslint-fix": "npm run eslint -- --fix",
"prepublishOnly": "rollup -c",
"test": "npm run test-coverage && npm run eslint",
"test-only": "jest",
"test-coverage": "jest --coverage"
"prepack": "rollup -c",
"prettier": "prettier --check src",
"prettier-write": "prettier --write src",
"test": "npm run test-only && npm run eslint && npm run prettier",
"test-only": "jest --coverage"
},
"repository": {
"type": "git",
"url": "git+https://github.com/cheminfo/chromatography.git"
},
"jest": {
"testEnvironment": "node",
"transformIgnorePatterns": []
},
"author": "Michaël Zasso",
"contributors": [
"Miguel Asencio <[email protected]>"
Expand All @@ -49,38 +46,39 @@
"homepage": "https://github.com/cheminfo/chromatography#readme",
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.16.8",
"@types/jest": "^27.4.0",
"@types/jest": "^27.4.1",
"cheminfo-build": "^1.1.11",
"convert-to-jcamp": "^5.1.1",
"eslint": "^8.6.0",
"eslint-config-cheminfo": "^7.2.1",
"convert-to-jcamp": "^5.2.0",
"eslint": "^8.10.0",
"eslint-config-cheminfo": "^7.2.2",
"esm": "^3.2.25",
"jest": "^27.4.7",
"jest": "^27.5.1",
"jest-matcher-deep-close-to": "^3.0.2",
"prettier": "^2.5.1",
"rollup": "^2.63.0",
"spectrum-generator": "^6.0.2",
"typescript": "^4.5.4"
"rollup": "^2.70.0",
"spectrum-generator": "^8.0.0",
"typescript": "^4.6.2"
},
"dependencies": {
"binary-search": "^1.3.6",
"is-any-array": "^2.0.0",
"isotopic-distribution": "^1.4.0",
"jcampconverter": "^8.2.4",
"mf-generator": "^1.3.8",
"mf-parser": "^1.4.0",
"ml-array-max": "^1.2.3",
"ml-array-mean": "^1.1.5",
"ml-array-median": "^1.1.5",
"ml-array-sum": "^1.1.5",
"ml-gsd": "^6.9.2",
"ml-matrix": "^6.8.2",
"isotopic-distribution": "^1.4.9",
"jcampconverter": "^8.2.5",
"mf-generator": "^1.3.20",
"mf-parser": "^1.4.5",
"ml-airpls": "^1.0.0",
"ml-array-max": "^1.2.4",
"ml-array-mean": "^1.1.6",
"ml-array-median": "^1.1.6",
"ml-array-sum": "^1.1.6",
"ml-gsd": "^10.1.2",
"ml-matrix": "^6.9.0",
"ml-ngmca": "^1.0.0",
"ml-pca": "^4.0.2",
"ml-regression-polynomial": "^2.2.0",
"ml-spectra-processing": "^8.0.3",
"ml-spectra-processing": "^11.0.0",
"mzdata": "^2.3.1",
"netcdf-gcms": "^1.4.0",
"xy-parser": "^4.0.1"
"xy-parser": "^5.0.1"
}
}
1 change: 0 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const config = {
'ml-array-median',
'ml-array-sum',
'ml-gsd',
'ml-gsd/src/gsd',
'ml-regression-polynomial',
'ml-spectra-processing',
'mzdata',
Expand Down
4 changes: 2 additions & 2 deletions src/Chromatogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ export class Chromatogram {
return this.getSeries(seriesName);
}

calculateForMF(targetMF, options = {}) {
async calculateForMF(targetMF, options = {}) {
const {
seriesName = `${targetMF}(${options.ionizations || 'H+'}${
options.slotWidth / 2 || 0.5
}${options.threshold ? `(${options.threshold})` : ''}`,
cache = false,
} = options;
if (cache && this.hasSeries(seriesName)) return this.getSeries(seriesName);
const result = calculateForMF(this, targetMF, options);
const result = await calculateForMF(this, targetMF, options);
this.addSeries(seriesName, result, options);
return this.getSeries(seriesName);
}
Expand Down
24 changes: 4 additions & 20 deletions src/__tests__/scaleAlignment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,10 @@ test('Simple case', () => {

expect(compared.peaksSimilarity).toStrictEqual([1, 1, 1, 1, 1]);
expect(compared.peaksFirst.map((val) => val.retentionTime)).toStrictEqual([
10,
20,
30,
40,
50,
10, 20, 30, 40, 50,
]);
expect(compared.peaksSecond.map((val) => val.retentionTime)).toStrictEqual([
20,
30,
40,
50,
60,
20, 30, 40, 50, 60,
]);

let aligned = scaleAlignment(compared.peaksFirst, compared.peaksSecond);
Expand Down Expand Up @@ -114,18 +106,10 @@ test('Quality and string', () => {
let compared = spectraComparison(chrom1, chrom2, options);
expect(compared.peaksSimilarity).toStrictEqual([1, 1, 1, 1, 1]);
expect(compared.peaksFirst.map((val) => val.retentionTime)).toStrictEqual([
10,
20,
30,
40,
50,
10, 20, 30, 40, 50,
]);
expect(compared.peaksSecond.map((val) => val.retentionTime)).toStrictEqual([
20,
30,
40,
50,
60,
20, 30, 40, 50, 60,
]);

let aligned = scaleAlignment(compared.peaksFirst, compared.peaksSecond, {
Expand Down
28 changes: 6 additions & 22 deletions src/__tests__/spectraComparison.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,10 @@ test('Simple case', () => {
let compared = spectraComparison(chrom1, chrom2, options);
expect(compared.peaksSimilarity).toStrictEqual([1, 1, 1, 1, 1]);
expect(compared.peaksFirst.map((val) => val.retentionTime)).toStrictEqual([
10,
20,
30,
40,
50,
10, 20, 30, 40, 50,
]);
expect(compared.peaksSecond.map((val) => val.retentionTime)).toStrictEqual([
20,
30,
40,
50,
60,
20, 30, 40, 50, 60,
]);
});

Expand Down Expand Up @@ -110,16 +102,10 @@ test('Shifted peaks', () => {
let compared = spectraComparison(chrom1, chrom2, options);
expect(compared.peaksSimilarity).toStrictEqual([1, 1, 1, 1]);
expect(compared.peaksFirst.map((val) => val.retentionTime)).toStrictEqual([
20,
30,
40,
50,
20, 30, 40, 50,
]);
expect(compared.peaksSecond.map((val) => val.retentionTime)).toStrictEqual([
20,
30,
40,
50,
20, 30, 40, 50,
]);
});

Expand Down Expand Up @@ -179,11 +165,9 @@ test('Remove similar peaks in the similarity matrix column', () => {

expect(compared.peaksSimilarity).toStrictEqual([1, 1]);
expect(compared.peaksFirst.map((val) => val.retentionTime)).toStrictEqual([
40,
50,
40, 50,
]);
expect(compared.peaksSecond.map((val) => val.retentionTime)).toStrictEqual([
50,
60,
50, 60,
]);
});
34 changes: 17 additions & 17 deletions src/ms/__tests__/calculateForMF.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@ import { Chromatogram } from '../..';
import { simple } from '../../../testFiles/examples';

describe('calculateForMF', () => {
it('basic', () => {
simple.calculateForMF('C8H3', { ionizations: 'H+' });
it('basic', async () => {
await simple.calculateForMF('C8H3', { ionizations: 'H+' });
expect(simple.getSeries('C8H3(H+)±0.5').data).toStrictEqual([10, 11]);
});

it('basic range', () => {
simple.calculateForMF('(CH)0-5C5', { ionizations: 'H+' });
it('basic range', async () => {
await simple.calculateForMF('(CH)0-5C5', { ionizations: 'H+' });
expect(simple.getSeries('(CH)0-5C5(H+)±0.5').data).toStrictEqual([10, 11]);
});

it('check threshold', () => {
simple.calculateForMF('C8H3', { threshold: 0.9, ionizations: 'H+' });
it('check threshold', async () => {
await simple.calculateForMF('C8H3', { threshold: 0.9, ionizations: 'H+' });
expect(simple.getSeries('C8H3(H+)±0.5(0.9)').data).toStrictEqual([10, 0]);
});

it('check many ionizations', () => {
simple.calculateForMF('C8H4', {
it('check many ionizations', async () => {
await simple.calculateForMF('C8H4', {
slotWidth: 0.01,
ionizations: '+,H+',
});
expect(simple.getSeries('C8H4(+,H+)±0.005').data).toStrictEqual([0, 0]);
});

it('check many ionizations, default slotWidth', () => {
simple.calculateForMF('C8H4', { ionizations: '+,H+' });
it('check many ionizations, default slotWidth', async () => {
await simple.calculateForMF('C8H4', { ionizations: '+,H+' });
expect(simple.getSeries('C8H4(+,H+)±0.5').data).toStrictEqual([10, 11]);
});

it('Errors', () => {
it('Errors', async () => {
const chromatogram = new Chromatogram([1, 2, 3, 5, 6]);
expect(() => {
chromatogram.calculateForMF();
}).toThrow('targetMF must be defined and a string');
expect(() => {
chromatogram.calculateForMF('C10');
}).toThrow('The series "ms" does not exist');
await expect(chromatogram.calculateForMF()).rejects.toThrow(
'targetMF must be defined and a string',
);
await expect(chromatogram.calculateForMF('C10')).rejects.toThrow(
'The series "ms" does not exist',
);
});
});
Loading

0 comments on commit c173e22

Please sign in to comment.