Skip to content

Commit

Permalink
fixing issue with location copy logic - TeselaGen/openVectorEditor#634
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrich committed Feb 28, 2023
1 parent af13675 commit e237c02
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/getSequenceDataBetweenRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function getSequenceDataBetweenRange(
annotationTypes.forEach(type => {
delete seqDataToUse[`filtered${startCase(type)}`];
});
let seqDataToReturn = extend(
const seqDataToReturn = extend(
{},
seqDataToUse,
{
Expand Down Expand Up @@ -120,6 +120,16 @@ function getAnnotationsBetweenRange(
}
}
}

return overlaps;
}).map(annotation => {
if (annotation.locations && annotation.locations.length) {
annotation.start = annotation.locations[0].start;
annotation.end =
annotation.locations[annotation.locations.length - 1].end;

if (annotation.locations.length === 1) delete annotation.locations;
}
return annotation;
}); //filter any fully deleted ranges
}
39 changes: 39 additions & 0 deletions src/getSequenceDataBetweenRange.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,45 @@ describe("getSequenceDataBetweenRange", function() {
]
});
});
it.only("feature with locations, non circular, non-fully enclosing range - it should trim the start/end correctly to match the location", function() {
const res = getSequenceDataBetweenRange(
{
sequence: "gggatgcatgca",
// 012345678901
// ffffff
// ll ll
// sssss
// 01234
features: [
{
start: 5,
end: 10,
locations: [
{ start: 5, end: 6 },
{ start: 9, end: 10 }
],
name: "happy"
}
]
},
{
start: 7,
end: 11
}
);

res.should.containSubset({
sequence: "atgca",
features: [
{
start: 2,
end: 3,
name: "happy",
locations: undefined
}
]
});
});
it("non circular feature, circular range", function() {
const res = getSequenceDataBetweenRange(
{
Expand Down

0 comments on commit e237c02

Please sign in to comment.