Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 91 #92

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,23 @@ Or
Nx: run-many
publish
Execute: nx run-many --target=publish

## Other

### Running OVE unit tests

In addition to cypress e2e tests, there are a few unit tests in OVE. To run them:

- You must start the dev server, even if the tests don't load the page.
manulera marked this conversation as resolved.
Show resolved Hide resolved
- You have to be in the directory `packages/ove`

```bash
# Run the dev server (you can do this from any directory)
yarn nx run ove:start

# Move the package directory
cd packages/ove

# Run the unit test
yarn cypress run --spec cypress/e2e/unit/getStructuredBases.spec.js
```
26 changes: 17 additions & 9 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@ export default ({
runMode: 3,
openMode: 0
},
// setupNodeEvents(on, config) {
// on(
// "file:preprocessor",
// vitePreprocessor({
// // configFile: "./vite.config.js",
// configFile: path.resolve(__dirname, "./vite.config.js"),
// mode: "development"
// })
// );
// Allow logging in the Cypress test runner
// calling cy.task('log', 'message') will log the message to the console
setupNodeEvents(on, config) {
manulera marked this conversation as resolved.
Show resolved Hide resolved
on("task", {
log(message) {
console.log(message);
return null;
}
});
// on(
// "file:preprocessor",
// vitePreprocessor({
// // configFile: "./vite.config.js",
// configFile: path.resolve(__dirname, "./vite.config.js"),
// mode: "development"
// })
},

// // return require("./cypress/plugins/index.js")(on, config);
// },
Expand Down
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);
manulera marked this conversation as resolved.
Show resolved Hide resolved
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
Loading