Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validate: (values, { sequenceLength }) => {
let errors = {};
if (
!isRangeWithinRange(
convertRangeTo0Based(values, sequenceLength),
{ start: 0, end: sequenceLength - 1 },
sequenceLength
)
) {
errors.start = "Range must fit within sequence";
errors.end = "Range must fit within sequence";
}
values.locations &&
values.locations.length > 1 &&
values.locations.forEach((loc, index) => {
// if (!isRangeWithinRange(loc, values, sequenceLength)) {
// errors.locations = errors.locations || {};
// errors.locations[index] = {
// start: "Range must fit within feature",
// end: "Range must fit within feature"
onClick={handleSubmit(data => {
let updatedData;
if (data.forward === true && data.strand !== 1) {
updatedData = { ...data, strand: 1 };
} else if (data.forward === false && data.strand !== -1) {
updatedData = { ...data, strand: -1 };
} else {
updatedData = data;
}
const hasJoinedLocations =
updatedData.locations && updatedData.locations.length > 1;
const newFeat = tidyUpAnnotation(
convertRangeTo0Based({
...updatedData,
locations: undefined, //by default clear locations
...(hasJoinedLocations && {
//only add locations if there are locations
start: updatedData.locations[0].start, //override the start and end to use the start and end of the joined locations
end:
updatedData.locations[updatedData.locations.length - 1]
.end,
locations: updatedData.locations.map(convertRangeTo0Based)
})
}),
{
sequenceData,
annotationType: "features"
}
);
onClick={handleSubmit(data => {
let updatedData;
if (data.forward === true && data.strand !== 1) {
updatedData = { ...data, strand: 1 };
} else if (data.forward === false && data.strand !== -1) {
updatedData = { ...data, strand: -1 };
} else {
updatedData = data;
}
upsertPrimer(convertRangeTo0Based(updatedData));
hideModal();
})}
intent={Intent.PRIMARY}
onClick={handleSubmit(data => {
let updatedData;
if (data.forward === true && data.strand !== 1) {
updatedData = { ...data, strand: 1 };
} else if (data.forward === false && data.strand !== -1) {
updatedData = { ...data, strand: -1 };
} else {
updatedData = data;
}
const hasJoinedLocations =
updatedData.locations && updatedData.locations.length > 1;
const newFeat = tidyUpAnnotation(
convertRangeTo0Based({
...updatedData,
...(annotationTypePlural === "primers" //if we're making a primer it should automatically have a type of primer
? { type: "primer" }
: {}),
locations: undefined, //by default clear locations
...(hasJoinedLocations && {
//only add locations if there are locations
start: updatedData.locations[0].start, //override the start and end to use the start and end of the joined locations
end:
updatedData.locations[updatedData.locations.length - 1]
.end,
locations: updatedData.locations.map(convertRangeTo0Based)
})
}),
{
sequenceData,
onClick={handleSubmit(data => {
let updatedData;
if (data.forward === true && data.strand !== 1) {
updatedData = { ...data, strand: 1 };
} else if (data.forward === false && data.strand !== -1) {
updatedData = { ...data, strand: -1 };
} else {
updatedData = data;
}
upsertPart(convertRangeTo0Based(updatedData));
hideModal();
})}
intent={Intent.PRIMARY}
validate: (values, { sequenceLength, sequenceData }) => {
let errors = {};
const { circular } = sequenceData || {};
if (!circular && values.start > values.end) {
errors.start = "Start must be less than End for a linear sequence";
errors.end = "Start must be less than End for a linear sequence";
}
if (
!isRangeWithinRange(
convertRangeTo0Based(values, sequenceLength),
{ start: 0, end: sequenceLength - 1 },
sequenceLength
)
) {
errors.start = "Range must fit within sequence";
errors.end = "Range must fit within sequence";
}
if (values.locations && values.locations.length > 1) {
const entireLocationSpan = {
start: values.locations[0].start,
end: values.locations[values.locations.length - 1].end
};
if (entireLocationSpan.start > entireLocationSpan.end && !circular) {
errors.locations = errors.locations || {};
errors.locations[0] = {
start:
validate: (values, { sequenceLength }) => {
let errors = {};
if (
!isRangeWithinRange(
convertRangeTo0Based(values, sequenceLength),
{ start: 0, end: sequenceLength - 1 },
sequenceLength
)
) {
errors.start = "Range must fit within sequence";
errors.end = "Range must fit within sequence";
return errors;
}
}
})
updateTempHighlight = ({ isStart, isEnd } = {}) => val => {
const { selectionLayerUpdate, from, to, invalid } = this.props;
if (invalid) return;
selectionLayerUpdate(
convertRangeTo0Based({
start: isStart ? Math.round(val) : from,
end: isEnd ? Math.round(val) : to
})
);
};
componentDidMount() {
onSubmit: values => {
const newRange = convertRangeTo0Based({
start: isProtein(props) ? values.from * 3 : values.from,
end: isProtein(props) ? values.to * 3 : values.to
});
return props.selectionLayerUpdate({
start: isProtein(props) ? newRange.start - 2 : newRange.start,
end: newRange.end
});
}
});