Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function toggleAnnotationDisplay({input: {type}, state, output}) {
ac.throw(ac.type, type);
var capitalizedType = capitalize({type});
// console.log(capitalizedType);
if (state.get('show' + capitalizedType)) {
state.set('show' + capitalizedType, false);
// console.log("set false");
} else {
state.set('show' + capitalizedType, true);
// console.log("set true");
}
}
export default function insertSequenceData({input, state, output}) {
var { newSequenceData } = input;
// console.log("input passed to insert is " + newSequenceData);
var { sequenceData, caretPosition } = state.get();
ac.throw(ac.posInt, caretPosition)
ac.throw(ac.sequenceData, sequenceData)
state.set('sequenceData', assign({}, sequenceData, insertSequenceDataAtPosition(newSequenceData, sequenceData, caretPosition)));
state.set('caretPosition', newSequenceData.sequence.length + caretPosition);
}
export default function insertSequenceData({input, state, output}) {
var { newSequenceData } = input;
// console.log("input passed to insert is " + newSequenceData);
var { sequenceData, caretPosition } = state.get();
ac.throw(ac.posInt, caretPosition)
ac.throw(ac.sequenceData, sequenceData)
state.set('sequenceData', assign({}, sequenceData, insertSequenceDataAtPosition(newSequenceData, sequenceData, caretPosition)));
state.set('caretPosition', newSequenceData.sequence.length + caretPosition);
}
module.exports = function getReverseComplementSequenceString (sequence) {
ac.throw([ac.string],arguments);
var reverseComplementSequenceString = "";
for (var i = sequence.length - 1; i >= 0; i--) {
var revChar = DNAComplementMap[sequence[i]];
if (!revChar) {
revChar = sequence[i];
// throw new Error('trying to get the reverse compelement of an invalid base');
}
reverseComplementSequenceString+= revChar;
}
return reverseComplementSequenceString;
};
module.exports = function getXStartAndWidthOfRowAnnotation(range, bpsPerRow, charWidth) {
ac.throw([ac.range, ac.posInt, ac.number], arguments);
// 24 bps long:
//
// if (range.end + 1 - range.start > 0 && )
// (range.end + 1 - range.start) % bpsPerRow
return {
xStart: (range.start % bpsPerRow) * charWidth,
width: ((range.end + 1 - range.start)) * charWidth,
};
};
module.exports = function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions) {
//isInBetweenPositions refers to:
// A T G C
// 0 1 2 3 <-- isInBetweenPositions = false is counting the positions themselves
//0 1 2 3 4 <-- isInBetweenPositions = true is counting the spaces between positions
ac.throw([ac.number, ac.posInt, ac.bool], arguments);
var position = pPosition;
if (position < 0) {
position += sequenceLength;
} else if (position + (isInBetweenPositions ? 0 : 1) > sequenceLength) {
position -= sequenceLength;
}
return position;
};
module.exports = function getComplementSequenceString (sequence) {
ac.throw([ac.string],arguments);
var complementSeqString = "";
for (var i = 0; i < sequence.length; i++) {
var complementChar = DNAComplementMap[sequence[i]];
if (!complementChar) {
complementChar = sequence[i];
// throw new Error('trying to get the reverse compelement of an invalid base');
}
complementSeqString+= complementChar;
}
return complementSeqString;
};
module.exports = function mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow) {
ac.throw(ac.arrayOf(ac.shape({
start: ac.posInt,
end: ac.posInt,
// id: ac.oneOfType([ac.object, ac.string])
})), annotations);
ac.throw(ac.posInt, sequenceLength);
ac.throw(ac.posInt, bpsPerRow);
var annotationsToRowsMap = {};
var yOffsetLevelMap = {};
each(annotations, function(annotation) {
mapAnnotationToRows(annotation, sequenceLength, bpsPerRow, annotationsToRowsMap, yOffsetLevelMap);
});
return annotationsToRowsMap;
};
export default function addAnnotations({input: {annotationType, annotationsToInsert, throwErrors}, state, output}) {
ac.throw(ac.annotationType, annotationType);
ac.throw(ac.arrayOf(ac.range), annotationsToInsert);
ac.throw(ac.bool.optional, throwErrors);
annotationsToInsert.forEach(function(annotationToInsert) {
if (!isBoolean(annotationToInsert.forward)) {
if (throwErrors) {
throw new Error('annotation direction not specified')
} else {
console.log('annotation direction not specified')
annotationToInsert.forward = true;
}
}
if (!areNonNegativeIntegers([annotationToInsert.start])) {
if (throwErrors) {
throw new Error('annotation position not specified')
} else {
export default function updateSelShiftHeldAndPreviousSel({updatedCaretPos, sequenceLength, selectionLayer}, tree, output) {
ac.throw(ac.object, selectionLayer);
ac.throw(ac.number.optional, updatedCaretPos);
ac.throw(ac.number.optional, sequenceLength);
var oldCaretPos = getCaretFromSelection(selectionLayer);
function getCaretFromSelection (selectionLayer) {
if (selectionLayer.cursorAtEnd) {
return selectionLayer.end + 1;
} else {
return selectionLayer.start;
}
}
var newSelectionLayer = assign({}, selectionLayer);
if (newSelectionLayer.cursorAtEnd) {
newSelectionLayer.end = updatedCaretPos - 1;
newSelectionLayer.end = trimNumberToFitWithin0ToAnotherNumber(newSelectionLayer.end, sequenceLength - 1);
if (newSelectionLayer.end + 1 === selectionLayer.start && updatedCaretPos < oldCaretPos) {
newSelectionLayer = false;