nucleotide
Advanced tools
Comparing version 0.8.0 to 0.9.1
@@ -23,6 +23,6 @@ { | ||
}, | ||
"version": "0.8.0", | ||
"version": "0.9.1", | ||
"devDependencies": { | ||
"mf-parser": "^0.8.0" | ||
"mf-parser": "^0.9.1" | ||
} | ||
} |
'use strict'; | ||
const { furanThreeTerm } = require('..'); | ||
const MF = require('mf-parser').MF; | ||
describe('test nucleotide', () => { | ||
test('remove base of three terminal of HDampDtmpDcmp', () => { | ||
it('remove base of three terminal of HDampDtmpDcmp', () => { | ||
let modified = furanThreeTerm('HDampDtmpDcmp', { a: true }); | ||
@@ -9,0 +8,0 @@ expect(modified).toBe('HDampDtmpC5H6O4P'); |
@@ -6,6 +6,7 @@ 'use strict'; | ||
describe('test generate fragments', () => { | ||
test('nucleotide to sequence of OHDampDtmpDcmpH', () => { | ||
it('nucleotide to sequence of OHDampDtmpDcmpH', () => { | ||
let fragments = generateFragments('HODampDtmpDcmpH', { a: true }); | ||
expect(fragments).toMatchSnapshot(); | ||
}); | ||
test('nucleotide to sequence of HODampDtmpDcmpH', () => { | ||
it('nucleotide to sequence of HODampDtmpDcmpH', () => { | ||
let fragments = generateFragments('HODampDtmpDcmpH', { a: true, ab: true }); | ||
@@ -15,3 +16,3 @@ expect(fragments).toMatchSnapshot(); | ||
test('nucleotide to sequence of HODampDtmpDcmpH', () => { | ||
it('nucleotide to sequence of HODampDtmpDcmpH and many fragments', () => { | ||
let fragments = generateFragments('HODampDtmpDcmpH', { | ||
@@ -18,0 +19,0 @@ a: true, |
'use strict'; | ||
const Nucleotide = require('..'); | ||
const MF = require('mf-parser').MF; | ||
describe('test nucleotide', () => { | ||
test('nucleotide to sequence of ATC', () => { | ||
it('nucleotide to sequence of ATC', () => { | ||
let sequence = Nucleotide.sequenceToMF('ATC'); | ||
expect(sequence).toEqual('HODampDtmpDcmpH.HODgmpDampDtmpH'); | ||
expect(sequence).toStrictEqual('HODampDtmpDcmpH.HODgmpDampDtmpH'); | ||
let mass = new MF(sequence).getInfo().mass; | ||
@@ -14,5 +15,5 @@ expect(mass).toBeCloseTo(1889.23, 1); | ||
test('nucleotide to sequence of AAU ', () => { | ||
it('nucleotide to sequence of AAU ', () => { | ||
let sequence = Nucleotide.sequenceToMF('AAU'); | ||
expect(sequence).toEqual('HOAmpAmpUmpH'); | ||
expect(sequence).toStrictEqual('HOAmpAmpUmpH'); | ||
let mass = new MF(sequence).getInfo().mass; | ||
@@ -22,5 +23,5 @@ expect(mass).toBeCloseTo(982.6, 1); | ||
test('nucleotide to sequence of circular AAA ', () => { | ||
it('nucleotide to sequence of circular AAA ', () => { | ||
let sequence = Nucleotide.sequenceToMF('AAA', { circular: true }); | ||
expect(sequence).toEqual('DampDampDamp.DtmpDtmpDtmp'); | ||
expect(sequence).toStrictEqual('DampDampDamp.DtmpDtmpDtmp'); | ||
let mass = new MF(sequence).getInfo().mass; | ||
@@ -30,5 +31,5 @@ expect(mass).toBeCloseTo(1852.21, 1); | ||
test('nucleotide to sequence of DNA AAA ', () => { | ||
it('nucleotide to sequence of DNA AAA ', () => { | ||
let sequence = Nucleotide.sequenceToMF('AAA', { kind: 'DNA' }); | ||
expect(sequence).toEqual('HODampDampDampH'); | ||
expect(sequence).toStrictEqual('HODampDampDampH'); | ||
let mass = new MF(sequence).getInfo().mass; | ||
@@ -38,5 +39,5 @@ expect(mass).toBeCloseTo(957.64, 1); | ||
test('nucleotide to sequence of ds-DNA AAA ', () => { | ||
it('nucleotide to sequence of ds-DNA AAA ', () => { | ||
let sequence = Nucleotide.sequenceToMF('AAA', { kind: 'ds-DNA' }); | ||
expect(sequence).toEqual('HODampDampDampH.HODtmpDtmpDtmpH'); | ||
expect(sequence).toStrictEqual('HODampDampDampH.HODtmpDtmpDtmpH'); | ||
let mass = new MF(sequence).getInfo().mass; | ||
@@ -46,3 +47,3 @@ expect(mass).toBeCloseTo(1888.24, 1); | ||
test(`nucleotide to sequence of DNA AAA with 5' alcohol`, () => { | ||
it('nucleotide to sequence of DNA AAA with 5\' alcohol', () => { | ||
let sequence = Nucleotide.sequenceToMF('AAA', { | ||
@@ -52,3 +53,3 @@ fivePrime: 'alcohol', | ||
}); | ||
expect(sequence).toEqual('HODadeDampDampH'); | ||
expect(sequence).toStrictEqual('HODadeDampDampH'); | ||
let mass = new MF(sequence).getInfo().mass; | ||
@@ -58,3 +59,3 @@ expect(mass).toBeCloseTo(877.66, 1); | ||
test(`nucleotide to sequence of DNA AAA with 5' monophosphate`, () => { | ||
it('nucleotide to sequence of DNA AAA with 5\' monophosphate', () => { | ||
let sequence = Nucleotide.sequenceToMF('AAA', { | ||
@@ -64,7 +65,7 @@ fivePrime: 'monophosphate', | ||
}); | ||
expect(sequence).toEqual('HODampDampDampH'); | ||
expect(sequence).toStrictEqual('HODampDampDampH'); | ||
let mass = new MF(sequence).getInfo().mass; | ||
expect(mass).toBeCloseTo(957.64, 1); | ||
}); | ||
test(`nucleotide to sequence of DNA AAA with 5' diphosphate`, () => { | ||
it('nucleotide to sequence of DNA AAA with 5\' diphosphate', () => { | ||
let sequence = Nucleotide.sequenceToMF('AAA', { | ||
@@ -74,3 +75,3 @@ fivePrime: 'diphosphate', | ||
}); | ||
expect(sequence).toEqual('HODadpDampDampH'); | ||
expect(sequence).toStrictEqual('HODadpDampDampH'); | ||
let mass = new MF(sequence).getInfo().mass; | ||
@@ -80,3 +81,3 @@ expect(mass).toBeCloseTo(1037.62, 1); | ||
test(`nucleotide to sequence of DNA AAA with 5' triphosphate`, () => { | ||
it('nucleotide to sequence of DNA AAA with 5\' triphosphate', () => { | ||
let sequence = Nucleotide.sequenceToMF('AAA', { | ||
@@ -86,3 +87,3 @@ fivePrime: 'triphosphate', | ||
}); | ||
expect(sequence).toEqual('HODatpDampDampH'); | ||
expect(sequence).toStrictEqual('HODatpDampDampH'); | ||
let mass = new MF(sequence).getInfo().mass; | ||
@@ -89,0 +90,0 @@ expect(mass).toBeCloseTo(1117.6, 1); |
@@ -7,13 +7,14 @@ 'use strict'; | ||
.replace(/ /g, '') | ||
.replace(/([a-zA-Z0-9\)])([A-Z])/g, '$1 $2') | ||
.replace(/([a-zA-Z0-9)])([A-Z])/g, '$1 $2') | ||
.split(/ /); | ||
let last = parts.pop(); | ||
if (!last.match(/^D[atcg]mp/)) { | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
'furanThreeTerm can not remove a non monophosphate nucleic acid: ' + last | ||
`furanThreeTerm can not remove a non monophosphate nucleic acid: ${last}` | ||
); | ||
} | ||
return parts.join('') + 'C5H6O4P'; | ||
return `${parts.join('')}C5H6O4P`; | ||
} | ||
module.exports = furanThreeTerm; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
module.exports = function(mf, options) { | ||
module.exports = function (mf, options) { | ||
if (options === undefined) { | ||
@@ -24,3 +24,3 @@ options = { | ||
var mfparts = mf | ||
.replace(/([a-z\)0-9])([A-Z][a-z](?=[a-z]))/g, '$1 $2') | ||
.replace(/([a-z)0-9])([A-Z][a-z](?=[a-z]))/g, '$1 $2') | ||
.split(/ /); | ||
@@ -46,14 +46,14 @@ | ||
function addFiveTerm(mfs, fiveTerm, i, options) { | ||
if (options.a) mfs.push(fiveTerm + 'O-1$a' + i); | ||
if (options.ab) mfs.push(furanThreeTerm(fiveTerm) + '$a' + i + ' - B'); | ||
if (options.b) mfs.push(fiveTerm + '$b' + i); | ||
if (options.c) mfs.push(fiveTerm + 'PO2H$c' + i); | ||
if (options.d) mfs.push(fiveTerm + 'PO3H$d' + i); | ||
if (options.a) mfs.push(`${fiveTerm}O-1$a${i}`); | ||
if (options.ab) mfs.push(`${furanThreeTerm(fiveTerm)}$a${i} - B`); | ||
if (options.b) mfs.push(`${fiveTerm}$b${i}`); | ||
if (options.c) mfs.push(`${fiveTerm}PO2H$c${i}`); | ||
if (options.d) mfs.push(`${fiveTerm}PO3H$d${i}`); | ||
} | ||
function addThreeTerm(mfs, threeTerm, i, options) { | ||
if (options.w) mfs.push('O' + threeTerm + '$w' + i); | ||
if (options.x) mfs.push('' + threeTerm + '$x' + i); | ||
if (options.y) mfs.push('O-2H-1P-1' + threeTerm + '$y' + i); | ||
if (options.z) mfs.push('O-3H-2P-1' + threeTerm + '$z' + i); | ||
if (options.w) mfs.push(`O${threeTerm}$w${i}`); | ||
if (options.x) mfs.push(`${threeTerm}$x${i}`); | ||
if (options.y) mfs.push(`O-2H-1P-1${threeTerm}$y${i}`); | ||
if (options.z) mfs.push(`O-3H-2P-1${threeTerm}$z${i}`); | ||
} |
@@ -48,2 +48,3 @@ 'use strict'; | ||
default: | ||
// eslint-disable-next-line no-console | ||
console.warn(`Nucleotide sequenceToMF: unknown kind: ${kind}`); | ||
@@ -54,7 +55,7 @@ } | ||
if (!circular) { | ||
results.forEach(result => result.unshift('HO')); | ||
results.forEach(result => result.push('H')); | ||
results.forEach((result) => result.unshift('HO')); | ||
results.forEach((result) => result.push('H')); | ||
} | ||
return results.map(result => result.join('')).join('.'); | ||
return results.map((result) => result.join('')).join('.'); | ||
} | ||
@@ -61,0 +62,0 @@ |
Sorry, the diff of this file is not supported yet
11757
290