Skip to content

Commit

Permalink
#4607 - Bugfix (monomers.ts): Correct isValidNucleoside(1), `isVali…
Browse files Browse the repository at this point in the history
…dNucleotide(1)`
  • Loading branch information
DmitriiP-EPAM committed Jun 5, 2024
1 parent 6b0221d commit c656774
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions packages/ketcher-core/src/domain/helpers/monomers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,38 @@ export function isMonomerBeginningOfChain(
);
}

export function isValidNucleotide(sugar: Sugar) {
export function isValidNucleotide(sugar: Sugar): boolean {
if (!getRnaBaseFromSugar(sugar)) {
return false;
}

const phosphate = getPhosphateFromSugar(sugar);
if (!phosphate) {
return false;
}

const nextMonomerAfterPhosphate = getNextMonomerInChain(phosphate);
if (!(nextMonomerAfterPhosphate instanceof Sugar)) {
return false;
}

return Boolean(
getRnaBaseFromSugar(sugar) &&
getPhosphateFromSugar(sugar) &&
nextMonomerAfterPhosphate,
);
return !!getRnaBaseFromSugar(nextMonomerAfterPhosphate);
}

export function isValidNucleoside(sugar: Sugar) {
export function isValidNucleoside(sugar: Sugar): boolean {
if (!getRnaBaseFromSugar(sugar)) {
return false;
}

const phosphate = getPhosphateFromSugar(sugar);
if (!phosphate) {
return true;
}

const nextMonomerAfterPhosphate = getNextMonomerInChain(phosphate);
if (!(nextMonomerAfterPhosphate instanceof Sugar)) {
return true;
}

return (
getRnaBaseFromSugar(sugar) && (!phosphate || !nextMonomerAfterPhosphate)
);
return !getRnaBaseFromSugar(nextMonomerAfterPhosphate);
}

0 comments on commit c656774

Please sign in to comment.