Skip to content

Commit 7e73c3d

Browse files
committed
Move the folding eternaScript API to a better file/directory
1 parent 4ec97e6 commit 7e73c3d

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/eterna/mode/PoseEdit/ScriptsApi.ts renamed to src/eterna/eternaScript/FoldingAPI.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ import Sequence from 'eterna/rnatypes/Sequence';
66
import {ExternalInterfaceCtx} from 'eterna/util/ExternalInterface';
77
import {Assert} from 'flashbang';
88

9-
export default class FoldingContextAPI {
9+
/**
10+
* An EternaScript API exposing all functions that handle folding an arbitrary
11+
* RNA sequence, and aren't dependent on what's the RNA in the puzzle.
12+
*
13+
* It adds itself to an existing script API (`ExternalInterfaceCtx`) from
14+
* `this.registerToScriptInterface`.
15+
*
16+
* Note: The API in this class is still affected by the selected folder
17+
* and the pseudoknot mode of the puzzle - just not the sequence.
18+
*/
19+
export default class FoldingAPI {
1020
private readonly _getFolder: () => Folder | null;
1121
private readonly _getIsPseudoknot: () => boolean;
1222

@@ -34,7 +44,9 @@ export default class FoldingContextAPI {
3444
return null;
3545
}
3646
const seqArr: Sequence = Sequence.fromSequenceString(seq);
37-
const folded: SecStruct | null = this._folder.foldSequence(seqArr, null, constraint, this._isPseudoknot);
47+
const folded: SecStruct | null = this._folder.foldSequence(
48+
seqArr, null, constraint, this._isPseudoknot
49+
);
3850
Assert.assertIsDefined(folded);
3951
return folded.getParenthesis(null, this._isPseudoknot);
4052
});

src/eterna/mode/PoseEdit/PoseEditMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import {FederatedPointerEvent} from '@pixi/events';
7878
import NuPACK from 'eterna/folding/NuPACK';
7979
import PasteStructureDialog from 'eterna/ui/PasteStructureDialog';
8080
import ConfirmTargetDialog from 'eterna/ui/ConfirmTargetDialog';
81+
import FoldingContextScriptAPI from 'eterna/eternaScript/FoldingAPI';
8182
import GameMode from '../GameMode';
8283
import SubmittingDialog from './SubmittingDialog';
8384
import SubmitPoseDialog from './SubmitPoseDialog';
@@ -88,7 +89,6 @@ import ViewSolutionOverlay from '../DesignBrowser/ViewSolutionOverlay';
8889
import {PuzzleEditPoseData} from '../PuzzleEdit/PuzzleEditMode';
8990
import {DesignCategory} from '../DesignBrowser/DesignBrowserMode';
9091
import VoteProcessor from '../DesignBrowser/VoteProcessor';
91-
import FoldingContextScriptAPI from './ScriptsApi';
9292

9393
export interface PoseEditParams {
9494
isReset?: boolean;

0 commit comments

Comments
 (0)