Huge News!Announcing our $40M Series B led by Abstract Ventures.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.6.2 to 0.6.4

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

47

package.json
{
"author": {
"name": "Luc Patiny"
},
"bugs": {
"url": "https://github.com/cheminfo/molecular-formula/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Deal with nucleotides and molecular formula",
"main": "src/index.js",
"files": [
"src"
],
"homepage": "https://github.com/cheminfo/molecular-formula/tree/master/packages/nucleotide#readme",
"keywords": [],
"license": "MIT",
"name": "nucleotide",
"repository": {
"type": "git",
"url": "git+https://github.com/cheminfo/molecular-formula.git"
},
"version": "0.6.2"
"author": {
"name": "Luc Patiny"
},
"bugs": {
"url": "https://github.com/cheminfo/molecular-formula/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Deal with nucleotides and molecular formula",
"main": "src/index.js",
"files": [
"src"
],
"homepage": "https://github.com/cheminfo/molecular-formula/tree/master/packages/nucleotide#readme",
"keywords": [],
"license": "MIT",
"name": "nucleotide",
"repository": {
"type": "git",
"url": "git+https://github.com/cheminfo/molecular-formula.git"
},
"version": "0.6.4",
"devDependencies": {
"mf-parser": "^0.6.4"
}
}

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

* @param {string} [options.kind] - rna, ds-dna or dna. Default if contains U: rna, otherwise ds-dna
* @param {string} [options.fivePrime=monophosphate] - alcohol, monophosphate, diphosphate, triphosphate
* @param {string} [options.circular=false]

@@ -13,58 +14,71 @@ */

function sequenceToMF(sequence, options = {}) {
let { kind, circular } = options;
sequence = sequence.toUpperCase().replace(/[^ATCGU]/g, '');
if (!kind) {
if (sequence.includes('U')) {
kind = 'rna';
} else {
kind = 'ds-dna';
}
let { kind, circular, fivePrime = 'monophosphate' } = options;
fivePrime = fivePrime.replace(/[^a-zA-Z]/g, '').toLowerCase();
sequence = sequence.toUpperCase().replace(/[^ATCGU]/g, '');
if (!kind) {
if (sequence.includes('U')) {
kind = 'rna';
} else {
kind = 'ds-dna';
}
}
kind = kind.replace(/[^A-Za-z]/g, '').toLowerCase();
kind = kind.replace(/[^A-Za-z]/g, '').toLowerCase();
let results = [[]];
if (kind === 'dsdna') results.push([]);
let results = [[]];
if (kind === 'dsdna') results.push([]);
for (let i = 0; i < sequence.length; i++) {
let nucleotide = sequence[i];
let nucleotideType = i === 0 ? fivePrime : 'monophosphate';
switch (kind) {
case 'dna':
for (let nucleotide of sequence) {
results[0].push(desoxyNucleotides[nucleotide]);
}
break;
case 'rna':
for (let nucleotide of sequence) {
results[0].push(oxyNucleotides[nucleotide]);
}
break;
case 'dsdna':
for (let nucleotide of sequence) {
results[0].push(oxyNucleotides[nucleotide]);
results[1].unshift(oxyNucleotides[complementary[nucleotide]]);
}
break;
default:
throw new Error(`Nucleotide sequenceToMF: unknown kind: ${kind}`);
case 'dna':
results[0].push(desoxyNucleotides[nucleotideType][nucleotide]);
break;
case 'rna':
results[0].push(oxyNucleotides[nucleotideType][nucleotide]);
break;
case 'dsdna':
results[0].push(desoxyNucleotides[nucleotideType][nucleotide]);
results[1].unshift(
desoxyNucleotides[nucleotideType][complementary[nucleotide]]
);
break;
default:
console.warn(`Nucleotide sequenceToMF: unknown kind: ${kind}`);
}
}
if (!circular) {
results.forEach((result) => result.unshift('HO'));
results.forEach((result) => result.push('H'));
}
if (!circular) {
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('.');
}
module.exports = {
sequenceToMF
sequenceToMF,
generateFragments: require('./generateFragments'),
furanThreeTerm: require('./furanThreeTerm')
};
const complementary = {
A: 'T',
T: 'A',
C: 'G',
G: 'C'
A: 'T',
T: 'A',
C: 'G',
G: 'C'
};
const desoxyNucleotides = {
alcohol: {
A: 'Dade',
C: 'Dcyt',
G: 'Dgua',
T: 'Dthy',
U: 'Dura'
},
monophosphate: {
A: 'Damp',

@@ -75,5 +89,28 @@ C: 'Dcmp',

U: 'Dump'
},
diphosphate: {
A: 'Dadp',
C: 'Dcdp',
G: 'Dgdp',
T: 'Dtdp',
U: 'Dudp'
},
triphosphate: {
A: 'Datp',
C: 'Dctp',
G: 'Dgtp',
T: 'Dttp',
U: 'Dutp'
}
};
const oxyNucleotides = {
alcohol: {
A: 'Ade',
C: 'Cyt',
G: 'Gua',
T: 'Thy',
U: 'Ura'
},
monophosphate: {
A: 'Amp',

@@ -84,2 +121,17 @@ C: 'Cmp',

U: 'Ump'
},
diphosphate: {
A: 'Adp',
C: 'Cdp',
G: 'Gdp',
T: 'Tdp',
U: 'Udp'
},
triphosphate: {
A: 'Atp',
C: 'Ctp',
G: 'Gtp',
T: 'Ttp',
U: 'Utp'
}
};
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