Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function prepareCircularViewData(sequenceData) {
var clonedSeqData = cloneDeep(sequenceData)
annotationTypes.forEach(function(annotationType){
if (annotationType !== 'cutsites') {
var {maxYOffset} = getYOffsetsForPotentiallyCircularRanges(clonedSeqData[annotationType]);
clonedSeqData[annotationType].maxYOffset = maxYOffset;
}
});
return clonedSeqData;
}
var totalRows = Math.ceil(sequenceLength / bpsPerRow) || 1; //this check makes sure there is always at least 1 row!
var rows = [];
var rowMap = {};
annotationTypes.forEach(function (type) {
rowMap[type] = mapAnnotationsToRows(sequenceData[type], sequenceLength, bpsPerRow)
})
for (var rowNumber = 0; rowNumber < totalRows; rowNumber++) {
var row = {};
row.rowNumber = rowNumber;
row.start = rowNumber * bpsPerRow;
row.end = (rowNumber + 1) * (bpsPerRow) - 1 < sequenceLength ? (rowNumber + 1) * (bpsPerRow) - 1 : sequenceLength - 1;
if (row.end < 0) {
row.end = 0
}
annotationTypes.forEach(function (type) {
row[type] = rowMap[type][rowNumber] || []
})
row.sequence = sequenceData.sequence.slice(row.start, (row.end + 1));
rows[rowNumber] = row;
}
return rows;
}