mf-generator
Advanced tools
Comparing version 1.2.4 to 1.3.0
@@ -6,2 +6,18 @@ # Change Log | ||
# [1.3.0](https://github.com/cheminfo/mass-tools/compare/mf-generator@1.2.4...mf-generator@1.3.0) (2021-04-20) | ||
### Bug Fixes | ||
* **mf-generator:** anchors were not working correctly ([c75da9c](https://github.com/cheminfo/mass-tools/commit/c75da9c5dc3d66d665f5fa98780173dd44c57ede)) | ||
### Features | ||
* **generate-mf:** allows to filter by matching # ([d32388a](https://github.com/cheminfo/mass-tools/commit/d32388acd9135f4315ead101c25312de4628f35c)) | ||
## [1.2.4](https://github.com/cheminfo/mass-tools/compare/mf-generator@1.2.3...mf-generator@1.2.4) (2021-03-24) | ||
@@ -8,0 +24,0 @@ |
{ | ||
"name": "mf-generator", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"description": "", | ||
@@ -22,9 +22,9 @@ "main": "src/index.js", | ||
"chemical-elements": "^1.1.9", | ||
"mf-finder": "^1.1.10", | ||
"mf-matcher": "^1.1.10", | ||
"mf-parser": "^1.1.10", | ||
"mf-utilities": "^1.2.4", | ||
"mf-finder": "^1.1.11", | ||
"mf-matcher": "^1.1.11", | ||
"mf-parser": "^1.2.0", | ||
"mf-utilities": "^1.2.5", | ||
"sum-object-keys": "^1.0.2" | ||
}, | ||
"gitHead": "14b0b932ce4e7e3e443ed6f8b45fb3be153c524f" | ||
"gitHead": "f89522c67fa933bbc753d670869d64bf0f460547" | ||
} |
@@ -220,2 +220,19 @@ 'use strict'; | ||
}); | ||
it('with links', function () { | ||
const mfsArray = [ | ||
['C#1', 'C#1C', 'C#2C'], | ||
['H#1', 'H#1H', 'H#2'], | ||
]; | ||
let result = generateMFs(mfsArray, { links: { filter: true } }).map( | ||
(item) => item.mf, | ||
); | ||
expect(result).toStrictEqual(['CH', 'CH2', 'C2H', 'C2H2']); | ||
result = generateMFs(mfsArray, { | ||
uniqueMFs: false, | ||
links: { filter: true }, | ||
}).map((item) => item.mf); | ||
expect(result).toStrictEqual(['CH', 'CH2', 'C2H', 'C2H', 'C2H2']); | ||
}); | ||
}); |
@@ -39,2 +39,4 @@ 'use strict'; | ||
* @param {string} [options.filterFct] | ||
* @param {object} [options.links] | ||
* @param {boolean} [options.links.filter] We filter all the MF that do not match the '*X' | ||
* @returns {Array} | ||
@@ -203,3 +205,3 @@ */ | ||
function appendResult(results, currents, keys, options = {}) { | ||
const { canonizeMF, filter, ionizations } = options; | ||
const { canonizeMF, filter, ionizations, links = {} } = options; | ||
// this script is designed to combine molecular formula | ||
@@ -209,2 +211,15 @@ // that may contain comments after a "$" sign | ||
if (links.filter) { | ||
let stars = []; | ||
for (let i = 0; i < keys.length; i++) { | ||
let anchors = keys[i][currents[i]].match(/#[0-9]+/g); | ||
if (anchors) stars.push(...anchors); | ||
} | ||
if (stars.length % 2 === 1) return; | ||
stars = stars.sort(); | ||
for (let i = 0; i < stars.length; i += 2) { | ||
if (stars[i] !== stars[i + 1]) return; | ||
} | ||
} | ||
for (let ionization of ionizations) { | ||
@@ -211,0 +226,0 @@ let result = getEMFromParts(keys, currents, ionization); |
20744
455
Updatedmf-finder@^1.1.11
Updatedmf-matcher@^1.1.11
Updatedmf-parser@^1.2.0
Updatedmf-utilities@^1.2.5