Skip to content

Commit

Permalink
Removed * aa from dna translation at the end of sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
juanneilson committed Nov 27, 2023
1 parent 860dc2f commit 436b190
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ export default function getAminoAcidStringFromSequenceString(sequenceString) {
);
const aaArray = [];
let aaString = "";
aminoAcidsPerBase.forEach(aa => {
aminoAcidsPerBase.forEach((aa, index) => {
if (!aa.fullCodon) {
return;
}
// Check if the current amino acid is the last in the sequence and is a stop codon
if (index === aminoAcidsPerBase.length - 1 && aa.aminoAcid.value === '*') {
return;
}
aaArray[aa.aminoAcidIndex] = aa.aminoAcid.value;
});
aaString = aaArray.join("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ describe("getAminoAcidStringFromSequenceString", () => {
assert.equal("MM", getAminoAcidStringFromSequenceString("atgatg"));
assert.equal("M--", getAminoAcidStringFromSequenceString("atg------"));
assert.equal("", getAminoAcidStringFromSequenceString("at"));
assert.equal("MTNYNQKNEN", getAminoAcidStringFromSequenceString("atgactaattataatcaaaaaaatgaaaattaa"));
});
});

0 comments on commit 436b190

Please sign in to comment.