-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Move isCorrectStereoCenter func to core * Move isStereoCanter from Struct to helpers/utils * Rename ValidateStereo tp StereoValidator
- Loading branch information
1 parent
049551b
commit 3295523
Showing
12 changed files
with
125 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './Scale' | ||
export * from './utils/StereoValidator' |
49 changes: 49 additions & 0 deletions
49
packages/ketcher-core/src/domain/helpers/utils/StereoValidator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Bond } from '../../entities/Bond' | ||
import { Struct, Neighbor } from '../../entities/Struct' | ||
|
||
function isCorrectStereoCenter( | ||
bond: Bond, | ||
beginNeighs: Array<Neighbor> | undefined, | ||
endNeighs: Array<Neighbor> | undefined, | ||
struct: Struct | ||
) { | ||
const beginAtom = struct.atoms.get(bond.begin) | ||
|
||
let EndAtomNeigh: number | undefined = NaN | ||
|
||
if (endNeighs?.length === 2) { | ||
EndAtomNeigh = | ||
endNeighs[0].aid === bond.begin ? endNeighs[1].aid : endNeighs[0].aid | ||
} | ||
|
||
if (bond.stereo > 0) { | ||
if ( | ||
endNeighs?.length === 1 && | ||
beginNeighs?.length === 2 && | ||
Number(beginAtom?.implicitH) % 2 === 0 | ||
) { | ||
return false | ||
} | ||
|
||
if ( | ||
endNeighs?.length === 2 && | ||
beginNeighs?.length === 2 && | ||
Number(beginAtom?.implicitH) % 2 === 0 && | ||
struct.atomGetNeighbors(EndAtomNeigh)?.length === 1 | ||
) { | ||
return false | ||
} | ||
|
||
if (beginNeighs?.length === 1) { | ||
return false | ||
} | ||
|
||
return true | ||
} else { | ||
return false | ||
} | ||
} | ||
|
||
export const StereoValidator = { | ||
isCorrectStereoCenter | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters