Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update aminoAcidToDegenerateDnaMap.js and add aminoAcidToDegenerateRnaMap.js #196

Merged
merged 2 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/aminoAcidToDegenerateDnaMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@ const aminoAcidToDegenerateDnaMap = {
".": "...",
"*": "trr",
a: "gcn",
b: "ray",
c: "ugy",
b: "ray", // D or N => aay + gay = ray
c: "tgy",
d: "gay",
e: "gar",
f: "uuy",
f: "tty",
g: "ggn",
h: "cay",
i: "auh",
i: "ath",
j: "htn", // L or I ytn + ath => htn
k: "aar",
l: "yun",
m: "aug",
l: "ytn", // YTR、CTN => Y=CT, N=AGCT
m: "atg",
n: "aay",
o: "tag", // Pyrrolysine, https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2933860/
p: "ccn",
q: "car",
r: "mng",
s: "wsn",
r: "mgn", // CGN、MGR => M=AC, N=AGCT
s: "wsn", // TCN、AGY => AT = w, CG = S, N is AGCT
t: "acn",
u: "uga",
v: "gun",
w: "ugg",
x: "nnn",
y: "uay",
z: "sar"
u: "tga", // Selenocysteine, https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2933860/
v: "gtn",
w: "tgg",
x: "nnn", // unknown aa.
y: "tay",
z: "sar" // E or Q, => gar + car = sar
};
module.exports = aminoAcidToDegenerateDnaMap;
32 changes: 32 additions & 0 deletions src/aminoAcidToDegenerateRnaMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const aminoAcidToDegenerateRnaMap = {
"-": "---",
".": "...",
"*": "trr",
a: "gcn",
b: "ray",
c: "ugy",
d: "gay",
e: "gar",
f: "uuy",
g: "ggn",
h: "cay",
i: "auh",
j: "hun",
k: "aar",
l: "yun",
m: "aug",
n: "aay",
o: "uag",
p: "ccn",
q: "car",
r: "mgn",
s: "wsn",
t: "acn",
u: "uga",
v: "gun",
w: "ugg",
x: "nnn",
y: "uay",
z: "sar"
};
module.exports = aminoAcidToDegenerateRnaMap;
27 changes: 27 additions & 0 deletions src/aminoAcidToDnaRna.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { expect } = require("chai");
const getDegenerateDnaStringFromAAString = require("./getDegenerateDnaStringFromAAString");
const getDegenerateRnaStringFromAAString = require("./getDegenerateRnaStringFromAAString");

describe("amino acid to RNA or DNA should be correct", function() {
it('should return a string with no "u/U" in it when parse AA sequence to DNA sequence.', function() {
const aaStr = "AQRSTFFVCL";
const DNASeq = getDegenerateDnaStringFromAAString(aaStr);
const RNASeq = getDegenerateRnaStringFromAAString(aaStr);
expect(DNASeq.length)
.equal(RNASeq.length)
.equal(aaStr.length * 3);
expect(DNASeq.toLowerCase().includes("u")).equal(false);
expect(DNASeq.toLowerCase().includes("t")).equal(true);

expect(RNASeq.toLowerCase().includes("t")).equal(false);
expect(RNASeq.toLowerCase().includes("u")).equal(true);

expect(RNASeq.toLowerCase().replace(/u/gi, "t")).equal(
DNASeq.toLowerCase()
);

expect(DNASeq.toLowerCase().replace(/t/gi, "u")).equal(
RNASeq.toLowerCase()
);
});
});
5 changes: 5 additions & 0 deletions src/degenerateRnaToAminoAcidMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { invert } = require("lodash");
const aminoAcidToDegenerateRnaMap = require("./aminoAcidToDegenerateRnaMap");

const degenerateRnaToAminoAcidMap = invert(aminoAcidToDegenerateRnaMap);
module.exports = degenerateRnaToAminoAcidMap;
8 changes: 8 additions & 0 deletions src/getDegenerateRnaStringFromAAString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const aminoAcidToDegenerateRnaMap = require("./aminoAcidToDegenerateRnaMap");

module.exports = function getDegenerateRnaStringFromAAString(aaString) {
return aaString
.split("")
.map(char => aminoAcidToDegenerateRnaMap[char.toLowerCase()] || "nnn")
.join("");
};
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports.patchSeqWithDiff = diffUtils.patchSeqWithDiff;
module.exports.reverseSeqDiff = diffUtils.reverseSeqDiff;
module.exports.getAllInsertionsInSeqReads = require("./getAllInsertionsInSeqReads");
module.exports.getDegenerateDnaStringFromAAString = require("./getDegenerateDnaStringFromAAString");
module.exports.getDegenerateRnaStringFromAAString = require("./getDegenerateRnaStringFromAAString");
module.exports.getVirtualDigest = require("./getVirtualDigest");
module.exports.isEnzymeType2S = require("./isEnzymeType2S");
module.exports.insertGapsIntoRefSeq = require("./insertGapsIntoRefSeq");
Expand Down Expand Up @@ -72,4 +73,6 @@ module.exports.getDigestFragmentsForRestrictionEnzymes = require("./getDigestFra
module.exports.convertDnaCaretPositionOrRangeToAA = require("./convertDnaCaretPositionOrRangeToAA");
module.exports.convertAACaretPositionOrRangeToDna = require("./convertAACaretPositionOrRangeToDna");
module.exports.aminoAcidToDegenerateDnaMap = require("./aminoAcidToDegenerateDnaMap");
module.exports.aminoAcidToDegenerateRnaMap = require("./aminoAcidToDegenerateRnaMap");
module.exports.degenerateDnaToAminoAcidMap = require("./degenerateDnaToAminoAcidMap");
module.exports.degenerateRnaToAminoAcidMap = require("./degenerateRnaToAminoAcidMap");
2 changes: 1 addition & 1 deletion src/insertSequenceDataAtPositionOrRange.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("insertSequenceData", function() {
sequenceToInsertInto,
caret
);
postInsertSeq.sequence.should.equal("atgauhgaymngagagagaaa");
postInsertSeq.sequence.should.equal("atgathgaymgnagagagaaa");
postInsertSeq.proteinSequence.should.equal("MIDRREK");
postInsertSeq.features.should.containSubset([
{ name: "feat2", start: 0, end: 14 }
Expand Down
2 changes: 1 addition & 1 deletion src/tidyUpSequenceData.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe("tidyUpSequenceData", function() {
isProtein: true,
size: 54, //size should refer to the DNA length
proteinSize: 18, //proteinSize should refer to the amino acid length
sequence: "ggngcnggnauhugacayuggggngcnggngcnyungcnwsnggnyuntrr...", //degenerate sequence
sequence: "ggngcnggnathtgacaytggggngcnggngcnytngcnwsnggnytntrr...", //degenerate sequence
proteinSequence: "gagiuhwgagalasgl*.",
circular: false,
features: [
Expand Down