Skip to content

Commit

Permalink
updating primer mapping to split primers above and below the sequence…
Browse files Browse the repository at this point in the history
… instead of mapping them all to be above
  • Loading branch information
tnrich committed Jan 13, 2022
1 parent 4255073 commit ccab5ef
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
28 changes: 19 additions & 9 deletions src/mapAnnotationsToRows.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const {
module.exports = function mapAnnotationsToRows(
annotations,
sequenceLength,
bpsPerRow
bpsPerRow,
{ splitForwardReverse } = {}
) {
const annotationsToRowsMap = {};
const yOffsetLevelMap = {};
const wrappedAnnotations = {};

each(annotations, function(annotation) {
const containsLocations = !!(
annotation.locations && annotation.locations.length
Expand All @@ -31,7 +31,8 @@ module.exports = function mapAnnotationsToRows(
bpsPerRow,
annotationsToRowsMap,
yOffsetLevelMap,
containsLocations
containsLocations,
splitForwardReverse
});
wrappedAnnotations[annotation.id] = true;
// annotation.yOffset = wrappedAnnotations[annotation.id];
Expand All @@ -45,7 +46,8 @@ module.exports = function mapAnnotationsToRows(
bpsPerRow,
annotationsToRowsMap,
yOffsetLevelMap,
containsLocations
containsLocations,
splitForwardReverse
});
if (containsLocations) {
annotation.locations.forEach(location => {
Expand All @@ -56,7 +58,8 @@ module.exports = function mapAnnotationsToRows(
bpsPerRow,
annotationsToRowsMap,
yOffsetLevelMap,
location
location,
splitForwardReverse
});
});
}
Expand All @@ -78,7 +81,8 @@ function mapAnnotationToRows({
annotationsToRowsMap,
yOffsetLevelMap,
location,
containsLocations
containsLocations,
splitForwardReverse
}) {
const ranges = splitRangeIntoTwoPartsIfItIsCircular(
location || annotation,
Expand All @@ -93,13 +97,19 @@ function mapAnnotationToRows({
if (!annotationsToRowsMap[rowNumber]) {
annotationsToRowsMap[rowNumber] = [];
}
const key = splitForwardReverse
? annotation.forward
? rowNumber + "_forward"
: rowNumber + "_reverse"
: rowNumber;

const annotationsForRow = annotationsToRowsMap[rowNumber];
if (!yOffsetLevelMap[rowNumber]) {
yOffsetLevelMap[rowNumber] = [];
if (!yOffsetLevelMap[key]) {
yOffsetLevelMap[key] = [];
}

let yOffset;
const yOffsetsForRow = yOffsetLevelMap[rowNumber];
const yOffsetsForRow = yOffsetLevelMap[key];
const start =
rowNumber === startingRow ? range.start : rowNumber * bpsPerRow;
const end =
Expand Down
3 changes: 2 additions & 1 deletion src/prepareRowData.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = function prepareRowData(sequenceData, bpsPerRow) {
rowMap[type] = mapAnnotationsToRows(
sequenceData[type],
sequenceLength,
bpsPerRow
bpsPerRow,
{ splitForwardReverse: type === "primers" }
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/prepareRowData.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("prepareRowData", function() {
parts: { a: annotation1 },
cutsites: { b: annotation2 },
orfs: [annotation2],
primers: [annotation2],
primers: [annotation2, { id: "asdfa", start: 1, end: 3, forward: true }], //reverse primers shouldn't offset forward primers
warnings: [annotation2],
assemblyPieces: [annotation2],
lineageAnnotations: [annotation2]
Expand Down
15 changes: 14 additions & 1 deletion src/prepareRowData_output1.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@
"end": 4,
"yOffset": 0,
"enclosingRangeType": "end"
},
{
"id": "asdfa",
"annotation": {
"id": "asdfa",
"start": 1,
"end": 3,
"forward": true
},
"start": 1,
"end": 3,
"yOffset": 0,
"enclosingRangeType": "beginningAndEnd"
}
],
"guides": [],
Expand Down Expand Up @@ -375,4 +388,4 @@
"guides": [],
"sequence": "a"
}
]
]

0 comments on commit ccab5ef

Please sign in to comment.