New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nucleotide

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nucleotide - npm Package Compare versions

Comparing version 0.9.1 to 0.12.0

src/__tests__/__snapshots__/generateFragments.internal.test.js.snap

7

package.json

@@ -23,6 +23,7 @@ {

},
"version": "0.9.1",
"version": "0.12.0",
"devDependencies": {
"mf-parser": "^0.9.1"
}
"mf-parser": "^0.12.0"
},
"gitHead": "aa2e6571c5f7121dda616b7d6920b7a653a8f9c7"
}

@@ -7,5 +7,20 @@ 'use strict';

it('remove base of three terminal of HDampDtmpDcmp', () => {
let modified = furanThreeTerm('HDampDtmpDcmp', { a: true });
let modified = furanThreeTerm('HDampDtmpDcmp');
expect(modified).toBe('HDampDtmpC5H6O4P');
});
it('remove base of three terminal of HDamp', () => {
let modified = furanThreeTerm('HDamp');
expect(modified).toBe('HC5H6O4P');
});
it('remove base of three terminal of (C5H3)DampDtmp', () => {
let modified = furanThreeTerm('(C5H3)DampDtmp');
expect(modified).toBe('(C5H3)DampC5H6O4P');
});
it('remove base of three terminal of HODamp', () => {
let modified = furanThreeTerm('HODamp');
expect(modified).toBe('HOC5H6O4P');
});
});

@@ -6,11 +6,31 @@ 'use strict';

describe('test generate fragments', () => {
it('nucleotide to sequence of OHDampDtmpDcmpH', () => {
it('nucleotide to sequence of HODampDtmpDcmpH', () => {
let fragments = generateFragments('HODampDtmpDcmpH', { a: true });
expect(fragments).toMatchSnapshot();
expect(fragments).toStrictEqual(['HODampO-1H-1$a1', 'HODampDtmpO-1H-1$a2']);
});
it('nucleotide to sequence of HODampDtmpDcmpH', () => {
it('nucleotide to sequence internal modification of HODamp(NH2)DtmpDcmpH', () => {
let fragments = generateFragments('HODamp(NH2)DtmpDcmpH', { a: true });
expect(fragments).toStrictEqual([
'HODamp(NH2)O-1H-1$a1',
'HODamp(NH2)DtmpO-1H-1$a2',
]);
});
it('nucleotide to sequence HODampDtmpDcmpH', () => {
let fragments = generateFragments('HODampDtmpDcmpH', { a: true, ab: true });
expect(fragments).toMatchSnapshot();
expect(fragments).toStrictEqual([
'HODampO-1H-1$a1',
'HODampDtmpO-1H-1$a2',
'HODampC5H6O4P$a2-B',
]);
});
it('nucleotide HODampDtmpDcmpH dh2o (d with loss of water)', () => {
let fragments = generateFragments('HODampDampH', {
dh2o: true,
});
expect(fragments).toStrictEqual(['HODampPO2$d-H2O1']);
});
it('nucleotide to sequence of HODampDtmpDcmpH and many fragments', () => {

@@ -26,6 +46,24 @@ let fragments = generateFragments('HODampDtmpDcmpH', {

y: true,
z: true
z: true,
});
expect(fragments).toMatchSnapshot();
expect(fragments).toStrictEqual([
'HODampO-1H-1$a1',
'HODampH$b1',
'HODampPO2$c1',
'HODampPO3H2$d1',
'HODcmpH$w1',
'H-1DcmpH$x1',
'O-2P-1DcmpH$y1',
'O-3H-2P-1DcmpH$z1',
'HODampDtmpO-1H-1$a2',
'HODampC5H6O4P$a2-B',
'HODampDtmpH$b2',
'HODampDtmpPO2$c2',
'HODampDtmpPO3H2$d2',
'HODtmpDcmpH$w2',
'H-1DtmpDcmpH$x2',
'O-2P-1DtmpDcmpH$y2',
'O-3H-2P-1DtmpDcmpH$z2',
]);
});
});

@@ -8,2 +8,16 @@ 'use strict';

describe('test nucleotide', () => {
it('nucleotide to sequence of emtpy string', () => {
let sequence = Nucleotide.sequenceToMF(' ');
expect(sequence).toStrictEqual('');
let mass = new MF(sequence).getInfo().mass;
expect(mass).toBeCloseTo(0, 1);
});
it('nucleotide to sequence of atc', () => {
let sequence = Nucleotide.sequenceToMF('atc');
expect(sequence).toStrictEqual('HODampDtmpDcmpH.HODgmpDampDtmpH');
let mass = new MF(sequence).getInfo().mass;
expect(mass).toBeCloseTo(1889.23, 1);
});
it('nucleotide to sequence of ATC', () => {

@@ -15,3 +29,17 @@ let sequence = Nucleotide.sequenceToMF('ATC');

});
it('nucleotide to sequence of A(H-1C-1)TC', () => {
let sequence = Nucleotide.sequenceToMF('A(H-1C-1)TC', { kind: 'dna' });
expect(sequence).toStrictEqual('HODamp(H-1C-1)DtmpDcmpH');
});
it('nucleotide to sequence of (HO)ATC(NH2)', () => {
let sequence = Nucleotide.sequenceToMF('(HO)ATC(NH2)', { kind: 'dna' });
expect(sequence).toStrictEqual('(HO)DampDtmpDcmp(NH2)');
});
it('nucleotide to sequence of (HO)atc(NH2)', () => {
let sequence = Nucleotide.sequenceToMF('(HO)atc(NH2)', { kind: 'dna' });
expect(sequence).toStrictEqual('(HO)DampDtmpDcmp(NH2)');
});
it('nucleotide to sequence of AAU ', () => {

@@ -45,6 +73,6 @@ let sequence = Nucleotide.sequenceToMF('AAU');

it('nucleotide to sequence of DNA AAA with 5\' alcohol', () => {
it("nucleotide to sequence of DNA AAA with 5' alcohol", () => {
let sequence = Nucleotide.sequenceToMF('AAA', {
fivePrime: 'alcohol',
kind: 'DNA'
kind: 'DNA',
});

@@ -56,6 +84,6 @@ expect(sequence).toStrictEqual('HODadeDampDampH');

it('nucleotide to sequence of DNA AAA with 5\' monophosphate', () => {
it("nucleotide to sequence of DNA AAA with 5' monophosphate", () => {
let sequence = Nucleotide.sequenceToMF('AAA', {
fivePrime: 'monophosphate',
kind: 'DNA'
kind: 'DNA',
});

@@ -66,6 +94,6 @@ expect(sequence).toStrictEqual('HODampDampDampH');

});
it('nucleotide to sequence of DNA AAA with 5\' diphosphate', () => {
it("nucleotide to sequence of DNA AAA with 5' diphosphate", () => {
let sequence = Nucleotide.sequenceToMF('AAA', {
fivePrime: 'diphosphate',
kind: 'DNA'
kind: 'DNA',
});

@@ -77,6 +105,6 @@ expect(sequence).toStrictEqual('HODadpDampDampH');

it('nucleotide to sequence of DNA AAA with 5\' triphosphate', () => {
it("nucleotide to sequence of DNA AAA with 5' triphosphate", () => {
let sequence = Nucleotide.sequenceToMF('AAA', {
fivePrime: 'triphosphate',
kind: 'DNA'
kind: 'DNA',
});

@@ -83,0 +111,0 @@ expect(sequence).toStrictEqual('HODatpDampDampH');

@@ -7,6 +7,6 @@ 'use strict';

.replace(/ /g, '')
.replace(/([a-zA-Z0-9)])([A-Z])/g, '$1 $2')
.replace(/([a-z)0-9])([A-Z][a-z](?=[a-z]))/g, '$1 $2')
.split(/ /);
let last = parts.pop();
if (!last.match(/^D[atcg]mp/)) {
if (!last.match(/D[atcg]mp(.*)$/)) {
// eslint-disable-next-line no-console

@@ -16,6 +16,7 @@ console.warn(

);
return parts.join('') + last;
}
return `${parts.join('')}C5H6O4P`;
return parts.join('') + last.replace(/D[atcg]mp(.*)$/, 'C5H6O4P');
}
module.exports = furanThreeTerm;
'use strict';
const furanThreeTerm = require('./furanThreeTerm');
const addInternalTerm = require('./addInternalTerm');
const addFiveTerm = require('./addFiveTerm');
const addFiveTermBaseLoss = require('./addFiveTermBaseLoss');
const addThreeTerm = require('./addThreeTerm');
const addThreeTermBaseLoss = require('./addThreeTermBaseLoss');
module.exports = function (mf, options) {
module.exports = function generateFragments(mf, options) {
if (options === undefined) {

@@ -13,27 +17,44 @@ options = {

d: false,
dh2o: false,
w: false,
x: false,
y: false,
z: false
z: false,
zch2: false,
aw: false,
bw: false,
abw: false,
aby: false,
abcdBaseLoss: false,
wxyzBaseLoss: false
};
}
var mfs = [];
let mfs = [];
// need to allow 0-9 to deal with neutral loss
var mfparts = mf
let mfparts = mf
.replace(/([a-z)0-9])([A-Z][a-z](?=[a-z]))/g, '$1 $2')
.split(/ /);
var fiveTerm = '';
var threeTerm = '';
let fiveTerm = '';
let threeTerm = '';
for (var i = 1; i < mfparts.length; i++) {
fiveTerm += mfparts[i - 1];
threeTerm = mfparts[mfparts.length - i] + threeTerm;
addFiveTerm(mfs, fiveTerm, i, options);
addThreeTerm(mfs, threeTerm, i, options);
for (let ter5 = 1; ter5 < mfparts.length; ter5++) {
fiveTerm += mfparts[ter5 - 1];
threeTerm = mfparts[mfparts.length - ter5] + threeTerm;
addFiveTerm(mfs, fiveTerm, ter5, options);
addFiveTermBaseLoss(mfs, fiveTerm, ter5, options);
addThreeTerm(mfs, threeTerm, ter5, options);
addThreeTermBaseLoss(mfs, threeTerm, ter5, options);
}
if (mfs.length === 0) {
mfs = mfs.concat([mf]);
for (let i = 1; i < mfparts.length - 1; i++) {
let internal = '';
for (let j = i; j < mfparts.length - 1; j++) {
internal += mfparts[j];
if (j > i) {
addInternalTerm(mfs, internal, mfparts.length - i, j + 1, options);
}
}
}

@@ -43,16 +64,1 @@

};
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}`);
}
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}`);
}

@@ -13,6 +13,10 @@ 'use strict';

function sequenceToMF(sequence, options = {}) {
let fivePrimeTerminal = 'HO';
let threePrimeTerminal = 'H';
sequence = sequence.trim();
if (sequence === '') return '';
let { kind, circular, fivePrime = 'monophosphate' } = options;
fivePrime = fivePrime.replace(/[^a-zA-Z]/g, '').toLowerCase();
sequence = sequence.toUpperCase().replace(/[^ATCGU]/g, '');
if (!kind) {

@@ -28,20 +32,59 @@ if (sequence.includes('U')) {

if (sequence.includes('(') && kind === 'dsdna') {
throw new Error(
'Nucleotide sequenceToMF: modifications not allowed for ds-DNA'
);
}
let results = [[]];
if (kind === 'dsdna') results.push([]);
let parenthesisCounter = 0;
for (let i = 0; i < sequence.length; i++) {
let nucleotide = sequence[i];
let currentSymbol = sequence[i];
if (
currentSymbol === '(' ||
currentSymbol === ')' ||
parenthesisCounter > 0
) {
if (currentSymbol === '(') {
parenthesisCounter++;
if (i === 0) fivePrimeTerminal = '';
}
if (currentSymbol === ')') {
parenthesisCounter--;
if (i === sequence.length - 1) threePrimeTerminal = '';
}
switch (kind) {
case 'dna':
case 'rna':
results[0].push(currentSymbol);
break;
default:
// eslint-disable-next-line no-console
console.warn(
`Nucleotide sequenceToMF with modification: unknown kind: ${kind}`
);
}
continue;
}
let nucleotideType = i === 0 ? fivePrime : 'monophosphate';
currentSymbol = currentSymbol.toUpperCase().replace(/[^ATCGU]/, '');
if (!currentSymbol) continue;
switch (kind) {
case 'dna':
results[0].push(desoxyNucleotides[nucleotideType][nucleotide]);
results[0].push(desoxyNucleotides[nucleotideType][currentSymbol]);
break;
case 'rna':
results[0].push(oxyNucleotides[nucleotideType][nucleotide]);
results[0].push(oxyNucleotides[nucleotideType][currentSymbol]);
break;
case 'dsdna':
results[0].push(desoxyNucleotides[nucleotideType][nucleotide]);
results[0].push(desoxyNucleotides[nucleotideType][currentSymbol]);
results[1].unshift(
desoxyNucleotides[nucleotideType][complementary[nucleotide]]
desoxyNucleotides[nucleotideType][complementary[currentSymbol]]
);

@@ -56,4 +99,4 @@ break;

if (!circular) {
results.forEach((result) => result.unshift('HO'));
results.forEach((result) => result.push('H'));
results.forEach((result) => result.unshift(fivePrimeTerminal));
results.forEach((result) => result.push(threePrimeTerminal));
}

@@ -67,3 +110,4 @@

generateFragments: require('./generateFragments'),
furanThreeTerm: require('./furanThreeTerm')
furanThreeTerm: require('./furanThreeTerm'),
baseLoss: require('./baseLoss')
};

@@ -70,0 +114,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc