Comparing version 1.1.10 to 1.2.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [1.2.0](https://github.com/cheminfo/mass-tools/compare/mf-parser@1.1.10...mf-parser@1.2.0) (2021-04-20) | ||
### Features | ||
* allow to have anchors # in MF ([4c920ff](https://github.com/cheminfo/mass-tools/commit/4c920ffea6c4020471ef6d7c1df8985e48bb4395)) | ||
* format MF containing anchors ([dc8d469](https://github.com/cheminfo/mass-tools/commit/dc8d46986144dead0d92e607160c1746ca9c3fb0)) | ||
## [1.1.10](https://github.com/cheminfo/mass-tools/compare/mf-parser@1.1.9...mf-parser@1.1.10) (2021-03-24) | ||
@@ -8,0 +20,0 @@ |
{ | ||
"name": "mf-parser", | ||
"version": "1.1.10", | ||
"version": "1.2.0", | ||
"description": "", | ||
@@ -28,3 +28,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "14b0b932ce4e7e3e443ed6f8b45fb3be153c524f" | ||
"gitHead": "f89522c67fa933bbc753d670869d64bf0f460547" | ||
} |
@@ -336,2 +336,19 @@ 'use strict'; | ||
it('C10#1H20', () => { | ||
let mf = new MF('C10#1H20'); | ||
let newMF = mf.toMF(); | ||
expect(newMF).toBe('C10H20'); | ||
let info = mf.getInfo(); | ||
expect(info).toStrictEqual({ | ||
mass: 140.26617404846803, | ||
monoisotopicMass: 140.1565006446, | ||
charge: 0, | ||
mf: 'C10H20', | ||
atoms: { C: 10, H: 20 }, | ||
unsaturation: 1, | ||
}); | ||
}); | ||
it('2NH3 . 2HCl', () => { | ||
@@ -338,0 +355,0 @@ let mf = new MF('2NH3 . 2HCl'); |
@@ -216,2 +216,7 @@ 'use strict'; | ||
], | ||
'C#2H': [ | ||
{ kind: 'atom', value: 'C' }, | ||
{ kind: 'anchor', value: 2 }, | ||
{ kind: 'atom', value: 'H' }, | ||
], | ||
}; | ||
@@ -218,0 +223,0 @@ |
@@ -19,3 +19,4 @@ 'use strict'; | ||
TEXT: 'text', | ||
ANCHOR: 'anchor', | ||
COMMENT: 'comment', | ||
}; |
@@ -53,2 +53,7 @@ 'use strict'; | ||
this.result.push({ kind: Kind.PRE_MULTIPLIER, value: value.from }); | ||
} else if (lastKind === Kind.ANCHOR) { | ||
if (value.to) { | ||
throw new MFError(this.mf, this.i, 'Anchor ID may not contain -'); | ||
} | ||
this.result[this.result.length - 1].value = value.from; | ||
} else { | ||
@@ -67,3 +72,2 @@ if (value.to) { | ||
} | ||
continue; | ||
@@ -75,2 +79,7 @@ } else if (char === '.') { | ||
// it must be in a salt | ||
} else if (char === '#') { | ||
// an anchor | ||
this.result.push({ kind: Kind.ANCHOR, value: 0 }); | ||
// it is not in a number otherwise it would have been taken before | ||
// it must be in a salt | ||
} else if (ascii > 64 && ascii < 91) { | ||
@@ -77,0 +86,0 @@ // an uppercase = new atom |
@@ -29,2 +29,4 @@ 'use strict'; | ||
break; | ||
case Kind.ANCHOR: | ||
break; | ||
default: | ||
@@ -31,0 +33,0 @@ throw new Error('partToMF unhandled Kind: ', line.kind); |
@@ -46,2 +46,4 @@ 'use strict'; | ||
break; | ||
case Kind.ANCHOR: // we ignore anchors to create the parts and canonized MF | ||
break; | ||
case Kind.COMMENT: // we ignore comments to create the parts and canonized MF | ||
@@ -48,0 +50,0 @@ break; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66973
2154