Skip to content

Commit

Permalink
adding doNotProvideIdsForAnnotations flag for tidyUpSequencData; addi…
Browse files Browse the repository at this point in the history
…ng alternate colorByFamily colors to amino acids
  • Loading branch information
tnrich committed Oct 19, 2021
1 parent d11f1ba commit edad0ce
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
30 changes: 29 additions & 1 deletion src/proteinAlphabet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,169 +4,194 @@ module.exports = {
name: "Alanine",
threeLettersName: "Ala",
hydrophobicity: 1.8,
colorByFamily: "#00FFFF",
color: "#FF5C5C"
},
R: {
value: "R",
name: "Arginine",
threeLettersName: "Arg",
hydrophobicity: -4.5,
colorByFamily: "#FFC0CB",
color: "#190000"
},
N: {
value: "N",
name: "Asparagine",
threeLettersName: "Asn",
hydrophobicity: -3.5,
colorByFamily: "#D3D3D3",
color: "#4D0000"
},
D: {
value: "D",
name: "Aspartic acid",
threeLettersName: "Asp",
hydrophobicity: -3.5,
colorByFamily: "#EE82EE",
color: "#4D0000"
},
C: {
value: "C",
name: "Cysteine",
threeLettersName: "Cys",
hydrophobicity: 2.5,
colorByFamily: "#FFFF00",
color: "#FF8080"
},
E: {
value: "E",
name: "Glutamic acid",
threeLettersName: "Glu",
hydrophobicity: -3.5,
colorByFamily: "#EE82EE",
color: "#4D0000"
},
Q: {
value: "Q",
name: "Glutamine",
threeLettersName: "Gln",
hydrophobicity: -3.5,
colorByFamily: "#D3D3D3",
color: "#4D0000"
},
G: {
value: "G",
name: "Glycine",
threeLettersName: "Gly",
hydrophobicity: -0.4,
colorByFamily: "#00FFFF",
color: "#EB0000"
},
H: {
value: "H",
name: "Histidine",
threeLettersName: "His",
hydrophobicity: -3.2,
colorByFamily: "#FFC0CB",
color: "#5C0000"
},
I: {
value: "I",
name: "Isoleucine ",
threeLettersName: "Ile",
hydrophobicity: 4.5,
colorByFamily: "#00FFFF",
color: "#FFE6E6"
},
L: {
value: "L",
name: "Leucine",
threeLettersName: "Leu",
hydrophobicity: 3.8,
colorByFamily: "#00FFFF",
color: "#FFC2C2"
},
K: {
value: "K",
name: "Lysine",
threeLettersName: "Lys",
hydrophobicity: -3.9,
colorByFamily: "#FFC0CB",
color: "#380000"
},
M: {
value: "M",
name: "Methionine",
threeLettersName: "Met",
hydrophobicity: 1.9,
colorByFamily: "#FFFF00",
color: "#FF6161"
},
F: {
value: "F",
name: "Phenylalanine",
threeLettersName: "Phe",
hydrophobicity: 2.8,
colorByFamily: "#FFA500",
color: "#FF8F8F"
},
P: {
value: "P",
name: "Proline",
threeLettersName: "Pro",
hydrophobicity: -1.6,
colorByFamily: "#00FFFF",
color: "#AD0000"
},
S: {
value: "S",
name: "Serine",
threeLettersName: "Ser",
hydrophobicity: -0.8,
colorByFamily: "#90EE90",
color: "#D60000"
},
T: {
value: "T",
name: "Threonine",
threeLettersName: "Thr",
hydrophobicity: -0.7,
colorByFamily: "#90EE90",
color: "#DB0000"
},
U: {
value: "U",
name: "Selenocysteine",
threeLettersName: "Sec",
colorByFamily: "#FF0000",
color: "#FF0000"
},
W: {
value: "W",
name: "Tryptophan",
threeLettersName: "Trp",
hydrophobicity: -0.9,
colorByFamily: "#FFA500",
color: "#D10000"
},
Y: {
value: "Y",
name: "Tyrosine",
threeLettersName: "Tyr",
hydrophobicity: -1.3,
colorByFamily: "#FFA500",
color: "#BD0000"
},
V: {
value: "V",
name: "Valine",
threeLettersName: "Val",
hydrophobicity: 4.2,
colorByFamily: "#00FFFF",
color: "#FFD6D6"
},
"*": {
value: "*",
name: "Stop",
threeLettersName: "Stop",
colorByFamily: "#FF0000",
color: "#FF0000"
},
".": {
//tnr: this is actually a deletion/gap character (previously we had this as a stop character which is incorrect) https://www.dnabaser.com/articles/IUPAC%20ambiguity%20codes.html
value: ".",
name: "Gap",
threeLettersName: "Gap",
threeLettersName: "Stop",
colorByFamily: "#FF0000",
color: "#FF0000"
},
"-": {
value: "-",
name: "Gap",
threeLettersName: "Gap",
colorByFamily: "#FF0000",
color: "#FF0000"
},
B: {
value: "B",
threeLettersName: "ND",
colorByFamily: "lightpurple",
color: "lightpurple",
isAmbiguous: true,
name: "B",
Expand All @@ -175,6 +200,7 @@ module.exports = {
J: {
value: "J",
threeLettersName: "IL",
colorByFamily: "lightpurple",
color: "lightpurple",
isAmbiguous: true,
name: "J",
Expand All @@ -183,6 +209,7 @@ module.exports = {
X: {
value: "X",
threeLettersName: "ACDEFGHIKLMNPQRSTVWY",
colorByFamily: "#FFFFFF",
color: "lightpurple",
isAmbiguous: true,
name: "X",
Expand All @@ -191,6 +218,7 @@ module.exports = {
Z: {
value: "Z",
threeLettersName: "QE",
colorByFamily: "lightpurple",
color: "lightpurple",
isAmbiguous: true,
name: "Z",
Expand Down
3 changes: 2 additions & 1 deletion src/tidyUpAnnotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = function tidyUpAnnotation(
convertAnnotationsFromAAIndices,
annotationType,
provideNewIdsForAnnotations,
doNotProvideIdsForAnnotations,
messages = [],
mutative
}
Expand All @@ -34,7 +35,7 @@ module.exports = function tidyUpAnnotation(
if (provideNewIdsForAnnotations) {
annotation.id = bsonObjectid().str;
}
if (!annotation.id && annotation.id !== 0) {
if (!annotation.id && annotation.id !== 0 && !doNotProvideIdsForAnnotations) {
annotation.id = bsonObjectid().str;
messages.push(
"Unable to detect valid ID for annotation, setting ID to " + annotation.id
Expand Down
5 changes: 4 additions & 1 deletion src/tidyUpSequenceData.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = function tidyUpSequenceData(pSeqData, options = {}) {
additionalValidChars,
noTranslationData,
charOverrides,
doNotProvideIdsForAnnotations,
proteinFilterOptions,
convertAnnotationsFromAAIndices
} = options;
Expand Down Expand Up @@ -143,7 +144,9 @@ module.exports = function tidyUpSequenceData(pSeqData, options = {}) {
itemId = item.id;
} else {
itemId = bsonObjectid().str;
item.id = itemId; //assign the newly created id to the item d
if (!doNotProvideIdsForAnnotations) {
item.id = itemId; //assign the newly created id to the item
}
}
acc[itemId] = item;
return acc;
Expand Down
21 changes: 18 additions & 3 deletions src/tidyUpSequenceData.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const assert = require("assert");

const tidyUpSequenceData = require("./tidyUpSequenceData");
const chai = require("chai");
const chaiSubset = require("chai-subset");
Expand Down Expand Up @@ -78,7 +80,8 @@ describe("tidyUpSequenceData", function() {
aminoAcid: {
value: ".",
name: "Gap",
threeLettersName: "Gap",
threeLettersName: "Stop",
colorByFamily: "#FF0000",
color: "#FF0000"
},
positionInCodon: 0,
Expand All @@ -94,7 +97,8 @@ describe("tidyUpSequenceData", function() {
aminoAcid: {
value: ".",
name: "Gap",
threeLettersName: "Gap",
threeLettersName: "Stop",
colorByFamily: "#FF0000",
color: "#FF0000"
},
positionInCodon: 1,
Expand All @@ -110,7 +114,8 @@ describe("tidyUpSequenceData", function() {
aminoAcid: {
value: ".",
name: "Gap",
threeLettersName: "Gap",
threeLettersName: "Stop",
colorByFamily: "#FF0000",
color: "#FF0000"
},
positionInCodon: 2,
Expand Down Expand Up @@ -250,6 +255,16 @@ describe("tidyUpSequenceData", function() {
);
res.features[0].id.should.not.equal(123);
});
it("should not add ids even if the ids are missing if doNotProvideIdsForAnnotations=true", function() {
const res = tidyUpSequenceData(
{
features: [{ start: 4, end: 5 }, {}]
},
{ doNotProvideIdsForAnnotations: true }
);

assert.strictEqual(res.features[0].id, undefined);
});
it("should add the annotationTypePlural field", function() {
const res = tidyUpSequenceData(
{
Expand Down

0 comments on commit edad0ce

Please sign in to comment.