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

Autotests: #6003 - autotests allow import and export of sequences with three letter amino acid codes #6010

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

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {
waitForIndigoToLoad,
waitForKetcherInit,
moveMouseAway,
MacroFileType,
SequenceType,
PeptideType,
} from '@utils';
import {
turnOnMacromoleculesEditor,
Expand Down Expand Up @@ -150,8 +153,7 @@ test.describe('Import/export sequence:', () => {

await pasteFromClipboardAndAddToMacromoleculesCanvas(
page,
'Sequence',
'RNA',
[MacroFileType.Sequence, SequenceType.RNA],
'ATCGUatcgu',
);

Expand All @@ -171,8 +173,7 @@ test.describe('Import/export sequence:', () => {

await pasteFromClipboardAndAddToMacromoleculesCanvas(
page,
'Sequence',
'RNA',
[MacroFileType.Sequence, SequenceType.RNA],
'ATCGUatcgu',
);

Expand All @@ -192,8 +193,10 @@ test.describe('Import/export sequence:', () => {

await pasteFromClipboardAndAddToMacromoleculesCanvas(
page,
'Sequence',
'Peptide',
[
MacroFileType.Sequence,
[SequenceType.PEPTIDE, PeptideType.oneLetterCode],
],
'ACDEFGHIKLMNPQRSTVWYacdefghiklmnpqrstcwy',
);

Expand Down
14 changes: 14 additions & 0 deletions ketcher-autotests/tests/utils/canvas/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
150 changes: 136 additions & 14 deletions ketcher-autotests/tests/utils/files/readFile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-len */
import * as fs from 'fs';
import * as path from 'path';
import { Page, expect } from '@playwright/test';
Expand All @@ -14,6 +15,9 @@ import {
selectMacromoleculesPanelButton,
selectImageTool,
clickOnCanvas,
SequenceType,
MacroFileType,
PeptideType,
} from '@utils';

import { MolfileFormat } from 'ketcher-core';
Expand Down Expand Up @@ -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, MacroFileType.Sequence | MacroFileType.FASTA>
| [MacroFileType.FASTA, SequenceType]
| [MacroFileType.Sequence, Exclude<SequenceType, SequenceType.PEPTIDE>]
| [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,
Expand Down
1 change: 1 addition & 0 deletions ketcher-autotests/tests/utils/macromolecules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export async function chooseFileFormat(
| 'FASTA'
| 'Sequence'
| 'Sequence (1-letter code)'
| 'Sequence (3-letter code)'
| 'IDT'
| 'HELM'
| 'SVG Document',
Expand Down
Loading