Skip to content

Commit

Permalink
starts TeselaGen#91 + extra docs + allow logging in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
manulera committed Jul 15, 2024
1 parent 25d46e1 commit 023b552
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 24 deletions.
81 changes: 81 additions & 0 deletions packages/ove/cypress/e2e/unit/getStructuredBases.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { getStructuredBases } from "../../../src/RowItem/StackedAnnotations/getStructuredBases";

describe("getStructuredBases", () => {
it.skip("works for non origin-spanning case", () => {
const fullSequence = "ACGTCCACGT";
let primerSeq = "ACGT";
const start = 0;
const end = 3;
let { allBasesWithMetaData } = getStructuredBases({
annotationRange: { start, end },
forward: true,
bases: primerSeq,
start: start,
end: end,
fullSequence,
primerBindsOn: "3prime",
sequenceLength: fullSequence.length
});

let expected = [true, true, true, true];
assert.deepEqual(
allBasesWithMetaData.map(({ isMatch }) => isMatch),
expected
);

primerSeq = "CCGT";
({ allBasesWithMetaData } = getStructuredBases({
annotationRange: { start, end },
forward: true,
bases: primerSeq,
start: start,
end: end,
fullSequence,
primerBindsOn: "3prime",
sequenceLength: fullSequence.length
}));
expected = [false, true, true, true];
assert.deepEqual(
allBasesWithMetaData.map(({ isMatch }) => isMatch),
expected
);
});
it("works for origin-spanning case", () => {
const fullSequence = "ACGTCCACGT";
let primerSeq = "TACGT";
const start = 9;
const end = 3;
let { allBasesWithMetaData } = getStructuredBases({
annotationRange: { start, end },
forward: true,
bases: primerSeq,
start: start,
end: end,
fullSequence,
primerBindsOn: "3prime",
sequenceLength: fullSequence.length
});
let expected = [true, true, true, true, true];
assert.deepEqual(
allBasesWithMetaData.map(({ isMatch }) => isMatch),
expected
);
primerSeq = "AACGT";
expected = [false, true, true, true, true];
({ allBasesWithMetaData } = getStructuredBases({
annotationRange: { start, end },
forward: true,
bases: primerSeq,
start: start,
end: end,
fullSequence,
primerBindsOn: "3prime",
sequenceLength: fullSequence.length
}));
cy.task("log", allBasesWithMetaData);
assert.deepEqual(
allBasesWithMetaData.map(({ isMatch }) => isMatch),
expected
);
});
});
58 changes: 39 additions & 19 deletions packages/ove/demo/src/exampleData/exampleSequenceData.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,48 @@ export default {
}
],
primers: [
// {
// name: "Example Primer 1",
// start: 280,
// end: 300,
// type: "primer_bind",
// forward: true
// },
// {
// name: "Blue primer",
// start: 1,
// end: 20,
// type: "primer_bind",
// forward: true,
// color: "blue"
// },
// {
// name: "Red primer",
// start: 21,
// end: 30,
// type: "primer_bind",
// forward: true,
// color: "red"
// },
// {
// name: "Normal primer",
// start: 1,
// end: 4,
// type: "primer_bind",
// forward: true,
// color: "blue",
// primerBindsOn: '3prime',
// bases: "acgt"
// },
{
name: "Example Primer 1",
start: 280,
end: 300,
type: "primer_bind",
forward: true
},
{
name: "Blue primer",
start: 1,
end: 20,
type: "primer_bind",
forward: true,
color: "blue"
},
{
name: "Red primer",
start: 21,
end: 30,
name: "Origin-spanning primer",
start: 5297,
end: 4,
type: "primer_bind",
forward: true,
color: "red"
color: "red",
primerBindsOn: "3prime",
bases: "tcgacgt"
}
],
afeatures: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getComplementSequenceString } from "@teselagen/sequence-utils";
import { bioData } from "@teselagen/sequence-utils";
const { ambiguous_dna_values } = bioData;
export function getStructuredBases({
annotationRange,
// annotationRange,
forward,
bases = "",
start,
Expand All @@ -29,9 +29,8 @@ export function getStructuredBases({
}
}
const aRange = {
//tnr: this probably needs to be changed in case annotation wraps origin
start: annotationRange.start - start,
end: annotationRange.end - start
start: 0,
end: basesToUse.length
};
const r = {
aRange,
Expand Down Expand Up @@ -63,7 +62,7 @@ export function getStructuredBases({
forward ? r.basesNoInserts : r.basesNoInserts.split("").reverse().join("")
);
r.basesNoInsertsWithMetaData = basesForRange.split("").map((b, i) => {
const indexOfBase = i + annotationRange.start;
const indexOfBase = (i + start) % sequenceLength;
let seqForBase = (fullSequence && fullSequence[indexOfBase]) || "";
if (!forward) {
seqForBase = getComplementSequenceString(seqForBase);
Expand Down

0 comments on commit 023b552

Please sign in to comment.