Skip to content

Commit

Permalink
updating getSequenceDataBetweenRange to properly handle annotations t…
Browse files Browse the repository at this point in the history
…hat overlap themselves
  • Loading branch information
tnrich committed Aug 16, 2021
1 parent ebaeb43 commit d846f2d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/getSequenceDataBetweenRange.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { flatMap, extend } = require("lodash");
const { flatMap, extend, forEach } = require("lodash");
const { getRangeLength } = require("ve-range-utils");
const convertDnaCaretPositionOrRangeToAa = require("./convertDnaCaretPositionOrRangeToAA");
const insertSequenceDataAtPosition = require("./insertSequenceDataAtPosition");
Expand Down Expand Up @@ -53,14 +53,30 @@ module.exports = function getSequenceDataBetweenRange(
seqDataToUse,
range.start
);
return getSequenceDataBetweenRange(

const toRet = getSequenceDataBetweenRange(
extendedSeqData,
{
start: range.end + 1,
end: range.end
},
options
);
annotationTypes.forEach(type => {
//we need to go through and adjust any anns where overlapsSelf=true to no longer overlap themselves if they match the range completely
forEach(toRet[type], ann => {
if (
ann.overlapsSelf &&
ann.start === 0 &&
getRangeLength(ann, seqDataToUse.sequence.length) ===
getRangeLength(range, seqDataToUse.sequence.length)
) {
ann.overlapsSelf = false;
ann.end = toRet.sequence.length - 1;
}
});
});
return tidyUpSequenceData(toRet);
}
return tidyUpSequenceData(seqDataToReturn);
};
Expand Down
16 changes: 16 additions & 0 deletions src/getSequenceDataBetweenRange.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ describe("getSequenceDataBetweenRange", function() {
// ffffffff gg
sequence: "tttggggaaaccc",
// ttg
parts: [
{
start: 1,
end: 3,
name: "iOverlapMyself",
overlapsSelf: true
}
],
features: [
{
start: 0,
Expand All @@ -36,8 +44,16 @@ describe("getSequenceDataBetweenRange", function() {
overlapsSelf: true
}
);
res.parts[0].overlapsSelf.should.equal(false); //if the range perfectly overlaps the selfOverlapped annotation, the annotation should no longer be wrapping
res.should.containSubset({
sequence: "ttggggaaaccctttg",
parts: [
{
start: 0,
end: 15,
name: "iOverlapMyself"
}
],
features: [
{
start: 0,
Expand Down

0 comments on commit d846f2d

Please sign in to comment.