Skip to content

Commit

Permalink
Move the folding eternaScript API to a better file/directory
Browse files Browse the repository at this point in the history
  • Loading branch information
guyguy2001 committed Jun 10, 2024
1 parent 4ec97e6 commit 7e73c3d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ import Sequence from 'eterna/rnatypes/Sequence';
import {ExternalInterfaceCtx} from 'eterna/util/ExternalInterface';
import {Assert} from 'flashbang';

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

Expand Down Expand Up @@ -34,7 +44,9 @@ export default class FoldingContextAPI {
return null;
}
const seqArr: Sequence = Sequence.fromSequenceString(seq);
const folded: SecStruct | null = this._folder.foldSequence(seqArr, null, constraint, this._isPseudoknot);
const folded: SecStruct | null = this._folder.foldSequence(
seqArr, null, constraint, this._isPseudoknot
);
Assert.assertIsDefined(folded);
return folded.getParenthesis(null, this._isPseudoknot);
});
Expand Down
2 changes: 1 addition & 1 deletion src/eterna/mode/PoseEdit/PoseEditMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import {FederatedPointerEvent} from '@pixi/events';
import NuPACK from 'eterna/folding/NuPACK';
import PasteStructureDialog from 'eterna/ui/PasteStructureDialog';
import ConfirmTargetDialog from 'eterna/ui/ConfirmTargetDialog';
import FoldingContextScriptAPI from 'eterna/eternaScript/FoldingAPI';
import GameMode from '../GameMode';
import SubmittingDialog from './SubmittingDialog';
import SubmitPoseDialog from './SubmitPoseDialog';
Expand All @@ -88,7 +89,6 @@ import ViewSolutionOverlay from '../DesignBrowser/ViewSolutionOverlay';
import {PuzzleEditPoseData} from '../PuzzleEdit/PuzzleEditMode';
import {DesignCategory} from '../DesignBrowser/DesignBrowserMode';
import VoteProcessor from '../DesignBrowser/VoteProcessor';
import FoldingContextScriptAPI from './ScriptsApi';

export interface PoseEditParams {
isReset?: boolean;
Expand Down

0 comments on commit 7e73c3d

Please sign in to comment.