Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for Sequence Customization #1516

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/components/sequencing/SequenceEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,19 @@
const sequence = viewUpdate.state.doc.toString();
disableCopyAndExport = sequence === '';
const tree = syntaxTree(viewUpdate.state);
const output = await selectedOutputFormat?.toOutputFormat?.(tree, sequence, commandDictionary, sequenceName);
let output = await selectedOutputFormat?.toOutputFormat?.(tree, sequence, commandDictionary, sequenceName);

if ($sequenceAdaptation?.modifyOutput !== undefined && output !== undefined) {
$sequenceAdaptation?.modifyOutput(output, parameterDictionaries, channelDictionary);
const modifiedOutput = $sequenceAdaptation.modifyOutput(output, parameterDictionaries, channelDictionary);
if (modifiedOutput === null) {
output = 'modifyOutput returned null. Verify your adaptation is correct';
} else if (modifiedOutput === undefined) {
output = 'modifyOutput returned undefined. Verify your adaptation is correct';
} else if (typeof modifiedOutput === 'object') {
output = JSON.stringify(modifiedOutput);
} else {
output = `${modifiedOutput}`;
}
}

editorOutputView.dispatch({ changes: { from: 0, insert: output, to: editorOutputView.state.doc.length } });
Expand Down
21 changes: 14 additions & 7 deletions src/utilities/sequence-editor/extension-points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,22 @@ export async function toInputFormat(
channelDictionary: ChannelDictionary | null,
) {
const modifyOutputParse = get(sequenceAdaptation).modifyOutputParse;
let modifiedOutput = null;

if (modifyOutputParse !== undefined) {
modifiedOutput = await modifyOutputParse(output, parameterDictionaries, channelDictionary);
}

const input = await get(inputFormat)?.toInputFormat?.(modifiedOutput ?? output);
let modifiedOutput = await modifyOutputParse(output, parameterDictionaries, channelDictionary);
if (modifiedOutput === null) {
modifiedOutput = 'modifyOutputParse returned null. Verify your adaptation is correct';
} else if (modifiedOutput === undefined) {
modifiedOutput = 'modifyOutputParse returned undefined. Verify your adaptation is correct';
} else if (typeof modifiedOutput === 'object') {
modifiedOutput = JSON.stringify(modifiedOutput);
} else {
modifiedOutput = `${modifiedOutput}`;
}

return input;
return await get(inputFormat)?.toInputFormat?.(modifiedOutput);
} else {
return await get(inputFormat)?.toInputFormat?.(output);
}
}

export function inputLinter(
Expand Down
Loading