Skip to content

Commit

Permalink
updating getAminoAcidStringFromSequenceString to have doNotExcludeAst…
Browse files Browse the repository at this point in the history
…erisk option, updating toastr error logging, updating bio parser tests for u chars
  • Loading branch information
tnrich committed Nov 28, 2023
1 parent 37d34c6 commit e563297
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### 0.2.0

- Fixed condition for removing * [`#52`](https://github.com/TeselaGen/tg-oss/pull/52)
- Removed * aa from dna translation at the end of sequence [`#50`](https://github.com/TeselaGen/tg-oss/pull/50)
- export feat locs [`#45`](https://github.com/TeselaGen/tg-oss/pull/45)
- unifying sequence filtering so filterSequenceString is always hit and… [`#31`](https://github.com/TeselaGen/tg-oss/pull/31)
- fixed genbank file embedded in another genbank comment [`#36`](https://github.com/TeselaGen/tg-oss/pull/36)
Expand Down
2 changes: 1 addition & 1 deletion packages/bio-parsers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@teselagen/bio-parsers",
"version": "0.4.7",
"version": "0.4.9",
"type": "commonjs",
"dependencies": {
"@gmod/gff": "^1.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/bio-parsers/test/fastaToJson.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ ggagagguagagagagg
isDNA: true
}
);
expect(result[0].parsedSequence.sequence[7]).toEqual("t");
expect(result[0].parsedSequence.sequence[7]).toEqual("u");
const result2 = await fastaToJson(
`>mySeq1
GGAGAGGUAGAGAGAGG
`,
{ isDNA: true }
);
expect(result2[0].parsedSequence.sequence[7]).toEqual("T");
expect(result2[0].parsedSequence.sequence[7]).toEqual("U");
});
it("handles parseName option correctly", async function () {
const fastaStr = `>gb|M73307|AGMA13GT
Expand Down
4 changes: 2 additions & 2 deletions packages/bio-parsers/test/genbankToJson.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ ORIGIN
});
});

it("will convert U base pairs to T for DNA", () => {
it("will not convert U base pairs to T for DNA", () => {
const string = fs.readFileSync(
path.join(__dirname, "./testData/genbank/genbankWithU.gb"),
"utf8"
Expand All @@ -875,8 +875,8 @@ ORIGIN
res.should.be.an("array");
res[0].success.should.be.true;
res[0].parsedSequence.features.length.should.equal(1);
expect(res[0].parsedSequence.sequence).toContain("u");
expect(res[0].parsedSequence.sequence).toContain("t");
expect(res[0].parsedSequence.sequence).not.toContain("u");
});
it("will NOT convert U base pairs to T for RNA", () => {
const string = fs.readFileSync(
Expand Down
2 changes: 1 addition & 1 deletion packages/ove/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@teselagen/ove",
"version": "0.3.60",
"version": "0.3.62",
"main": "./src/index.js",
"exports": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion packages/sequence-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@teselagen/sequence-utils",
"version": "0.3.13",
"version": "0.3.15",
"type": "commonjs",
"dependencies": {
"bson-objectid": "^2.0.4",
Expand Down
10 changes: 7 additions & 3 deletions packages/sequence-utils/src/findSequenceMatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,22 @@ function findSequenceMatchesTopStrand(sequence, searchString, options = {}) {
if (isProteinSearch) {
sequencesToCheck = [
{
seqToCheck: getAminoAcidStringFromSequenceString(sequenceToUse),
seqToCheck: getAminoAcidStringFromSequenceString(sequenceToUse, {
doNotExcludeAsterisk: true
}),
offset: 0
},
{
seqToCheck: getAminoAcidStringFromSequenceString(
sequenceToUse.substr(1)
sequenceToUse.substr(1),
{ doNotExcludeAsterisk: true }
),
offset: 1
},
{
seqToCheck: getAminoAcidStringFromSequenceString(
sequenceToUse.substr(2)
sequenceToUse.substr(2),
{ doNotExcludeAsterisk: true }
),
offset: 2
}
Expand Down
12 changes: 6 additions & 6 deletions packages/sequence-utils/src/findSequenceMatches.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import findSequenceMatches from "./findSequenceMatches";

describe("findSequenceMatches", () => {
it("ambiguous protein sequence with * as stop codon", () => {
it("ambiguous protein sequence with asterisk as stop codon", () => {
expect(
findSequenceMatches("mmhlrl*", "Mxxlrl*", {
isAmbiguous: true,
Expand Down Expand Up @@ -29,7 +29,7 @@ describe("findSequenceMatches", () => {
}
]);
});
it("protein sequence with * as stop codon", () => {
it("protein sequence with asterisk as stop codon", () => {
expect(
findSequenceMatches("mmhlrl*", "mMh", {
isProteinSequence: true /* isProteinSearch: true */
Expand Down Expand Up @@ -132,11 +132,11 @@ describe("findSequenceMatches", () => {
const matches = findSequenceMatches("atg", "*", { isAmbiguous: true });
expect(matches).toEqual([]);
});
it("ambiguous, dna searches with *", () => {
it("ambiguous, dna searches with asterisk", () => {
const matches = findSequenceMatches("atg", "", { isAmbiguous: true });
expect(matches).toEqual([]);
});
it(" AA with * as stop codon", () => {
it("AA with asterisk as stop codon in atgtaa", () => {
expect(
findSequenceMatches("atgtaa", "M*", { isProteinSearch: true })
).toEqual([
Expand All @@ -146,7 +146,7 @@ describe("findSequenceMatches", () => {
}
]);
});
it(" AA with * as stop codon", () => {
it("AA with asterisk as stop codon in atgtaaccc", () => {
expect(
findSequenceMatches("atgtaaccc", "M**", { isProteinSearch: true })
).toEqual([]);
Expand All @@ -164,7 +164,7 @@ describe("findSequenceMatches", () => {
}
]);
});
it("works with ambiguous AA with * in search string", () => {
it("works with ambiguous AA with asterisk in search string", () => {
expect(
findSequenceMatches("atgtaa", "M*", {
isProteinSearch: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import getAminoAcidDataForEachBaseOfDna from "./getAminoAcidDataForEachBaseOfDna";

export default function getAminoAcidStringFromSequenceString(sequenceString) {
export default function getAminoAcidStringFromSequenceString(
sequenceString,
{ doNotExcludeAsterisk } = {}
) {
const aminoAcidsPerBase = getAminoAcidDataForEachBaseOfDna(
sequenceString,
true
Expand All @@ -12,7 +15,11 @@ export default function getAminoAcidStringFromSequenceString(sequenceString) {
return;
}
// Check if the current amino acid is the last in the sequence and is a stop codon
if (index >= aminoAcidsPerBase.length - 3 && aa.aminoAcid.value === '*') {
if (
!doNotExcludeAsterisk &&
index >= aminoAcidsPerBase.length - 3 &&
aa.aminoAcid.value === "*"
) {
return;
}
aaArray[aa.aminoAcidIndex] = aa.aminoAcid.value;
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@teselagen/ui",
"version": "0.3.51",
"version": "0.3.52",
"main": "./src/index.js",
"exports": {
".": {
Expand Down
9 changes: 6 additions & 3 deletions packages/ui/src/toastr.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ const generateToast = intent => (message, options) => {
updatedTimeout = ++counter;
}
}
if (window.Cypress && intent === Intent.DANGER) {
console.error("toastr error message: ", message);
if (intent === Intent.DANGER) {
console.error("Toastr error message: ", message);
}
const uniqKey = toastToUse.show(
{
intent,
message,
timeout: options.timeout || updatedTimeout,
timeout:
options.timeout || updatedTimeout || intent === Intent.DANGER
? 60000
: undefined,
action: options.action,
icon: options.icon,
className: options.className
Expand Down
2 changes: 1 addition & 1 deletion tools/scripts/publish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function invariant(condition, message) {

// Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag}
// Default "tag" to "next" so we won't publish the "latest" tag by accident.
let [, , name, version, tag = "next"] = process.argv;
let [, , name, version, tag = "latest"] = process.argv;

// Get all internal dependencies to write them to the package.json in the dist folder
execSync(`yarn nx graph --file=output.json`);
Expand Down

0 comments on commit e563297

Please sign in to comment.