Skip to content

Commit

Permalink
fixing computeDigestFragments for linear seqs w no cutsites
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrich committed Sep 13, 2022
1 parent e4b2663 commit 53f5c76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/computeDigestFragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function computeDigestFragments({
const sortedCutsites = cutsites.sort((a, b) => {
return a.topSnipPosition - b.topSnipPosition;
});
if (!circular) {
if (!circular && cutsites.length) {
sortedCutsites.push({
id: "seqTerm_" + bsonObjectId().str,
start: 0,
Expand Down
18 changes: 17 additions & 1 deletion src/computeDigestFragments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
const aliasedEnzymesByName = require("./aliasedEnzymesByName");

describe("computeDigestFragments", function() {
it.only("it should correctly generate fragments for bamhi cutting once in a circular sequence", function() {
it("it should correctly generate fragments for bamhi cutting once in a circular sequence", function() {
const result = getDigestFragsForSeqAndEnzymes({
sequence: "ggggatccggggggggggggggggggggggggggggggggggggggggg",
circular: true,
Expand Down Expand Up @@ -41,4 +41,20 @@ describe("computeDigestFragments", function() {
expect(result.fragments[1].size).toEqual(3);
expect(result.fragments[1].madeFromOneCutsite).toEqual(false);
});
it("it should not generate any fragments for bamhi if it doesn't cut in a linear sequence", function() {
const result = getDigestFragsForSeqAndEnzymes({
sequence: "ggggggggggggggggggggggggggggggggggggggggggggg",
circular: false,
enzymes: [aliasedEnzymesByName.bamhi]
});
expect(result.fragments).toHaveLength(0);
});
it("it should not generate any fragments for bamhi if it doesn't cut in a circular sequence", function() {
const result = getDigestFragsForSeqAndEnzymes({
sequence: "ggggggggggggggggggggggggggggggggggggggggggggg",
circular: true,
enzymes: [aliasedEnzymesByName.bamhi]
});
expect(result.fragments).toHaveLength(0);
});
});

0 comments on commit 53f5c76

Please sign in to comment.