Skip to content

Commit

Permalink
#4495 - Macro: UI support for IDT import/export
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-asiyuk-epam committed Apr 29, 2024
1 parent 65a15fa commit 99ee2c0
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ const formatProperties: FormatPropertiesMap = {
['.fasta'],
true,
),
idt: new SupportedFormatProperties(
'IDT',
ChemicalMimeType.IDT,
['.idt'],
false,
),
sequence: new SupportedFormatProperties(
'SEQUENCE',
ChemicalMimeType.SEQUENCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export enum SupportedFormat {
sdfV3000 = 'sdfV3000',
fasta = 'fasta',
sequence = 'sequence',
idt = 'idt',
unknown = 'unknown',
}

Expand Down
9 changes: 9 additions & 0 deletions packages/ketcher-core/src/application/ketcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ export class Ketcher {
return molfile;
}

getIdt(): Promise<string> {
return getStructure(
SupportedFormat.idt,
this.#formatterFactory,
this.#editor.struct(),
CoreEditor.provideEditorInstance()?.drawingEntitiesManager,
);
}

async getRxn(molfileFormat: MolfileFormat = 'v2000'): Promise<string> {
if (window.isPolymerEditorTurnedOn) {
throw new Error('RXN format is not available in macro mode');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export enum ChemicalMimeType {
RNA = 'chemical/x-rna-sequence',
DNA = 'chemical/x-dna-sequence',
PEPTIDE = 'chemical/x-peptide-sequence',
IDT = 'chemical/x-idt',
}

export interface WithStruct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const options: Array<Option> = [
{ id: 'mol', label: 'MDL Molfile V3000' },
{ id: 'seq', label: 'Sequence' },
{ id: 'fasta', label: 'FASTA' },
{ id: 'idt', label: 'IDT' },
];

const additionalOptions: Array<Option> = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ const options: Array<Option> = [
{ id: 'mol', label: 'MDL Molfile V3000' },
{ id: 'sequence', label: 'Sequence' },
{ id: 'fasta', label: 'FASTA' },
{ id: 'idt', label: 'IDT' },
];

const formatDetector = {
mol: ChemicalMimeType.Mol,
fasta: ChemicalMimeType.FASTA,
sequence: ChemicalMimeType.SEQUENCE,
idt: ChemicalMimeType.IDT,
};

const StyledModal = styled(Modal)({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SupportedFormatProperties,
} from './supportedFormatProperties';

export type SupportedFormats = 'mol' | 'ket' | 'fasta' | 'sequence';
export type SupportedFormats = 'mol' | 'ket' | 'fasta' | 'sequence' | 'idt';

type FormatProperties = {
[key in SupportedFormats]: SupportedFormatProperties;
Expand Down Expand Up @@ -54,6 +54,13 @@ const formatProperties: FormatProperties = {
false,
{},
),
idt: new SupportedFormatProperties(
'IDT',
ChemicalMimeType.Idt,
['.idt'],
false,
{},
),
};

export const getPropertiesByFormat = (format: SupportedFormats) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum ChemicalMimeType {
Helm = 'chemical/x-helm',
Fasta = 'chemical/x-fasta',
Sequence = 'chemical/x-sequence',
Idt = 'chemical/x-idt',
}

interface SupportedFormatPropertiesOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export enum SupportedFormat {
SDF = 'sdf',
FASTA = 'fasta',
SEQUENCE = 'sequence',
IDT = 'idt',
}

export interface WithStruct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ function convertMimeTypeToOutputFormat(
format = SupportedFormat.SEQUENCE;
break;
}
case ChemicalMimeType.IDT: {
format = SupportedFormat.IDT;
break;
}
case ChemicalMimeType.UNKNOWN:
default: {
throw new Error('Unsupported chemical mime type');
Expand Down Expand Up @@ -271,6 +275,7 @@ class IndigoService implements StructService {
struct,
} = data;
const format = convertMimeTypeToOutputFormat(outputFormat);
console.log('convert format', format);

return new Promise((resolve, reject) => {
const action = ({ data }: OutputMessageWrapper) => {
Expand Down Expand Up @@ -308,6 +313,7 @@ class IndigoService implements StructService {
this.EE.removeListener(WorkerEvent.Convert, action);
this.EE.addListener(WorkerEvent.Convert, action);

console.log('convert worker.postMessage', inputMessage);
this.worker.postMessage(inputMessage);
});
}
Expand Down

0 comments on commit 99ee2c0

Please sign in to comment.