-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombineMF.js
executable file
·109 lines (88 loc) · 3.49 KB
/
combineMF.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
'use strict';
var CE = require('..');
var mfsArray=[["C","H$YY"],[],[""],["Cl","Br$XX"]];
var result=CE.combineMFs(mfsArray);
describe('combine MFs test', function () {
it('From array of array with comment', function () {
var mfsArray=[["C","H$YY"],[],[""],["Cl","Br$XX"]];
var result=CE.combineMFs(mfsArray);
result[0].mf.should.equal('CCl');
result.length.should.equal(4);
});
it('From array of string with comment', function () {
var mfsArray=["C.H.O","+,++",['Cl','Br$XX']];
var result=CE.combineMFs(mfsArray);
result[0].mf.should.equal('C+Cl');
result.length.should.equal(12);
});
it('From array of string with some range and non range', function () {
var mfsArray=['CN0-2'];
var result=CE.combineMFs(mfsArray);
result[0].mf.should.equal('C');
result[1].mf.should.equal('CN');
result[2].mf.should.equal('CN2');
result.length.should.equal(3);
});
it('From array of string with some range and non range CN0-2O00-1K', function () {
var mfsArray=['CN0-2O00-1K'];
var result=CE.combineMFs(mfsArray);
result[0].mf.should.equal('CK');
result[1].mf.should.equal('CNK');
result[2].mf.should.equal('CN2K');
result[3].mf.should.equal('COK');
result[4].mf.should.equal('CNOK');
result[5].mf.should.equal('CN2OK');
result.length.should.equal(6);
});
it('From array of string with some range and non range NaK0-2', function () {
var mfsArray=['NaK0-2'];
var result=CE.combineMFs(mfsArray);
result[0].mf.should.equal('Na');
result[1].mf.should.equal('NaK');
result[2].mf.should.equal('NaK2');
result.length.should.equal(3);
});
it('From array of string with some range and non range C(Me(N2))0-2(CH3)0-1K', function () {
var mfsArray=['C(Me(N2))0-2(CH3)0-1K'];
var result=CE.combineMFs(mfsArray);
result[0].mf.should.equal('CK');
result[1].mf.should.equal('C(Me(N2))K');
result[2].mf.should.equal('C(Me(N2))2K');
result[3].mf.should.equal('C(CH3)K');
result[4].mf.should.equal('C(Me(N2))(CH3)K');
result[5].mf.should.equal('C(Me(N2))2(CH3)K');
result.length.should.equal(6);
});
it('From array of string with some range', function () {
var mfsArray=["C1-3N0-2Cl0-0BrO1-1.C2-3H3-4",['C','O']];
var result=CE.combineMFs(mfsArray);
result[0].mf.should.equal('CBrOC');
result.length.should.equal(26);
});
it('From array of string chem em and msem', function () {
var mfsArray=["C0-2.O",['+','-','++','--']];
var result=CE.combineMFs(mfsArray);
result[0].mf.should.equal('+');
result[0].charge.should.equal(1);
result.length.should.equal(16);
});
it('From array of string to large array', function () {
var mfsArray=["C0-100","O0-100"];
var result=CE.combineMFs(mfsArray);
result.length.should.equal(101*101);
});
it('From array of string to large array and filter', function () {
var mfsArray=["C0-100","O0-100"];
var result=CE.combineMFs(mfsArray,
{
minMass: 0.1,
maxMass:13
});
result.length.should.equal(1);
});
it('Strange comments', function () {
var mfsArray=["C$1>10","O$D2>20"];
var result=CE.combineMFs(mfsArray);
result[0].mf.should.equal('CO$1>10 D2>20');
});
});