nmr-processing 7.4.3 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assignment/getAssignments.js +1 -1
- package/lib/assignment/getAssignments.js.map +1 -1
- package/lib/databases/getDatabase.d.ts +6 -1
- package/lib/databases/getDatabase.js +13 -3
- package/lib/databases/getDatabase.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/prediction/predictAllSpectra.d.ts +22 -4
- package/lib/prediction/predictAllSpectra.js +102 -16
- package/lib/prediction/predictAllSpectra.js.map +1 -1
- package/lib/xyz/NMRSignal2D.d.ts +3 -3
- package/lib-esm/assignment/getAssignments.js +1 -1
- package/lib-esm/assignment/getAssignments.js.map +1 -1
- package/lib-esm/databases/getDatabase.js +13 -3
- package/lib-esm/databases/getDatabase.js.map +1 -1
- package/lib-esm/prediction/predictAllSpectra.js +102 -16
- package/lib-esm/prediction/predictAllSpectra.js.map +1 -1
- package/package.json +12 -12
- package/src/assignment/getAssignments.ts +1 -1
- package/src/databases/getDatabase.ts +19 -2
- package/src/index.ts +1 -1
- package/src/prediction/predictAllSpectra.ts +151 -14
- package/src/xyz/NMRSignal2D.ts +3 -3
|
@@ -10,7 +10,7 @@ const checkIDs_1 = require("./utils/getAssignment/checkIDs");
|
|
|
10
10
|
const getTargetsAndCorrelations_1 = require("./utils/getAssignment/getTargetsAndCorrelations");
|
|
11
11
|
const getWorkFlow_1 = __importDefault(require("./utils/getAssignment/getWorkFlow"));
|
|
12
12
|
async function getAssignments(input, options = {}) {
|
|
13
|
-
let { restrictionByCS = {}, justAssign, minScore =
|
|
13
|
+
let { restrictionByCS = {}, justAssign, minScore = 0.01, maxSolutions = 10, nbAllowedUnAssigned, timeout = 6000, predictionOptions = {}, predictions = {}, correlation: correlationOptions = {}, } = options;
|
|
14
14
|
const { tolerance = { H: 0.2, C: 1 }, useChemicalShiftScore = false, chemicalShiftRestriction = true, } = restrictionByCS;
|
|
15
15
|
const molecule = input.molecule;
|
|
16
16
|
if (!molecule)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAssignments.js","sourceRoot":"","sources":["../../src/assignment/getAssignments.ts"],"names":[],"mappings":";;;;;;AACA,yDAAsE;AAQtE,6EAIgD;AAChD,6DAA0D;AAC1D,+FAA4F;AAC5F,oFAA4D;AA0ErD,KAAK,UAAU,cAAc,CAClC,KAA6B,EAC7B,UAAiC,EAAE;IAEnC,IAAI,EACF,eAAe,GAAG,EAAE,EACpB,UAAU,EACV,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"getAssignments.js","sourceRoot":"","sources":["../../src/assignment/getAssignments.ts"],"names":[],"mappings":";;;;;;AACA,yDAAsE;AAQtE,6EAIgD;AAChD,6DAA0D;AAC1D,+FAA4F;AAC5F,oFAA4D;AA0ErD,KAAK,UAAU,cAAc,CAClC,KAA6B,EAC7B,UAAiC,EAAE;IAEnC,IAAI,EACF,eAAe,GAAG,EAAE,EACpB,UAAU,EACV,QAAQ,GAAG,IAAI,EACf,YAAY,GAAG,EAAE,EACjB,mBAAmB,EACnB,OAAO,GAAG,IAAI,EACd,iBAAiB,GAAG,EAAE,EACtB,WAAW,GAAG,EAAE,EAChB,WAAW,EAAE,kBAAkB,GAAG,EAAE,GACrC,GAAG,OAAO,CAAC;IAEZ,MAAM,EACJ,SAAS,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,EAC5B,qBAAqB,GAAG,KAAK,EAC7B,wBAAwB,GAAG,IAAI,GAChC,GAAG,eAAe,CAAC;IAEpB,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;IAEhC,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAEpE,QAAQ,CAAC,oBAAoB,EAAE,CAAC;IAChC,IAAA,qDAAiC,EAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,OAAO,GAAG,IAAA,mBAAQ,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,IAAA,qDAAyB,EACzD,OAAO,EACP,kBAAkB,CACnB,CAAC;IAEF,MAAM,EAAE,eAAe,EAAE,GAAG,IAAA,qBAAW,EAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAElE,MAAM,SAAS,GAAG,MAAM,IAAA,mCAAgB,EAAC;QACvC,eAAe,EAAE;YACf,SAAS;YACT,qBAAqB;YACrB,wBAAwB;SACzB;QACD,OAAO;QACP,QAAQ;QACR,OAAO;QACP,QAAQ;QACR,YAAY;QACZ,eAAe;QACf,mBAAmB;QACnB,YAAY;QACZ,OAAO;QACP,iBAAiB;QACjB,WAAW;KACZ,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC;AAzDD,wCAyDC"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { DatabaseNMREntry } from './DatabaseNMREntry';
|
|
2
|
-
export declare function getDatabase(url?: string
|
|
2
|
+
export declare function getDatabase(url?: string, options?: {
|
|
3
|
+
/**
|
|
4
|
+
* @default 'tsv'
|
|
5
|
+
*/
|
|
6
|
+
format?: 'tsv' | 'json';
|
|
7
|
+
}): Promise<DatabaseNMREntry[]>;
|
|
@@ -3,13 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getDatabase = void 0;
|
|
4
4
|
const cross_fetch_1 = require("cross-fetch");
|
|
5
5
|
const resurrectRange_1 = require("../utilities/resurrectRange");
|
|
6
|
-
async function getDatabase(url = 'https://docs.google.com/spreadsheets/d/1uwyq_L38PMRWCcT4If_EhPbHKyY3q_2tpjV8vr5_zh0/edit?usp=sharing') {
|
|
6
|
+
async function getDatabase(url = 'https://docs.google.com/spreadsheets/d/1uwyq_L38PMRWCcT4If_EhPbHKyY3q_2tpjV8vr5_zh0/edit?usp=sharing', options = {}) {
|
|
7
|
+
const { format = 'tsv' } = options;
|
|
7
8
|
if (url.includes('google.com')) {
|
|
8
9
|
url = `https://googledocs.cheminfo.org/spreadsheets/d/${extractGoogleUUID(url)}/export?format=tsv`;
|
|
9
10
|
}
|
|
11
|
+
let parsed;
|
|
10
12
|
const response = await (0, cross_fetch_1.fetch)(url);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
switch (format) {
|
|
14
|
+
case 'tsv':
|
|
15
|
+
parsed = parseData(await response.text());
|
|
16
|
+
break;
|
|
17
|
+
case 'json':
|
|
18
|
+
parsed = await response.json();
|
|
19
|
+
break;
|
|
20
|
+
default:
|
|
21
|
+
throw new Error('unknown database format');
|
|
22
|
+
}
|
|
13
23
|
const results = [];
|
|
14
24
|
for (let line of parsed.data) {
|
|
15
25
|
const result = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDatabase.js","sourceRoot":"","sources":["../../src/databases/getDatabase.ts"],"names":[],"mappings":";;;AAAA,6CAAoC;AAEpC,gEAA6D;AAItD,KAAK,UAAU,WAAW,CAC/B,GAAG,GAAG,sGAAsG;
|
|
1
|
+
{"version":3,"file":"getDatabase.js","sourceRoot":"","sources":["../../src/databases/getDatabase.ts"],"names":[],"mappings":";;;AAAA,6CAAoC;AAEpC,gEAA6D;AAItD,KAAK,UAAU,WAAW,CAC/B,GAAG,GAAG,sGAAsG,EAC5G,UAKI,EAAE;IAEN,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAEnC,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;QAC9B,GAAG,GAAG,kDAAkD,iBAAiB,CACvE,GAAG,CACJ,oBAAoB,CAAC;KACvB;IAED,IAAI,MAAM,CAAC;IACX,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC,CAAC;IAClC,QAAQ,MAAM,EAAE;QACd,KAAK,KAAK;YACR,MAAM,GAAG,SAAS,CAAC,MAAM,QAAQ,CAAC,IAAI,EA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CHANGED
|
@@ -28,7 +28,7 @@ export * from './databases/getDatabase';
|
|
|
28
28
|
export * from './databases/carbonImpurities';
|
|
29
29
|
export * from './databases/protonImpurities';
|
|
30
30
|
export type { NMRSignal1D } from './signals/NMRSignal1D';
|
|
31
|
-
export type { NMRSignal2D,
|
|
31
|
+
export type { NMRSignal2D, Signal2DProjection } from './xyz/NMRSignal2D';
|
|
32
32
|
export type { NMRRange } from './xy/NMRRange';
|
|
33
33
|
export type { NMRZone } from './xyz/NMRZone';
|
|
34
34
|
export type { NMRPeak1D } from './peaks/NMRPeak1D';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { FromTo, PointXY } from 'cheminfo-types';
|
|
1
2
|
import type { Molecule } from 'openchemlib';
|
|
2
|
-
import { OptionsSignalsToXY } from '../signals/signalsToXY';
|
|
3
3
|
import { PredictAllOptions } from './predictAll';
|
|
4
4
|
/**
|
|
5
5
|
* This function will generate an object compatible with NMR-ium
|
|
@@ -7,12 +7,30 @@ import { PredictAllOptions } from './predictAll';
|
|
|
7
7
|
* @param molecule
|
|
8
8
|
* @param options
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
interface OneDOptions {
|
|
11
|
+
proton: FromTo;
|
|
12
|
+
carbon: FromTo;
|
|
13
|
+
nbPoints: number;
|
|
14
|
+
lineWidth: number;
|
|
15
|
+
}
|
|
16
|
+
interface TwoDOptions {
|
|
17
|
+
from: PointXY;
|
|
18
|
+
to: PointXY;
|
|
19
|
+
nbPoints: PointXY;
|
|
20
|
+
}
|
|
21
|
+
interface SimulationOptions {
|
|
22
|
+
frequency: number;
|
|
23
|
+
oneD?: Partial<OneDOptions>;
|
|
24
|
+
twoD?: Partial<TwoDOptions>;
|
|
25
|
+
}
|
|
26
|
+
interface PredictAllSpectraOptions {
|
|
11
27
|
prediction?: PredictAllOptions;
|
|
12
|
-
simulation?:
|
|
13
|
-
}
|
|
28
|
+
simulation?: SimulationOptions;
|
|
29
|
+
}
|
|
30
|
+
export declare function predictAllSpectra(molecule: Molecule, options?: PredictAllSpectraOptions): Promise<{
|
|
14
31
|
spectra: any[];
|
|
15
32
|
molecules: {
|
|
16
33
|
molfile: any;
|
|
17
34
|
}[];
|
|
18
35
|
}>;
|
|
36
|
+
export {};
|
|
@@ -1,40 +1,126 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.predictAllSpectra = void 0;
|
|
4
|
+
const signals2DToZ_1 = require("../signals/signals2DToZ");
|
|
4
5
|
const signalsToXY_1 = require("../signals/signalsToXY");
|
|
6
|
+
const getFrequency_1 = require("../utilities/getFrequency");
|
|
5
7
|
const predictAll_1 = require("./predictAll");
|
|
6
|
-
/**
|
|
7
|
-
* This function will generate an object compatible with NMR-ium
|
|
8
|
-
*
|
|
9
|
-
* @param molecule
|
|
10
|
-
* @param options
|
|
11
|
-
*/
|
|
12
8
|
async function predictAllSpectra(molecule, options = {}) {
|
|
13
|
-
const
|
|
9
|
+
const { simulation: simulationOptions = { oneD: {}, twoD: {} }, prediction: predictionOptions = {}, } = options;
|
|
10
|
+
const predictions = await (0, predictAll_1.predictAll)(molecule, predictionOptions);
|
|
14
11
|
const spectra = [];
|
|
15
12
|
const result = { spectra, molecules: [{ molfile: predictions.molfile }] };
|
|
16
|
-
|
|
13
|
+
const oneDOptions = {
|
|
14
|
+
...{
|
|
15
|
+
proton: { from: 0, to: 14 },
|
|
16
|
+
carbon: { from: 0, to: 200 },
|
|
17
|
+
nbPoints: 4098,
|
|
18
|
+
lineWidth: 0.03,
|
|
19
|
+
},
|
|
20
|
+
...(simulationOptions.oneD || {}),
|
|
21
|
+
};
|
|
22
|
+
const twoDOptions = {
|
|
23
|
+
...{
|
|
24
|
+
from: { x: oneDOptions.proton.from, y: oneDOptions.carbon.from },
|
|
25
|
+
to: { x: oneDOptions.proton.to, y: oneDOptions.carbon.to },
|
|
26
|
+
nbPoints: { x: 1024, y: 1024 },
|
|
27
|
+
},
|
|
28
|
+
...(simulationOptions.twoD || {}),
|
|
29
|
+
};
|
|
30
|
+
for (const experiment in predictions) {
|
|
31
|
+
switch (experiment) {
|
|
32
|
+
case 'carbon':
|
|
33
|
+
case 'proton': {
|
|
34
|
+
spectra.push(get1DSpectrum(predictions[experiment], {
|
|
35
|
+
nbPoints: oneDOptions.nbPoints,
|
|
36
|
+
lineWidth: oneDOptions.lineWidth,
|
|
37
|
+
...oneDOptions[experiment],
|
|
38
|
+
experiment,
|
|
39
|
+
frequency: simulationOptions.frequency,
|
|
40
|
+
}));
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case 'cosy':
|
|
44
|
+
case 'hsqc':
|
|
45
|
+
case 'hmbc': {
|
|
46
|
+
spectra.push(get2DSpectrum(predictions[experiment], {
|
|
47
|
+
...twoDOptions,
|
|
48
|
+
experiment,
|
|
49
|
+
frequency: simulationOptions.frequency,
|
|
50
|
+
}));
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
default:
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
17
57
|
return result;
|
|
18
58
|
}
|
|
19
59
|
exports.predictAllSpectra = predictAllSpectra;
|
|
20
|
-
function
|
|
21
|
-
const {
|
|
60
|
+
function get2DSpectrum(prediction, options) {
|
|
61
|
+
const { signals, zones, nuclei } = prediction;
|
|
62
|
+
const { frequency: baseFrequency, experiment } = options;
|
|
63
|
+
const width = get2DWidth(nuclei);
|
|
64
|
+
const frequency = calculateFrequency(nuclei, baseFrequency);
|
|
65
|
+
const spectrumData = (0, signals2DToZ_1.signals2DToZ)(signals, {
|
|
66
|
+
...options,
|
|
67
|
+
width,
|
|
68
|
+
factor: 3,
|
|
69
|
+
});
|
|
70
|
+
const spectrum = {
|
|
71
|
+
data: { ...spectrumData, noise: 0.01 },
|
|
72
|
+
info: {
|
|
73
|
+
nucleus: nuclei,
|
|
74
|
+
originFrequency: frequency,
|
|
75
|
+
baseFrequency: frequency,
|
|
76
|
+
pulseSequence: experiment,
|
|
77
|
+
experiment: '2d',
|
|
78
|
+
},
|
|
79
|
+
zones: { values: zones },
|
|
80
|
+
};
|
|
81
|
+
return spectrum;
|
|
82
|
+
}
|
|
83
|
+
function get2DWidth(nucleus) {
|
|
84
|
+
return nucleus[0] === nucleus[1] ? 0.02 : { x: 0.02, y: 0.2133 };
|
|
85
|
+
}
|
|
86
|
+
function get1DSpectrum(prediction, options) {
|
|
87
|
+
const { frequency = 400, experiment } = options;
|
|
88
|
+
const { signals, nucleus } = prediction;
|
|
89
|
+
const realFrequency = calculateFrequency(nucleus, frequency);
|
|
90
|
+
const { x, y } = (0, signalsToXY_1.signalsToXY)(signals, {
|
|
91
|
+
...options,
|
|
92
|
+
frequency: realFrequency,
|
|
93
|
+
});
|
|
22
94
|
const spectrum = {
|
|
23
|
-
id: '',
|
|
24
95
|
// todo Array.from is temporary for the developement
|
|
25
96
|
data: { x: Array.from(x), re: Array.from(y), im: null },
|
|
26
97
|
info: {
|
|
27
98
|
nucleus: prediction.nucleus,
|
|
28
99
|
dimension: 1,
|
|
29
|
-
originFrequency:
|
|
30
|
-
baseFrequency:
|
|
100
|
+
originFrequency: realFrequency,
|
|
101
|
+
baseFrequency: realFrequency,
|
|
31
102
|
pulseSequence: 'prediction',
|
|
32
|
-
experiment
|
|
103
|
+
experiment,
|
|
33
104
|
isFt: true,
|
|
34
105
|
},
|
|
35
|
-
|
|
36
|
-
//ranges: { values: prediction.ranges },
|
|
106
|
+
ranges: { values: prediction.ranges },
|
|
37
107
|
};
|
|
38
108
|
return spectrum;
|
|
39
109
|
}
|
|
110
|
+
function calculateFrequency(nucleus, frequency) {
|
|
111
|
+
if (typeof nucleus === 'string') {
|
|
112
|
+
return (0, getFrequency_1.getFrequency)(nucleus, { nucleus: '1H', frequency });
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
if (nucleus[0] === nucleus[1]) {
|
|
116
|
+
return `${frequency},${frequency}`;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
return `${frequency},${(0, getFrequency_1.getFrequency)(nucleus[1], {
|
|
120
|
+
nucleus: nucleus[0],
|
|
121
|
+
frequency,
|
|
122
|
+
})}`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
40
126
|
//# sourceMappingURL=predictAllSpectra.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predictAllSpectra.js","sourceRoot":"","sources":["../../src/prediction/predictAllSpectra.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"predictAllSpectra.js","sourceRoot":"","sources":["../../src/prediction/predictAllSpectra.ts"],"names":[],"mappings":";;;AAGA,0DAAuD;AACvD,wDAAyE;AACzE,4DAAyD;AAEzD,6CAA6D;AA8BtD,KAAK,UAAU,iBAAiB,CACrC,QAAkB,EAClB,UAAoC,EAAE;IAEtC,MAAM,EACJ,UAAU,EAAE,iBAAiB,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAuB,EAC3E,UAAU,EAAE,iBAAiB,GAAG,EAAE,GACnC,GAAG,OAAO,CAAC;IAEZ,MAAM,WAAW,GAAG,MAAM,IAAA,uBAAU,EAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAClE,MAAM,OAAO,GAAU,EAAE,CAAC;IAC1B,MAAM,MAAM,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;IAE1E,MAAM,WAAW,GAAgB;QAC/B,GAAG;YACD,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;YAC3B,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE;YAC5B,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;SAChB;QACD,GAAG,CAAC,iBAAiB,CAAC,IAAI,IAAI,EAAE,CA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|
|
3
|
-
export interface
|
|
3
|
+
export interface Signal2DProjection {
|
|
4
4
|
nucleus?: string;
|
|
5
5
|
delta: number;
|
|
6
6
|
resolution?: number;
|
|
@@ -8,8 +8,8 @@ export interface Signal2DAxisData {
|
|
|
8
8
|
diaIDs?: string[];
|
|
9
9
|
}
|
|
10
10
|
export interface NMRSignal2D {
|
|
11
|
-
x:
|
|
12
|
-
y:
|
|
11
|
+
x: Signal2DProjection;
|
|
12
|
+
y: Signal2DProjection;
|
|
13
13
|
j?: {
|
|
14
14
|
pathLength?: number | FromTo;
|
|
15
15
|
};
|
|
@@ -4,7 +4,7 @@ import { checkIDs } from './utils/getAssignment/checkIDs';
|
|
|
4
4
|
import { getTargetsAndCorrelations } from './utils/getAssignment/getTargetsAndCorrelations';
|
|
5
5
|
import getWorkFlow from './utils/getAssignment/getWorkFlow';
|
|
6
6
|
export async function getAssignments(input, options = {}) {
|
|
7
|
-
let { restrictionByCS = {}, justAssign, minScore =
|
|
7
|
+
let { restrictionByCS = {}, justAssign, minScore = 0.01, maxSolutions = 10, nbAllowedUnAssigned, timeout = 6000, predictionOptions = {}, predictions = {}, correlation: correlationOptions = {}, } = options;
|
|
8
8
|
const { tolerance = { H: 0.2, C: 1 }, useChemicalShiftScore = false, chemicalShiftRestriction = true, } = restrictionByCS;
|
|
9
9
|
const molecule = input.molecule;
|
|
10
10
|
if (!molecule)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAssignments.js","sourceRoot":"","sources":["../../src/assignment/getAssignments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AAQtE,OAAO,EAEL,gBAAgB,GAEjB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,OAAO,WAAW,MAAM,mCAAmC,CAAC;AA0E5D,MAAM,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M,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,yBAAyB,CACzD,OAAO,EACP,kBAAkB,CACnB,CAAC;IAEF,MAAM,EAAE,eAAe,EAAE,GAAG,WAAW,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAElE,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC;QACvC,eAAe,EAAE;YACf,SAAS;YACT,qBAAqB;YACrB,wBAAwB;SACzB;QACD,OAAO;QACP,QAAQ;QACR,OAAO;QACP,QAAQ;QACR,YAAY;QACZ,eAAe;QACf,mBAAmB;QACnB,YAAY;QACZ,OAAO;QACP,iBAAiB;QACjB,WAAW;KACZ,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { fetch } from 'cross-fetch';
|
|
2
2
|
import { resurrectRange } from '../utilities/resurrectRange';
|
|
3
|
-
export async function getDatabase(url = 'https://docs.google.com/spreadsheets/d/1uwyq_L38PMRWCcT4If_EhPbHKyY3q_2tpjV8vr5_zh0/edit?usp=sharing') {
|
|
3
|
+
export async function getDatabase(url = 'https://docs.google.com/spreadsheets/d/1uwyq_L38PMRWCcT4If_EhPbHKyY3q_2tpjV8vr5_zh0/edit?usp=sharing', options = {}) {
|
|
4
|
+
const { format = 'tsv' } = options;
|
|
4
5
|
if (url.includes('google.com')) {
|
|
5
6
|
url = `https://googledocs.cheminfo.org/spreadsheets/d/${extractGoogleUUID(url)}/export?format=tsv`;
|
|
6
7
|
}
|
|
8
|
+
let parsed;
|
|
7
9
|
const response = await fetch(url);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
switch (format) {
|
|
11
|
+
case 'tsv':
|
|
12
|
+
parsed = parseData(await response.text());
|
|
13
|
+
break;
|
|
14
|
+
case 'json':
|
|
15
|
+
parsed = await response.json();
|
|
16
|
+
break;
|
|
17
|
+
default:
|
|
18
|
+
throw new Error('unknown database format');
|
|
19
|
+
}
|
|
10
20
|
const results = [];
|
|
11
21
|
for (let line of parsed.data) {
|
|
12
22
|
const result = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDatabase.js","sourceRoot":"","sources":["../../src/databases/getDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI7D,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAG,GAAG,sGAAsG;
|
|
1
|
+
{"version":3,"file":"getDatabase.js","sourceRoot":"","sources":["../../src/databases/getDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI7D,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAG,GAAG,sGAAsG,EAC5G,UAKI,EAAE;IAEN,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAEnC,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;QAC9B,GAAG,GAAG,kDAAkD,iBAAiB,CACvE,GAAG,CACJ,oBAAoB,CAAC;KACvB;IAED,IAAI,MAAM,CAAC;IACX,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,QAAQ,MAAM,EAAE;QACd,KAAK,KAAK;YACR,MAAM,GAAG,SAAS,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YAC1C,MAAM;QACR,KAAK,MAAM;YACT,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC/B,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC9C;IAED,MAAM,OAAO,GAAG,EAAE,CAAC;IAEnB,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE;QAC5B,MA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gBACD;oBACE,MAAM,IAAI,KAAK,CAAC,wBAAwB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;aAC9D;SACF;QACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KACtB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,OAAO,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,MAAM,MAAM,GAAG,IAAI;SAChB,KAAK,CAAC,OAAO,CAAC;SACd,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAE9E,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO;QACL,MAAM;QACN,KAAK;QACL,IAAI;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -1,36 +1,122 @@
|
|
|
1
|
+
import { signals2DToZ } from '../signals/signals2DToZ';
|
|
1
2
|
import { signalsToXY } from '../signals/signalsToXY';
|
|
3
|
+
import { getFrequency } from '../utilities/getFrequency';
|
|
2
4
|
import { predictAll } from './predictAll';
|
|
3
|
-
/**
|
|
4
|
-
* This function will generate an object compatible with NMR-ium
|
|
5
|
-
*
|
|
6
|
-
* @param molecule
|
|
7
|
-
* @param options
|
|
8
|
-
*/
|
|
9
5
|
export async function predictAllSpectra(molecule, options = {}) {
|
|
10
|
-
const
|
|
6
|
+
const { simulation: simulationOptions = { oneD: {}, twoD: {} }, prediction: predictionOptions = {}, } = options;
|
|
7
|
+
const predictions = await predictAll(molecule, predictionOptions);
|
|
11
8
|
const spectra = [];
|
|
12
9
|
const result = { spectra, molecules: [{ molfile: predictions.molfile }] };
|
|
13
|
-
|
|
10
|
+
const oneDOptions = {
|
|
11
|
+
...{
|
|
12
|
+
proton: { from: 0, to: 14 },
|
|
13
|
+
carbon: { from: 0, to: 200 },
|
|
14
|
+
nbPoints: 4098,
|
|
15
|
+
lineWidth: 0.03,
|
|
16
|
+
},
|
|
17
|
+
...(simulationOptions.oneD || {}),
|
|
18
|
+
};
|
|
19
|
+
const twoDOptions = {
|
|
20
|
+
...{
|
|
21
|
+
from: { x: oneDOptions.proton.from, y: oneDOptions.carbon.from },
|
|
22
|
+
to: { x: oneDOptions.proton.to, y: oneDOptions.carbon.to },
|
|
23
|
+
nbPoints: { x: 1024, y: 1024 },
|
|
24
|
+
},
|
|
25
|
+
...(simulationOptions.twoD || {}),
|
|
26
|
+
};
|
|
27
|
+
for (const experiment in predictions) {
|
|
28
|
+
switch (experiment) {
|
|
29
|
+
case 'carbon':
|
|
30
|
+
case 'proton': {
|
|
31
|
+
spectra.push(get1DSpectrum(predictions[experiment], {
|
|
32
|
+
nbPoints: oneDOptions.nbPoints,
|
|
33
|
+
lineWidth: oneDOptions.lineWidth,
|
|
34
|
+
...oneDOptions[experiment],
|
|
35
|
+
experiment,
|
|
36
|
+
frequency: simulationOptions.frequency,
|
|
37
|
+
}));
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case 'cosy':
|
|
41
|
+
case 'hsqc':
|
|
42
|
+
case 'hmbc': {
|
|
43
|
+
spectra.push(get2DSpectrum(predictions[experiment], {
|
|
44
|
+
...twoDOptions,
|
|
45
|
+
experiment,
|
|
46
|
+
frequency: simulationOptions.frequency,
|
|
47
|
+
}));
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
default:
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
14
54
|
return result;
|
|
15
55
|
}
|
|
16
|
-
function
|
|
17
|
-
const {
|
|
56
|
+
function get2DSpectrum(prediction, options) {
|
|
57
|
+
const { signals, zones, nuclei } = prediction;
|
|
58
|
+
const { frequency: baseFrequency, experiment } = options;
|
|
59
|
+
const width = get2DWidth(nuclei);
|
|
60
|
+
const frequency = calculateFrequency(nuclei, baseFrequency);
|
|
61
|
+
const spectrumData = signals2DToZ(signals, {
|
|
62
|
+
...options,
|
|
63
|
+
width,
|
|
64
|
+
factor: 3,
|
|
65
|
+
});
|
|
66
|
+
const spectrum = {
|
|
67
|
+
data: { ...spectrumData, noise: 0.01 },
|
|
68
|
+
info: {
|
|
69
|
+
nucleus: nuclei,
|
|
70
|
+
originFrequency: frequency,
|
|
71
|
+
baseFrequency: frequency,
|
|
72
|
+
pulseSequence: experiment,
|
|
73
|
+
experiment: '2d',
|
|
74
|
+
},
|
|
75
|
+
zones: { values: zones },
|
|
76
|
+
};
|
|
77
|
+
return spectrum;
|
|
78
|
+
}
|
|
79
|
+
function get2DWidth(nucleus) {
|
|
80
|
+
return nucleus[0] === nucleus[1] ? 0.02 : { x: 0.02, y: 0.2133 };
|
|
81
|
+
}
|
|
82
|
+
function get1DSpectrum(prediction, options) {
|
|
83
|
+
const { frequency = 400, experiment } = options;
|
|
84
|
+
const { signals, nucleus } = prediction;
|
|
85
|
+
const realFrequency = calculateFrequency(nucleus, frequency);
|
|
86
|
+
const { x, y } = signalsToXY(signals, {
|
|
87
|
+
...options,
|
|
88
|
+
frequency: realFrequency,
|
|
89
|
+
});
|
|
18
90
|
const spectrum = {
|
|
19
|
-
id: '',
|
|
20
91
|
// todo Array.from is temporary for the developement
|
|
21
92
|
data: { x: Array.from(x), re: Array.from(y), im: null },
|
|
22
93
|
info: {
|
|
23
94
|
nucleus: prediction.nucleus,
|
|
24
95
|
dimension: 1,
|
|
25
|
-
originFrequency:
|
|
26
|
-
baseFrequency:
|
|
96
|
+
originFrequency: realFrequency,
|
|
97
|
+
baseFrequency: realFrequency,
|
|
27
98
|
pulseSequence: 'prediction',
|
|
28
|
-
experiment
|
|
99
|
+
experiment,
|
|
29
100
|
isFt: true,
|
|
30
101
|
},
|
|
31
|
-
|
|
32
|
-
//ranges: { values: prediction.ranges },
|
|
102
|
+
ranges: { values: prediction.ranges },
|
|
33
103
|
};
|
|
34
104
|
return spectrum;
|
|
35
105
|
}
|
|
106
|
+
function calculateFrequency(nucleus, frequency) {
|
|
107
|
+
if (typeof nucleus === 'string') {
|
|
108
|
+
return getFrequency(nucleus, { nucleus: '1H', frequency });
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
if (nucleus[0] === nucleus[1]) {
|
|
112
|
+
return `${frequency},${frequency}`;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return `${frequency},${getFrequency(nucleus[1], {
|
|
116
|
+
nucleus: nucleus[0],
|
|
117
|
+
frequency,
|
|
118
|
+
})}`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
36
122
|
//# sourceMappingURL=predictAllSpectra.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predictAllSpectra.js","sourceRoot":"","sources":["../../src/prediction/predictAllSpectra.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"predictAllSpectra.js","sourceRoot":"","sources":["../../src/prediction/predictAllSpectra.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAsB,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAqB,UAAU,EAAE,MAAM,cAAc,CAAC;AA8B7D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAkB,EAClB,UAAoC,EAAE;IAE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AED,SAAS,kBAAkB,CACzB,OAA0B,EAC1B,SAAiB;IAEjB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,YAAY,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;KAC5D;SAAM;QACL,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE;YAC7B,OAAO,GAAG,SAAS,IAAI,SAAS,EAAE,CAAC;SACpC;aAAM;YACL,OAAO,GAAG,SAAS,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;gBAC9C,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;gBACnB,SAAS;aACV,CAAC,EAAE,CAAC;SACN;KACF;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmr-processing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Pure functions allowing to process NMR spectra.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -38,21 +38,21 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/cheminfo/nmr-processing#readme",
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@types/jest": "^27.
|
|
41
|
+
"@types/jest": "^27.5.0",
|
|
42
42
|
"cheminfo-build": "^1.1.11",
|
|
43
43
|
"cheminfo-types": "^1.1.0",
|
|
44
|
-
"eslint": "^8.
|
|
44
|
+
"eslint": "^8.14.0",
|
|
45
45
|
"eslint-config-cheminfo-typescript": "^10.4.0",
|
|
46
|
-
"jest": "^
|
|
46
|
+
"jest": "^28.0.3",
|
|
47
47
|
"jest-matcher-deep-close-to": "^3.0.2",
|
|
48
48
|
"md5": "^2.3.0",
|
|
49
49
|
"ml-array-median": "^1.1.6",
|
|
50
50
|
"nmr-xy-testdata": "^0.5.1",
|
|
51
51
|
"openchemlib": "^7.4.3",
|
|
52
|
-
"prettier": "^2.6.
|
|
52
|
+
"prettier": "^2.6.2",
|
|
53
53
|
"rimraf": "^3.0.2",
|
|
54
|
-
"ts-jest": "^
|
|
55
|
-
"typescript": "^4.6.
|
|
54
|
+
"ts-jest": "^28.0.1",
|
|
55
|
+
"typescript": "^4.6.4"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"binary-search": "^1.3.6",
|
|
@@ -63,19 +63,19 @@
|
|
|
63
63
|
"ml-array-rescale": "^1.3.7",
|
|
64
64
|
"ml-array-sequential-fill": "^1.1.8",
|
|
65
65
|
"ml-array-sum": "^1.1.6",
|
|
66
|
-
"ml-gsd": "^
|
|
66
|
+
"ml-gsd": "^11.2.0",
|
|
67
67
|
"ml-hclust": "^3.1.0",
|
|
68
68
|
"ml-levenberg-marquardt": "^4.1.0",
|
|
69
|
-
"ml-matrix": "^6.
|
|
69
|
+
"ml-matrix": "^6.10.0",
|
|
70
70
|
"ml-matrix-convolution": "^1.0.0",
|
|
71
71
|
"ml-matrix-peaks-finder": "^1.0.0",
|
|
72
72
|
"ml-peak-shape-generator": "^4.1.1",
|
|
73
73
|
"ml-simple-clustering": "^0.1.0",
|
|
74
74
|
"ml-sparse-matrix": "^2.1.0",
|
|
75
|
-
"ml-spectra-processing": "^11.
|
|
75
|
+
"ml-spectra-processing": "^11.5.0",
|
|
76
76
|
"ml-tree-set": "^0.1.1",
|
|
77
77
|
"nmr-correlation": "^2.2.5",
|
|
78
|
-
"openchemlib-utils": "^1.
|
|
79
|
-
"spectrum-generator": "^8.0.
|
|
78
|
+
"openchemlib-utils": "^1.11.0",
|
|
79
|
+
"spectrum-generator": "^8.0.1"
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -6,16 +6,33 @@ import { DatabaseNMREntry } from './DatabaseNMREntry';
|
|
|
6
6
|
|
|
7
7
|
export async function getDatabase(
|
|
8
8
|
url = 'https://docs.google.com/spreadsheets/d/1uwyq_L38PMRWCcT4If_EhPbHKyY3q_2tpjV8vr5_zh0/edit?usp=sharing',
|
|
9
|
+
options: {
|
|
10
|
+
/**
|
|
11
|
+
* @default 'tsv'
|
|
12
|
+
*/
|
|
13
|
+
format?: 'tsv' | 'json';
|
|
14
|
+
} = {},
|
|
9
15
|
) {
|
|
16
|
+
const { format = 'tsv' } = options;
|
|
17
|
+
|
|
10
18
|
if (url.includes('google.com')) {
|
|
11
19
|
url = `https://googledocs.cheminfo.org/spreadsheets/d/${extractGoogleUUID(
|
|
12
20
|
url,
|
|
13
21
|
)}/export?format=tsv`;
|
|
14
22
|
}
|
|
15
23
|
|
|
24
|
+
let parsed;
|
|
16
25
|
const response = await fetch(url);
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
switch (format) {
|
|
27
|
+
case 'tsv':
|
|
28
|
+
parsed = parseData(await response.text());
|
|
29
|
+
break;
|
|
30
|
+
case 'json':
|
|
31
|
+
parsed = await response.json();
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
throw new Error('unknown database format');
|
|
35
|
+
}
|
|
19
36
|
|
|
20
37
|
const results = [];
|
|
21
38
|
|
package/src/index.ts
CHANGED
|
@@ -38,7 +38,7 @@ export * from './databases/carbonImpurities';
|
|
|
38
38
|
export * from './databases/protonImpurities';
|
|
39
39
|
|
|
40
40
|
export type { NMRSignal1D } from './signals/NMRSignal1D';
|
|
41
|
-
export type { NMRSignal2D,
|
|
41
|
+
export type { NMRSignal2D, Signal2DProjection } from './xyz/NMRSignal2D';
|
|
42
42
|
export type { NMRRange } from './xy/NMRRange';
|
|
43
43
|
export type { NMRZone } from './xyz/NMRZone';
|
|
44
44
|
export type { NMRPeak1D } from './peaks/NMRPeak1D';
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { FromTo, PointXY } from 'cheminfo-types';
|
|
1
2
|
import type { Molecule } from 'openchemlib';
|
|
2
3
|
|
|
4
|
+
import { signals2DToZ } from '../signals/signals2DToZ';
|
|
3
5
|
import { OptionsSignalsToXY, signalsToXY } from '../signals/signalsToXY';
|
|
6
|
+
import { getFrequency } from '../utilities/getFrequency';
|
|
4
7
|
|
|
5
8
|
import { PredictAllOptions, predictAll } from './predictAll';
|
|
6
9
|
/**
|
|
@@ -10,39 +13,173 @@ import { PredictAllOptions, predictAll } from './predictAll';
|
|
|
10
13
|
* @param options
|
|
11
14
|
*/
|
|
12
15
|
|
|
16
|
+
interface OneDOptions {
|
|
17
|
+
proton: FromTo;
|
|
18
|
+
carbon: FromTo;
|
|
19
|
+
nbPoints: number;
|
|
20
|
+
lineWidth: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface TwoDOptions {
|
|
24
|
+
from: PointXY;
|
|
25
|
+
to: PointXY;
|
|
26
|
+
nbPoints: PointXY;
|
|
27
|
+
}
|
|
28
|
+
interface SimulationOptions {
|
|
29
|
+
frequency: number;
|
|
30
|
+
oneD?: Partial<OneDOptions>;
|
|
31
|
+
twoD?: Partial<TwoDOptions>;
|
|
32
|
+
}
|
|
33
|
+
interface PredictAllSpectraOptions {
|
|
34
|
+
prediction?: PredictAllOptions;
|
|
35
|
+
simulation?: SimulationOptions;
|
|
36
|
+
}
|
|
37
|
+
|
|
13
38
|
export async function predictAllSpectra(
|
|
14
39
|
molecule: Molecule,
|
|
15
|
-
options: {
|
|
16
|
-
prediction?: PredictAllOptions;
|
|
17
|
-
simulation?: OptionsSignalsToXY;
|
|
18
|
-
} = {},
|
|
40
|
+
options: PredictAllSpectraOptions = {},
|
|
19
41
|
) {
|
|
20
|
-
const
|
|
42
|
+
const {
|
|
43
|
+
simulation: simulationOptions = { oneD: {}, twoD: {} } as SimulationOptions,
|
|
44
|
+
prediction: predictionOptions = {},
|
|
45
|
+
} = options;
|
|
46
|
+
|
|
47
|
+
const predictions = await predictAll(molecule, predictionOptions);
|
|
21
48
|
const spectra: any[] = [];
|
|
22
49
|
const result = { spectra, molecules: [{ molfile: predictions.molfile }] };
|
|
23
|
-
|
|
50
|
+
|
|
51
|
+
const oneDOptions: OneDOptions = {
|
|
52
|
+
...{
|
|
53
|
+
proton: { from: 0, to: 14 },
|
|
54
|
+
carbon: { from: 0, to: 200 },
|
|
55
|
+
nbPoints: 4098,
|
|
56
|
+
lineWidth: 0.03,
|
|
57
|
+
},
|
|
58
|
+
...(simulationOptions.oneD || {}),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const twoDOptions: TwoDOptions = {
|
|
62
|
+
...{
|
|
63
|
+
from: { x: oneDOptions.proton.from, y: oneDOptions.carbon.from },
|
|
64
|
+
to: { x: oneDOptions.proton.to, y: oneDOptions.carbon.to },
|
|
65
|
+
nbPoints: { x: 1024, y: 1024 },
|
|
66
|
+
},
|
|
67
|
+
...(simulationOptions.twoD || {}),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
for (const experiment in predictions) {
|
|
71
|
+
switch (experiment) {
|
|
72
|
+
case 'carbon':
|
|
73
|
+
case 'proton': {
|
|
74
|
+
spectra.push(
|
|
75
|
+
get1DSpectrum(predictions[experiment], {
|
|
76
|
+
nbPoints: oneDOptions.nbPoints,
|
|
77
|
+
lineWidth: oneDOptions.lineWidth,
|
|
78
|
+
...oneDOptions[experiment],
|
|
79
|
+
experiment,
|
|
80
|
+
frequency: simulationOptions.frequency,
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case 'cosy':
|
|
86
|
+
case 'hsqc':
|
|
87
|
+
case 'hmbc': {
|
|
88
|
+
spectra.push(
|
|
89
|
+
get2DSpectrum(predictions[experiment], {
|
|
90
|
+
...twoDOptions,
|
|
91
|
+
experiment,
|
|
92
|
+
frequency: simulationOptions.frequency,
|
|
93
|
+
}),
|
|
94
|
+
);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
default:
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
24
101
|
|
|
25
102
|
return result;
|
|
26
103
|
}
|
|
27
104
|
|
|
28
|
-
|
|
29
|
-
|
|
105
|
+
type Get2DSpectrumOptions = TwoDOptions & {
|
|
106
|
+
experiment: string;
|
|
107
|
+
frequency: number;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
function get2DSpectrum(prediction: any, options: Get2DSpectrumOptions) {
|
|
111
|
+
const { signals, zones, nuclei } = prediction;
|
|
112
|
+
const { frequency: baseFrequency, experiment } = options;
|
|
113
|
+
|
|
114
|
+
const width = get2DWidth(nuclei);
|
|
115
|
+
const frequency = calculateFrequency(nuclei, baseFrequency);
|
|
116
|
+
|
|
117
|
+
const spectrumData = signals2DToZ(signals, {
|
|
118
|
+
...options,
|
|
119
|
+
width,
|
|
120
|
+
factor: 3,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const spectrum = {
|
|
124
|
+
data: { ...spectrumData, noise: 0.01 },
|
|
125
|
+
info: {
|
|
126
|
+
nucleus: nuclei,
|
|
127
|
+
originFrequency: frequency,
|
|
128
|
+
baseFrequency: frequency,
|
|
129
|
+
pulseSequence: experiment,
|
|
130
|
+
experiment: '2d',
|
|
131
|
+
},
|
|
132
|
+
zones: { values: zones },
|
|
133
|
+
};
|
|
134
|
+
return spectrum;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function get2DWidth(nucleus: string[]) {
|
|
138
|
+
return nucleus[0] === nucleus[1] ? 0.02 : { x: 0.02, y: 0.2133 };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
type Get1DSpectrumOptions = OptionsSignalsToXY & { experiment: string };
|
|
142
|
+
|
|
143
|
+
function get1DSpectrum(prediction: any, options: Get1DSpectrumOptions) {
|
|
144
|
+
const { frequency = 400, experiment } = options;
|
|
145
|
+
const { signals, nucleus } = prediction;
|
|
146
|
+
const realFrequency = calculateFrequency(nucleus, frequency) as number;
|
|
147
|
+
const { x, y } = signalsToXY(signals, {
|
|
148
|
+
...options,
|
|
149
|
+
frequency: realFrequency,
|
|
150
|
+
});
|
|
30
151
|
const spectrum = {
|
|
31
|
-
id: '',
|
|
32
152
|
// todo Array.from is temporary for the developement
|
|
33
153
|
data: { x: Array.from(x), re: Array.from(y), im: null },
|
|
34
154
|
info: {
|
|
35
155
|
nucleus: prediction.nucleus,
|
|
36
156
|
dimension: 1,
|
|
37
|
-
originFrequency:
|
|
38
|
-
baseFrequency:
|
|
157
|
+
originFrequency: realFrequency,
|
|
158
|
+
baseFrequency: realFrequency,
|
|
39
159
|
pulseSequence: 'prediction',
|
|
40
|
-
experiment
|
|
160
|
+
experiment,
|
|
41
161
|
isFt: true,
|
|
42
162
|
},
|
|
43
|
-
|
|
44
|
-
//ranges: { values: prediction.ranges },
|
|
163
|
+
ranges: { values: prediction.ranges },
|
|
45
164
|
};
|
|
46
165
|
|
|
47
166
|
return spectrum;
|
|
48
167
|
}
|
|
168
|
+
|
|
169
|
+
function calculateFrequency(
|
|
170
|
+
nucleus: string | string[],
|
|
171
|
+
frequency: number,
|
|
172
|
+
): number | string {
|
|
173
|
+
if (typeof nucleus === 'string') {
|
|
174
|
+
return getFrequency(nucleus, { nucleus: '1H', frequency });
|
|
175
|
+
} else {
|
|
176
|
+
if (nucleus[0] === nucleus[1]) {
|
|
177
|
+
return `${frequency},${frequency}`;
|
|
178
|
+
} else {
|
|
179
|
+
return `${frequency},${getFrequency(nucleus[1], {
|
|
180
|
+
nucleus: nucleus[0],
|
|
181
|
+
frequency,
|
|
182
|
+
})}`;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
package/src/xyz/NMRSignal2D.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FromTo } from 'cheminfo-types';
|
|
2
2
|
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
3
3
|
|
|
4
|
-
export interface
|
|
4
|
+
export interface Signal2DProjection {
|
|
5
5
|
nucleus?: string;
|
|
6
6
|
delta: number;
|
|
7
7
|
resolution?: number;
|
|
@@ -9,8 +9,8 @@ export interface Signal2DAxisData {
|
|
|
9
9
|
diaIDs?: string[];
|
|
10
10
|
}
|
|
11
11
|
export interface NMRSignal2D {
|
|
12
|
-
x:
|
|
13
|
-
y:
|
|
12
|
+
x: Signal2DProjection;
|
|
13
|
+
y: Signal2DProjection;
|
|
14
14
|
j?: {
|
|
15
15
|
pathLength?: number | FromTo;
|
|
16
16
|
};
|