Skip to content

Commit

Permalink
#3114 - Add support for exporting to InChiKey file format (#3165)
Browse files Browse the repository at this point in the history
* #3114 Add support for exporting to InChiKey file format
  • Loading branch information
StarlaStarla authored Aug 22, 2023
1 parent 7a8c6a5 commit bbecd5a
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect, test } from '@playwright/test';
import {
clickInTheMiddleOfTheScreen,
RingButton,
selectRingButton,
} from '@utils';

test.describe('Save dialog dropdown', () => {
test.beforeEach(async ({ page }) => {
await page.goto('');
});

test('should render opened file format dropdown when the closed dropdown is clicked', async ({
page,
}) => {
await selectRingButton(RingButton.Benzene, page);
await clickInTheMiddleOfTheScreen(page);
await page.keyboard.press('Control+s');
await page.getByText('MDL Molfile V2000').click();
expect(page.getByText('inChIKey')).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ const formatProperties: FormatPropertiesMap = {
ChemicalMimeType.InChIAuxInfo,
['.inchi'],
),
inChIKey: new SupportedFormatProperties(
'inChIKey',
ChemicalMimeType.InChIKey,
['.inchi'],
),
cml: new SupportedFormatProperties(
'CML',
ChemicalMimeType.CML,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class FormatterFactory {
case SupportedFormat.cml:
case SupportedFormat.inChIAuxInfo:
case SupportedFormat.inChI:
case SupportedFormat.inChIKey:
case SupportedFormat.molV3000:
case SupportedFormat.smiles:
case SupportedFormat.rxnV3000:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export enum SupportedFormat {
smarts = 'smarts',
inChI = 'inChI',
inChIAuxInfo = 'inChIAuxInfo',
inChIKey = 'inChIKey',
cml = 'cml',
ket = 'ket',
cdxml = 'cdxml',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum ChemicalMimeType {
DaylightSmarts = 'chemical/x-daylight-smarts',
InChI = 'chemical/x-inchi',
InChIAuxInfo = 'chemical/x-inchi-aux',
InChIKey = 'chemical/x-inchi-key',
CDX = 'chemical/x-cdx',
CDXML = 'chemical/x-cdxml',
CML = 'chemical/x-cml',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ export function couldBeSaved(

if (
(
['inChI', 'inChIAuxInfo', 'smiles', 'smilesExt'] as SupportedFormat[]
[
'inChI',
'inChIAuxInfo',
'inChIKey',
'smiles',
'smilesExt',
] as SupportedFormat[]
).includes(format)
) {
if (struct.rgroups.size !== 0)
Expand Down Expand Up @@ -102,6 +108,7 @@ export function couldBeSaved(
'smarts',
'inChI',
'inChIAuxInfo',
'inChIKey',
'cml',
] as SupportedFormat[]
).includes(format)
Expand All @@ -127,7 +134,13 @@ export function couldBeSaved(

if (
(
['inChI', 'inChIAuxInfo', 'smiles', 'smilesExt'] as SupportedFormat[]
[
'inChI',
'inChIAuxInfo',
'inChIKey',
'smiles',
'smilesExt',
] as SupportedFormat[]
).includes(format)
) {
if (struct.functionalGroups.size !== 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class SaveDialog extends Component {
'<----firstDivider--->', // for dividers in select list
'inChI',
'inChIAuxInfo',
'inChIKey',
'<----secondDivider--->', // for dividers in select list
'svg',
'png',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ describe('Save Dialog should be rendered correctly', () => {
const view = renderWithMockContext(<Save />);

userEvent.click(screen.getByText('MDL Molfile V2000'));

await screen.findByText('MDL Molfile V3000');

expect(view).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@ Object {
>
InChI AuxInfo
</li>
<li
aria-selected="false"
class="MuiButtonBase-root MuiMenuItem-root MuiMenuItem-gutters MuiMenuItem-root MuiMenuItem-gutters css-kk1bwy-MuiButtonBase-root-MuiMenuItem-root"
data-value="inChIKey"
role="option"
tabindex="-1"
>
inChIKey
</li>
<hr
aria-selected="false"
class="MuiDivider-root MuiDivider-fullWidth listDivider css-9mgopn-MuiDivider-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export enum SupportedFormat {
CML = 'cml',
InChI = 'inchi',
InChIAuxInfo = 'inchi-aux',
InChIKey = 'inchi-key',
Ket = 'ket',
CDX = 'cdx',
CDXML = 'cdxml',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ function convertMimeTypeToOutputFormat(
format = SupportedFormat.InChIAuxInfo;
break;
}
case ChemicalMimeType.InChIKey: {
format = SupportedFormat.InChIKey;
break;
}
case ChemicalMimeType.CML: {
format = SupportedFormat.CML;
break;
Expand Down

0 comments on commit bbecd5a

Please sign in to comment.