nmr-processing 7.1.0 → 7.2.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/get13CAssignments.d.ts +3 -3
- package/lib/assignment/get13CAssignments.js.map +1 -1
- package/lib/assignment/get1HAssignments.d.ts +3 -3
- package/lib/assignment/get1HAssignments.js.map +1 -1
- package/lib/assignment/getAssignments.d.ts +81 -0
- package/lib/assignment/getAssignments.js +44 -0
- package/lib/assignment/getAssignments.js.map +1 -0
- package/lib/assignment/utils/buildAssignments.d.ts +4 -4
- package/lib/assignment/utils/buildAssignments.js.map +1 -1
- package/lib/assignment/utils/createMapPossibleAssignments.d.ts +2 -2
- package/lib/assignment/utils/exploreTreeRec.d.ts +3 -3
- package/lib/assignment/utils/exploreTreeRec.js.map +1 -1
- package/lib/assignment/utils/getAssignment/buildAssignments.d.ts +72 -0
- package/lib/assignment/utils/getAssignment/buildAssignments.js +205 -0
- package/lib/assignment/utils/getAssignment/buildAssignments.js.map +1 -0
- package/lib/assignment/utils/getAssignment/checkIDs.d.ts +23 -0
- package/lib/assignment/utils/getAssignment/checkIDs.js +57 -0
- package/lib/assignment/utils/getAssignment/checkIDs.js.map +1 -0
- package/lib/assignment/utils/getAssignment/createMapPossibleAssignment.d.ts +15 -0
- package/lib/assignment/utils/getAssignment/createMapPossibleAssignment.js +55 -0
- package/lib/assignment/utils/getAssignment/createMapPossibleAssignment.js.map +1 -0
- package/lib/assignment/utils/getAssignment/exploreTree.d.ts +22 -0
- package/lib/assignment/utils/getAssignment/exploreTree.js +93 -0
- package/lib/assignment/utils/getAssignment/exploreTree.js.map +1 -0
- package/lib/assignment/utils/getAssignment/formatData.d.ts +14 -0
- package/lib/assignment/utils/getAssignment/formatData.js +20 -0
- package/lib/assignment/utils/getAssignment/formatData.js.map +1 -0
- package/lib/assignment/utils/getAssignment/getIntegrationOfAttachedProtons.d.ts +3 -0
- package/lib/assignment/utils/getAssignment/getIntegrationOfAttachedProtons.js +14 -0
- package/lib/assignment/utils/getAssignment/getIntegrationOfAttachedProtons.js.map +1 -0
- package/lib/assignment/utils/getAssignment/getTargetsAndCorrelations.d.ts +18 -0
- package/lib/assignment/utils/getAssignment/getTargetsAndCorrelations.js +37 -0
- package/lib/assignment/utils/getAssignment/getTargetsAndCorrelations.js.map +1 -0
- package/lib/assignment/utils/getAssignment/getWorkFlow.d.ts +19 -0
- package/lib/assignment/utils/getAssignment/getWorkFlow.js +52 -0
- package/lib/assignment/utils/getAssignment/getWorkFlow.js.map +1 -0
- package/lib/assignment/utils/getAssignment/groupCarbonTargetByIntegrationZone.d.ts +7 -0
- package/lib/assignment/utils/getAssignment/groupCarbonTargetByIntegrationZone.js +43 -0
- package/lib/assignment/utils/getAssignment/groupCarbonTargetByIntegrationZone.js.map +1 -0
- package/lib/assignment/utils/getAssignment/isSpectraData1D.d.ts +2 -0
- package/lib/assignment/utils/getAssignment/isSpectraData1D.js +8 -0
- package/lib/assignment/utils/getAssignment/isSpectraData1D.js.map +1 -0
- package/lib/assignment/utils/getAssignment/partialScore.d.ts +13 -0
- package/lib/assignment/utils/getAssignment/partialScore.js +221 -0
- package/lib/assignment/utils/getAssignment/partialScore.js.map +1 -0
- package/lib/assignment/utils/getAssignment/searchIndices.d.ts +6 -0
- package/lib/assignment/utils/getAssignment/searchIndices.js +21 -0
- package/lib/assignment/utils/getAssignment/searchIndices.js.map +1 -0
- package/lib/assignment/utils/partialScore.d.ts +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/peaks/peaksToRanges.js +1 -0
- package/lib/peaks/peaksToRanges.js.map +1 -1
- package/lib/prediction/utils/predict2D.d.ts +0 -2
- package/lib/prediction/utils/predict2D.js.map +1 -1
- package/lib-esm/assignment/get13CAssignments.js.map +1 -1
- package/lib-esm/assignment/get1HAssignments.js.map +1 -1
- package/lib-esm/assignment/getAssignments.js +37 -0
- package/lib-esm/assignment/getAssignments.js.map +1 -0
- package/lib-esm/assignment/utils/buildAssignments.js.map +1 -1
- package/lib-esm/assignment/utils/exploreTreeRec.js.map +1 -1
- package/lib-esm/assignment/utils/getAssignment/buildAssignments.js +198 -0
- package/lib-esm/assignment/utils/getAssignment/buildAssignments.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/checkIDs.js +48 -0
- package/lib-esm/assignment/utils/getAssignment/checkIDs.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/createMapPossibleAssignment.js +51 -0
- package/lib-esm/assignment/utils/getAssignment/createMapPossibleAssignment.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/exploreTree.js +89 -0
- package/lib-esm/assignment/utils/getAssignment/exploreTree.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/formatData.js +16 -0
- package/lib-esm/assignment/utils/getAssignment/formatData.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/getIntegrationOfAttachedProtons.js +10 -0
- package/lib-esm/assignment/utils/getAssignment/getIntegrationOfAttachedProtons.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/getTargetsAndCorrelations.js +33 -0
- package/lib-esm/assignment/utils/getAssignment/getTargetsAndCorrelations.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/getWorkFlow.js +50 -0
- package/lib-esm/assignment/utils/getAssignment/getWorkFlow.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/groupCarbonTargetByIntegrationZone.js +41 -0
- package/lib-esm/assignment/utils/getAssignment/groupCarbonTargetByIntegrationZone.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/isSpectraData1D.js +4 -0
- package/lib-esm/assignment/utils/getAssignment/isSpectraData1D.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/partialScore.js +214 -0
- package/lib-esm/assignment/utils/getAssignment/partialScore.js.map +1 -0
- package/lib-esm/assignment/utils/getAssignment/searchIndices.js +17 -0
- package/lib-esm/assignment/utils/getAssignment/searchIndices.js.map +1 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/peaks/peaksToRanges.js +1 -0
- package/lib-esm/peaks/peaksToRanges.js.map +1 -1
- package/lib-esm/prediction/utils/predict2D.js.map +1 -1
- package/package.json +2 -1
- package/src/assignment/get13CAssignments.ts +2 -2
- package/src/assignment/get1HAssignments.ts +2 -2
- package/src/assignment/getAssignments.ts +149 -0
- package/src/assignment/utils/buildAssignments.ts +4 -4
- package/src/assignment/utils/createMapPossibleAssignments.ts +2 -2
- package/src/assignment/utils/exploreTreeRec.ts +5 -5
- package/src/assignment/utils/getAssignment/buildAssignments.ts +339 -0
- package/src/assignment/utils/getAssignment/checkIDs.ts +76 -0
- package/src/assignment/utils/getAssignment/createMapPossibleAssignment.ts +85 -0
- package/src/assignment/utils/getAssignment/data/correlations.js +713 -0
- package/src/assignment/utils/getAssignment/data/predictions.js +34 -0
- package/src/assignment/utils/getAssignment/exploreTree.ts +171 -0
- package/src/assignment/utils/getAssignment/formatData.ts +35 -0
- package/src/assignment/utils/getAssignment/getIntegrationOfAttachedProtons.ts +16 -0
- package/src/assignment/utils/getAssignment/getTargetsAndCorrelations.ts +63 -0
- package/src/assignment/utils/getAssignment/getWorkFlow.ts +72 -0
- package/src/assignment/utils/getAssignment/groupCarbonTargetByIntegrationZone.ts +55 -0
- package/src/assignment/utils/getAssignment/isSpectraData1D.ts +7 -0
- package/src/assignment/utils/getAssignment/partialScore.ts +308 -0
- package/src/assignment/utils/getAssignment/searchIndices.ts +19 -0
- package/src/assignment/utils/partialScore.ts +2 -2
- package/src/index.ts +1 -0
- package/src/ml-tree-set.d.ts +1 -1
- package/src/peaks/peaksToRanges.ts +1 -0
- package/src/prediction/utils/predict2D.ts +0 -2
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import treeSet from 'ml-tree-set';
|
|
2
|
+
import { getConnectivityMatrix } from 'openchemlib-utils';
|
|
3
|
+
import { predictCarbon } from '../../../prediction/predictCarbon';
|
|
4
|
+
import { predictProton } from '../../../prediction/predictProton';
|
|
5
|
+
import { createMapPossibleAssignment, } from './createMapPossibleAssignment';
|
|
6
|
+
import { exploreTree } from './exploreTree';
|
|
7
|
+
import { isSpectraData1D } from './isSpectraData1D';
|
|
8
|
+
import { searchIndices } from './searchIndices';
|
|
9
|
+
const comparator = (a, b) => {
|
|
10
|
+
return b.score - a.score;
|
|
11
|
+
};
|
|
12
|
+
const predictor = { H: predictProton, C: predictCarbon };
|
|
13
|
+
function checkNMRSignal1D(signals) {
|
|
14
|
+
const keys = [
|
|
15
|
+
'nbAtoms',
|
|
16
|
+
'diaIDs',
|
|
17
|
+
'atoms',
|
|
18
|
+
];
|
|
19
|
+
for (const signal of signals) {
|
|
20
|
+
for (let key of keys) {
|
|
21
|
+
if (!signal[key])
|
|
22
|
+
throw new Error(`property ${key} does not exist`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const getAllHydrogens = {
|
|
27
|
+
C: (m, i) => m.getAllHydrogens(i),
|
|
28
|
+
H: () => 1,
|
|
29
|
+
};
|
|
30
|
+
export async function buildAssignments(props) {
|
|
31
|
+
const { spectra, molecule, restrictionByCS, timeout, minScore, nbAllowedUnAssigned = {}, maxSolutions, correlations, assignmentOrder, predictionOptions, predictions: inputPrediction = {}, targets, } = props;
|
|
32
|
+
let date = new Date();
|
|
33
|
+
let timeStart = date.getTime();
|
|
34
|
+
let lowerBoundScore = minScore;
|
|
35
|
+
let store = {
|
|
36
|
+
solutions: new treeSet(comparator),
|
|
37
|
+
nSolutions: 0,
|
|
38
|
+
};
|
|
39
|
+
const pathLengthMatrix = getConnectivityMatrix(molecule, {
|
|
40
|
+
pathLength: true,
|
|
41
|
+
});
|
|
42
|
+
let infoByAtomType = {};
|
|
43
|
+
const predictions = {};
|
|
44
|
+
let possibleAssignmentMap = {};
|
|
45
|
+
let diaIDPeerPossibleAssignment = {};
|
|
46
|
+
for (const atomTypesToPredict of assignmentOrder) {
|
|
47
|
+
for (const atomType of atomTypesToPredict) {
|
|
48
|
+
const options = predictionOptions[atomType];
|
|
49
|
+
const predictedSignals = inputPrediction[atomType];
|
|
50
|
+
let { joinedSignals } = predictedSignals
|
|
51
|
+
? { joinedSignals: predictedSignals }
|
|
52
|
+
: await predictor[atomType](molecule, options);
|
|
53
|
+
checkNMRSignal1D(joinedSignals);
|
|
54
|
+
if (!predictions[atomType])
|
|
55
|
+
predictions[atomType] = {};
|
|
56
|
+
for (let prediction of joinedSignals) {
|
|
57
|
+
const diaID = prediction.diaIDs[0];
|
|
58
|
+
const index = prediction.atoms[0];
|
|
59
|
+
const allHydrogens = getAllHydrogens[atomType](molecule, index);
|
|
60
|
+
predictions[atomType][diaID] = {
|
|
61
|
+
...prediction,
|
|
62
|
+
diaIDIndex: index,
|
|
63
|
+
allHydrogens: prediction.nbAtoms * allHydrogens,
|
|
64
|
+
protonsCount: allHydrogens,
|
|
65
|
+
pathLength: pathLengthMatrix[index],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
infoByAtomType[atomType] = {
|
|
69
|
+
nSources: joinedSignals.length,
|
|
70
|
+
currentIndex: 0,
|
|
71
|
+
nbAllowedUnAssigned: nbAllowedUnAssigned[atomType] || 0,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
possibleAssignmentMap = createMapPossibleAssignment(possibleAssignmentMap, {
|
|
75
|
+
restrictionByCS,
|
|
76
|
+
predictions,
|
|
77
|
+
targets,
|
|
78
|
+
});
|
|
79
|
+
diaIDPeerPossibleAssignment = {};
|
|
80
|
+
for (const atomType in possibleAssignmentMap) {
|
|
81
|
+
diaIDPeerPossibleAssignment[atomType] = Object.keys(possibleAssignmentMap[atomType]);
|
|
82
|
+
}
|
|
83
|
+
let sourceOfPartials = getSourceOfPartials(store, infoByAtomType, atomTypesToPredict);
|
|
84
|
+
store = {
|
|
85
|
+
solutions: new treeSet(comparator),
|
|
86
|
+
nSolutions: 0,
|
|
87
|
+
};
|
|
88
|
+
for (let partial of sourceOfPartials) {
|
|
89
|
+
exploreTree({
|
|
90
|
+
currentAtomTypes: atomTypesToPredict,
|
|
91
|
+
restrictionByCS,
|
|
92
|
+
timeout,
|
|
93
|
+
timeStart,
|
|
94
|
+
targets,
|
|
95
|
+
predictions,
|
|
96
|
+
correlations,
|
|
97
|
+
maxSolutions,
|
|
98
|
+
lowerBoundScore,
|
|
99
|
+
possibleAssignmentMap,
|
|
100
|
+
diaIDPeerPossibleAssignment,
|
|
101
|
+
}, infoByAtomType, partial, store);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return annotateSpectraData({
|
|
105
|
+
store,
|
|
106
|
+
spectra,
|
|
107
|
+
diaIDPeerPossibleAssignment,
|
|
108
|
+
targets,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function annotateSpectraData(input) {
|
|
112
|
+
var _a;
|
|
113
|
+
const { store, spectra, diaIDPeerPossibleAssignment, targets } = input;
|
|
114
|
+
const { solutions } = store;
|
|
115
|
+
const mapSignalId = {};
|
|
116
|
+
const atomTypes = Object.keys(targets);
|
|
117
|
+
for (const atomType of atomTypes) {
|
|
118
|
+
const targetByAtomType = targets[atomType];
|
|
119
|
+
for (const targetId in targetByAtomType) {
|
|
120
|
+
let target = targetByAtomType[targetId];
|
|
121
|
+
for (const link of target.link) {
|
|
122
|
+
const signalId = link.signal.id;
|
|
123
|
+
if (mapSignalId[signalId])
|
|
124
|
+
continue;
|
|
125
|
+
mapSignalId[link.signal.id] = searchIndices(signalId, spectra);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const result = [];
|
|
130
|
+
for (let solution of solutions.elements) {
|
|
131
|
+
const spectraResult = JSON.parse(JSON.stringify(spectra));
|
|
132
|
+
const { assignment, score } = solution;
|
|
133
|
+
const atomTypes = Object.keys(assignment);
|
|
134
|
+
for (const atomType of atomTypes) {
|
|
135
|
+
const targetByAtomType = targets[atomType];
|
|
136
|
+
const assignmentPeerAtomType = assignment[atomType];
|
|
137
|
+
for (let index = 0; index < assignmentPeerAtomType.length; index++) {
|
|
138
|
+
const targetID = assignmentPeerAtomType[index];
|
|
139
|
+
if (targetID === '*' || !targetID)
|
|
140
|
+
continue;
|
|
141
|
+
const target = targetByAtomType[targetID];
|
|
142
|
+
const diaId = diaIDPeerPossibleAssignment[atomType][index];
|
|
143
|
+
for (let link of target.link) {
|
|
144
|
+
const { spectrumIndex, elementIndex, signalIndex } = mapSignalId[link.signal.id];
|
|
145
|
+
const spectrum = spectraResult[spectrumIndex];
|
|
146
|
+
if (isSpectraData1D(spectrum)) {
|
|
147
|
+
let { ranges } = spectrum;
|
|
148
|
+
let range = ranges[elementIndex];
|
|
149
|
+
let signal = range.signals[signalIndex];
|
|
150
|
+
if (!signal.diaIDs)
|
|
151
|
+
signal.diaIDs = [];
|
|
152
|
+
signal.diaIDs.push(diaId);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const axis = link.axis;
|
|
156
|
+
const signal = spectrum.zones[elementIndex].signals[signalIndex];
|
|
157
|
+
if (!signal[axis].diaIDs)
|
|
158
|
+
signal[axis].diaIDs = [];
|
|
159
|
+
(_a = signal[axis].diaIDs) === null || _a === void 0 ? void 0 : _a.push(diaId);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
result.push({
|
|
165
|
+
score,
|
|
166
|
+
assignment: spectraResult,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
function getSourceOfPartials(store, infoByAtomType, currentAtoms) {
|
|
172
|
+
return store.nSolutions > 0
|
|
173
|
+
? store.solutions.elements.map((e) => {
|
|
174
|
+
let currentAssignment = e.assignment;
|
|
175
|
+
for (const atom of currentAtoms) {
|
|
176
|
+
currentAssignment[atom] = fillPartial(infoByAtomType[atom].nSources);
|
|
177
|
+
}
|
|
178
|
+
return currentAssignment;
|
|
179
|
+
})
|
|
180
|
+
: initializePartials(infoByAtomType, currentAtoms);
|
|
181
|
+
}
|
|
182
|
+
function initializePartials(infoByAtomType, currentAtoms) {
|
|
183
|
+
const partial = {};
|
|
184
|
+
const atomsType = Object.keys(infoByAtomType);
|
|
185
|
+
for (const atom of atomsType) {
|
|
186
|
+
const value = currentAtoms.includes(atom) ? null : '*';
|
|
187
|
+
partial[atom] = fillPartial(infoByAtomType[atom].nSources, value);
|
|
188
|
+
}
|
|
189
|
+
return [partial];
|
|
190
|
+
}
|
|
191
|
+
function fillPartial(nSources, value = null) {
|
|
192
|
+
const partial = new Array(nSources);
|
|
193
|
+
for (let i = 0; i < nSources; i++) {
|
|
194
|
+
partial[i] = value;
|
|
195
|
+
}
|
|
196
|
+
return partial;
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=buildAssignments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildAssignments.js","sourceRoot":"","sources":["../../../../src/assignment/utils/getAssignment/buildAssignments.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAO1D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAKlE,OAAO,EACL,2BAA2B,GAE5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAsB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,UAAU,GAAG,CAAC,CAAqB,EAAE,CAAqB,EAAE,EAAE;IAClE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,EA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from '../generateID';
|
|
2
|
+
import { isSpectraData1D } from './isSpectraData1D';
|
|
3
|
+
export function checkIDs(input = []) {
|
|
4
|
+
let inputClone = JSON.parse(JSON.stringify(input));
|
|
5
|
+
let spectra = [];
|
|
6
|
+
for (const spectraData of inputClone) {
|
|
7
|
+
const { info, id } = spectraData;
|
|
8
|
+
if (isSpectraData1D(spectraData)) {
|
|
9
|
+
let data = addIDs(spectraData.ranges);
|
|
10
|
+
for (const element of data) {
|
|
11
|
+
const { integration } = element;
|
|
12
|
+
for (let signal of element.signals || []) {
|
|
13
|
+
if (!signal.integration)
|
|
14
|
+
signal.integration = integration;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
spectra.push({ id, info, ranges: data });
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
let data = addIDs(spectraData.zones);
|
|
21
|
+
spectra.push({ id, info, zones: data });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return spectra;
|
|
25
|
+
}
|
|
26
|
+
export function hasIDs(data) {
|
|
27
|
+
for (const element of data) {
|
|
28
|
+
if (!element.id)
|
|
29
|
+
throw new Error('A range/zone has not an ID');
|
|
30
|
+
for (let signal of element.signals || []) {
|
|
31
|
+
if (!signal.id)
|
|
32
|
+
throw new Error('A signal has not an ID');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function addIDs(data) {
|
|
37
|
+
for (const element of data) {
|
|
38
|
+
if (!element.id)
|
|
39
|
+
element.id = generateID();
|
|
40
|
+
for (let signal of element.signals || []) {
|
|
41
|
+
if (!signal.id)
|
|
42
|
+
signal.id = generateID();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
hasIDs(data);
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=checkIDs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkIDs.js","sourceRoot":"","sources":["../../../../src/assignment/utils/getAssignment/check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AAC,CAAC;QAC/D,KAAK,IAAI,MAAM,IAAI,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE;YACxC,IAAI,CAAC,MAAM,CAAC,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3D;KACF;AACH,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAA4B;IACjD,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE;QAC1B,IAAI,CAAC,OAAO,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;QAC3C,KAAK,IAAI,MAAM,IAAI,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE;YACxC,IAAI,CAAC,MAAM,CAAC,EAAE;gBAAE,MAAM,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;SAC1C;KACF;IACD,MAAM,CAAC,IAAI,CAAC,CAAC;IACb,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getCorrelationDelta } from 'nmr-correlation';
|
|
2
|
+
export function createMapPossibleAssignment(expandMap, props) {
|
|
3
|
+
const { restrictionByCS, predictions, targets } = props;
|
|
4
|
+
const { tolerance: toleranceCS, chemicalShiftRestriction } = restrictionByCS;
|
|
5
|
+
const atomTypes = Object.keys(predictions);
|
|
6
|
+
for (const atomType of atomTypes) {
|
|
7
|
+
let errorAbs = toleranceCS[atomType];
|
|
8
|
+
let predictionByAtomType = predictions[atomType];
|
|
9
|
+
let targetByAtomType = targets[atomType];
|
|
10
|
+
if (!expandMap[atomType])
|
|
11
|
+
expandMap[atomType] = {};
|
|
12
|
+
for (const diaID in predictionByAtomType) {
|
|
13
|
+
let prediction = predictionByAtomType[diaID];
|
|
14
|
+
expandMap[atomType][diaID] = [];
|
|
15
|
+
if (targetByAtomType) {
|
|
16
|
+
for (const targetID in targetByAtomType) {
|
|
17
|
+
let target = targetByAtomType[targetID];
|
|
18
|
+
const { nbAtoms, protonsCount: protonsCountFromPrediction } = prediction;
|
|
19
|
+
const { integration, protonsCount } = target;
|
|
20
|
+
const couldBeAssigned = !integration
|
|
21
|
+
? true
|
|
22
|
+
: atomType === 'H'
|
|
23
|
+
? nbAtoms - integration < 1
|
|
24
|
+
: protonsCount.length > 0
|
|
25
|
+
? protonsCount.some((count) => protonsCountFromPrediction === count)
|
|
26
|
+
: true;
|
|
27
|
+
if (couldBeAssigned) {
|
|
28
|
+
if (!chemicalShiftRestriction ||
|
|
29
|
+
typeof prediction.delta === 'undefined') {
|
|
30
|
+
// Chemical shift is not a restriction
|
|
31
|
+
expandMap[atomType][diaID].push(targetID);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
let targetDelta = getCorrelationDelta(target);
|
|
35
|
+
if (targetDelta === undefined) {
|
|
36
|
+
throw new Error(`Correlation has not delta`);
|
|
37
|
+
}
|
|
38
|
+
let distAfterLimit = Math.abs(prediction.delta - targetDelta - errorAbs);
|
|
39
|
+
if (distAfterLimit < 4 * errorAbs) {
|
|
40
|
+
expandMap[atomType][diaID].push(targetID);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
expandMap[atomType][diaID].push('*');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return expandMap;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=createMapPossibleAssignment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMapPossibleAssignment.js","sourceRoot":"","sources":["../../../../src/assignment/utils/getAssignment/createMapPossibleAssignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAsBtD,MAAM,UAAU,2BAA2B,CACzC,SAAiC,EACjC,KAAyC;IAEzC,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAExD,MAAM,EAAE,SAAS,EAAE,WAA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AAwB;4BACzB,OAAO,UAAU,CAAC,KAAK,KAAK,WAAW,EACvC;4BACA,sCAAsC;4BACtC,SAAS,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;yBAC3C;6BAAM;4BACL,IAAI,WAAW,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;4BAC9C,IAAI,WAAW,KAAK,SAAS,EAAE;gCAC7B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;6BAC9C;4BACD,IAAI,cAAc,GAAG,IAAI,CAAC,GAAG,CAC3B,UAAU,CAAC,KAAK,GAAG,WAAW,GAAG,QAAQ,CAC1C,CAAC;4BAEF,IAAI,cAAc,GAAG,CAAC,GAAG,QAAQ,EAAE;gCACjC,SAAS,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;6BAC3C;yBACF;qBACF;iBACF;aACF;YACD,SAAS,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACtC;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { partialScore } from './partialScore';
|
|
2
|
+
export function exploreTree(props, infoByAtomTypes, partial, store) {
|
|
3
|
+
const { currentAtomTypes, restrictionByCS, timeout, timeStart, maxSolutions, targets, predictions, correlations, lowerBoundScore, possibleAssignmentMap, diaIDPeerPossibleAssignment, } = props;
|
|
4
|
+
const currentDate = new Date();
|
|
5
|
+
if (currentDate.getTime() - timeStart > timeout) {
|
|
6
|
+
new Error('timeout expired');
|
|
7
|
+
return store;
|
|
8
|
+
}
|
|
9
|
+
for (const atomType of currentAtomTypes) {
|
|
10
|
+
const { currentIndex, nSources } = infoByAtomTypes[atomType];
|
|
11
|
+
if (currentIndex >= nSources - 1 &&
|
|
12
|
+
partial[atomType][currentIndex] !== null) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
const diaID = diaIDPeerPossibleAssignment[atomType][currentIndex];
|
|
16
|
+
const possibleAssignments = possibleAssignmentMap[atomType][diaID];
|
|
17
|
+
for (let targetID of possibleAssignments) {
|
|
18
|
+
partial[atomType][currentIndex] = targetID;
|
|
19
|
+
let score = partialScore(partial, {
|
|
20
|
+
diaIDPeerPossibleAssignment,
|
|
21
|
+
infoByAtomTypes,
|
|
22
|
+
restrictionByCS,
|
|
23
|
+
predictions,
|
|
24
|
+
correlations,
|
|
25
|
+
targets,
|
|
26
|
+
});
|
|
27
|
+
if (score === 0) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (isLastOne(currentAtomTypes, infoByAtomTypes) &&
|
|
31
|
+
score >= lowerBoundScore) {
|
|
32
|
+
addSolution(store, { predictions, partial, score, maxSolutions });
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const newInfo = JSON.parse(JSON.stringify(infoByAtomTypes));
|
|
36
|
+
newInfo[atomType].currentIndex += 1;
|
|
37
|
+
exploreTree({
|
|
38
|
+
currentAtomTypes,
|
|
39
|
+
restrictionByCS,
|
|
40
|
+
timeout,
|
|
41
|
+
timeStart,
|
|
42
|
+
maxSolutions,
|
|
43
|
+
targets,
|
|
44
|
+
predictions,
|
|
45
|
+
correlations,
|
|
46
|
+
lowerBoundScore,
|
|
47
|
+
possibleAssignmentMap,
|
|
48
|
+
diaIDPeerPossibleAssignment,
|
|
49
|
+
}, newInfo, JSON.parse(JSON.stringify(partial)), store);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function addSolution(store, props) {
|
|
55
|
+
let { score, maxSolutions, partial, predictions } = props;
|
|
56
|
+
score /= doubleAssignmentPenalty(partial, predictions);
|
|
57
|
+
let solution = {
|
|
58
|
+
assignment: JSON.parse(JSON.stringify(partial)),
|
|
59
|
+
score,
|
|
60
|
+
};
|
|
61
|
+
if (store.nSolutions >= maxSolutions) {
|
|
62
|
+
if (solution.score > store.solutions.last().score) {
|
|
63
|
+
store.solutions.pollLast();
|
|
64
|
+
store.solutions.add(solution);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
store.solutions.add(solution);
|
|
69
|
+
store.nSolutions++;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function isLastOne(currentAtomTypes, infoByAtomTypes) {
|
|
73
|
+
let lastOne = true;
|
|
74
|
+
for (const atomType of currentAtomTypes) {
|
|
75
|
+
const { currentIndex, nSources } = infoByAtomTypes[atomType];
|
|
76
|
+
lastOne = lastOne && currentIndex >= nSources - 1;
|
|
77
|
+
}
|
|
78
|
+
return lastOne;
|
|
79
|
+
}
|
|
80
|
+
function doubleAssignmentPenalty(partial, predictions) {
|
|
81
|
+
let nbDoubleAssignment = 0;
|
|
82
|
+
for (const atomType in predictions) {
|
|
83
|
+
const nbSources = Object.keys(predictions[atomType]).length;
|
|
84
|
+
let assignments = new Set(partial[atomType]);
|
|
85
|
+
nbDoubleAssignment += nbSources - assignments.size;
|
|
86
|
+
}
|
|
87
|
+
return nbDoubleAssignment > 0 ? 2 * nbDoubleAssignment : 1;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=exploreTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exploreTree.js","sourceRoot":"","sources":["../../../../src/assignment/utils/getAssignment/exploreTree.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAsB9C,MAAM,UAAU,WAAW,CACzB,KAA4B,EAC5B,eAA+B,EAC/B,OAAgB,EAChB,KAAuB;IAEvB,MAAM,EACJ,gBAAgB,EAChB,eAAe,EACf,OAAO,EACP,SAAS,EACT,YAAY,EACZ,OAAO,EACP,WAAW,EACX,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,2BAA2B,GAC5B,GAAG,KAAK,CAAC;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AAQ,CAAC,CAAC;QAC7D,OAAO,GAAG,OAAO,IAAI,YAAY,IAAI,QAAQ,GAAG,CAAC,CAAC;KACnD;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,uBAAuB,CAC9B,OAAgB,EAChB,WAAkC;IAElC,IAAI,kBAAkB,GAAG,CAAC,CAAC;IAC3B,KAAK,MAAM,QAAQ,IAAI,WAAW,EAAE;QAClC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;QAC5D,IAAI,WAAW,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC7C,kBAAkB,IAAI,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC;KACpD;IACD,OAAO,kBAAkB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isSpectraData1D } from './isSpectraData1D';
|
|
2
|
+
export function formatData(input = []) {
|
|
3
|
+
let inputClone = JSON.parse(JSON.stringify(input));
|
|
4
|
+
let spectra = [];
|
|
5
|
+
for (const spectraData of inputClone) {
|
|
6
|
+
const { info } = spectraData;
|
|
7
|
+
if (isSpectraData1D(spectraData)) {
|
|
8
|
+
spectra.push({ info, ranges: { values: spectraData.ranges } });
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
spectra.push({ info, zones: { values: spectraData.zones } });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return spectra;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=formatData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatData.js","sourceRoot":"","sources":["../../../../src/assignment/utils/getAssignment/formatData.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAapD,MAAM,UAAU,UAAU,CACxB,QAA8B,EAAE;IAEhC,IAAI,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAyB,CAAC;IAC3E,IAAI,OAAO,GAA2B,EAAE,CAAC;IACzC,KAAK,MAAM,WAAW,IAAI,UAAU,EAAE;QACpC,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC;QAC7B,IAAI,eAAe,CAAC,WAAW,CAAC,EAAE;YAChC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SAChE;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;SAC9D;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function getIntegrationOfAttachedProtons(target, correlations) {
|
|
2
|
+
const { H: attachment = [] } = target.attachment;
|
|
3
|
+
let integration = 0;
|
|
4
|
+
for (const match of attachment) {
|
|
5
|
+
const correlation = correlations[match];
|
|
6
|
+
integration += Number(correlation.link[0].signal.integration);
|
|
7
|
+
}
|
|
8
|
+
return integration;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=getIntegrationOfAttachedProtons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getIntegrationOfAttachedProtons.js","sourceRoot":"","sources":["../../../../src/assignment/utils/getAssignment/getIntegrationOfAttachedProtons.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,+BAA+B,CAC7C,MAAkC,EAClC,YAAoB;IAEpB,MAAM,EAAE,CAAC,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC;IACjD,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE;QAC9B,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACxC,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;KAC/D;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { buildCorrelationData } from 'nmr-correlation';
|
|
2
|
+
import { formatData } from './formatData';
|
|
3
|
+
import { getIntegrationOfAttachedProtons } from './getIntegrationOfAttachedProtons';
|
|
4
|
+
export function getTargetsAndCorrelations(spectra, options = {}) {
|
|
5
|
+
//add indirect links, if a carbon C1 is attached to a proton H1 that correlating
|
|
6
|
+
//with carbon C2, so the carbon C1 and C2 are also correlating
|
|
7
|
+
const { tolerance = { C: 0.25, H: 0.05 } } = options;
|
|
8
|
+
const spectraData = formatData(spectra);
|
|
9
|
+
const { values: correlations } = buildCorrelationData(spectraData, {
|
|
10
|
+
tolerance,
|
|
11
|
+
});
|
|
12
|
+
let targets = {};
|
|
13
|
+
for (const correlation of correlations) {
|
|
14
|
+
if (correlation.pseudo)
|
|
15
|
+
continue;
|
|
16
|
+
const { id: targetID, atomType } = correlation;
|
|
17
|
+
if (!targets[atomType])
|
|
18
|
+
targets[atomType] = {};
|
|
19
|
+
targets[atomType][targetID] = correlation;
|
|
20
|
+
if (atomType === 'H') {
|
|
21
|
+
targets[atomType][targetID].integration =
|
|
22
|
+
correlation.link[0].signal.integration;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
targets[atomType][targetID].integration = getIntegrationOfAttachedProtons(correlation, correlations);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
targets,
|
|
30
|
+
correlations,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=getTargetsAndCorrelations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTargetsAndCorrelations.js","sourceRoot":"","sources":["../../../../src/assignment/utils/getAssignment/getTargetsAndCorrelations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAIvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAsBpF,MAAM,UAAU,yBAAyB,CACvC,OAA6B,EAC7B,UAAe,EAAE;IAEjB,gFAAgF;IAChF,8DAA8D;IAE9D,MAAM,EAAE,SAAS,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,oBAAoB,CAAC,WAAW,EAAE;QACjE,SAAS;KACV,CAAC,CAAC;IAEH,IAAI,OAAO,GAAQ,EAAE,CAAC;IACtB,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;QACtC,IAAI,WAAW,CAAC,MAAM;YAAE,SAAS;QACjC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC/C,OAAO,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC;QAC1C,IAAI,QAAQ,KAAK,GAAG,EAAE;YACpB,OAAO,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,WAAW;gBACrC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;SAC1C;aAAM;YACL,OAAO,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,WAAW,GAAG,+BAA+B,CACvE,WAAW,EACX,YAAY,CACb,CAAC;SACH;KACF;IAED,OAAO;QACL,OAAO;QACP,YAAY;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* if hsqc is present in experimentTypes we can just predict 13C
|
|
3
|
+
* spectrum and try to assign the carbons first.
|
|
4
|
+
* @param {*} correlations
|
|
5
|
+
* @param {*} justAssign
|
|
6
|
+
*/
|
|
7
|
+
function getWorkFlow(correlations, justAssign = []) {
|
|
8
|
+
const experimentTypes = extractExperimentType(correlations);
|
|
9
|
+
const { hasHSQC, types } = experimentTypes;
|
|
10
|
+
if (justAssign.length > 0) {
|
|
11
|
+
return { assignmentOrder: justAssign, experimentTypes };
|
|
12
|
+
}
|
|
13
|
+
const assignmentOrder = [];
|
|
14
|
+
if (hasHSQC) {
|
|
15
|
+
assignmentOrder.push(['C'], ['H']);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
assignmentOrder.push(types.filter((type) => type === 'H' || type === 'C'));
|
|
19
|
+
}
|
|
20
|
+
return { assignmentOrder, experimentTypes };
|
|
21
|
+
}
|
|
22
|
+
export default getWorkFlow;
|
|
23
|
+
function extractExperimentType(correlations) {
|
|
24
|
+
const types = [];
|
|
25
|
+
for (const correlation of correlations) {
|
|
26
|
+
let experimentType = correlation.experimentType;
|
|
27
|
+
if (experimentType === '1d') {
|
|
28
|
+
experimentType = `${correlation.atomType.toUpperCase()}`;
|
|
29
|
+
}
|
|
30
|
+
if (!types.includes(experimentType)) {
|
|
31
|
+
types.push(experimentType);
|
|
32
|
+
}
|
|
33
|
+
for (const link of correlation.link) {
|
|
34
|
+
experimentType = link.experimentType;
|
|
35
|
+
if (experimentType === '1d') {
|
|
36
|
+
experimentType = `${link.atomType[0].toUpperCase()}`;
|
|
37
|
+
}
|
|
38
|
+
if (!types.includes(experimentType)) {
|
|
39
|
+
types.push(experimentType);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
types,
|
|
45
|
+
hasProton: types.includes('H'),
|
|
46
|
+
hasCarbon: types.includes('C'),
|
|
47
|
+
hasHSQC: types.includes('hsqc'),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=getWorkFlow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWorkFlow.js","sourceRoot":"","sources":["../../../../src/assignment/utils/getAssignment/getWorkFlow.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,SAAS,WAAW,CAClB,YAAoB,EACpB,aAAiC,EAAE;IAEnC,MAAM,eAAe,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAE5D,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,eAAe,CAAC;IAE3C,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;QACzB,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;KACzD;IAED,MAAM,eAAe,GAAuB,EAAE,CAAC;IAE/C,IAAI,OAAO,EAAE;QACX,eAAe,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KACpC;SAAM;QACL,eAAe,CAAC,IAAI,CAClB,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAgB,CACpE,CAAC;KACH;IAED,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;AAC9C,CAAC;AAED,eAAe,WAAW,CAAC;AAS3B,SAAS,qBAAqB,CAAC,YAAoB;IACjD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;QACtC,IAAI,cAAc,GAAW,WAAW,CAAC,cAAc,CAAC;QACxD,IAAI,cAAc,KAAK,IAAI,EAAE;YAC3B,cAAc,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;SAC1D;QACD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;YACnC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SAC5B;QACD,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,IAAI,EAAE;YACnC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;YACrC,IAAI,cAAc,KAAK,IAAI,EAAE;gBAC3B,cAAc,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;aACtD;YACD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;gBACnC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;aAC5B;SACF;KACF;IAED,OAAO;QACL,KAAK;QACL,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC9B,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC9B,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;KAChC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function groupCarbonTargetByIntegrationZone(activeDomainOnTarget, targets, correlations) {
|
|
2
|
+
let targetID = activeDomainOnTarget[0];
|
|
3
|
+
let { H: attachments = [] } = targets[targetID].attachment;
|
|
4
|
+
let targetByIntegral = [
|
|
5
|
+
{ targetIDs: [targetID], attachments: new Set(attachments) },
|
|
6
|
+
];
|
|
7
|
+
for (let i = 1; i < activeDomainOnTarget.length; i++) {
|
|
8
|
+
let targetID = activeDomainOnTarget[i];
|
|
9
|
+
let target = targets[targetID];
|
|
10
|
+
let { H: attachments = [] } = target.attachment;
|
|
11
|
+
let alone = true;
|
|
12
|
+
for (let group of targetByIntegral) {
|
|
13
|
+
const pertain = attachments.some((attachment) => group.attachments.has(attachment));
|
|
14
|
+
if (pertain) {
|
|
15
|
+
alone = false;
|
|
16
|
+
group.targetIDs.push(targetID);
|
|
17
|
+
for (let attachment of attachments) {
|
|
18
|
+
group.attachments.add(attachment);
|
|
19
|
+
}
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (alone) {
|
|
24
|
+
targetByIntegral.push({
|
|
25
|
+
targetIDs: [targetID],
|
|
26
|
+
attachments: new Set(attachments),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return targetByIntegral.map((t) => ({
|
|
31
|
+
atomType: 'C',
|
|
32
|
+
targetIDs: t.targetIDs,
|
|
33
|
+
integration: correlations
|
|
34
|
+
? Array.from(t.attachments).reduce((sum, index) => {
|
|
35
|
+
return correlations[index].integration + sum;
|
|
36
|
+
}, 0)
|
|
37
|
+
: 0,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
export default groupCarbonTargetByIntegrationZone;
|
|
41
|
+
//# sourceMappingURL=groupCarbonTargetByIntegrationZone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groupCarbonTargetByIntegrationZone.js","sourceRoot":"","sources":["../../../../src/assignment/utils/getAssignment/groupCarbonTargetByIntegrationZone.ts"],"names":[],"mappings":"AAKA,SAAS,kCAAkC,CACzC,oBAA8B,EAC9B,OAAgB,EAChB,YAA0C;IAE1C,IAAI,QAAQ,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACvC,IAAI,EAAE,CAAC,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC;IAE3D,IAAI,gBAAgB,GAAG;QACrB,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,GAAG,CAAS,WAAW,CAAC,EAAE;KACrE,CAA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,YAAY,CAAC,KAAK,CAAC,CAAC,WAAW,GAAG,GAAG,CAAC;YAC/C,CAAC,EAAE,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;KACN,CAAC,CAAC,CAAC;AACN,CAAC;AAED,eAAe,kCAAkC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isSpectraData1D.js","sourceRoot":"","sources":["../../../../src/assignment/utils/getAssignment/isSpectraData1D.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAC7B,QAAqB;IAErB,OAAO,QAAQ,IAAI,QAAQ,CAAC;AAC9B,CAAC"}
|