-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLN-32292: update aminoAcidToDegenerateDnaMap.js
- Loading branch information
Showing
8 changed files
with
93 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(""); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters