Skip to content

Commit

Permalink
cary500 (#247)
Browse files Browse the repository at this point in the history
* wip: prepare cary500Loader

* update!: support for fileCollection and guess the spectra type (#246)

* update: support for fileCollection and classification of spectra

* update: a few missing types, and prettify

* test: disable temporarely getIVMeasurement

* chore: rename files to fileCollection

* chore: add todo to use FiltCollection.filter

Co-authored-by: Luc Patiny <luc@patiny.com>

* feat: add experimental cary500Loader

* chore: update dependencies and add testcase

* chore: add missing vitest import

* chore: fix prettier

Co-authored-by: Santiago Miranda <santimir@protonmail.com>
  • Loading branch information
lpatiny and Santiago Miranda committed Oct 15, 2022
1 parent 0bb78c5 commit 4bf2a26
Show file tree
Hide file tree
Showing 9 changed files with 2,020 additions and 34 deletions.
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@tanstack/react-table": "^8.5.15",
"biologic-converter": "^0.2.0",
"cheminfo-types": "^1.4.0",
"filelist-utils": "^0.12.0",
"filelist-utils": "^1.0.1",
"immer": "^9.0.15",
"jcampconverter": "^9.0.2",
"lodash": "^4.17.21",
Expand All @@ -76,7 +76,7 @@
"@types/react-dom": "^18.0.6",
"@types/react-inspector": "^4.0.2",
"@vitejs/plugin-react": "^2.1.0",
"@vitest/coverage-c8": "^0.24.1",
"@vitest/coverage-c8": "^0.24.3",
"@zakodium/eslint-config": "^6.0.0",
"babel-loader": "^8.2.5",
"cheminfo-font": "^1.9.0",
Expand All @@ -87,15 +87,15 @@
"prettier": "^2.7.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0",
"react-icons": "^4.6.0",
"react-inspector": "^6.0.1",
"react-ocl": "^5.0.0",
"react-plot": "^0.20.2",
"rimraf": "^3.0.2",
"typescript": "^4.8.4",
"vite": "^3.1.8",
"vite-tsconfig-paths": "^3.5.1",
"vitest": "^0.24.1"
"vitest": "^0.24.3"
},
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion src/app/context/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { getIRAutoPeakPickingEnhancer } from '../data/enhancers/irAutoPeakPickin
import { irMeasurementEnhancer } from '../data/enhancers/irMeasurementEnhancer';
import { biologicLoader } from '../data/loaders/biologicLoader';
import { jcampLoader } from '../data/loaders/jcampLoader';
import { cary500Loader } from '../data/loaders/proprietary/agilent/cary500Loader';
import { spcLoader } from '../data/loaders/spcLoader';
import { wdfLoader } from '../data/loaders/wdfLoader';

import type { AppDispatch } from './appState';

const options = {
loaders: [jcampLoader, spcLoader, wdfLoader, biologicLoader],
loaders: [jcampLoader, spcLoader, wdfLoader, biologicLoader, cary500Loader],
enhancers: {
ir: [
irMeasurementEnhancer,
Expand Down
5 changes: 5 additions & 0 deletions src/app/data/DataState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export interface Measurements {
uv: {
entries: MeasurementBase[];
};
uvvis: {
entries: MeasurementBase[];
};
nmr1h: {
entries: MeasurementBase[];
};
Expand All @@ -42,6 +45,7 @@ export const kindsLabel: Record<MeasurementKind, string> = {
iv: 'IV',
raman: 'Raman',
uv: 'UV',
uvvis: 'UV-VIS',
mass: 'Mass',
nmr1h: 'NMR 1H',
other: 'Other',
Expand All @@ -64,6 +68,7 @@ export function getEmptyMeasurements(): Measurements {
iv: { entries: [] },
raman: { entries: [] },
uv: { entries: [] },
uvvis: { entries: [] },
nmr1h: { entries: [] },
mass: { entries: [] },
other: { entries: [] },
Expand Down
1 change: 1 addition & 0 deletions src/app/data/__tests__/append.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ test('append', async () => {
'iv',
'raman',
'uv',
'uvvis',
'nmr1h',
'mass',
'other',
Expand Down
18 changes: 6 additions & 12 deletions src/app/data/__tests__/getIRMeasurement.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'path';

import { FileCollection, fileCollectionFromPath } from 'filelist-utils';
import { fileCollectionFromPath } from 'filelist-utils';

import { getEmptyDataState } from '../DataState';
import { append } from '../append';
Expand All @@ -18,17 +18,11 @@ const enhancers = {

export async function getIRMeasurement() {
const dataState = getEmptyDataState();
const fileCollection = await fileCollectionFromPath(
join(__dirname, 'data/jdx/'),
);
//todo use 'filter' from fileCollection
let filteredFileCollection;
for (let f of fileCollection) {
if (f.name === 'ir.jdx') {
filteredFileCollection = new FileCollection([f]);
break;
}
}

const filteredFileCollection = (
await fileCollectionFromPath(join(__dirname, 'data/jdx/'))
).filter((file) => file.name === 'ir.jdx');

const irEntry = (
await append(filteredFileCollection, dataState, { loaders, enhancers })
).dataState.measurements.ir.entries[0];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { join } from 'path';

import { fileCollectionFromPath } from 'filelist-utils';
import { expect, test } from 'vitest';

import { cary500Loader } from '../cary500Loader';

test('cary500Loader', async () => {
const fileCollection = await fileCollectionFromPath(join(__dirname, 'data'));
// we should filter to keep only the right data
const results = await cary500Loader(fileCollection);

expect(results.uvvis.entries).toHaveLength(8);
});

0 comments on commit 4bf2a26

Please sign in to comment.