diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts index 6706caa174..23c7c0f565 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import { test, expect } from '@playwright/test'; +import { test, expect, Page } from '@playwright/test'; import { TopPanelButton, openFileAndAddToCanvasMacro, @@ -18,6 +18,11 @@ import { moveMouseAway, openFileAndAddToCanvasAsNewProjectMacro, TypeDropdownOptions, + pasteFromClipboardAndAddToMacromoleculesCanvas, + SequenceType, + PeptideType, + MacroFileType, + selectSaveTool, } from '@utils'; import { closeErrorMessage, pageReload } from '@utils/common/helpers'; import { @@ -679,3 +684,702 @@ test.describe('Import correct Sequence file: ', () => { }); } }); + +interface ISequenceString { + testCaseDescription: string; + sequenceDescription: string; + sequenceString: string; + sequenceType: + | Exclude + | [SequenceType.PEPTIDE, PeptideType]; + HELMString?: string; + // Set shouldFail to true if you expect test to fail because of existed bug and put issues link to issueNumber + shouldFail?: boolean; + // issueNumber is mandatory if shouldFail === true + issueNumber?: string; + // set pageReloadNeeded to true if you need to restart ketcher before test (f.ex. to restart font renderer) + pageReloadNeeded?: boolean; + // Some times export result is different to import string + differentSequenceExport?: string; +} + +const correctSequences: ISequenceString[] = [ + { + testCaseDescription: + '1. Verify import with valid three-letter codes in the sequence', + sequenceDescription: 'Three letters peptide codes - part 1', + sequenceString: 'AlaAsxCysAspGluPheGlyHisIle', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, + { + testCaseDescription: + '1. Verify import with valid three-letter codes in the sequence', + sequenceDescription: 'Three letters peptide codes - part 2', + sequenceString: 'XleLysLeuMetAsnPylProGlnArg', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, + { + testCaseDescription: + '1. Verify import with valid three-letter codes in the sequence', + sequenceDescription: 'Three letters peptide codes - part 3', + sequenceString: 'SerThrSecValTrpXaaTyrGlx', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, + { + testCaseDescription: + '2. Verify that spaces separate different amino acid sequences in import', + sequenceDescription: 'e.g. AlaAla CysCys (1)', + sequenceString: + 'AlaAsx CysAspGlu PheGlyHisIle XleLysLeuMetAsn PylProGlnArgSerThr SecValTrpXaaTyrGlx', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, + { + testCaseDescription: '3. Verify ignoring of line breaks during import', + sequenceDescription: 'e.g. AlaGly\nCys (2)', + sequenceString: + 'Ala\nAsx\n\n Cys\n\n\nAsp\n\n\n\nGlu\n Phe\nGly\nHis\nIle \n\nXle\nLys\nLeu\nMet\nAsn Pyl\nPro\nGln\nArg\nSer\nThr\n SecValTrpXaaTyrGlx', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, +]; + +for (const correctSequence of correctSequences) { + test(`${correctSequence.testCaseDescription} (with ${correctSequence.sequenceDescription})`, async ({ + page, + }) => { + /* + * Description: Verify import of Sequence files works correct + * Case: 1. Load Sequence file + * 2. Take screenshot to make sure import works correct + */ + if (correctSequence.pageReloadNeeded) { + await pageReload(page); + } + // Test should be skipped if related bug exists + test.fixme( + correctSequence.shouldFail === true, + `That test fails because of ${correctSequence.issueNumber} issue.`, + ); + + await pasteFromClipboardAndAddToMacromoleculesCanvas( + page, + [MacroFileType.Sequence, correctSequence.sequenceType], + correctSequence.sequenceString, + ); + await zoomWithMouseWheel(page, -200); + await takeEditorScreenshot(page); + }); +} + +const incorrectSequences: ISequenceString[] = [ + { + testCaseDescription: + '4. Verify error message for unsupported symbols in import', + sequenceDescription: 'Ala| (1)', + sequenceString: 'Ala|', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, + { + testCaseDescription: + '4. Verify error message for unsupported symbols in import', + sequenceDescription: 'ala (2)', + sequenceString: 'ala', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, + { + testCaseDescription: + '4. Verify error message for unsupported symbols in import', + sequenceDescription: 'alA (3)', + sequenceString: 'alA', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, + { + testCaseDescription: + '4. Verify error message for unsupported symbols in import', + sequenceDescription: 'aLa (4)', + sequenceString: 'aLa', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, + { + testCaseDescription: + '4. Verify error message for unsupported symbols in import', + sequenceDescription: 'ALA (5)', + sequenceString: 'ALA', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, + { + testCaseDescription: '5. Verify error for incorrect formatting in import', + sequenceDescription: 'uppercase/lowercase mix - CysALAAsx', + sequenceString: 'CysALAAsx', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, + { + testCaseDescription: + '6. Verify error when a three-letter sequence cannot be matched to amino acids', + sequenceDescription: 'Alx', + sequenceString: 'Alx', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + }, +]; + +for (const incorrectSequence of incorrectSequences) { + test(`${incorrectSequence.testCaseDescription} (with ${incorrectSequence.sequenceDescription})`, async ({ + page, + }) => { + /* + * Description: Verify import of Sequence files works correct + * Case: 1. Load Sequence file + * 2. Take screenshot to make sure error message is correct + */ + if (incorrectSequence.pageReloadNeeded) { + await pageReload(page); + } + // Test should be skipped if related bug exists + test.fixme( + incorrectSequence.shouldFail === true, + `That test fails because of ${incorrectSequence.issueNumber} issue.`, + ); + + await pasteFromClipboardAndAddToMacromoleculesCanvas( + page, + [MacroFileType.Sequence, incorrectSequence.sequenceType], + incorrectSequence.sequenceString, + true, + ); + + await takeEditorScreenshot(page); + + await closeErrorMessage(page); + }); +} + +test(`7. Verify export option includes both single-letter and three-letter sequence codes)`, async ({ + page, +}) => { + /* + * Description: Verify export option includes both single-letter and three-letter sequence codes + * Case: 1. Open Save structure dialog + * 2. Verify File format list contains single-letter and three-letter Sequence options + */ + await selectSaveTool(page); + + // Click on "File format" dropdown + await page.getByRole('combobox').click(); + const dropdown = page.locator('ul[role="listbox"]'); + const singleLetter = dropdown.locator('li', { + hasText: 'Sequence (1-letter code)', + }); + const threeLetter = dropdown.locator('li', { + hasText: 'Sequence (3-letter code)', + }); + + await expect(singleLetter).toBeVisible(); + await expect(threeLetter).toBeVisible(); +}); + +const sequencesToExport: ISequenceString[] = [ + { + testCaseDescription: + '8. Verify export functionality for sequences using three-letter codes only', + sequenceDescription: 'Three letters peptide codes - part 1', + sequenceString: 'AlaAsxCysAspGluPheGlyHisIle', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: + '8. Verify export functionality for sequences using three-letter codes only', + sequenceDescription: 'Three letters peptide codes - part 2', + sequenceString: 'XleLysLeuMetAsnPylProGlnArg', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: + '8. Verify export functionality for sequences using three-letter codes only', + sequenceDescription: 'Three letters peptide codes - part 3', + sequenceString: 'SerThrSecValTrpXaaTyrGlx', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, +]; + +async function openSaveToSequenceDialog(page: Page, seqeunceType: PeptideType) { + await selectSaveTool(page); + await chooseFileFormat(page, `Sequence (${seqeunceType})`); +} + +for (const sequenceToExport of sequencesToExport) { + test(`${sequenceToExport.testCaseDescription} with ${sequenceToExport.sequenceDescription}`, async ({ + page, + }) => { + /* + Test case: https://github.com/epam/ketcher/issues/5215 + Description: Load correct 3-letter sequences, open Save dialog and compare export result with the template + Case: + 1. Load correct sequence via paste from clipboard way + 2. Export canvas to 3-letter sequence + 2. Compare export result with source sequence string + */ + test.setTimeout(35000); + // Test should be skipped if related bug exists + test.fixme( + sequenceToExport.shouldFail === true, + `That test fails because of ${sequenceToExport.issueNumber} issue.`, + ); + if (sequenceToExport.pageReloadNeeded) await pageReload(page); + + await pasteFromClipboardAndAddToMacromoleculesCanvas( + page, + [MacroFileType.Sequence, sequenceToExport.sequenceType], + sequenceToExport.sequenceString, + ); + + await openSaveToSequenceDialog(page, PeptideType.threeLetterCode); + const sequenceExportResult = await page + .getByTestId('preview-area-text') + .textContent(); + + if (sequenceToExport.differentSequenceExport) { + expect(sequenceExportResult).toEqual( + sequenceToExport.differentSequenceExport, + ); + } else { + expect(sequenceExportResult).toEqual(sequenceToExport.sequenceString); + } + + await pressButton(page, 'Cancel'); + }); +} + +const nonStandardAmbiguousPeptides: ISequenceString[] = [ + { + testCaseDescription: + '9. Verify export with non-standard ambiguous amino acids', + sequenceDescription: 'ambiguous peptide mixture of A, C, D', + HELMString: 'PEPTIDE1{(A+C+D)}$$$$V2.0', + sequenceString: + 'not applicable - export of anmbiguous petide to sequence is impossible', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: + '9. Verify export with non-standard ambiguous amino acids', + sequenceDescription: 'ambiguous peptide alternative of A, C, D', + HELMString: 'PEPTIDE1{(A,C,D)}$$$$V2.0', + sequenceString: + 'not applicable - export of anmbiguous petide to sequence is impossible', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: + '10. Verify that non pure peptide sequences are prevented from exporting', + sequenceDescription: 'peptide (A) and sugar (R)', + HELMString: 'PEPTIDE1{A}|RNA1{R}$PEPTIDE1,RNA1,1:R2-1:R1$$$V2.0', + sequenceString: + 'not applicable - export on pure peptide sequences to sequence is impossible', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: + '10. Verify that non pure peptide sequences are prevented from exporting', + sequenceDescription: 'peptide (A) and phopsphate (P)', + HELMString: 'PEPTIDE1{A}|RNA1{P}$PEPTIDE1,RNA1,1:R2-1:R1$$$V2.0', + sequenceString: + 'not applicable - export on pure peptide sequences to sequence is impossible', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: + '10. Verify that non pure peptide sequences are prevented from exporting', + sequenceDescription: 'peptide (A) and unsplit nucleotide (2-damdA)', + HELMString: 'PEPTIDE1{A}|RNA1{[2-damdA]}$PEPTIDE1,RNA1,1:R2-1:R1$$$V2.0', + sequenceString: + 'not applicable - export on pure peptide sequences to sequence is impossible', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: + '10. Verify that non pure peptide sequences are prevented from exporting', + sequenceDescription: 'peptide (A) and CHEM(4aPEGMal)', + HELMString: 'PEPTIDE1{A}|CHEM1{[4aPEGMal]}$PEPTIDE1,CHEM1,1:R2-1:R1$$$V2.0', + sequenceString: + 'not applicable - export on pure peptide sequences to sequence is impossible', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, +]; + +for (const sequenceToExport of nonStandardAmbiguousPeptides) { + test(`${sequenceToExport.testCaseDescription} with ${sequenceToExport.sequenceDescription}`, async ({ + page, + }) => { + /* + * Test case: https://github.com/epam/ketcher/issues/5215 + * Description: Verify export with non-standard ambiguous amino acids(error should appear) + * Case: + * 1. Load correct HELM via paste from clipboard way + * 2. Export canvas to 3-letter sequence + * 2. Take a screenshot to ensure error message + * For ambigous monomer: "Non-standard ambiguous amino acids cannot be exported to the selected format" + * For non pure peptide chains: "Convert error! Error during sequence type recognition(RNA, DNA or Peptide)" + */ + test.setTimeout(35000); + // Test should be skipped if related bug exists + test.fixme( + sequenceToExport.shouldFail === true, + `That test fails because of ${sequenceToExport.issueNumber} issue.`, + ); + if (sequenceToExport.pageReloadNeeded) await pageReload(page); + + if (sequenceToExport.HELMString) { + await pasteFromClipboardAndAddToMacromoleculesCanvas( + page, + MacroFileType.HELM, + sequenceToExport.HELMString, + ); + } + + await openSaveToSequenceDialog(page, PeptideType.threeLetterCode); + + await takeEditorScreenshot(page); + await closeErrorMessage(page); + }); +} + +const nonNaturalPeptideSequences: ISequenceString[] = [ + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog A', + HELMString: + 'PEPTIDE1{A.[1Nal].[2Nal].[3Pal].[4Pal].[Abu].[Ala-al]}|PEPTIDE2{[D-2Pal].[D-2Nal].[D-1Nal].[Cya].[Cha].[bAla].[Ala-ol]}|PEPTIDE3' + + '{[D-OAla].[D-2Thi].[D-3Pal].[D-Abu].[D-Cha]}|PEPTIDE4{[DAlaol].[dA]}|PEPTIDE5{[L-OAla].[Dha]}|PEPTIDE6{[meA].[NMebAl].[Thi].[Tza]}$$$$V2.0', + sequenceString: + 'AlaAlaAlaAlaAlaAlaAla AlaAlaAlaAlaAlaAlaAla AlaAlaAlaAlaAla AlaAla AlaAla AlaAlaAlaAla ', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog C', + HELMString: + 'PEPTIDE1{C.[Cys_Bn].[Cys_Me]}|PEPTIDE2{[DACys].[dC].[Edc].[Hcy].[meC]}$$$$V2.0', + sequenceString: 'CysCysCys CysCysCysCysCys', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog D', + HELMString: 'PEPTIDE1{D.[AspOMe].[D*].[dD].[dD]}$$$$V2.0', + sequenceString: 'AspAspAspAspAsp', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog E', + HELMString: 'PEPTIDE1{E.[D-gGlu].[dE].[gGlu].[Gla].[meE]}$$$$V2.0', + sequenceString: 'GluGluGluGluGluGlu', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog F', + HELMString: + 'PEPTIDE1{F.[aMePhe].[Bip].[Bpa].[D-hPhe]}|PEPTIDE2{[DAhPhe].[dF].[DPhe4C].[DPhe4F].[DPhe4u].[hPhe].' + + '[meF]}|PEPTIDE3{[DAPhg3].[Phe_2F].[Phe_3F].[Phe_4F].[Phe_4I].[Phe-al]}|PEPTIDE4{[Phe2Me].[Phe34d].' + + '[Phe3Cl].[Phe4Br].[Phe4Cl].[Phe-ol]}|PEPTIDE5{[Phe4Me].[Phe4NH].[Phe4NO].[Phe4SD].[PheaDH].[Phebbd].' + + '[PheNO2]}|PEPTIDE6{[PhLA]}$$$$V2.0', + sequenceString: + 'PhePhePhePhePhe PhePhePhePhePhePhePhe PhePhePhePhePhePhe PhePhePhePhePhePhe PhePhePhePhePhePhePhe Phe', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog G', + HELMString: + 'PEPTIDE1{G.[Chg].[D-Chg].[D-Phg].[D-Pyr]}|PEPTIDE2{[DAGlyB].[DAGlyO]}|PEPTIDE3{[DAGlyC].[Gly-al]}' + + '|PEPTIDE4{[DAGlyP].[DPhgol]}|PEPTIDE5{[DAGlyT].[Gly-ol]}|PEPTIDE6{[DAPhg4].[Glyall].[GlycPr].[meG].' + + '[Phg].[Phg-ol]}|PEPTIDE7{[Pyr]}$$$$V2.0', + sequenceString: + 'GlyGlyGlyGlyGly GlyGly GlyGly GlyGly GlyGlyGlyGlyGlyGly GlyGly Gly', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog H', + HELMString: + 'PEPTIDE1{H.[dH].[DHis1B].[Hhs].[His1Bn].[His1Me].[His3Me].[meH]}$$$$V2.0', + sequenceString: 'HisHisHisHisHisHisHisHis', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog I', + HELMString: + 'PEPTIDE1{I.[aIle].[D-aIle].[dI].[DxiIle].[meI].[xiIle]}$$$$V2.0', + sequenceString: 'IleIleIleIleIleIleIle', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog K', + HELMString: + 'PEPTIDE1{K.[Aad].[D-Orn].[DALys].[dK].[Dpm].[Hyl5xi].[Lys_Ac].[Lys-al]}|PEPTIDE2{[LysBoc].[LysiPr].[LysMe3].[meK].[Orn].[Lys-ol]}$$$$V2.0', + sequenceString: 'LysLysLysLysLysLysLysLysLys LysLysLysLysLysLys', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog L', + HELMString: + 'PEPTIDE1{L.[Ar5c].[D-Nle]}|PEPTIDE2{[DALeu].[dL].[Leu-al]}|PEPTIDE3{[OLeu].[Leu-ol]}|PEPTIDE4{[meL].[Nle].[tLeu]}$$$$V2.0', + sequenceString: 'LeuLeuLeu LeuLeuLeu LeuLeuLeu Leu', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog M', + HELMString: 'PEPTIDE1{M.[dM].[DMetSO].[meM].[Met_O].[Met_O2]}$$$$V2.0', + sequenceString: 'MetMetMetMetMetMet', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog N', + HELMString: 'PEPTIDE1{N.[Asp-al]}|PEPTIDE2{[dN].[meN]}$$$$V2.0', + sequenceString: 'AsnAsn AsnAsn', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog O', + HELMString: 'PEPTIDE1{O.[dO].[meO]}$$$$V2.0', + sequenceString: 'PylPylPyl', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog P', + HELMString: + 'PEPTIDE1{P.[aHyp].[aMePro].[Aze].[D-aHyp].[D-Hyp].[D-Thz].[dP].[DProol]}|PEPTIDE2{[meP].[Hyp]}' + + '|PEPTIDE3{[Mhp].[Pro-al]}|PEPTIDE4{[Thz].[xiHyp].[Pro-ol]}$$$$V2.0', + sequenceString: 'ProProProProProProProProPro ProPro ProPro ProProPro', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog Q', + HELMString: 'PEPTIDE1{Q.[dQ].[meQ]}$$$$V2.0', + sequenceString: 'GlnGlnGln', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog R', + HELMString: + 'PEPTIDE1{R.[Arg-al]}|PEPTIDE2{[Cit].[D-Cit].[D-hArg].[DhArgE].[dR].[Har].[hArg].[LhArgE].[meR]}$$$$V2.0', + sequenceString: 'ArgArg ArgArgArgArgArgArgArgArgArg', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog S', + HELMString: + 'PEPTIDE1{S.[D-Dap].[Dap].[dS].[DSerBn].[DSertB].[Hse].[meS].[Ser_Bn].[SerPO3].[SertBu]}$$$$V2.0', + sequenceString: 'SerSerSerSerSerSerSerSerSerSerSer', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog T', + HELMString: + 'PEPTIDE1{T.[aThr].[D-aThr].[dT].[dThrol]}|PEPTIDE2{[meT].[Thr-ol]}|PEPTIDE3{[ThrPO3].[xiThr]}$$$$V2.0', + sequenceString: 'ThrThrThrThrThr ThrThr ThrThr', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog U', + HELMString: 'PEPTIDE1{U.[dU].[meU]}$$$$V2.0', + sequenceString: 'SecSecSec', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog V', + HELMString: + 'PEPTIDE1{V.[D-Nva].[D-Pen].[DaMeAb].[dV].[Iva]}|PEPTIDE2{[D-OVal].[meV].[Nva].[Pen]}|PEPTIDE3{[L-OVal].[Val-ol]}|PEPTIDE4{[Val3OH]}$$$$V2.0', + sequenceString: 'ValValValValValVal ValValValVal ValVal Val', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog W', + HELMString: + 'PEPTIDE1{W.[DTrp2M].[DTrpFo].[dW].[Kyn].[meW].[Trp_Me].[Trp5OH].[TrpOme]}$$$$V2.0', + sequenceString: 'TrpTrpTrpTrpTrpTrpTrpTrpTrp', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with no natulal analog - X', + HELMString: + 'PEPTIDE1{[Am-]}|PEPTIDE2{[Bn-].[Aoda].[-Bn]}|PEPTIDE3{[Boc-].[Apm].[-Et]}|PEPTIDE4{[Bua-].[App].[-Me]}|' + + 'PEPTIDE5{[Et-].[Aib].[-NHBn]}|PEPTIDE6{[Ac6c].[D-Tic].[-NMe]}|PEPTIDE7{[Cbz-].[Ac3c].[-OBn]}|' + + 'PEPTIDE8{[Abu23D].[D-Pip].[-OEt]}|PEPTIDE9{[DANcy].[4Abz].[-OMe]}|PEPTIDE10{[Ac-].[2Abz].[-OtBu]}|' + + 'PEPTIDE11{[Mba].[3Abz].[-Ph]}|PEPTIDE12{[Aca].[Sta3xi].[-NHEt]}|PEPTIDE13{[Me-].[Bux].[Aib-ol]}|' + + 'PEPTIDE14{[Bz-].[Cap].[D-Bmt]}|PEPTIDE15{[DAChg].[D-Dip].[Dab]}|PEPTIDE16{[DADip].[Bmt].[DADab]}|' + + 'PEPTIDE17{[Glc].[Azi].[Dip]}|PEPTIDE18{[fmoc-].[D-Dab].[Dsu]}|PEPTIDE19{[Hva].[Asu].[Oxa]}|' + + 'PEPTIDE20{[Mpa].[Pqa].[Pyrro]}|PEPTIDE21{[MsO-].[Wil].[Hsl]}|PEPTIDE22{[NHBn-].[pnA].[pnC]}|' + + 'PEPTIDE23{[NMe23A].[Oic3aR].[Oic3aS]}|PEPTIDE24{[NMe24A].[NMe2Ab].[NMe4Ab]}|PEPTIDE25{[OBn-].[pnT].[pnG]}|' + + 'PEPTIDE26{[OMe-].[Oic].[Pip]}|PEPTIDE27{[Tos-].[Tic].[Sta]}$$$$V2.0', + sequenceString: + 'Xun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun ' + + 'XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun ' + + 'XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun XunXunXun', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '11. Verify natural analogue conversion on export', + sequenceDescription: 'All peptides with natulal analog Y', + HELMString: + 'PEPTIDE1{Y.[aMeTy3].[aMeTyr].[D-nTyr]}|PEPTIDE2{[DAnTyr].[DTyr3O]}|PEPTIDE3{[DTyrEt].[DTyrMe].[dY].[meY]' + + '.[nTyr].[Tyr_3I].[Tyr_Bn].[Tyr_Me]}|PEPTIDE4{[Tyr26d].[Tyr35d].[Tyr3NO].[Tyr3OH].[TyrabD].[TyrPh4].[TyrPO3].[TyrSO3].[TyrtBu]}$$$$V2.0', + sequenceString: + 'TyrTyrTyrTyr TyrTyr TyrTyrTyrTyrTyrTyrTyrTyr TyrTyrTyrTyrTyrTyrTyrTyrTyr', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: + '12. Verify specific export format for "Any amino acid"', + sequenceDescription: '(X) as "Xun', + HELMString: + 'PEPTIDE1{(A,C,D,E,F,G,H,I,K,L,M,N,O,P,Q,R,S,T,U,V,W,Y)}$$$$V2.0', + sequenceString: 'Xun', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: '13. Verify export format for ambiguous amino acids', + sequenceDescription: 'B, J, Z', + HELMString: 'PEPTIDE1{(D,N).(L,I).(E,Q)}$$$$V2.0', + sequenceString: 'AsxXleGlx', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, + { + testCaseDescription: + '14. Verify that multiple sequences are separated by space in exported file', + sequenceDescription: '6 chains from 1 to 6 length', + HELMString: + 'PEPTIDE1{A}|PEPTIDE2{C.D}|PEPTIDE3{E.F.G}|PEPTIDE4{H.I.K.L}|PEPTIDE5{M.N.O.P.Q}|PEPTIDE6{R.S.T.U.V.W}$$$$V2.0', + sequenceString: + 'Ala CysAsp GluPheGly HisIleLysLeu MetAsnPylProGln ArgSerThrSecValTrp', + sequenceType: [SequenceType.PEPTIDE, PeptideType.threeLetterCode], + shouldFail: true, + issueNumber: 'https://github.com/epam/ketcher/issues/5972', + }, +]; + +for (const sequenceToExport of nonNaturalPeptideSequences) { + test(`${sequenceToExport.testCaseDescription} with ${sequenceToExport.sequenceDescription}`, async ({ + page, + }) => { + /* + * Test case: https://github.com/epam/ketcher/issues/5215 + * Description: Load correct 3-letter sequences, open Save dialog and compare export result with the template + * Case: + * 1. Load correct sequence via paste from clipboard way + * 2. Export canvas to 3-letter sequence + * 2. Compare export result with source sequence string + */ + test.setTimeout(35000); + // Test should be skipped if related bug exists + test.fixme( + sequenceToExport.shouldFail === true, + `That test fails because of ${sequenceToExport.issueNumber} issue.`, + ); + if (sequenceToExport.pageReloadNeeded) await pageReload(page); + + await pasteFromClipboardAndAddToMacromoleculesCanvas( + page, + [MacroFileType.Sequence, sequenceToExport.sequenceType], + sequenceToExport.sequenceString, + ); + + await openSaveToSequenceDialog(page, PeptideType.threeLetterCode); + const sequenceExportResult = await page + .getByTestId('preview-area-text') + .textContent(); + + if (sequenceToExport.differentSequenceExport) { + expect(sequenceExportResult).toEqual( + sequenceToExport.differentSequenceExport, + ); + } else { + expect(sequenceExportResult).toEqual(sequenceToExport.sequenceString); + } + + await pressButton(page, 'Cancel'); + }); +} diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/1-Verify-import-with-valid-three-letter-codes-6c6fe-e-with-Three-letters-peptide-codes---part-3-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/1-Verify-import-with-valid-three-letter-codes-6c6fe-e-with-Three-letters-peptide-codes---part-3-1-chromium-linux.png new file mode 100644 index 0000000000..9034ff45ab Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/1-Verify-import-with-valid-three-letter-codes-6c6fe-e-with-Three-letters-peptide-codes---part-3-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/1-Verify-import-with-valid-three-letter-codes-b7b82-e-with-Three-letters-peptide-codes---part-2-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/1-Verify-import-with-valid-three-letter-codes-b7b82-e-with-Three-letters-peptide-codes---part-2-1-chromium-linux.png new file mode 100644 index 0000000000..7f5a1c289f Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/1-Verify-import-with-valid-three-letter-codes-b7b82-e-with-Three-letters-peptide-codes---part-2-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/1-Verify-import-with-valid-three-letter-codes-edeb0-e-with-Three-letters-peptide-codes---part-1-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/1-Verify-import-with-valid-three-letter-codes-edeb0-e-with-Three-letters-peptide-codes---part-1-1-chromium-linux.png new file mode 100644 index 0000000000..3ce7441894 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/1-Verify-import-with-valid-three-letter-codes-edeb0-e-with-Three-letters-peptide-codes---part-1-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/2-Verify-that-spaces-separate-different-amino-1a1a0-ences-in-import-with-e-g-AlaAla-CysCys-1-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/2-Verify-that-spaces-separate-different-amino-1a1a0-ences-in-import-with-e-g-AlaAla-CysCys-1-1-chromium-linux.png new file mode 100644 index 0000000000..2e54a44e5c Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/2-Verify-that-spaces-separate-different-amino-1a1a0-ences-in-import-with-e-g-AlaAla-CysCys-1-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/2-Verify-that-spaces-separate-different-amino-acid-sequences-in-import-with-e-g-AlaAla-CysCys-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/2-Verify-that-spaces-separate-different-amino-acid-sequences-in-import-with-e-g-AlaAla-CysCys-1-chromium-linux.png new file mode 100644 index 0000000000..2e54a44e5c Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/2-Verify-that-spaces-separate-different-amino-acid-sequences-in-import-with-e-g-AlaAla-CysCys-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/3-Verify-ignoring-of-line-breaks-during-import-with-e-g-AlaGly-Cys-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/3-Verify-ignoring-of-line-breaks-during-import-with-e-g-AlaGly-Cys-1-chromium-linux.png new file mode 100644 index 0000000000..1fe3d27506 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/3-Verify-ignoring-of-line-breaks-during-import-with-e-g-AlaGly-Cys-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/3-Verify-ignoring-of-line-breaks-during-import-with-e-g-AlaGly-Cys-2-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/3-Verify-ignoring-of-line-breaks-during-import-with-e-g-AlaGly-Cys-2-1-chromium-linux.png new file mode 100644 index 0000000000..2e54a44e5c Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/3-Verify-ignoring-of-line-breaks-during-import-with-e-g-AlaGly-Cys-2-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-ALA-5-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-ALA-5-1-chromium-linux.png new file mode 100644 index 0000000000..0f27c7b354 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-ALA-5-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-Ala-1-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-Ala-1-1-chromium-linux.png new file mode 100644 index 0000000000..03cee3583c Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-Ala-1-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-Zzz-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-Zzz-1-chromium-linux.png new file mode 100644 index 0000000000..b0040d28d9 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-Zzz-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-aLa-4-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-aLa-4-1-chromium-linux.png new file mode 100644 index 0000000000..5210a62e4a Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-aLa-4-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-alA-3-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-alA-3-1-chromium-linux.png new file mode 100644 index 0000000000..7801bc13e6 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-alA-3-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-ala-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-ala-1-chromium-linux.png new file mode 100644 index 0000000000..c332afef38 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-ala-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-ala-2-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-ala-2-1-chromium-linux.png new file mode 100644 index 0000000000..e3e38f2eab Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/4-Verify-error-message-for-unsupported-symbols-in-import-with-ala-2-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/5-Verify-error-for-incorrect-formatting-in-import-with-uppercase-lowercase-mix---CysALAAsx-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/5-Verify-error-for-incorrect-formatting-in-import-with-uppercase-lowercase-mix---CysALAAsx-1-chromium-linux.png new file mode 100644 index 0000000000..50b02425f2 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/5-Verify-error-for-incorrect-formatting-in-import-with-uppercase-lowercase-mix---CysALAAsx-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/6-Verify-error-when-a-three-letter-sequence-cannot-be-matched-to-amino-acids-with-Alx-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/6-Verify-error-when-a-three-letter-sequence-cannot-be-matched-to-amino-acids-with-Alx-1-chromium-linux.png new file mode 100644 index 0000000000..997eb20e60 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/6-Verify-error-when-a-three-letter-sequence-cannot-be-matched-to-amino-acids-with-Alx-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/6-Verify-export-option-includes-both-single-l-11e30--three-letter-sequence-codes-with-Cys-A-Asx-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/6-Verify-export-option-includes-both-single-l-11e30--three-letter-sequence-codes-with-Cys-A-Asx-1-chromium-linux.png new file mode 100644 index 0000000000..549ef19711 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/6-Verify-export-option-includes-both-single-l-11e30--three-letter-sequence-codes-with-Cys-A-Asx-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/6-Verify-export-option-includes-both-single-letter-and-three-letter-sequence-codes-with-CysAAsx-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/6-Verify-export-option-includes-both-single-letter-and-three-letter-sequence-codes-with-CysAAsx-1-chromium-linux.png new file mode 100644 index 0000000000..8e9eee6eb1 Binary files /dev/null and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-sequence.spec.ts-snapshots/6-Verify-export-option-includes-both-single-letter-and-three-letter-sequence-codes-with-CysAAsx-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-import-export.spec.ts b/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-import-export.spec.ts index 59704481f0..8770cfc117 100644 --- a/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-import-export.spec.ts +++ b/ketcher-autotests/tests/Macromolecule-editor/Sequence-Mode/sequence-mode-import-export.spec.ts @@ -13,6 +13,9 @@ import { waitForIndigoToLoad, waitForKetcherInit, moveMouseAway, + MacroFileType, + SequenceType, + PeptideType, } from '@utils'; import { turnOnMacromoleculesEditor, @@ -150,8 +153,7 @@ test.describe('Import/export sequence:', () => { await pasteFromClipboardAndAddToMacromoleculesCanvas( page, - 'Sequence', - 'RNA', + [MacroFileType.Sequence, SequenceType.RNA], 'ATCGUatcgu', ); @@ -171,8 +173,7 @@ test.describe('Import/export sequence:', () => { await pasteFromClipboardAndAddToMacromoleculesCanvas( page, - 'Sequence', - 'RNA', + [MacroFileType.Sequence, SequenceType.RNA], 'ATCGUatcgu', ); @@ -192,8 +193,10 @@ test.describe('Import/export sequence:', () => { await pasteFromClipboardAndAddToMacromoleculesCanvas( page, - 'Sequence', - 'Peptide', + [ + MacroFileType.Sequence, + [SequenceType.PEPTIDE, PeptideType.oneLetterCode], + ], 'ACDEFGHIKLMNPQRSTVWYacdefghiklmnpqrstcwy', ); diff --git a/ketcher-autotests/tests/utils/canvas/types.ts b/ketcher-autotests/tests/utils/canvas/types.ts index 21c68171c7..b2d728f439 100644 --- a/ketcher-autotests/tests/utils/canvas/types.ts +++ b/ketcher-autotests/tests/utils/canvas/types.ts @@ -86,3 +86,17 @@ export enum SequenceType { DNA = 'DNA', PEPTIDE = 'PEPTIDE', } + +export enum PeptideType { + oneLetterCode = '1-letter code', + threeLetterCode = '3-letter code', +} + +export enum MacroFileType { + Ket = 'Ket', + MOLv3000 = 'MDL Molfile V3000', + Sequence = 'Sequence', + FASTA = 'FASTA', + IDT = 'IDT', + HELM = 'HELM', +} diff --git a/ketcher-autotests/tests/utils/files/readFile.ts b/ketcher-autotests/tests/utils/files/readFile.ts index 2ad8856d87..73823fc147 100644 --- a/ketcher-autotests/tests/utils/files/readFile.ts +++ b/ketcher-autotests/tests/utils/files/readFile.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-len */ import * as fs from 'fs'; import * as path from 'path'; import { Page, expect } from '@playwright/test'; @@ -14,6 +15,9 @@ import { selectMacromoleculesPanelButton, selectImageTool, clickOnCanvas, + SequenceType, + MacroFileType, + PeptideType, } from '@utils'; import { MolfileFormat } from 'ketcher-core'; @@ -254,37 +258,155 @@ export async function pasteFromClipboardAndOpenAsNewProject( } } +/** + * Usage examples: + * 1. pasteFromClipboardAndAddToMacromoleculesCanvas( + * page, + * MacroFileType.Ket, + * 'Some KET content', + * ); + * + * 2. pasteFromClipboardAndAddToMacromoleculesCanvas( + * page, + * [MacroFileType.FASTA, SequenceType.DNA], + * 'Some FASTA content of DNA type', + * ); + * 3. pasteFromClipboardAndAddToMacromoleculesCanvas( + * page, + * [MacroFileType.Sequence, SequenceType.RNA], + * 'Some Sequence content of RNA type', + * ); + * 4. pasteFromClipboardAndAddToMacromoleculesCanvas( + * page, + * [MacroFileType.Sequence, [SequenceType.PEPTIDE, PeptideType.threeLetterCode]], + * 'Some Sequence content of Peptide type of 3-letter code', + * ); + * @param {Page} page - The Playwright page instance where the button is located. + * @param {structureFormat} structureFormat - Content type from enum MacroFileType, if Sequence or FASTA - require array of [MacroFileType, SequenceType], if SequenceType === Peptide - requre [MacroFileType, [SequenceType, PeptideType]] + * @param {fillStructure} fillStructure - content to load on the canvas via "Paste from clipboard" way + * @param {errorExpected} errorExpected - have to be true if you know if error should occure + */ export async function pasteFromClipboardAndAddToMacromoleculesCanvas( page: Page, - structureFormat: string, - sequenceFormat: string, + structureFormat: + | Exclude + | [MacroFileType.FASTA, SequenceType] + | [MacroFileType.Sequence, Exclude] + | [MacroFileType.Sequence, [SequenceType.PEPTIDE, PeptideType]], fillStructure: string, - needToWait = true, + errorExpected = false, ) { + let structureType: MacroFileType = MacroFileType.Ket; + let sequenceOrFastaType: SequenceType = SequenceType.RNA; + let peptideType: PeptideType = PeptideType.oneLetterCode; + + if (Array.isArray(structureFormat)) { + const [tmpFastaOrSequenceStructureType, tmpSequenceOrFastaType] = + structureFormat; + structureType = tmpFastaOrSequenceStructureType; + if (Array.isArray(tmpSequenceOrFastaType)) { + const [tmpSequenceType, tmpPetideType] = tmpSequenceOrFastaType; + sequenceOrFastaType = tmpSequenceType; + peptideType = tmpPetideType; + } else { + sequenceOrFastaType = tmpSequenceOrFastaType; + } + } else { + structureType = structureFormat; + } + await selectMacromoleculesPanelButton( MacromoleculesTopPanelButton.Open, page, ); await page.getByText('Paste from clipboard').click(); - if (!(structureFormat === 'Ket')) { + if (structureFormat !== MacroFileType.Ket) { await page.getByRole('combobox').click(); - await page.getByText(structureFormat).click(); + await page.getByText(structureType).click(); } - if (!(sequenceFormat === 'RNA')) { + + if ( + structureType === MacroFileType.Sequence || + structureType === MacroFileType.FASTA + ) { await page.getByTestId('dropdown-select-type').click(); - const lowCaseSequenceFormat = sequenceFormat.toLowerCase(); + const lowCaseSequenceFormat = sequenceOrFastaType.toLowerCase(); await page.locator(`[data-value=${lowCaseSequenceFormat}]`).click(); - } + if ( + sequenceOrFastaType === SequenceType.PEPTIDE && + peptideType === PeptideType.threeLetterCode + ) { + await page + .getByTestId('dropdown-select-peptide-letters-format') + .getByRole('combobox') + .click(); + await page.getByText(PeptideType.threeLetterCode).click(); + } - await page.getByRole('dialog').getByRole('textbox').fill(fillStructure); - if (needToWait) { - await waitForLoad(page, async () => { + await page.getByRole('dialog').getByRole('textbox').fill(fillStructure); + + if (!errorExpected) { + await waitForLoad(page, async () => { + await pressButton(page, 'Add to Canvas'); + }); + } else { await pressButton(page, 'Add to Canvas'); - }); - } else { - await pressButton(page, 'Add to Canvas'); + } } } +// export async function pasteFromClipboardAndAddToMacromoleculesCanvas2( +// page: Page, +// structureFormat: MacroFileType, +// sequenceFormat: SequenceType | [SequenceType, PeptideType?], +// fillStructure: string, +// needToWait = true, +// ) { +// await selectMacromoleculesPanelButton( +// MacromoleculesTopPanelButton.Open, +// page, +// ); +// await page.getByText('Paste from clipboard').click(); +// if (structureFormat !== MacroFileType.Ket) { +// await page.getByRole('combobox').click(); +// await page.getByText(structureFormat).click(); +// } + +// let sequenceType: SequenceType = SequenceType.RNA; +// let peptideType: PeptideType = PeptideType.oneLetterCode; + +// if (Array.isArray(sequenceFormat) && sequenceFormat[1]) { +// [sequenceType, peptideType] = sequenceFormat; +// } +// if (!Array.isArray(sequenceFormat)) { +// sequenceType = sequenceFormat; +// } + +// if (sequenceType !== SequenceType.RNA) { +// await page.getByTestId('dropdown-select-type').click(); +// const lowCaseSequenceFormat = sequenceType.toLowerCase(); +// await page.locator(`[data-value=${lowCaseSequenceFormat}]`).click(); + +// if ( +// sequenceType === SequenceType.PEPTIDE && +// peptideType !== PeptideType.oneLetterCode +// ) { +// await page +// .getByTestId('dropdown-select-peptide-letters-format') +// .getByRole('combobox') +// .click(); +// await page.getByText(PeptideType.threeLetterCode).click(); +// } +// } + +// await page.getByRole('dialog').getByRole('textbox').fill(fillStructure); +// if (needToWait) { +// await waitForLoad(page, async () => { +// await pressButton(page, 'Add to Canvas'); +// }); +// } else { +// await pressButton(page, 'Add to Canvas'); +// } +// } export async function receiveMolFileComparisonData( page: Page, diff --git a/ketcher-autotests/tests/utils/macromolecules/index.ts b/ketcher-autotests/tests/utils/macromolecules/index.ts index be42f2215f..c8c7fe315d 100644 --- a/ketcher-autotests/tests/utils/macromolecules/index.ts +++ b/ketcher-autotests/tests/utils/macromolecules/index.ts @@ -68,6 +68,7 @@ export async function chooseFileFormat( | 'FASTA' | 'Sequence' | 'Sequence (1-letter code)' + | 'Sequence (3-letter code)' | 'IDT' | 'HELM' | 'SVG Document',